private async Task FaultProcessing(ISession session, EventModel data, Vwcontractorsite siteInfo, IEnumerable <UInt32> bitflags) { foreach (UInt32 bit in bitflags) { // 발생한 이벤트가 이미 존재하는지 체크 EventMap map = await GetEventMap(session, data, bit); // 복구 이벤트 체크 if (map == null) { continue; } var existEvents = await session.CreateCriteria <EventRecord>().Add( Restrictions.Eq("Eventcode", map.Eventcode) && Restrictions.IsNull("Recoveryts") && Restrictions.Eq("Devicetype", data.DeviceType) && Restrictions.Eq("Deviceindex", data.DeviceIndex) && Restrictions.Eq("Siteid", data.SiteId)).ListAsync <EventRecord>(); // 이벤트가 발생했는데, 기존에 엑티브 이벤트에 없을 경우 이벤트를 인서트 한다. if (existEvents.Count == 0) { EventRecord newEventRecode = new EventRecord(); DateTime dt = DateTime.FromFileTime(data.UnixTimestamp); newEventRecode.Createts = dt; newEventRecode.Eventcode = map.Eventcode; newEventRecode.Siteid = data.SiteId; newEventRecode.Devicetype = data.DeviceType; newEventRecode.Deviceindex = data.DeviceIndex; await session.SaveOrUpdateAsync(newEventRecode); await FaultReportMMS(siteInfo.Represenation, data.SiteId, data.DeviceType, data.DeviceIndex, map.Name, dt); logger.LogWarning($"[NEW EVENT] SITEID: {data.SiteId} / GC:{data.GroupCode} / BF:{bit} / DT:{data.DeviceType} / INDEX:{data.DeviceIndex}"); } } }
private async Task RecoveryProcessing(ISession session, EventModel data, Vwcontractorsite siteInfo, IEnumerable <UInt32> bitflags) { IList <EventMap> map = await GetEventMaps(session, data, bitflags); if (map == null || map.Count == 0) // 없는 이벤트 일 경우 무시 { return; } var existEvents = await session.CreateCriteria <EventRecord>().Add( Restrictions.InG <int>("Eventcode", map.Select(x => x.Eventcode)) && Restrictions.IsNull("Recoveryts") && Restrictions.Eq("Devicetype", data.DeviceType) && Restrictions.Eq("Deviceindex", data.DeviceIndex) && Restrictions.Eq("Siteid", data.SiteId)).ListAsync <EventRecord>(); foreach (EventRecord record in existEvents) { DateTime dt = DateTime.FromFileTime(data.UnixTimestamp); record.Recoveryts = dt; await session.UpdateAsync(record); EventMap target_map = map.FirstOrDefault(x => x.Eventcode == record.Eventcode); await RecoveryReportMMS(siteInfo.Represenation, data.SiteId, data.DeviceType, data.DeviceIndex, target_map.Name, dt); logger.LogWarning($"[RECOVERY EVENT] SITEID: {data.SiteId} / GC:{data.GroupCode} / BF:tail{data.BitFlag} / DT:{data.DeviceType} / INDEX:{data.DeviceIndex}"); } }