public override void Initialize() { SetStartDate(2013, 10, 07); SetEndDate(2013, 10, 11); EnableAutomaticIndicatorWarmUp = true; // Test case 1 _spy = AddEquity("SPY").Symbol; var sma = SMA(_spy, 10); if (!sma.IsReady) { throw new Exception("Expected SMA to be warmed up"); } // Test case 2 var indicator = new CustomIndicator(10); RegisterIndicator(_spy, indicator, Resolution.Minute, (Func <IBaseData, decimal>)null); if (indicator.IsReady) { throw new Exception("Expected CustomIndicator Not to be warmed up"); } WarmUpIndicator(_spy, indicator); if (!indicator.IsReady) { throw new Exception("Expected CustomIndicator to be warmed up"); } }
private void btnAddCustomIndicator_Click(object sender, RoutedEventArgs e) { //count indicator, just to give an unique name for a new indicator _indicatorCount = _stockChartX.GetIndicatorCountByType(IndicatorType.CustomIndicator); //create inidcator name string indicatorName = "Custom Indicator"; if (_indicatorCount > 0) { indicatorName += _indicatorCount; } //get a reference to the custom indicator CustomIndicator indicator = (CustomIndicator)_stockChartX.AddIndicator(IndicatorType.CustomIndicator, indicatorName, _stockChartX.AddChartPanel(), true); //Add some parameters to the custom indicator, these parameters willl apear in indicator's dialog //where user will be able to set them manually indicator.AddParameter("My Param1", ParameterType.ptPeriods, 10, typeof(int)); indicator.AddParameter("My Param2", ParameterType.ptPointsOrPercent, 12, typeof(int)); indicator.AddParameter("My Param3", ParameterType.ptSymbol, "", typeof(string)); indicator.AddParameter(null, ParameterType.ptLimitMoveValue, 16, typeof(int)); indicator.SetParameterValue(0, 10); indicator.SetParameterValue(1, 12); indicator.SetParameterValue(2, "MSFT.CLOSE"); indicator.SetParameterValue(3, 2); //after we set parameters call Update, this will raise the event OnCustomIndicatorNeedsData //where you use your own formulas to calculate the indicator values _stockChartX.Update(); }
private void CreateCustomIndicator(string beUserId, string beUserName, ExamineStage esEnt, ExamineStageDetail esdEnt) { ExamineIndicator eiEnt = ExamineIndicator.Find(esdEnt.ExamineIndicatorId); IList <IndicatorFirst> ifEnts = IndicatorFirst.FindAllByProperties(IndicatorFirst.Prop_ExamineIndicatorId, eiEnt.Id, IndicatorFirst.Prop_CustomColumn, "T"); if (ifEnts.Count > 0)//只有当考核指标下指定了需要自定义的指标后,才有必要创建自定义指标 如果没有直接生成考核任务即可 { IList <IndicatorSecond> isEnts = IndicatorSecond.FindAllByProperty(IndicatorSecond.Prop_IndicatorFirstId, ifEnts[0].Id); if (isEnts.Count > 0) { CustomIndicator ciEnt = new CustomIndicator(); ciEnt.ExamineStageId = esEnt.Id; ciEnt.CreateId = beUserId; ciEnt.CreateName = beUserName; ciEnt.CreateTime = DateTime.Now; ciEnt.DeptId = esEnt.LaunchDeptId; ciEnt.DeptName = esEnt.LaunchDeptName; ciEnt.IndicatorNo = DataHelper.QueryValue <string>("select BJKY_Examine.dbo.fun_getIndicatorNo()"); ciEnt.DeptIndicatorName = eiEnt.IndicatorName; ciEnt.DeptIndicatorId = eiEnt.Id; ciEnt.IndicatorSecondId = isEnts[0].Id; ciEnt.IndicatorSecondName = ifEnts[0].IndicatorFirstName; ciEnt.Weight = ifEnts[0].MaxScore; ciEnt.Year = esEnt.Year; ciEnt.StageType = esEnt.StageType; ciEnt.State = "0"; ciEnt.DoCreate(); } } }
private void LaunchExamine() { // 如果是部门级考核 启动时需要把自定义指标状态置为3 if (esEnt.ExamineType == "部门级考核") { sql = @"select A.* from BJKY_Examine..DeptExamineRelation as A left join BJKY_Examine..ExamineStageDetail as B on A.Id=B.ExamineRelationId where B.ExamineStageId='" + esEnt.Id + "'";//找到部门考核关系里面的所有被考核人 查找他们的自定义指标 IList <EasyDictionary> dicsRelation = DataHelper.QueryDictList(sql); string beUserIds = ""; string beUserNames = ""; foreach (EasyDictionary dic in dicsRelation) { beUserIds += dic.Get <string>("BeUserIds") + ","; beUserNames += dic.Get <string>("BeUserNames") + ","; } string[] userIdArray = null; if (!string.IsNullOrEmpty(beUserIds)) { userIdArray = beUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } for (int j = 0; j < userIdArray.Length; j++) { IList <CustomIndicator> ciEnts = CustomIndicator.FindAllByProperties("CreateId", userIdArray[j], "Year", esEnt.Year, "StageType", esEnt.StageType); if (ciEnts.Count > 0) { ciEnts[0].State = "3";//启动考核的时候将自定义指标的状态改为3 已结束 ciEnts[0].DoUpdate(); } } IList <ExamineTask> etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, id); foreach (ExamineTask etEnt in etEnts) { etEnt.State = "1";//任务状态 etEnt.DoUpdate(); } esEnt.State = 2; esEnt.DoUpdate(); PageState.Add("Result", "T"); } else//院级考核 { IList <ExamineTask> etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, id); foreach (ExamineTask etEnt in etEnts) { etEnt.State = "1";//任务状态 etEnt.DoUpdate(); } esEnt.State = 2; esEnt.DoUpdate(); PageState.Add("Result", "T"); } }
protected void Page_Load(object sender, EventArgs e) { PersonFirstIndicator ent = null; CustomIndicatorId = RequestData.Get <string>("CustomIndicatorId"); switch (RequestActionString) { case "delete": IList <string> ids = RequestData.GetList <string>("ids"); foreach (string str in ids) { ent = PersonFirstIndicator.Find(str); IList <PersonSecondIndicator> psiEnts = PersonSecondIndicator.FindAllByProperty(PersonSecondIndicator.Prop_PersonFirstIndicatorId, str); foreach (PersonSecondIndicator psiEnt in psiEnts) { psiEnt.DoDelete(); } ent.DoDelete(); } break; case "AutoUpdate": IList <string> entStrList = RequestData.GetList <string>("data"); if (entStrList.Count > 0) { ents = entStrList.Select(tent => JsonHelper.GetObject <PersonFirstIndicator>(tent) as PersonFirstIndicator).ToList(); } if (ents.Count > 0) { ents[0].DoUpdate(); } break; case "create": PersonFirstIndicator pfiEnt = new PersonFirstIndicator(); CustomIndicator ciEnt = CustomIndicator.Find(CustomIndicatorId); string sql = @"select max(SortIndex) from BJKY_Examine..PersonFirstIndicator where CustomIndicatorId='" + CustomIndicatorId + "'"; pfiEnt.SortIndex = DataHelper.QueryValue <int>(sql) + 1; pfiEnt.CustomIndicatorId = ciEnt.Id; pfiEnt.TotalWeight = ciEnt.Weight; pfiEnt.DoCreate(); PageState.Add("Entity", pfiEnt); break; default: DoSelect(); break; } }
private void CancelLaunch() //撤销启动 { if (esEnt.ExamineType == "部门级考核") //撤销启动的时候 如果是部门级考核 需要将考核对象的自定义指标状态设置为2 也就是可以还填写自我评价 { sql = @"select A.* from BJKY_Examine..DeptExamineRelation as A left join BJKY_Examine..ExamineStageDetail as B on A.Id=B.ExamineRelationId where B.ExamineStageId='" + esEnt.Id + "'"; //找到部门考核关系里面的所有被考核人 查找他们的自定义指标 IList <EasyDictionary> dicsRelation = DataHelper.QueryDictList(sql); string beUserIds = ""; string beUserNames = ""; foreach (EasyDictionary dic in dicsRelation) { beUserIds += dic.Get <string>("BeUserIds") + ","; beUserNames += dic.Get <string>("BeUserNames") + ","; } string[] userIdArray = null; if (!string.IsNullOrEmpty(beUserIds)) { userIdArray = beUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } for (int j = 0; j < userIdArray.Length; j++) { IList <CustomIndicator> ciEnts = CustomIndicator.FindAllByProperties("CreateId", userIdArray[j], "Year", esEnt.Year, "StageType", esEnt.StageType); if (ciEnts.Count > 0) { ciEnts[0].State = "2"; ciEnts[0].DoUpdate(); } } } IList <ExamineTask> etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, esEnt.Id); foreach (ExamineTask etEnt in etEnts) { IList <IndicatorScore> isEnts = IndicatorScore.FindAllByProperty(IndicatorScore.Prop_ExamineTaskId, etEnt.Id); foreach (IndicatorScore isEnt in isEnts) { isEnt.DoDelete(); } etEnt.DoDelete(); } esEnt.TaskQuan = 0; esEnt.State = 0; esEnt.DoUpdate(); }
protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { ciEnt = CustomIndicator.Find(id); } IList <string> entStrList = RequestData.GetList <string>("data"); switch (RequestActionString) { case "agree": ciEnt.Result = "同意"; ciEnt.ApproveTime = System.DateTime.Now; ciEnt.State = "2"; ciEnt.DoUpdate(); if (entStrList.Count > 0) { IList <CustomIndicatorOpinion> eiEnts = entStrList.Select(tent => JsonHelper.GetObject <CustomIndicatorOpinion>(tent) as CustomIndicatorOpinion).ToList(); eiEnts[0].DoCreate(); } FormatOpinion(); break; case "disagree": ciEnt.Result = "不同意"; ciEnt.ApproveTime = System.DateTime.Now; ciEnt.State = "0";//不同意后自定义指标的状态归0 ciEnt.DoUpdate(); if (entStrList.Count > 0) { IList <CustomIndicatorOpinion> eiEnts = entStrList.Select(tent => JsonHelper.GetObject <CustomIndicatorOpinion>(tent) as CustomIndicatorOpinion).ToList(); eiEnts[0].DoCreate(); } FormatOpinion(); break; default: DoSelect(); break; } }
private void DoBatchDelete() { IList <object> ids = RequestData.GetList <object>("ids"); foreach (string str in ids) { CustomIndicator ciEnt = CustomIndicator.Find(str); IList <PersonFirstIndicator> pfiEnts = PersonFirstIndicator.FindAllByProperty(PersonFirstIndicator.Prop_CustomIndicatorId, str); foreach (PersonFirstIndicator pfiEnt in pfiEnts) { IList <PersonSecondIndicator> psiEnts = PersonSecondIndicator.FindAllByProperty(PersonSecondIndicator.Prop_PersonFirstIndicatorId, pfiEnt.Id); foreach (PersonSecondIndicator psiEnt in psiEnts) { psiEnt.DoDelete(); } pfiEnt.DoDelete(); } ciEnt.DoDelete(); } }
protected void Page_Load(object sender, EventArgs e) { IList <string> entStrList = RequestData.GetList <string>("data"); id = RequestData.Get <string>("id"); Index = RequestData.Get <string>("Index"); if (!string.IsNullOrEmpty(id)) { ciEnt = CustomIndicator.Find(id); } switch (RequestActionString) { case "submit": ciEnt.State = "1"; ciEnt.Result = "审批中"; ciEnt.DoUpdate(); break; default: DoSelect(); break; } }
public override void Initialize() { UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw; EnableAutomaticIndicatorWarmUp = true; SetStartDate(2013, 10, 07); SetEndDate(2013, 10, 09); var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME); _symbol = FutureChainProvider.GetFutureContractList(SP500, StartDate).First(); // Test case: custom IndicatorBase<QuoteBar> indicator using Future unsubscribed symbol var indicator1 = new CustomIndicator(); AssertIndicatorState(indicator1, isReady: false); WarmUpIndicator(_symbol, indicator1); AssertIndicatorState(indicator1, isReady: true); // Test case: SimpleMovingAverage<IndicatorDataPoint> using Future unsubscribed symbol (should use TradeBar) var sma1 = new SimpleMovingAverage(10); AssertIndicatorState(sma1, isReady: false); WarmUpIndicator(_symbol, sma1); AssertIndicatorState(sma1, isReady: true); // Test case: SimpleMovingAverage<IndicatorDataPoint> using Equity unsubscribed symbol var spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA); var sma = new SimpleMovingAverage(10); AssertIndicatorState(sma, isReady: false); WarmUpIndicator(spy, sma); AssertIndicatorState(sma, isReady: true); // We add the symbol AddFutureContract(_symbol); AddEquity("SPY"); // force spy for use Raw data mode so that it matches the used when unsubscribed which uses the universe settings SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(spy).SetDataNormalizationMode(DataNormalizationMode.Raw); // Test case: custom IndicatorBase<QuoteBar> indicator using Future subscribed symbol var indicator = new CustomIndicator(); var consolidator = CreateConsolidator(TimeSpan.FromMinutes(1), typeof(QuoteBar)); RegisterIndicator(_symbol, indicator, consolidator); AssertIndicatorState(indicator, isReady: false); WarmUpIndicator(_symbol, indicator); AssertIndicatorState(indicator, isReady: true); // Test case: SimpleMovingAverage<IndicatorDataPoint> using Future Subscribed symbol (should use TradeBar) var sma11 = new SimpleMovingAverage(10); AssertIndicatorState(sma11, isReady: false); WarmUpIndicator(_symbol, sma11); AssertIndicatorState(sma11, isReady: true); if (!sma11.Current.Equals(sma1.Current)) { throw new Exception("Expected SMAs warmed up before and after adding the Future to the algorithm to have the same current value. " + "The result of 'WarmUpIndicator' shouldn't change if the symbol is or isn't subscribed"); } // Test case: SimpleMovingAverage<IndicatorDataPoint> using Equity unsubscribed symbol var smaSpy = new SimpleMovingAverage(10); AssertIndicatorState(smaSpy, isReady: false); WarmUpIndicator(spy, smaSpy); AssertIndicatorState(smaSpy, isReady: true); if (!smaSpy.Current.Equals(sma.Current)) { throw new Exception("Expected SMAs warmed up before and after adding the Equity to the algorithm to have the same current value. " + "The result of 'WarmUpIndicator' shouldn't change if the symbol is or isn't subscribed"); } }
/// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> public override void Initialize() { SetStartDate(2013, 10, 08); SetEndDate(2013, 10, 09); var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME); _symbol = FutureChainProvider.GetFutureContractList(SP500, StartDate).First(); AddFutureContract(_symbol); // this collection will hold all indicators and at the end of the algorithm we will assert that all of them are ready _indicators = new List <IIndicator>(); // Test the different APIs for IndicatorBase<QuoteBar> works correctly. // Should be able to determine the correct consolidator and not throw an exception var indicator = new CustomIndicator(); RegisterIndicator(_symbol, indicator, Resolution.Minute); _indicators.Add(indicator); // specifying a selector and using resolution var indicator2 = new CustomIndicator(); RegisterIndicator(_symbol, indicator2, Resolution.Minute, data => (QuoteBar)data); _indicators.Add(indicator2); // specifying a selector and using timeSpan var indicator3 = new CustomIndicator(); RegisterIndicator(_symbol, indicator3, TimeSpan.FromMinutes(1), data => (QuoteBar)data); _indicators.Add(indicator3); // directly sending in the desired consolidator var indicator4 = new SimpleMovingAverage(10); var consolidator = ResolveConsolidator(_symbol, Resolution.Minute, typeof(QuoteBar)); RegisterIndicator(_symbol, indicator4, consolidator); _indicators.Add(indicator4); // directly sending in the desired consolidator and specifying a selector var indicator5 = new SimpleMovingAverage(10); var consolidator2 = ResolveConsolidator(_symbol, Resolution.Minute, typeof(QuoteBar)); RegisterIndicator(_symbol, indicator5, consolidator2, data => { var quoteBar = data as QuoteBar; return(quoteBar.High - quoteBar.Low); }); _indicators.Add(indicator5); // Now make sure default data type TradeBar works correctly and does not throw an exception // Specifying resolution and selector var movingAverage = new SimpleMovingAverage(10); RegisterIndicator(_symbol, movingAverage, Resolution.Minute, data => data.Value); _indicators.Add(movingAverage); // Specifying resolution var movingAverage2 = new SimpleMovingAverage(10); RegisterIndicator(_symbol, movingAverage2, Resolution.Minute); _indicators.Add(movingAverage2); // Specifying TimeSpan var movingAverage3 = new SimpleMovingAverage(10); RegisterIndicator(_symbol, movingAverage3, TimeSpan.FromMinutes(1)); _indicators.Add(movingAverage3); // Specifying TimeSpan and selector var movingAverage4 = new SimpleMovingAverage(10); RegisterIndicator(_symbol, movingAverage4, TimeSpan.FromMinutes(1), data => data.Value); _indicators.Add(movingAverage4); // Test custom data is able to register correctly and indicators updated var smaCustomData = new SimpleMovingAverage(1); var symbol = AddData <CustomDataRegressionAlgorithm.Bitcoin>("BTC", Resolution.Minute).Symbol; RegisterIndicator(symbol, smaCustomData, TimeSpan.FromMinutes(1), data => data.Value); _indicators.Add(smaCustomData); var smaCustomData2 = new SimpleMovingAverage(1); RegisterIndicator(symbol, smaCustomData2, Resolution.Minute); _indicators.Add(smaCustomData2); }
protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { esEnt = ExamineStage.Find(id); } switch (RequestActionString) { case "UpdatePathLevel": IList <SysGroup> sgEnts = SysGroup.FindAll(); foreach (SysGroup sgEnt in sgEnts) { if (!string.IsNullOrEmpty(sgEnt.Path)) { string[] array = sgEnt.Path.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); sgEnt.PathLevel = array.Length; sgEnt.DoUpdate(); } } break; case "CreateTask": esdEnts = ExamineStageDetail.FindAllByProperty(ExamineStageDetail.Prop_ExamineStageId, id); bool allowStart = true; //确认考核对象 考核关系 考核指标 配置是否齐全 if (esdEnts.Count == 0) { allowStart = false; } else { foreach (ExamineStageDetail esdEnt in esdEnts) { if (string.IsNullOrEmpty(esdEnt.ExamineRelationId) || string.IsNullOrEmpty(esdEnt.ExamineIndicatorId)) { allowStart = false; break; } } } if (allowStart) { CreateTask(); //生成考核任务 esEnt.State = 1; //更新考核阶段状态为 etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, id); esEnt.TaskQuan = etEnts.Count; esEnt.DoUpdate(); PageState.Add("Result", "考核任务生成成功!"); } else { PageState.Add("Result", "考核任务生成失败!请检查考核对象、考核关系、考核指标是否配置完整!"); } break; case "TakeBack": etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, id); foreach (ExamineTask etEnt in etEnts) { etEnt.DoDelete(); } //删除所有的自定义指标 sql = "delete BJKY_Examine..CustomIndicator where ExamineStageId='" + id + "'"; DataHelper.ExecSql(sql); esEnt.State = 0; esEnt.TaskQuan = 0; esEnt.DoUpdate(); PageState.Add("Result", "T"); break; case "JudgeCustomIndicator": if (esEnt.ExamineType == "部门级考核") { sql = @"select A.* from BJKY_Examine..DeptExamineRelation as A left join BJKY_Examine..ExamineStageDetail as B on A.Id=B.ExamineRelationId where B.ExamineStageId='" + esEnt.Id + "'";//找到部门考核关系里面的所有被考核人 查找他们的自定义指标 IList <EasyDictionary> dicsRelation = DataHelper.QueryDictList(sql); string beUserIds = ""; string beUserNames = ""; foreach (EasyDictionary dic in dicsRelation) { beUserIds += dic.Get <string>("BeUserIds") + ","; beUserNames += dic.Get <string>("BeUserNames") + ","; } string[] userIdArray = null; if (!string.IsNullOrEmpty(beUserIds)) { userIdArray = beUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } bool allowLaunch = true; for (int i = 0; i < userIdArray.Length; i++) { IList <CustomIndicator> ciEnts = CustomIndicator.FindAllByProperties("CreateId", userIdArray[i], "Year", esEnt.Year, "StageType", esEnt.StageType, "Result", "同意"); if (ciEnts.Count == 0) { allowLaunch = false; break; } } PageState.Add("Result", allowLaunch == true ? "T" : "F"); } else { PageState.Add("Result", "T"); } break; case "Launch": //生成考核任务 LaunchExamine(); break; case "CancelLaunch": CancelLaunch(); break; case "EndExamine": EndExamine(); break; case "delete": IList <ExamineStageDeptDetail> esddEnts = ExamineStageDeptDetail.FindAllByProperty(ExamineStageDeptDetail.Prop_ExamineStageId, id); foreach (ExamineStageDeptDetail esddEnt in esddEnts) { esddEnt.DoDelete(); } esdEnts = ExamineStageDetail.FindAllByProperty(ExamineStageDetail.Prop_ExamineStageId, id); foreach (ExamineStageDetail esdEnt in esdEnts) { esdEnt.DoDelete(); } esEnt.DoDelete(); break; default: DoSelect(); break; } }
protected void Page_Load(object sender, EventArgs e) { IList <string> entStrList = RequestData.GetList <string>("data"); id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { ciEnt = CustomIndicator.Find(id); } switch (RequestActionString) { case "create": ciEnt = new CustomIndicator(); ciEnt.IndicatorNo = DataHelper.QueryValue <string>("select BJKY_Examine.dbo.fun_getIndicatorNo()"); ciEnt.DeptId = RequestData.Get <string>("DeptId"); ciEnt.DeptName = RequestData.Get <string>("DeptName"); ciEnt.IndicatorSecondId = RequestData.Get <string>("IndicatorSecondId"); ciEnt.IndicatorSecondName = RequestData.Get <string>("IndicatorSecondName"); ciEnt.DeptIndicatorName = RequestData.Get <string>("DeptIndicatorName"); ciEnt.Weight = RequestData.Get <int>("Weight"); PersonConfig pcEnt = PersonConfig.Find(ciEnt.DeptId); if (pcEnt != null) { ciEnt.Remark = pcEnt.GroupID; //备注字段用来存储足够机构的ID 方便选人 } ciEnt.State = "0"; ciEnt.DoCreate(); if (!string.IsNullOrEmpty(RequestData.Get <string>("originalId"))) //如果改字段不为空 说明是复制操作 { IList <PersonFirstIndicator> pfiEnts = PersonFirstIndicator.FindAllByProperty(PersonFirstIndicator.Prop_CustomIndicatorId, RequestData.Get <string>("originalId")); foreach (PersonFirstIndicator pfiEnt in pfiEnts) { PersonFirstIndicator nEnt1 = new PersonFirstIndicator(); nEnt1.CustomIndicatorId = ciEnt.Id; nEnt1.PersonFirstIndicatorName = pfiEnt.PersonFirstIndicatorName; nEnt1.TotalWeight = pfiEnt.TotalWeight; nEnt1.Weight = pfiEnt.Weight; nEnt1.SortIndex = pfiEnt.SortIndex; nEnt1.IndicatorType = pfiEnt.IndicatorType; nEnt1.CreateId = UserInfo.UserID; nEnt1.CreateName = UserInfo.Name; nEnt1.CreateTime = DateTime.Now; nEnt1.DoCreate(); IList <PersonSecondIndicator> psiEnts = PersonSecondIndicator.FindAllByProperty(PersonSecondIndicator.Prop_PersonFirstIndicatorId, pfiEnt.Id); foreach (PersonSecondIndicator psiEnt in psiEnts) { PersonSecondIndicator NEnt2 = new PersonSecondIndicator(); NEnt2.PersonFirstIndicatorId = nEnt1.Id; NEnt2.PersonFirstIndicatorName = nEnt1.PersonFirstIndicatorName; NEnt2.PersonSecondIndicatorName = psiEnt.PersonSecondIndicatorName; NEnt2.Weight = psiEnt.Weight; NEnt2.SortIndex = psiEnt.SortIndex; NEnt2.ToolTip = psiEnt.ToolTip; NEnt2.SelfRemark = psiEnt.SelfRemark; NEnt2.CreateId = UserInfo.UserID; NEnt2.CreateName = UserInfo.Name; NEnt2.CreateTime = DateTime.Now; NEnt2.DoCreate(); } } } PageState.Add("Entity", ciEnt); break; case "AutoUpdate": string ApproveUserId = RequestData.Get <string>("ApproveUserId"); string ApproveUserName = RequestData.Get <string>("ApproveUserName"); if (!string.IsNullOrEmpty(ApproveUserId)) { ciEnt.ApproveUserId = ApproveUserId; ciEnt.ApproveUserName = ApproveUserName; } ciEnt.DoUpdate(); break; case "submit": sql = @"select isnull(sum(A.Weight),0) from BJKY_Examine..PersonSecondIndicator as A left join BJKY_Examine..PersonFirstIndicator as B on A.PersonFirstIndicatorId=B.Id where B.CustomIndicatorId='" + id + "'"; int useWeight = DataHelper.QueryValue <int>(sql); if (ciEnt.Weight == useWeight) { ciEnt.State = "1"; ciEnt.Result = "审批中"; ciEnt.DoUpdate(); PageState.Add("Result", "T"); } else { PageState.Add("Result", "F"); } break; case "delete": DoBatchDelete(); break; case "UpLoadSummary": ciEnt.Summary = RequestData.Get <string>("Summary"); ciEnt.DoUpdate(); PageState.Add("Result", ciEnt.Summary); break; default: DoSelect(); break; } }