public FaultRuleItem(Wlst.client.FaultTypes.FaultSettingRuleOne rule, ObservableCollection <TmlFaultTypeViewModel> allfaults) { RuleId = rule.RuleId; Rule_name = rule.RuleName; target_equipment = rule.TargetEquipment; Op = rule.Op; Op_extend = rule.OpExtend; OpTimeSet = rule.AlarmTimeSet + 1; if (OpTimeSet == 2 || OpTimeSet == 3) { DtStart = rule.AlarmTimeStart + ""; DtEnd = rule.AlarmTimeEnd + ""; } if (OpTimeSet == 1) { DtStart = gettostr(rule.AlarmTimeStart); DtEnd = gettostr(rule.AlarmTimeEnd); } if (OpTimeSet == 4 || OpTimeSet == 5) { DtStart = rule.AlarmTimeStart + ""; DtEnd = rule.AlarmTimeEnd + ""; } for (int i = 0; i < 5; i++) { if (rule.ProperyContainKey.Count > i) { ProperyContainKey[i].Name = rule.ProperyContainKey[i]; } else { ProperyContainKey[i].Name = ""; } } ItemsAddto.Clear(); ItemsRemoveto.Clear(); var ntr = (from t in allfaults where t.IsEnable select t).ToList(); foreach (var f in ntr) { ItemsRemoveto.Add(new NameIntBool() { IsSelected = rule.FaultsRemoveOff.Contains(f.FaultId), Name = string.IsNullOrEmpty(f.FaultNameByDefine) ? f.FaultName : f.FaultNameByDefine, Value = f.FaultId }); } UpdateProCkey(); UpdateRemoveOffStr(); }
public Wlst.client.FaultTypes.FaultSettingRuleOne BackTo() { var d1 = 0; var d2 = 0; if (OpTimeSet == 2) { if (!IsNumberic(DtStart) || !IsNumberic(DtEnd)) { return(null); } d1 = Convert.ToInt32(DtStart.Trim());//gettostr(DtStart); d2 = Convert.ToInt32(DtEnd.Trim()); //d1 = DtS2; //StrTip = "开灯后设置为分钟数值"; } else if (OpTimeSet == 3) { if (!IsNumberic(DtStart) || !IsNumberic(DtEnd)) { return(null); } d1 = Convert.ToInt32(DtStart.Trim());//gettostr(DtStart); d2 = Convert.ToInt32(DtEnd.Trim()); //d1 = DtS2; //StrTip = "关灯后设置为分钟数值"; } else if (OpTimeSet == 1) { d1 = getStrInt(DtStart); d2 = getStrInt(DtEnd); //StrTip = "全天时间 为几点几分"; } else if (OpTimeSet == 4) { //lvf 负数 判断 if (DtStart.StartsWith("-")) //先判断是否以-开头 { string subdtStartStr = DtStart.Substring(1); //取-剩下的字符串 if (!IsNumberic(subdtStartStr)) { return(null); } } if (DtEnd.StartsWith("-")) //先判断是否以-开头 { string subdtEndStr = DtEnd.Substring(1); //取-剩下的字符串 if (!IsNumberic(subdtEndStr)) { return(null); } } //if (!IsNumberic(DtStart) || !IsNumberic(DtEnd)) return null; d1 = Convert.ToInt32(DtStart.Trim()); //gettostr(DtStart); d2 = Convert.ToInt32(DtEnd.Trim()); //StrTip = "日出-日落偏移量 为分钟数值"; } else if (OpTimeSet == 5) { if (DtStart.StartsWith("-")) //先判断是否以-开头 { string subdtStartStr = DtStart.Substring(1); //取-剩下的字符串 if (!IsNumberic(subdtStartStr)) { return(null); } } if (DtEnd.StartsWith("-")) //先判断是否以-开头 { string subdtEndStr = DtEnd.Substring(1); //取-剩下的字符串 if (!IsNumberic(subdtEndStr)) { return(null); } } //if (!IsNumberic(DtStart) || !IsNumberic(DtEnd)) return null; d1 = Convert.ToInt32(DtStart.Trim());//gettostr(DtStart); d2 = Convert.ToInt32(DtEnd.Trim()); //StrTip = "日落-日出偏移量 为分钟数值"; } //int optimeset = OpTimeSet; //if (OpTimeSet < 4) optimeset = OpTimeSet - 1; var rtn = new Wlst.client.FaultTypes.FaultSettingRuleOne() { FaultsAddTo = new List <int>(), AlarmTimeEnd = d2, AlarmTimeSet = OpTimeSet - 1, AlarmTimeStart = d1, FaultsRemoveOff = (from t in ItemsRemoveto where t.IsSelected select t.Value).ToList(), ProperyContainKey = (from t in ProperyContainKey where string.IsNullOrEmpty(t.Name) == false select t.Name) .ToList(), Op = Op, OpExtend = Op_extend, RuleId = RuleId, RuleName = Rule_name, TargetEquipment = 1 }; return(rtn); }