void LegacyInstance_StateChanged(object sender, ServiceStateChangedEventArgs e) { Easynet.Edge.Core.Services.ServiceInstance instance = (Easynet.Edge.Core.Services.ServiceInstance)sender; if (e.StateAfter == ServiceState.Ready) { instance.Start(); //TODO: TRY CATCH } }
static void ActiveRuleProperty_Setting(object sender, ValueTranslationEventArgs e) { ServiceInstance current = (ServiceInstance)e.Entity; if ((int)current.State > (int)ServiceState.Uninitialized) { throw new InvalidOperationException("Cannot change properties after Initialize has been called."); } current._activeRule = (SchedulingRuleElement)e.Input; e.Output = null; }
void ChildOutcomeReported(object sender, EventArgs e) { ServiceInstance child = (ServiceInstance)sender; child.StateChanged -= _childStateHandler; child.OutcomeReported -= _childOutcomeHandler; int stepNumer = _childServices[child]; _childServices.Remove(child); if (_commChannel != null && _commChannel.State == CommunicationState.Opened) { _commChannel.Engine.ChildServiceOutcomeReported(stepNumer, child.Outcome); } }
/*=========================*/ #endregion #region Constructor /*=========================*/ /// <summary> /// /// </summary> internal ServiceInstance(ActiveServiceElement activeConfiguration, ServiceInstance parentInstance, int accountID) { ActiveConfigurationProperty.SetValue(this, activeConfiguration); ParentInstanceProperty.SetValue(this, parentInstance); if (accountID > -1) { AccountIDProperty.SetValue(this, accountID); } _childStateHandler = new EventHandler <ServiceStateChangedEventArgs>(ChildStateChanged); _childOutcomeHandler = new EventHandler(ChildOutcomeReported); Log = new Log(this); }
public ServiceInstanceInfo(ServiceInstance instance) { _accountID = instance.AccountID; _instanceID = instance.InstanceID; _priority = instance.Priority; _config = instance.Configuration; _rule = instance.ActiveSchedulingRule; _timeStarted = instance.TimeStarted; _timeScheduled = instance.TimeScheduled; _serviceUrl = instance.ServiceUrl; if (instance.ParentInstance != null) { _parentInstanceData = new ServiceInstanceInfo(instance.ParentInstance); } }
void LegacyInstance_ChildServiceRequested(object sender, Easynet.Edge.Core.Services.ServiceRequestedEventArgs e) { try { legacy.ServiceInstance instance = (legacy.ServiceInstance)sender; this.Invoke(setLogMethod, new Object[] { string.Format("\nChild Service: {0} requestedd {1}\r\n", e.RequestedService.Configuration.Name, DateTime.Now.ToString("dd/MM/yy HH:mm")) }); e.RequestedService.ChildServiceRequested += new EventHandler <legacy.ServiceRequestedEventArgs>(LegacyInstance_ChildServiceRequested); e.RequestedService.StateChanged += new EventHandler <legacy.ServiceStateChangedEventArgs>(LegacyInstance_StateChanged); e.RequestedService.Initialize(); } catch (Exception ex) { Easynet.Edge.Core.Utilities.Log.Write("SchedulingControlForm", ex.Message, ex, Easynet.Edge.Core.Utilities.LogMessageType.Error); } }
void LegacyInstance_StateChanged(object sender, Easynet.Edge.Core.Services.ServiceStateChangedEventArgs e) { try { legacy.ServiceInstance instance = (Easynet.Edge.Core.Services.ServiceInstance)sender; instance.OutcomeReported += new EventHandler(instance_OutcomeReported); this.Invoke(updateGridMethod, new Object[] { instance }); this.Invoke(setLogMethod, new Object[] { string.Format("\n{0}: {1} is {2} {3}\r\n", instance.AccountID, instance.Configuration.Name, e.StateAfter, DateTime.Now.ToString("dd/MM/yy HH:mm")) }); if (e.StateAfter == legacy.ServiceState.Ready) { instance.Start(); } } catch (Exception ex) { Easynet.Edge.Core.Utilities.Log.Write("SchedulingControlForm", ex.Message, ex, Easynet.Edge.Core.Utilities.LogMessageType.Error); } }
private void UpdateGridData(legacy.ServiceInstance serviceInstance) { try { foreach (DataGridViewRow row in scheduleInfoGrid.Rows) { if (Object.Equals(row.Tag, serviceInstance)) { row.Cells["dynamicStaus"].Value = serviceInstance.State; row.Cells["outCome"].Value = serviceInstance.Outcome; row.Cells["actualEndTime"].Value = serviceInstance.TimeEnded.ToString("dd/MM/yyyy HH:mm:ss"); Color color = GetColorByState(serviceInstance.State, serviceInstance.Outcome); row.DefaultCellStyle.BackColor = color; } } } catch (Exception ex) { Easynet.Edge.Core.Utilities.Log.Write("SchedulingControlForm", ex.Message, ex, Easynet.Edge.Core.Utilities.LogMessageType.Error); } }
/// <summary> /// /// </summary> public static ServiceInstance CreateInstance(EnabledConfigurationElement configuration, ServiceInstance parentInstance, int accountID) { return(ServiceInstance.Generate(configuration, parentInstance, accountID)); }
/*=========================*/ #endregion #region CreateInstance /*=========================*/ /// <summary> /// /// </summary> public static ServiceInstance CreateInstance(EnabledConfigurationElement configuration) { return(ServiceInstance.Generate(configuration, null, -1)); }
static void ActiveRuleProperty_Getting(object sender, ValueTranslationEventArgs e) { ServiceInstance current = (ServiceInstance)e.Entity; e.Output = current._activeRule; }
void instance_OutcomeReported(object sender, EventArgs e) { legacy.ServiceInstance instance = (Easynet.Edge.Core.Services.ServiceInstance)sender; this.Invoke(updateGridMethod, new Object[] { instance }); }