public JournalModel(JournalItem journalItem) { if (journalItem.JournalEventDescriptionType != JournalEventDescriptionType.NULL) { Description = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventDescriptionType); if (!string.IsNullOrEmpty(journalItem.DescriptionText)) Description += " " + journalItem.DescriptionText; } else { Description = journalItem.DescriptionText; } SystemDate = journalItem.SystemDateTime.ToString(); Name = journalItem.JournalEventNameType.ToDescription(); DeviceDate = journalItem.DeviceDateTime.ToString(); User = journalItem.UserName; ObjectUid = journalItem.ObjectUID; Color = GetStateColor(journalItem); ObjectType = journalItem.JournalObjectType; ObjectImageSource = JournalItem.GetImageSource(ObjectType).Replace("/Controls;component/", "/Content/Image/"); Subsystem = journalItem.JournalSubsystemType.ToDescription(); EventImage = GetEventImage(journalItem.JournalEventNameType); ObjectName = journalItem.ObjectName; GetObject(journalItem); }
public JournalItemViewModel(JournalItem journalItem) { ShowObjectCommand = new RelayCommand(OnShowObject, CanShowObject); JournalItem = journalItem; if (journalItem.JournalEventNameType != JournalEventNameType.NULL) { Name = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventNameType); } if (journalItem.JournalEventDescriptionType != JournalEventDescriptionType.NULL) { Description = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventDescriptionType); if (!string.IsNullOrEmpty(journalItem.DescriptionText)) Description += " " + journalItem.DescriptionText; } else { Description = journalItem.DescriptionText; } InitializeTypeAddressImageSource(journalItem); PresentationName = TypeName + " " + Address; InitializePresentationName(); var noItem = journalItem.JournalDetalisationItems.FirstOrDefault(x => x.Name == "Запись ГК"); if (noItem != null) { GKJournalRecordNo = noItem.Value; } StateClass = EventDescriptionAttributeHelper.ToStateClass(journalItem.JournalEventNameType); }
static void ProcessPassJournal(JournalItem journalItem) { if (journalItem.JournalEventNameType == JournalEventNameType.Проход_пользователя_разрешен) { Guid? zoneUID = null; var door = GKManager.Doors.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (door != null) { if (journalItem.JournalEventDescriptionType == JournalEventDescriptionType.Вход_Глобал) { zoneUID = door.EnterZoneUID; } else if (journalItem.JournalEventDescriptionType == JournalEventDescriptionType.Выход_Глобал) { zoneUID = door.ExitZoneUID; } } if (zoneUID.HasValue) { using (var databaseService = new RubezhDAL.DataClasses.DbService()) { databaseService.PassJournalTranslator.AddPassJournal(journalItem.EmployeeUID, zoneUID.Value); } } } }
public ConfirmationViewModel(JournalItem journalItem) { Title = "Подтверждение критических событий"; ConfirmCommand = new RelayCommand(OnConfirm); JournalItemViewModel = new JournalItemViewModel(journalItem); if (parentWindow == null) parentWindow = DialogService.GetActiveWindow(); }
public override void OnClosed() { var deltaSeconds = (int)(DateTime.Now - StartDateTime).TotalSeconds; var journalItem = new JournalItem(); journalItem.DeviceDateTime = DateTime.Now; journalItem.JournalEventNameType = JournalEventNameType.Подтверждение_тревоги; journalItem.DescriptionText = JournalItemViewModel.Name + " " + JournalItemViewModel.Description + " (время реакции " + deltaSeconds.ToString() + " сек)"; ClientManager.RubezhService.AddJournalItem(journalItem); AlarmPlayerHelper.Stop(); }
public OperationResult<bool> AddJournalItem(Guid clientUID, JournalItem journalItem) { try { journalItem.UserName = GetUserName(clientUID); journalItem.JournalSubsystemType = EventDescriptionAttributeHelper.ToSubsystem(journalItem.JournalEventNameType); AddCommonJournalItems(new List<JournalItem>() { journalItem }, clientUID); } catch (Exception e) { return OperationResult<bool>.FromError(e.Message); } return new OperationResult<bool>(true); }
public void ConnectionChanged(bool isConnected) { lock (connectionChangedLocker) { if (!isConnected) { DeviceBytesHelper.Ping(GkDatabase.RootDevice); ConnectionLostCount++; if (ConnectionLostCount < 3) return; } else { if (ConnectionLostCount != 0) { ConnectionLostCount = 0; IsHashFailure = GetHashResult().Item1; } } if (IsConnected != isConnected) { IsConnected = isConnected; var journalItem = new JournalItem() { SystemDateTime = DateTime.Now, DeviceDateTime = DateTime.Now, JournalObjectType = JournalObjectType.GKDevice, ObjectUID = GkDatabase.RootDevice.UID, JournalEventNameType = isConnected ? JournalEventNameType.Восстановление_связи_с_прибором : JournalEventNameType.Потеря_связи_с_прибором, }; //var gkIpAddress = GKManager.GetIpAddress(GkDatabase.RootDevice); //if (!string.IsNullOrEmpty(gkIpAddress)) // journalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("IP-адрес ГК", gkIpAddress.ToString())); AddJournalItem(journalItem); if (!IsHashFailure && isConnected) { GetAllStates(); } foreach (var descriptor in GkDatabase.Descriptors) { descriptor.GKBase.InternalState.IsConnectionLost = !isConnected; } NotifyAllObjectsStateChanged(); } } }
public static void AddJournalMessage(JournalEventNameType journalEventNameType, string objectName, Guid? objectUID, Guid? clientUID, JournalEventDescriptionType journalEventDescriptionType = JournalEventDescriptionType.NULL, JournalObjectType journalObjectType = JournalObjectType.None) { var journalItem = new JournalItem() { SystemDateTime = DateTime.Now, JournalEventNameType = journalEventNameType, JournalEventDescriptionType = journalEventDescriptionType, JournalSubsystemType = EventDescriptionAttributeHelper.ToSubsystem(journalEventNameType), JournalObjectType = journalObjectType, ObjectUID = objectUID != null ? objectUID.Value : Guid.Empty, ObjectName = objectName, UserName = GetUserName(clientUID) }; AddCommonJournalItems(new List<JournalItem>() { journalItem }, clientUID); }
public static void RunOnJournal(JournalItem journalItem, User user, Guid? clientUID) { if (ProcedureExecutionContext.SystemConfiguration == null) return; foreach (var procedure in ProcedureExecutionContext.SystemConfiguration.AutomationConfiguration.Procedures.Where(x => x.ContextType == ProcedureExecutionContext.ContextType)) { foreach (var filtersUID in procedure.FiltersUids) { var filter = ProcedureExecutionContext.SystemConfiguration.JournalFilters.FirstOrDefault(x => x.UID == filtersUID); if (filter != null) { if (filter.JournalSubsystemTypes.Count + filter.JournalEventNameTypes.Count + filter.JournalEventDescriptionTypes.Count + filter.JournalObjectTypes.Count + filter.ObjectUIDs.Count == 0) continue; if (filter.JournalSubsystemTypes.Count > 0 && !filter.JournalSubsystemTypes.Contains(journalItem.JournalSubsystemType)) continue; if ((filter.JournalEventNameTypes.Count != 0) || (filter.JournalEventDescriptionTypes.Count != 0)) { if (!filter.JournalEventNameTypes.Contains(journalItem.JournalEventNameType)) { if (!filter.JournalEventDescriptionTypes.Contains(journalItem.JournalEventDescriptionType)) { continue; } } } if (filter.JournalObjectTypes.Count > 0 && !filter.JournalObjectTypes.Contains(journalItem.JournalObjectType)) continue; if (filter.ObjectUIDs.Count > 0 && !filter.ObjectUIDs.Contains(journalItem.ObjectUID)) continue; RunProcedure(procedure, new List<Argument>(), null, user, journalItem, clientUID); } } } }
public static void AddJournalItem(Guid clientUID, string message, Guid? objectUID = null) { var journalItem = new JournalItem() { SystemDateTime = DateTime.Now, JournalEventNameType = JournalEventNameType.Сообщение_автоматизации, DescriptionText = message }; if (objectUID.HasValue) { string objectName; JournalObjectType journalObjectType; if (GetObjectInfo(objectUID.Value, out objectName, out journalObjectType)) { journalItem.ObjectUID = objectUID.Value; journalItem.ObjectName = objectName; journalItem.JournalObjectType = journalObjectType; } } Service.RubezhService.AddCommonJournalItems(new List<JournalItem>() { journalItem }, clientUID); }
public ProcedureThread(Procedure procedure, List<Argument> arguments, List<Variable> callingProcedureVariables, JournalItem journalItem = null, User user = null, Guid? clientUID = null) { UID = Guid.NewGuid(); ClientUID = clientUID.HasValue ? clientUID.Value : Guid.Empty; ContextType = procedure.ContextType; User = user; IsAlive = true; JournalItem = journalItem; TimeOut = procedure.TimeOut; TimeType = procedure.TimeType; AutoResetEvent = new AutoResetEvent(false); Steps = procedure.Steps; AllVariables = Utils.Clone(procedure.Variables); var procedureArguments = Utils.Clone(procedure.Arguments); InitializeArguments(procedureArguments, arguments, callingProcedureVariables); AllVariables.AddRange(procedureArguments); AllVariables.AddRange(ProcedureExecutionContext.GlobalVariables); Thread = new Thread(() => RunInThread(arguments)) { Name = string.Format("ProcedureThread [{0}]", UID), }; IsSync = procedure.IsSync; }
bool CheckFilter(JournalItem journalItem) { if (Filter.JournalSubsystemTypes.Count > 0 && !Filter.JournalSubsystemTypes.Contains(journalItem.JournalSubsystemType)) return false; if (Filter.JournalEventNameTypes.Count > 0 && !Filter.JournalEventNameTypes.Contains(journalItem.JournalEventNameType)) return false; if (Filter.JournalEventDescriptionTypes.Count > 0 && !Filter.JournalEventDescriptionTypes.Contains(journalItem.JournalEventDescriptionType)) return false; if (Filter.JournalObjectTypes.Count > 0 && Filter.JournalObjectTypes.Contains(journalItem.JournalObjectType)) return true; if (Filter.ObjectUIDs.Count > 0 && !Filter.ObjectUIDs.Contains(journalItem.ObjectUID)) return false; return true; }
void AddFailureJournalItem(JournalEventNameType journalEventNameType, string description = "") { var journalItem = new JournalItem() { JournalEventNameType = journalEventNameType, DescriptionText = description, }; //var gkIpAddress = GkDatabase.RootDevice.GetGKIpAddress(); //if (!string.IsNullOrEmpty(gkIpAddress)) // journalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("IP-адрес ГК", gkIpAddress.ToString())); GKCallbackResult.JournalItems.Add(journalItem); }
public static void RunProcedure(Procedure procedure, List<Argument> arguments, List<Variable> callingProcedureVariables, User user = null, JournalItem journalItem = null, Guid? clientUID = null) { if (procedure.IsActive && _procedureThreads != null) { var procedureThread = new ProcedureThread(procedure, arguments, callingProcedureVariables, journalItem, user, clientUID); _procedureThreads.TryAdd(procedureThread.UID, procedureThread); procedureThread.Start(); } }
JournalItem ReadOneJournalItem(SqlDataReader reader) { var journalItem = new JournalItem(); if (!reader.IsDBNull(reader.GetOrdinal("DescriptionText"))) journalItem.DescriptionText = reader.GetString(reader.GetOrdinal("DescriptionText")); if (!reader.IsDBNull(reader.GetOrdinal("ObjectName"))) journalItem.ObjectName = reader.GetString(reader.GetOrdinal("ObjectName")); if (!reader.IsDBNull(reader.GetOrdinal("ObjectType"))) { var intValue = (int)reader.GetValue(reader.GetOrdinal("ObjectType")); if (Enum.IsDefined(typeof(JournalObjectType), intValue)) journalItem.JournalObjectType = (JournalObjectType)intValue; } if (!reader.IsDBNull(reader.GetOrdinal("ObjectUID"))) journalItem.ObjectUID = reader.GetGuid(reader.GetOrdinal("ObjectUID")); if (!reader.IsDBNull(reader.GetOrdinal("Subsystem"))) { var intValue = (int)reader.GetValue(reader.GetOrdinal("Subsystem")); if (Enum.IsDefined(typeof(JournalSubsystemType), intValue)) journalItem.JournalSubsystemType = (JournalSubsystemType)intValue; } if (!reader.IsDBNull(reader.GetOrdinal("UID"))) journalItem.UID = reader.GetGuid(reader.GetOrdinal("UID")); if (!reader.IsDBNull(reader.GetOrdinal("UserName"))) journalItem.UserName = reader.GetString(reader.GetOrdinal("UserName")); if (!reader.IsDBNull(reader.GetOrdinal("SystemDate"))) journalItem.SystemDateTime = reader.GetDateTime(reader.GetOrdinal("SystemDate")); if (!reader.IsDBNull(reader.GetOrdinal("DeviceDate"))) journalItem.DeviceDateTime = reader.GetDateTime(reader.GetOrdinal("DeviceDate")); if (!reader.IsDBNull(reader.GetOrdinal("Name"))) { var intValue = (int)reader.GetValue(reader.GetOrdinal("Name")); if (Enum.IsDefined(typeof(JournalEventNameType), intValue)) journalItem.JournalEventNameType = (JournalEventNameType)intValue; } if (!reader.IsDBNull(reader.GetOrdinal("Description"))) { var intValue = (int)reader.GetValue(reader.GetOrdinal("Description")); if (Enum.IsDefined(typeof(JournalEventDescriptionType), intValue)) journalItem.JournalEventDescriptionType = (JournalEventDescriptionType)intValue; } if (!reader.IsDBNull(reader.GetOrdinal("Detalisation"))) { var detalisationString = reader.GetString(reader.GetOrdinal("Detalisation")); journalItem.JournalDetalisationItems = JournalDetalisationItem.StringToList(detalisationString); } return journalItem; }
internal void AddMessage(JournalEventNameType journalEventNameType) { var journalItem = new JournalItem() { JournalEventNameType = journalEventNameType, SystemDateTime = DateTime.Now, }; AddJournalItem(journalItem); }
public OperationResult<bool> AddJournalItem(JournalItem journalItem) { return SafeOperationCall(() => { var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10)); using (rubezhService as IDisposable) return rubezhService.AddJournalItem(RubezhServiceFactory.UID, journalItem); }, "AddJournalItem"); }
string GetStateColor(JournalItem journalItem) { var stateClass = EventDescriptionAttributeHelper.ToStateClass(journalItem.JournalEventNameType); switch (stateClass) { case XStateClass.Unknown: case XStateClass.DBMissmatch: case XStateClass.ConnectionLost: case XStateClass.TechnologicalRegime: case XStateClass.HasNoLicense: return ColorTranslator.ToHtml(System.Drawing.Color.Gray); case XStateClass.Fire2: case XStateClass.Fire1: return ColorTranslator.ToHtml(System.Drawing.Color.Red); case XStateClass.Attention: return ColorTranslator.ToHtml(System.Drawing.Color.Orange); case XStateClass.Failure: return ColorTranslator.ToHtml(System.Drawing.Color.Pink); case XStateClass.Service: return ColorTranslator.ToHtml(System.Drawing.Color.Yellow); case XStateClass.Ignore: return ColorTranslator.ToHtml(System.Drawing.Color.Yellow); case XStateClass.On: return ColorTranslator.ToHtml(System.Drawing.Color.LightBlue); case XStateClass.AutoOff: return ColorTranslator.ToHtml(System.Drawing.Color.Yellow); case XStateClass.Test: case XStateClass.Norm: return ColorTranslator.ToHtml(System.Drawing.Color.Transparent); default: return ColorTranslator.ToHtml(System.Drawing.Color.Transparent); } }
void OnRunThread() { while (true) { try { if (IsStopping) return; if (!InitializeMonitoring()) return; if (IsStopping) return; } catch (Exception e) { AddMessage(JournalEventNameType.Ошибка_инициализации_мониторинга); Logger.Error(e, "JournalWatcher.InitializeMonitoring"); } GKCallbackResult = new GKCallbackResult(); var journalItem = new JournalItem() { SystemDateTime = DateTime.Now, DeviceDateTime = DateTime.Now, JournalObjectType = JournalObjectType.GKDevice, ObjectUID = GkDatabase.RootDevice.UID, JournalEventNameType = JournalEventNameType.Начало_мониторинга, }; AddJournalItem(journalItem); OnGKCallbackResult(GKCallbackResult); while (true) { if (IsStopping) return; Monitor.TryEnter(CallbackResultLocker, TimeSpan.FromSeconds(30)); { GKCallbackResult = new GKCallbackResult(); } Monitor.Exit(CallbackResultLocker); RunMonitoring(); Monitor.TryEnter(CallbackResultLocker, TimeSpan.FromSeconds(30)); { OnGKCallbackResult(GKCallbackResult); } Monitor.Exit(CallbackResultLocker); if (IsStopping) return; if (IsHashFailure) break; if (StopEvent != null) { var pollInterval = 10; var property = GkDatabase.RootDevice.Properties.FirstOrDefault(x => x.Name == "PollInterval"); if (property != null) { pollInterval = property.Value; } if (ReturnAfterWait(pollInterval)) break; } WaitIfSuspending(); LastUpdateTime = DateTime.Now; } } }
public static void AddGKMessage(JournalEventNameType journalEventNameType, JournalEventDescriptionType journalEventDescriptionType, string description, GKBase gkBase, string userName) { Guid uid = Guid.Empty; var journalObjectType = JournalObjectType.None; if (gkBase != null) { uid = gkBase.UID; if (gkBase is GKDevice) { journalObjectType = JournalObjectType.GKDevice; } if (gkBase is GKZone) { journalObjectType = JournalObjectType.GKZone; } if (gkBase is GKDirection) { journalObjectType = JournalObjectType.GKDirection; } if (gkBase is GKDelay) { journalObjectType = JournalObjectType.GKDelay; } if (gkBase is GKPim) { journalObjectType = JournalObjectType.GKPim; } if (gkBase is GKGuardZone) { journalObjectType = JournalObjectType.GKGuardZone; } if (gkBase is GKSKDZone) { journalObjectType = JournalObjectType.GKSKDZone; } if (gkBase is GKDoor) { journalObjectType = JournalObjectType.GKDoor; } if (gkBase is GKMPT) { journalObjectType = JournalObjectType.GKMPT; } if (gkBase is GKPumpStation) { journalObjectType = JournalObjectType.GKPumpStation; } } var journalItem = new JournalItem { SystemDateTime = DateTime.Now, DeviceDateTime = null, JournalObjectType = journalObjectType, JournalEventNameType = journalEventNameType, JournalEventDescriptionType = journalEventDescriptionType, DescriptionText = description, ObjectUID = uid, UserName = userName, JournalSubsystemType = JournalSubsystemType.GK }; if (gkBase != null) { journalItem.ObjectName = gkBase.PresentationName; var gkObjectNo = gkBase.GKDescriptorNo; if (gkObjectNo > 0) journalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("Компонент ГК", gkObjectNo.ToString())); } var gkCallbackResult = new GKCallbackResult(); gkCallbackResult.JournalItems.Add(journalItem); OnGKCallbackResult(gkCallbackResult); }
public JournalItemViewModel(JournalItem journalItem) { ShowObjectCommand = new RelayCommand(OnShowObject, CanShowObject); ShowPropertiesCommand = new RelayCommand(OnShowProperties, CanShowProperties); ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan); ShowObjectOrPlanCommand = new RelayCommand(OnShowObjectOrPlan); ShowVideoCommand = new RelayCommand(OnShowVideo, CanShowVideo); JournalItem = journalItem; if (journalItem.JournalEventNameType != JournalEventNameType.NULL) { Name = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventNameType); } if (journalItem.JournalEventDescriptionType != JournalEventDescriptionType.NULL) { Description = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventDescriptionType); if (!string.IsNullOrEmpty(journalItem.DescriptionText)) Description += " " + journalItem.DescriptionText; } else { Description = journalItem.DescriptionText; } IsExistsInConfig = true; _isVideoExist = journalItem.VideoUID != Guid.Empty; ObjectImageSource = JournalItem.GetImageSource(journalItem.JournalObjectType); StateClass = EventDescriptionAttributeHelper.ToStateClass(journalItem.JournalEventNameType); switch (JournalItem.JournalObjectType) { case JournalObjectType.GKDevice: Device = GKManager.Devices.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Device != null) { ObjectName = Device.GetGKDescriptorName(GKManager.DeviceConfiguration.GKNameGenerationType); ObjectImageSource = Device.Driver.ImageSource; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDeviceEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDeviceDetailsEvent>(); } else ObjectImageSource = "/Controls;component/Images/Blank.png"; break; case JournalObjectType.GKZone: Zone = GKManager.Zones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Zone != null) { ObjectName = Zone.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKZoneEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKZoneDetailsEvent>(); } break; case JournalObjectType.GKDirection: Direction = GKManager.Directions.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Direction != null) { ObjectName = Direction.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDirectionEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDirectionDetailsEvent>(); } break; case JournalObjectType.GKPumpStation: PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (PumpStation != null) { ObjectName = PumpStation.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>(); } break; case JournalObjectType.GKMPT: MPT = GKManager.MPTs.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (MPT != null) { ObjectName = MPT.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKMPTEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKMPTDetailsEvent>(); } break; case JournalObjectType.GKDelay: Delay = GKManager.Delays.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Delay != null) { ObjectName = Delay.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDelayEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDelayDetailsEvent>(); } else { Delay = GKManager.AutoGeneratedDelays.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Delay != null) { ObjectName = Delay.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDelayEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDelayDetailsEvent>(); if (Delay.PumpStationUID != Guid.Empty) { PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == Delay.PumpStationUID); if (PumpStation != null) { ObjectName += " (" + PumpStation.PresentationName + ")"; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>(); ObjectImageSource = "/Controls;component/Images/BPumpStation.png"; break; } } } } break; case JournalObjectType.GKPim: Pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Pim != null) { ObjectName = Pim.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPimEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPIMDetailsEvent>(); if (Pim.PumpStationUID != Guid.Empty) { PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == Pim.PumpStationUID); if (PumpStation != null) { ObjectName += " (" + PumpStation.PresentationName + ")"; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>(); ObjectImageSource = "/Controls;component/Images/BPumpStation.png"; break; } } if (Pim.MPTUID != Guid.Empty) { MPT = GKManager.MPTs.FirstOrDefault(x => x.UID == Pim.MPTUID); if (MPT != null) { ObjectName += " (" + MPT.PresentationName + ")"; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKMPTEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKMPTDetailsEvent>(); ObjectImageSource = "/Controls;component/Images/BMPT.png"; break; } } } break; case JournalObjectType.GKGuardZone: GuardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (GuardZone != null) { ObjectName = GuardZone.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKGuardZoneEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKGuardZoneDetailsEvent>(); } break; case JournalObjectType.GKSKDZone: GKSKDZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (GKSKDZone != null) { ObjectName = GKSKDZone.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKSKDZoneEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKSKDZoneDetailsEvent>(); } break; case JournalObjectType.GKDoor: GKDoor = GKManager.Doors.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (GKDoor != null) { ObjectName = GKDoor.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDoorEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDoorDetailsEvent>(); } break; case JournalObjectType.Camera: Camera = ClientManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Camera != null) { ObjectName = Camera.PresentationName; ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowCameraEvent>(); ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowCameraDetailsEvent>(); } break; case JournalObjectType.None: case JournalObjectType.GKUser: ObjectName = JournalItem.ObjectName != null ? JournalItem.ObjectName : ""; break; } if (ObjectName == null) { ObjectName = JournalItem.ObjectName; IsExistsInConfig = false; } if (ObjectName == null) ObjectName = "<Нет в конфигурации>"; if (JournalItem.JournalSubsystemType == JournalSubsystemType.SKD) { IsExistsInConfig = true; if ((int)JournalItem.JournalObjectType >= 11 && (int)JournalItem.JournalObjectType <= 19) ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowJournalHREvent>(); if ((int)JournalItem.JournalObjectType >= 20 && (int)JournalItem.JournalObjectType <= 26) ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowJournalTimeTrackingEvent>(); } }
public OperationResult<bool> Add(JournalItem apiItem) { return DbServiceHelper.InTryCatch(() => { var result = Context.Journals.Add(TranslateBack(apiItem)); Context.SaveChanges(); return true; }); }
Journal TranslateBack(JournalItem apiItem) { return new Journal { UID = apiItem.UID, SystemDate = apiItem.SystemDateTime.CheckDate(), DeviceDate = apiItem.DeviceDateTime.CheckDate(), Subsystem = (int)EventDescriptionAttributeHelper.ToSubsystem(apiItem.JournalEventNameType), Name = (int)apiItem.JournalEventNameType, Description = (int)apiItem.JournalEventDescriptionType, DescriptionText = apiItem.DescriptionText, ObjectType = (int)apiItem.JournalObjectType, ObjectUID = apiItem.ObjectUID, ObjectName = apiItem.ObjectName, UserName = apiItem.UserName, CardNo = apiItem.CardNo, EmployeeUID = apiItem.EmployeeUID.EmptyToNull(), VideoUID = apiItem.VideoUID, CameraUID = apiItem.CameraUID, Detalisation = JournalDetalisationItem.ListToString(apiItem.JournalDetalisationItems), }; }
void AddJournalItem(JournalItem journalItem) { GKCallbackResult.JournalItems.Add(journalItem); }
void OnSetPtzPreset() { try { //RviClient.RviClientHelper.SetPtzPreset(ClientManager.SystemConfiguration, Camera, SelectedPreset - 1); RviClient.RviClientHelper.SetPtzPreset(ClientManager.SystemConfiguration.RviSettings, Camera, SelectedPreset); var journalItem = new JournalItem() { SystemDateTime = DateTime.Now, JournalEventNameType = JournalEventNameType.Перевод_в_предустановку, JournalEventDescriptionType = JournalEventDescriptionType.NULL, DescriptionText = SelectedPreset.ToString(), JournalSubsystemType = JournalSubsystemType.Video, JournalObjectType = JournalObjectType.Camera, ObjectUID = Camera.UID, ObjectName = Camera.PresentationName, }; ClientManager.RubezhService.AddJournalItem(journalItem); } catch { MessageBoxService.ShowWarning("Возникла ошибка при переводе в предустановку"); } }
void GetObject(JournalItem journalItem) { switch (journalItem.JournalObjectType) { case JournalObjectType.GKDevice: var device = GKManager.Devices.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (device != null) { ObjectName = device.GetGKDescriptorName(GKManager.DeviceConfiguration.GKNameGenerationType); ObjectImageSource = device.Driver.ImageSource.Replace("/Controls;component/", "/Content/Image/"); } else ObjectImageSource = "/Content/Image/Images/Blank.png"; break; case JournalObjectType.GKZone: var zone = GKManager.Zones.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (zone != null) { ObjectName = zone.PresentationName; } break; case JournalObjectType.GKDirection: var direction = GKManager.Directions.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (direction != null) { ObjectName = direction.PresentationName; } break; case JournalObjectType.GKPumpStation: var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (pumpStation != null) { ObjectName = pumpStation.PresentationName; } break; case JournalObjectType.GKMPT: var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (mpt != null) { ObjectName = mpt.PresentationName; } break; case JournalObjectType.GKDelay: var delay = GKManager.Delays.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (delay != null) { ObjectName = delay.PresentationName; } else { delay = GKManager.AutoGeneratedDelays.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (delay != null) { ObjectName = delay.PresentationName; if (delay.PumpStationUID != Guid.Empty) { var delayPumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == delay.PumpStationUID); if (delayPumpStation != null) { ObjectName += " (" + delayPumpStation.PresentationName + ")"; ObjectImageSource = "/Content/Image/Images/BPumpStation.png"; break; } } } } break; case JournalObjectType.GKPim: var pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (pim != null) { ObjectName = pim.PresentationName; if (pim.PumpStationUID != Guid.Empty) { var pimPumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == pim.PumpStationUID); if (pimPumpStation != null) { ObjectName += " (" + pimPumpStation.PresentationName + ")"; ObjectImageSource = "/Content/Image/Images/BPumpStation.png"; break; } } if (pim.MPTUID != Guid.Empty) { var pimMPT = GKManager.MPTs.FirstOrDefault(x => x.UID == pim.MPTUID); if (pimMPT != null) { ObjectName += " (" + pimMPT.PresentationName + ")"; ObjectImageSource = "/Content/Image/Images/BMPT.png"; break; } } } break; case JournalObjectType.GKGuardZone: var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (guardZone != null) { ObjectName = guardZone.PresentationName; } break; case JournalObjectType.GKSKDZone: var gkSKDZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (gkSKDZone != null) { ObjectName = gkSKDZone.PresentationName; } break; case JournalObjectType.GKDoor: var gkDoor = GKManager.Doors.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (gkDoor != null) { ObjectName = gkDoor.PresentationName; } break; case JournalObjectType.Camera: var camera = RubezhClient.ClientManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == journalItem.ObjectUID); if (camera != null) { ObjectName = camera.PresentationName; } break; case JournalObjectType.None: case JournalObjectType.GKUser: ObjectName = journalItem.ObjectName != null ? journalItem.ObjectName : ""; break; } CanShow = journalItem.JournalObjectType != JournalObjectType.None && journalItem.JournalObjectType != JournalObjectType.GKUser; if (ObjectName == null) { ObjectName = journalItem.ObjectName; } if (ObjectName == null) ObjectName = "<Нет в конфигурации>"; }
public JournalItemViewModel(JournalItem journalItem) { JournalItem = journalItem; if (journalItem.JournalEventNameType != JournalEventNameType.NULL) { Name = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventNameType); } if (journalItem.JournalEventDescriptionType != JournalEventDescriptionType.NULL) { Description = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventDescriptionType); if (!string.IsNullOrEmpty(journalItem.DescriptionText)) Description += " " + journalItem.DescriptionText; } else { Description = journalItem.DescriptionText; } IsExistsInConfig = true; ObjectImageSource = "/Controls;component/Images/Blank.png"; StateClass = EventDescriptionAttributeHelper.ToStateClass(journalItem.JournalEventNameType); switch (JournalItem.JournalObjectType) { case JournalObjectType.GKDevice: Device = GKManager.Devices.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Device != null) { ObjectName = Device.PresentationName; ObjectImageSource = Device.Driver.ImageSource; } break; case JournalObjectType.GKZone: Zone = GKManager.Zones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Zone != null) { ObjectName = Zone.PresentationName; } ObjectImageSource = "/Controls;component/Images/Zone.png"; break; case JournalObjectType.GKDirection: Direction = GKManager.Directions.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Direction != null) { ObjectName = Direction.PresentationName; } ObjectImageSource = "/Controls;component/Images/Blue_Direction.png"; break; case JournalObjectType.GKPumpStation: PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (PumpStation != null) { ObjectName = PumpStation.PresentationName; } ObjectImageSource = "/Controls;component/Images/BPumpStation.png"; break; case JournalObjectType.GKMPT: MPT = GKManager.MPTs.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (MPT != null) { ObjectName = MPT.PresentationName; } ObjectImageSource = "/Controls;component/Images/BMPT.png"; break; case JournalObjectType.GKDelay: Delay = GKManager.Delays.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Delay != null) { ObjectName = Delay.PresentationName; ObjectImageSource = "/Controls;component/Images/Delay.png"; } else { Delay = GKManager.AutoGeneratedDelays.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Delay != null) { ObjectName = Delay.PresentationName; if (Delay.PumpStationUID != Guid.Empty) { PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == Delay.PumpStationUID); if (PumpStation != null) { ObjectName += " (" + PumpStation.PresentationName + ")"; ObjectImageSource = "/Controls;component/Images/BPumpStation.png"; break; } } } } break; case JournalObjectType.GKPim: Pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Pim != null) { ObjectName = Pim.PresentationName; ObjectImageSource = "/Controls;component/Images/Pim.png"; if (Pim.PumpStationUID != Guid.Empty) { PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == Pim.PumpStationUID); if (PumpStation != null) { ObjectName += " (" + PumpStation.PresentationName + ")"; ObjectImageSource = "/Controls;component/Images/BPumpStation.png"; break; } } if (Pim.MPTUID != Guid.Empty) { MPT = GKManager.MPTs.FirstOrDefault(x => x.UID == Pim.MPTUID); if (MPT != null) { ObjectName += " (" + MPT.PresentationName + ")"; ObjectImageSource = "/Controls;component/Images/BMPT.png"; break; } } } break; case JournalObjectType.GKGuardZone: GuardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (GuardZone != null) { ObjectName = GuardZone.PresentationName; } ObjectImageSource = "/Controls;component/Images/Zone.png"; break; case JournalObjectType.GKSKDZone: GKSKDZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (GKSKDZone != null) { ObjectName = GKSKDZone.PresentationName; } ObjectImageSource = "/Controls;component/Images/Zone.png"; break; case JournalObjectType.GKDoor: GKDoor = GKManager.Doors.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (GKDoor != null) { ObjectName = GKDoor.PresentationName; } ObjectImageSource = "/Controls;component/Images/Door.png"; break; case JournalObjectType.VideoDevice: Camera = ClientManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (Camera != null) { ObjectName = Camera.Name; } ObjectImageSource = "/Controls;component/Images/Camera.png"; break; case JournalObjectType.None: case JournalObjectType.GKUser: ObjectName = JournalItem.ObjectName != null ? JournalItem.ObjectName : ""; break; } if (ObjectName == null) { ObjectName = JournalItem.ObjectName; IsExistsInConfig = false; } if (ObjectName == null) ObjectName = "<Нет в конфигурации>"; }
void AddFailureJournalItem(JournalEventNameType journalEventNameType, JournalEventDescriptionType description) { var journalItem = new JournalItem() { JournalEventNameType = journalEventNameType, JournalEventDescriptionType = description, }; var gkIpAddress = GkDatabase.RootDevice.GetGKIpAddress(); if (!string.IsNullOrEmpty(gkIpAddress)) journalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("IP-адрес ГК", gkIpAddress.ToString())); }
void CheckServiceRequired(GKBase gkBase, JournalItem journalItem) { if (journalItem.JournalEventNameType == JournalEventNameType.Запыленность || journalItem.JournalEventNameType == JournalEventNameType.Запыленность_устранена) { if (gkBase is GKDevice) { var device = gkBase as GKDevice; if (journalItem.JournalEventNameType == JournalEventNameType.Запыленность) device.InternalState.IsService = true; if (journalItem.JournalEventNameType == JournalEventNameType.Запыленность_устранена) device.InternalState.IsService = false; } } }
public JournalParser(GKDevice gkControllerDevice, List<byte> bytes) { JournalItem = new JournalItem(); JournalItem.JournalObjectType = JournalObjectType.GKDevice; GKJournalRecordNo = BytesHelper.SubstructInt(bytes, 0); if (GKJournalRecordNo > 0) JournalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("Запись ГК", GKJournalRecordNo.ToString())); GKObjectNo = BytesHelper.SubstructShort(bytes, 4); JournalItem.ObjectUID = gkControllerDevice.UID; var controllerAddress = BytesHelper.SubstructShort(bytes, 32 + 10); if (controllerAddress != 0x200) { var kauDevice = gkControllerDevice.AllChildren.FirstOrDefault(x => (x.Driver.IsKau || x.DriverType == GKDriverType.GKMirror) && x.IntAddress == controllerAddress); if (kauDevice != null) JournalItem.ObjectUID = kauDevice.UID; KauJournalRecordNo = BytesHelper.SubstructInt(bytes, 0x20); } InitializeFromObjectUID(gkControllerDevice); var kauObjectNo = BytesHelper.SubstructShort(bytes, 54); InitializeDateTime(bytes); JournalSourceType = (JournalSourceType)(int)(bytes[32 + 12]); var code = bytes[32 + 13]; switch (JournalSourceType) { case JournalSourceType.Controller: switch (code) { case 0: JournalItem.JournalEventNameType = JournalEventNameType.Перевод_в_технологический_режим; break; case 2: JournalItem.JournalEventNameType = JournalEventNameType.Синхронизация_времени_прибора_с_временем_ПК; break; case 4: JournalItem.JournalEventNameType = JournalEventNameType.Смена_ПО; break; case 5: JournalItem.JournalEventNameType = JournalEventNameType.Смена_БД; break; case 6: JournalItem.JournalEventNameType = JournalEventNameType.Перевод_в_рабочий_режим; break; case 7: JournalItem.JournalEventNameType = JournalEventNameType.Вход_пользователя_в_прибор; JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToUser(bytes[32 + 15], true); var bytes1 = bytes.GetRange(6, 31 - 6 + 1); var bytes2 = bytes.GetRange(48, 53 - 48 + 1); bytes1.AddRange(bytes2); JournalItem.UserName = Encoding.Default.GetString(bytes1.ToArray(), 0, bytes1.Count); JournalItem.JournalObjectType = JournalObjectType.GKDevice; break; case 8: JournalItem.JournalEventNameType = JournalEventNameType.Выход_пользователя_из_прибора; JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToUser(bytes[32 + 15], false); bytes1 = bytes.GetRange(6, 31 - 6 + 1); bytes2 = bytes.GetRange(48, 53 - 48 + 1); bytes1.AddRange(bytes2); JournalItem.UserName = Encoding.Default.GetString(bytes1.ToArray(), 0, bytes1.Count); JournalItem.JournalObjectType = JournalObjectType.GKDevice; break; case 9: JournalItem.JournalEventNameType = JournalEventNameType.Ошибка_управления; GKObjectNo = BytesHelper.SubstructShort(bytes, 18); break; case 10: JournalItem.JournalEventNameType = JournalEventNameType.Введен_новый_пользователь; bytes1 = bytes.GetRange(6, 31 - 6 + 1); bytes2 = bytes.GetRange(48, 53 - 48 + 1); bytes1.AddRange(bytes2); JournalItem.UserName = Encoding.Default.GetString(bytes1.ToArray(), 0, bytes1.Count); JournalItem.JournalObjectType = JournalObjectType.GKDevice; break; case 11: JournalItem.JournalEventNameType = JournalEventNameType.Изменена_учетная_информация_пользователя; bytes1 = bytes.GetRange(6, 31 - 6 + 1); bytes2 = bytes.GetRange(48, 53 - 48 + 1); bytes1.AddRange(bytes2); JournalItem.UserName = Encoding.Default.GetString(bytes1.ToArray(), 0, bytes1.Count); JournalItem.JournalObjectType = JournalObjectType.GKDevice; break; case 12: JournalItem.JournalEventNameType = JournalEventNameType.Произведена_настройка_сети; break; case 13: JournalItem.JournalEventNameType = JournalEventNameType.Проход_пользователя_разрешен; var gkCardNo = BytesHelper.SubstructInt(bytes, 32 + 24); JournalItem.CardNo = gkCardNo; var door = GKManager.Doors.FirstOrDefault(x => x.GKDescriptorNo == GKObjectNo && x.GkDatabaseParent.GKParent == gkControllerDevice); if (door != null) { var readerDevice = GKManager.Devices.FirstOrDefault(x => x.GKDescriptorNo == kauObjectNo && x.GkDatabaseParent.GKParent == gkControllerDevice); if (readerDevice != null) { if (door.EnterDeviceUID == readerDevice.UID) { JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Вход_Глобал; } else if (door.ExitDeviceUID == readerDevice.UID) { JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Выход_Глобал; } } } using (var databaseService = new RubezhDAL.DataClasses.DbService()) { var cardNo = databaseService.GKCardTranslator.GetCardNoByGKNo(gkControllerDevice.GetGKIpAddress(), (int)gkCardNo); var operationResult = databaseService.CardTranslator.GetEmployeeByCardNo(cardNo); if (!operationResult.HasError) { var employeeUID = operationResult.Result; JournalItem.EmployeeUID = employeeUID; if (employeeUID != Guid.Empty) { var employee = databaseService.EmployeeTranslator.GetSingle(employeeUID); if (employee != null) { JournalItem.UserName = employee.Result.Name; } } } } break; case 14: JournalItem.JournalEventNameType = JournalEventNameType.Рабочий_график; var scheduleNo = (uint)BytesHelper.SubstructInt(bytes, 32 + 24); bytes1 = bytes.GetRange(6, 31 - 6 + 1); bytes2 = bytes.GetRange(48, 53 - 48 + 1); bytes1.AddRange(bytes2); var scheduleName = Encoding.Default.GetString(bytes1.ToArray(), 0, bytes1.Count).TrimEnd(' '); if (string.IsNullOrEmpty(scheduleName)) scheduleName = scheduleNo.ToString(); JournalItem.DescriptionText = scheduleName; break; case 15: JournalItem.JournalEventNameType = JournalEventNameType.Проход_пользователя_запрещен; gkCardNo = BytesHelper.SubstructInt(bytes, 32 + 24); JournalItem.CardNo = gkCardNo; door = GKManager.Doors.FirstOrDefault(x => x.GKDescriptorNo == GKObjectNo && x.GkDatabaseParent.GKParent == gkControllerDevice); if (door != null) { var readerDevice = GKManager.Devices.FirstOrDefault(x => x.GKDescriptorNo == kauObjectNo && x.GkDatabaseParent.GKParent == gkControllerDevice); if (readerDevice != null) { if (door.EnterDeviceUID == readerDevice.UID) { JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Вход_Глобал; } else if (door.ExitDeviceUID == readerDevice.UID) { JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Выход_Глобал; } } } using (var databaseService = new RubezhDAL.DataClasses.DbService()) { var cardNo = databaseService.GKCardTranslator.GetCardNoByGKNo(gkControllerDevice.GetGKIpAddress(), (int)gkCardNo); var operationResult = databaseService.CardTranslator.GetEmployeeByCardNo(cardNo); if (!operationResult.HasError) { var employeeUID = operationResult.Result; JournalItem.EmployeeUID = employeeUID; if (employeeUID != Guid.Empty) { var employee = databaseService.EmployeeTranslator.GetSingle(employeeUID); if (employee != null) { JournalItem.UserName = employee.Result.Name; } } } } break; default: JournalItem.JournalEventNameType = JournalEventNameType.Неизвестный_код_события_контроллекра; JournalItem.DescriptionText = code.ToString(); break; } break; case JournalSourceType.Device: var unknownType = BytesHelper.SubstructShort(bytes, 32 + 14); var unknownAddress = BytesHelper.SubstructShort(bytes, 32 + 16); var presentationAddress = (unknownAddress / 256 + 1).ToString() + "." + (unknownAddress % 256).ToString(); var driverName = unknownType.ToString(); var driver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == unknownType); if (driver != null) { driverName = driver.ShortName; }; var unknownDescription = "Тип: " + driverName + " Адрес: " + presentationAddress; switch (code) { case 0: JournalItem.JournalEventNameType = JournalEventNameType.Неизвестный_тип; JournalItem.DescriptionText = unknownDescription; break; case 1: JournalItem.JournalEventNameType = JournalEventNameType.Устройство_с_таким_адресом_не_описано_при_конфигурации; JournalItem.DescriptionText = unknownDescription; break; default: JournalItem.JournalEventNameType = JournalEventNameType.Неизвестный_код_события_устройства; JournalItem.DescriptionText = code.ToString(); break; } break; case JournalSourceType.Object: var UNUSED_ObjectNo = BytesHelper.SubstructShort(bytes, 32 + 18); var descriptorType = BytesHelper.SubstructShort(bytes, 32 + 20); JournalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("Тип дескриптора", descriptorType.ToString())); var descriptorAddress = BytesHelper.SubstructShort(bytes, 32 + 22); JournalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("Адрес дескриптора", descriptorAddress.ToString())); var objectFactoryNo = (uint)BytesHelper.SubstructInt(bytes, 32 + 24); if (objectFactoryNo > 0) JournalItem.JournalDetalisationItems.Add(new JournalDetalisationItem("Заводской номер", objectFactoryNo.ToString())); ObjectState = BytesHelper.SubstructInt(bytes, 32 + 28); switch (code) { case 0: JournalItem.JournalEventNameType = JournalEventNameType.При_конфигурации_описан_другой_тип; var realType = BytesHelper.SubstructShort(bytes, 32 + 14); var realDriverString = "Неизвестный тип " + realType.ToString(); var realDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == realType); if (realDriver != null) { realDriverString = realDriver.ShortName; } JournalItem.DescriptionText = "Действительный тип: " + realDriverString; break; case 1: JournalItem.JournalEventNameType = JournalEventNameType.Изменился_заводской_номер; JournalItem.DescriptionText = "Старый заводской номер: " + BytesHelper.SubstructInt(bytes, 32 + 14).ToString() + " Новый заводской номер: " + objectFactoryNo.ToString(); break; case 2: JournalItem.JournalEventNameType = JournalEventNameType.Пожар_1; if (JournalItem.JournalObjectType == JournalObjectType.GKDevice) { JournalItem.JournalEventNameType = JournalEventNameType.Сработка_1; } if (JournalItem.JournalObjectType == JournalObjectType.GKGuardZone || JournalItem.JournalObjectType == JournalObjectType.GKDoor) { JournalItem.JournalEventNameType = JournalEventNameType.Тревога; } JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToFire(bytes[32 + 15]); break; case 3: JournalItem.JournalEventNameType = JournalEventNameType.Пожар_2; if (JournalItem.JournalObjectType == JournalObjectType.GKDevice) { JournalItem.JournalEventNameType = JournalEventNameType.Сработка_2; } JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToFire(bytes[32 + 15]); break; case 4: JournalItem.JournalEventNameType = JournalEventNameType.Внимание; break; case 5: JournalItem.JournalEventNameType = JournalEventNameType.Неисправность; if (bytes[32 + 14] == 0) { JournalItem.JournalEventNameType = JournalEventNameType.Неисправность_устранена; } bool isFailure = JournalItem.JournalEventNameType == JournalEventNameType.Неисправность; switch (descriptorType) { case 0xD6: JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToBatteryFailure(bytes[32 + 15], isFailure); break; default: JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToFailure(bytes[32 + 15], isFailure, descriptorType == 0xE5); if (bytes[32 + 15] >= 241 && bytes[32 + 15] <= 254) { var firstAdditionalDescription = bytes[32 + 16].ToString(); var secondAdditionalDescription = bytes[32 + 17].ToString(); if (JournalItem.JournalEventDescriptionType == JournalEventDescriptionType.ОЛС_Неисправность || JournalItem.JournalEventDescriptionType == JournalEventDescriptionType.ОЛС_Неисправность_устранена) { var gkDevice = GKManager.Devices.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (gkDevice != null) { var kauCount = gkDevice.AllChildren.FindAll(x => x.Driver.IsKau || x.DriverType == GKDriverType.GKMirror).Count; if (firstAdditionalDescription == "0") firstAdditionalDescription = "ГК"; else firstAdditionalDescription = "КАУ " + bytes[32 + 16]; if (bytes[32 + 17] > kauCount) secondAdditionalDescription = "ГК"; else { var device = gkDevice.Children.FirstOrDefault(x => (x.Driver.IsKau || x.DriverType == GKDriverType.GKMirror) && x.IntAddress == bytes[32 + 17]); if (device != null) secondAdditionalDescription = device.PresentationName; } } } else { var kauDevice = GKManager.Devices.FirstOrDefault(x => x.UID == JournalItem.ObjectUID); if (kauDevice != null) { var device1 = kauDevice.AllChildren.FirstOrDefault(x => x.IntAddress == bytes[32 + 16]); var device2 = kauDevice.AllChildren.FirstOrDefault(x => x.IntAddress == bytes[32 + 17]); if (firstAdditionalDescription == "0" || (device1 != null && device1.DriverType == GKDriverType.RSR2_KAU_Shleif)) firstAdditionalDescription = "КАУ"; if (secondAdditionalDescription == "0" || (device2 == null || device2.DriverType == GKDriverType.RSR2_KAU_Shleif)) secondAdditionalDescription = "КАУ"; } } if (JournalItem.JournalEventNameType == JournalEventNameType.Неисправность_устранена) break; JournalItem.DescriptionText = "устройства " + firstAdditionalDescription + " _ " + secondAdditionalDescription; } break; } break; case 6: JournalItem.JournalEventNameType = JournalEventNameType.Тест; if (bytes[32 + 14] == 0) { JournalItem.JournalEventNameType = JournalEventNameType.Тест_устранен; } break; case 7: JournalItem.JournalEventNameType = JournalEventNameType.Запыленность; if (bytes[32 + 14] == 0) { JournalItem.JournalEventNameType = JournalEventNameType.Запыленность_устранена; } bool isDust = JournalItem.JournalEventNameType == JournalEventNameType.Запыленность; switch (bytes[32 + 15]) { case 1: JournalItem.JournalEventDescriptionType = isDust ? JournalEventDescriptionType.Предварительная_Запыленность : JournalEventDescriptionType.Предварительная_Запыленность_устранена; break; case 2: JournalItem.JournalEventDescriptionType = isDust ? JournalEventDescriptionType.Критическая_Запыленность : JournalEventDescriptionType.Критическая_Запыленность_устранена; break; } break; case 8: JournalItem.JournalEventNameType = JournalEventNameType.Информация; JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToInformation(bytes[32 + 15]); if (Device != null && (Device.DriverType == GKDriverType.RSR2_Valve_KV || Device.DriverType == GKDriverType.RSR2_Valve_KVMV || Device.DriverType == GKDriverType.RSR2_Valve_DU)) { JournalItem.JournalEventDescriptionType = JournalStringsHelper.ToValveInformation(bytes[32 + 15]); } break; case 9: JournalItem.JournalEventNameType = JournalStringsHelper.ToState(bytes[32 + 15]); if (Device != null && (Device.DriverType == GKDriverType.RSR2_Valve_KV || Device.DriverType == GKDriverType.RSR2_Valve_KVMV || Device.DriverType == GKDriverType.RSR2_Valve_DU || Device.DriverType == GKDriverType.RSR2_Buz_KV || Device.DriverType == GKDriverType.RSR2_Buz_KVMV || Device.DriverType == GKDriverType.RSR2_Buz_KVDU)) { JournalItem.JournalEventNameType = JournalStringsHelper.ToValveState(bytes[32 + 15]); } if (GuardZone != null) { JournalItem.JournalEventNameType = JournalStringsHelper.ToGuardZoneState(bytes[32 + 15]); } break; case 10: switch (bytes[32 + 15]) { case 0: JournalItem.JournalEventNameType = JournalEventNameType.Перевод_в_автоматический_режим; break; case 1: JournalItem.JournalEventNameType = JournalEventNameType.Перевод_в_ручной_режим; break; case 2: JournalItem.JournalEventNameType = JournalEventNameType.Перевод_в_отключенный_режим; break; case 3: JournalItem.JournalEventNameType = JournalEventNameType.Перевод_в_неопределенный_режим; break; default: JournalItem.JournalEventNameType = JournalEventNameType.Неизвестный_код_события_объекта; break; } break; case 12: JournalItem.JournalEventNameType = JournalEventNameType.Управление_ПМФ; switch (bytes[32 + 15]) { case 1: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Перевод_в_автоматический_режим_Управление_ПМФ; break; case 2: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Перевод_в_ручной_режим_Управление_ПМФ; break; case 4: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Постановка_на_охрану; break; case 5: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Снятие_с_охраны; break; case 8: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Сброс_Управление_ПМФ; break; case 9: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Пуск; break; case 10: JournalItem.JournalEventDescriptionType = JournalEventDescriptionType.Стоп; break; } break; case 13: JournalItem.JournalEventNameType = JournalEventNameType.Запись_параметра; break; case 14: JournalItem.JournalEventNameType = JournalEventNameType.Норма; break; default: JournalItem.JournalEventNameType = JournalEventNameType.Неизвестный_код_события_объекта; JournalItem.DescriptionText = code.ToString(); break; } break; } JournalItem.JournalSubsystemType = EventDescriptionAttributeHelper.ToSubsystem(JournalItem.JournalEventNameType); InitializeMAMessage(); }