123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using CB.Data;
- using CB.Entity;
- using CB.Framework;
- using CB.Common;
- using System.Reflection;
- using CB.TrendChart;
- using CB.TrendMiss;
- using CB.TrendMiss.LotteryTrendMiss;
- namespace CB.Admin.Plugins.TrendMissConfig
- {
- public partial class TrendMissItemInfo1 : AdminPage
- {
- protected int chartId = 0, Cid = 0;
- protected string typeName = "";
- List<MissFunction> Attributelist = new List<MissFunction>();
- protected void Page_Load(object sender, EventArgs e)
- {
- chartId = WRequest.GetQueryInt("Id");
- Cid = WRequest.GetQueryInt("Cid");
- BindList<MissItemFunction>();
- if (!Page.IsPostBack)
- {
- InitData();
- }
- }
- protected override void InitData()
- {
- #region dlFuntionType列表绑定
- ddlFuntionType.Items.Clear();
- for (int i = 0; i < Attributelist.Count; i++)
- {
- ddlFuntionType.Items.Add(new ListItem(Attributelist[i].Name, i.ToString()));
- }
- #endregion
- if (0 < chartId)
- {
- typeName = GetChartName(chartId);
- TrendMissItemInfo entity = CB.Data.TrendMissItemService.Get(chartId);
- if (null != entity && 0 < entity.Id)
- {
- //txtChartId.Text = entity.ChartId.ToString();
- txtCycle.Text = entity.Cycle.ToString();
- txtItemCycle.Text = string.Join(",", entity.ItemCycle);
- txtItemMinValue.Text = entity.ItemMinValue.ToString();
- txtItemMaxValue.Text = entity.ItemMaxValue.ToString();
- txtItemCount.Text = entity.ItemCount.ToString();
- txtItemString.Text = string.Join(",", entity.ItemString);
- txtSplitNumberOfDX.Text = entity.SplitNumberOfDX.ToString();
- txtIndexStart.Text = entity.IndexStart.ToString();
- txtIndexEnd.Text = entity.IndexEnd.ToString();
- for (int i = 0; i < Attributelist.Count; i++)
- {
- if (Attributelist[i].ItemType == entity.FuntionType)
- {
- ddlFuntionType.SelectedIndex = i;
- break;
- }
- }
- labID.Text = entity.Id.ToString();
- }
- }
- base.InitData();
- }
- protected void btnUpdate_Click(object sender, EventArgs e)
- {
- var entity = new Entity.TrendMissItemInfo()
- {
- Id = TypeConverter.StrToInt(labID.Text.Trim()),
- ChartId = chartId,
- Cycle = TypeConverter.StrToInt(txtCycle.Text.Trim()),
- ItemCycle = txtItemCycle.Text.TrimEnd(',').Split(','),
- ItemMinValue = TypeConverter.StrToInt(txtItemMinValue.Text.Trim()),
- ItemMaxValue = TypeConverter.StrToInt(txtItemMaxValue.Text.Trim()),
- ItemCount = TypeConverter.StrToInt(txtItemCount.Text.Trim()),
- ItemString = txtItemString.Text.TrimEnd(',').Split(','),
- SplitNumberOfDX = TypeConverter.StrToInt(txtSplitNumberOfDX.Text.Trim()),
- IndexStart = TypeConverter.StrToInt(txtIndexStart.Text.Trim()),
- IndexEnd = TypeConverter.StrToInt(txtIndexEnd.Text.Trim()),
- FuntionType = Attributelist[ddlFuntionType.SelectedIndex].ItemType,
- ClassName = Attributelist[ddlFuntionType.SelectedIndex].ClassName
- };
- Validate(entity);//验证数据
- if (0 < entity.Id)
- {
- if (CB.Data.TrendMissItemService.Update(entity))
- {
- ChangeState(TrendChartStatus.Test, chartId);
- Logs("修改遗漏配置信息", string.Format("修改遗漏配置信息:[{0}]", entity.Id));
- ShowMessageBox("提示:修改成功!", string.Format("TrendMissItemInfo.aspx?authPage={0}&id={1}", authPage, entity.ChartId));
- }
- else
- {
- ShowMessageBox("提示:修改失败!");
- }
- }
- else
- {
- if (CB.Data.TrendMissItemService.Save(entity))
- {
- ChangeState(TrendChartStatus.Test, chartId);
- Logs("新增遗漏配置信息", string.Format("新增遗漏配置:[{0}]", entity.Id));
- Entity.TrendMissItemInfo info = CB.Data.TrendMissItemService.Get(entity.ChartId);
- ShowMessageBox("提示:添加成功!!!", string.Format("TrendMissItemInfo.aspx?authPage={0}&id={1}", authPage, info.ChartId));
- }
- else
- {
- ShowMessageBox("提示:添加失败!");
- }
- }
- }
- public string GetChartName(int chartid)
- {
- var entity = CB.Data.TrendChartService.Get(chartid);
- return null != entity ? entity.Name : "";
- }
- //绑定方法列表方法
- private void BindList<T>()
- {
- MethodInfo[] methodList = typeof(T).GetMethods();
- if (null != methodList && 0 < methodList.Length)
- {
- foreach (MethodInfo item in methodList)
- {
- MissFunction[] Description = item.GetCustomAttributes(typeof(MissFunction), false) as MissFunction[];
- if (null != Description && 1 <= Description.Length)
- Attributelist.Add(new MissFunction(Description[0].Name, Description[0].ItemType, Description[0].ClassName));
- }
- }
- }
- //数据验证
- public void Validate(Entity.TrendMissItemInfo entity)
- {
- if (entity.ItemCycle.Length != entity.ItemCount)
- ShowMessageBox("配置项个数不等于项长度!");
- if (entity.ItemString.Length != entity.ItemCount)
- ShowMessageBox("项的字符串个数不等于项长度");
- if (entity.ItemMinValue != -1 || entity.ItemMaxValue != -1)
- if (entity.ItemMaxValue < entity.ItemMinValue)
- ShowMessageBox("项的最大值小于最小值");
- else if ((entity.ItemMaxValue - entity.ItemMinValue + 1) != entity.ItemCount)
- ShowMessageBox("配置项最大值和最小值之间个数不等于项长度!");
- else if (entity.SplitNumberOfDX != -1)
- if (entity.ItemMaxValue < entity.SplitNumberOfDX && entity.SplitNumberOfDX > entity.ItemMinValue)
- ShowMessageBox("项的大小分隔值不在配置项最大值和最小值之间!");
- }
- //生成遗漏数据
- protected void btn_CreateMissData_Click_Click(object sender, EventArgs e)
- {
- switch (Cid)
- {
- case 1:
- FC3DTrendMiss.CreateMissData(chartId, 0, null);
- break;
- case 2:
- TCP3TrendMiss.CreateMissData(chartId, 0, null);
- break;
- case 4:
- FCSSQTrendMiss.CreateMissData(chartId, 0, null);
- break;
- }
- }
- }
- }
|