void OnAutomationCallback(AutomationCallbackResult automationCallbackResult) { if (automationCallbackResult.AutomationCallbackType == AutomationCallbackType.GlobalVariable) { var data = automationCallbackResult.Data as GlobalVariableCallBackData; if (data != null) { var variable = ProcedureExecutionContext.GlobalVariables.FirstOrDefault(x => x.Uid == data.VariableUID); variable.Value = data.ExplicitValue.Value; } return; } if (automationCallbackResult.AutomationCallbackType == AutomationCallbackType.OpcDaTag) { var data = automationCallbackResult.Data as OpcDaTagCallBackData; if (data != null) OpcDaHelper.SetTagValue(data.TagUID, data.Value); return; } if (!AutomationHelper.CheckLayoutFilter(automationCallbackResult, GetLayoutUID())) return; switch (automationCallbackResult.AutomationCallbackType) { case AutomationCallbackType.ShowDialog: var showDialogData = automationCallbackResult.Data as ShowDialogCallbackData; if (showDialogData != null) LayoutDialogViewModel.Show(showDialogData); break; case AutomationCallbackType.CloseDialog: var closeDialogData = automationCallbackResult.Data as CloseDialogCallbackData; if (closeDialogData != null) LayoutDialogViewModel.Close(closeDialogData); break; case AutomationCallbackType.Sound: var soundData = (SoundCallbackData)automationCallbackResult.Data; var sound = ClientManager.SystemConfiguration.AutomationConfiguration.AutomationSounds.FirstOrDefault( x => x.Uid == soundData.SoundUID); if (sound != null) ApplicationService.Invoke( () => AlarmPlayerHelper.Play( FileHelper.GetSoundFilePath(Path.Combine(ServiceFactoryBase.ContentService.ContentFolder, sound.Uid.ToString())), false)); break; case AutomationCallbackType.Message: var messageData = (MessageCallbackData)automationCallbackResult.Data; ApplicationService.Invoke(() => { if (messageData.WithConfirmation) { ApplicationService.BeginInvoke(() => { var confirm = MessageBoxService.ShowConfirmation(messageData.Message, "Сообщение"); ProcedureExecutionContext.CallbackResponse(RubezhServiceFactory.UID, automationCallbackResult.ContextType, automationCallbackResult.CallbackUID, confirm); }); } else MessageBoxService.ShowExtended(messageData.Message, "Сообщение", messageData.IsModalWindow); }); break; case AutomationCallbackType.Property: { var propertyData = (PropertyCallBackData)automationCallbackResult.Data; var ShowObjectDetailsEvent = new CompositePresentationEvent<Guid>(); switch (propertyData.ObjectType) { case ObjectType.Device: var device = GKManager.Devices.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (device != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDeviceDetailsEvent>(); break; case ObjectType.Zone: var zone = GKManager.Zones.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (zone != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKZoneDetailsEvent>(); break; case ObjectType.Direction: var direction = GKManager.Directions.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (direction != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDirectionDetailsEvent>(); break; case ObjectType.Delay: var delay = GKManager.Delays.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (delay != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDelayDetailsEvent>(); break; case ObjectType.GuardZone: var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (guardZone != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKGuardZoneDetailsEvent>(); break; case ObjectType.VideoDevice: var videoDevice = ClientManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (videoDevice != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowCameraDetailsEvent>(); break; case ObjectType.GKDoor: var gkDoor = GKManager.Doors.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (gkDoor != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDoorDetailsEvent>(); break; case ObjectType.PumpStation: var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (pumpStation != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>(); break; case ObjectType.MPT: var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == propertyData.ObjectUid); if (mpt != null) ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKMPTDetailsEvent>(); break; } if (ShowObjectDetailsEvent != null) ApplicationService.BeginInvoke(() => ShowObjectDetailsEvent.Publish(propertyData.ObjectUid)); } break; case AutomationCallbackType.GetPlanProperty: var controlPlanEventArg = new ControlPlanEventArg { ControlElementType = ControlElementType.Get, PlanCallbackData = (PlanCallbackData)automationCallbackResult.Data }; ServiceFactory.Events.GetEvent<ControlPlanEvent>().Publish(controlPlanEventArg); ProcedureExecutionContext.CallbackResponse(RubezhServiceFactory.UID, automationCallbackResult.ContextType, automationCallbackResult.CallbackUID, controlPlanEventArg.PlanCallbackData.Value); break; case AutomationCallbackType.SetPlanProperty: controlPlanEventArg = new ControlPlanEventArg { ControlElementType = ControlElementType.Set, PlanCallbackData = (PlanCallbackData)automationCallbackResult.Data }; ServiceFactory.Events.GetEvent<ControlPlanEvent>().Publish(controlPlanEventArg); break; } }
void OnControlPlan(ControlPlanEventArg controlPlanEventArg) { switch (controlPlanEventArg.ControlElementType) { case ControlElementType.Get: GetPlanProperty(controlPlanEventArg.PlanCallbackData); break; case ControlElementType.Set: SetPlanProperty(controlPlanEventArg.PlanCallbackData); break; } }