public int RegStsMonWarnType(WarnModule wm) { if (WarnAll.ContainsKey(wm.ModName)) { Logging.logger.Warn(MsgConstStr.WarnInfoExist); return(0); } if (ModWarnSts.ContainsKey(wm.ModName)) { Logging.logger.Warn(MsgConstStr.WarnInfoExist); return(0); } WarnAll.Add(wm.ModName, wm); ModWarnStsAll mwa = new ModWarnStsAll(); mwa.ModName = wm.ModName; mwa.WarnStsMon = new Dictionary <string, WarnStsMonAll>(); foreach (var item in wm.WarnNos) { WarnStsMonAll wsma = new WarnStsMonAll(); wsma.WarnNo = item.WarnNo; wsma.WarnCodeAll = new Dictionary <string, WarnStatusMon>(); mwa.WarnStsMon.Add(item.WarnNo, wsma); } ModWarnSts.Add(wm.ModName, mwa); return(0); }
private int ProcessWarnIssue(PushMessage pm) { bool ret; int rlt = -1; if (ModWarnSts.ContainsKey(pm.ModName)) { ModWarnStsAll mwsa = ModWarnSts[pm.ModName]; if (mwsa.ModName != pm.ModName) { Logging.logger.Error(MsgConstStr.ModNameWrong + mwsa.ModName + " " + pm.ModName); return(rlt); } WarningMessageModel wmm = (WarningMessageModel)JsonConvert.DeserializeObject(pm.Content, typeof(WarningMessageModel)); if (mwsa.WarnStsMon.ContainsKey(wmm.warnNo)) { WarnStsMonAll wsma = mwsa.WarnStsMon[wmm.warnNo]; if (wsma.WarnNo != wmm.warnNo) { Logging.logger.Error(MsgConstStr.WarnIssueWrong); return(rlt); } WarnStatusMon wsm; if (wsma.WarnCodeAll.ContainsKey(wmm.code)) { wsm = wsma.WarnCodeAll[wmm.code]; if (wsm.code != wmm.code) { Logging.logger.Warn(MsgConstStr.WarnCodeWrong); wsm.code = wmm.code; } if (wsm.WarnNo != wmm.warnNo) { Logging.logger.Warn(MsgConstStr.WarnIssueWrong); wsm.WarnNo = wmm.warnNo; } if (wsm.status == WarningSts.NormalSts) { //save data to db ret = WarningDA.AddWarning(wmm); if (ret) { wsm.status = WarningSts.WarnSts; wsm.start = Convert.ToDateTime(wmm.time); wsm.count = 0; rlt = 0; } else { Logging.logger.Error(MsgConstStr.SaveWarn2DBWrong); } } else { if (DateTime.Compare(wsm.start.AddMinutes(warntimelimit), DateTime.Now) < 0) { //save data to db ret = WarningDA.AddWarning(wmm); if (ret) { wsm.status = WarningSts.WarnSts; wsm.count = 0; wsm.start = Convert.ToDateTime(wmm.time); rlt = 0; } else { Logging.logger.Error(MsgConstStr.SaveWarn2DBWrong); } } else { wsm.count += 1; } } } else { wsm = new WarnStatusMon(); wsm.code = wmm.code; wsm.start = Convert.ToDateTime(wmm.time); wsm.status = WarningSts.WarnSts; wsm.WarnNo = wmm.warnNo; wsm.WarnValue = wmm.title; wsm.count = 0; ret = WarningDA.AddWarning(wmm); if (!ret) { Logging.logger.Error(MsgConstStr.SaveWarn2DBWrong); } rlt = 0; wsma.WarnCodeAll.Add(wsm.code, wsm); } } else { Logging.logger.Error(MsgConstStr.NoWarnIssue); return(rlt); } } else { Logging.logger.Error(MsgConstStr.NoWarnIssue); rlt = 0; } return(rlt); }