/// <summary> /// This method is used to set the command ready to run the master job. /// </summary> /// <param name="negotiationChannelIn">The negotiation channel in.</param> /// <param name="negotiationChannelOut">The negotiation channel out.</param> /// <param name="negotiationMessageType">The Message Type for the negotiation message.</param> /// <param name="strategy">The negotiation strategy. If this is not set, MasterJobNegotiationStrategyDebug will be used.</param> /// <exception cref="CommandHarnessException">MasterJobEnable should be called before the command is started.</exception> public void MasterJobNegotiationEnable(string negotiationChannelIn = null , string negotiationChannelOut = null , string negotiationMessageType = null , MasterJobNegotiationStrategyBase strategy = null) { if (Service.Status == ServiceStatus.Running) { throw new CommandHarnessException("MasterJobEnable should be called before the command is started."); } Policy.MasterJobNegotiationStrategy = strategy ?? new MasterJobNegotiationStrategyDebug(); if (string.IsNullOrEmpty(Policy.MasterJobNegotiationChannelIdIncoming)) { Policy.MasterJobNegotiationChannelIdIncoming = negotiationChannelIn ?? "masterjob"; } if (string.IsNullOrEmpty(Policy.MasterJobNegotiationChannelIdOutgoing)) { Policy.MasterJobNegotiationChannelIdOutgoing = negotiationChannelOut ?? "masterjob"; } if (string.IsNullOrEmpty(Policy.MasterJobNegotiationChannelMessageType)) { Policy.MasterJobNegotiationChannelMessageType = negotiationMessageType ?? Service.FriendlyName.ToLowerInvariant(); } //Trigger the schedule to run when the command starts. Service.StatusChanged += (object sender, StatusChangedEventArgs e) => { if (e.StatusNew == ServiceStatus.Running) { //Inject the master job message. MasterJobScheduleExecute(); } }; //Intercept outgoing MasterJob Messages and loop back to pass the comms check. MasterJobOutgoingLoopbackEnable(); //Set the policy to enable the MasterJob Policy.MasterJobEnabled = true; }
/// <summary> /// Initializes a new instance of the <see cref="MasterJobContext"/> class. /// </summary> public MasterJobContext(string name, MasterJobNegotiationStrategyBase strategy) { Name = name; NegotiationStrategy = strategy ?? new MasterJobNegotiationStrategy(); }