protected async Task StateChanged(PipelineModuleStatus newState) { if (newState == Status) { return; } PEMBus.InstanceLogger.AddCustomEvent(LagoVista.Core.PlatformSupport.LogLevel.StateChange, $"StatusChange: {GetType().Name} from {Status} to {newState}.", "statusChange", new KeyValuePair <string, string>("oldState", Status.ToString()), new KeyValuePair <string, string>("newState", newState.ToString()), new KeyValuePair <string, string>("pipelineModuleId", Id)); var stateChangeNotification = new StateChangeNotification() { OldState = EntityHeader <PipelineModuleStatus> .Create(Status), NewState = EntityHeader <PipelineModuleStatus> .Create(newState), }; var msg = new Notification() { Payload = JsonConvert.SerializeObject(stateChangeNotification), PayloadType = typeof(StateChangeNotification).Name, Channel = EntityHeader <Services.Channels> .Create(Services.Channels.PipelineModule), ChannelId = Id, Text = $"Status Change from {stateChangeNotification.OldState.Text} to {stateChangeNotification.NewState.Text}" }; await PEMBus.NotificationPublisher.PublishAsync(Targets.WebSocket, msg); StateChangeTimeStamp = DateTime.Now.ToJSONString(); Status = newState; }
protected async Task SendChangeStateMessageAsync(string msg, PipelineModuleStatus newState) { try { SendNotification(Runtime.Core.Services.Targets.WebSocket, msg); LogMessage(this.GetType().Name, msg); await StateChanged(newState); } catch (Exception ex) { LogException("PipelineModule_SendChangeStateMessageAsync", ex); } }