public Command(Guid userId, Guid agentId, Guid companyId, Guid itemId, SolicitationType solicitationType, string name, string displayName, string newValue) { UserId = userId; AgentId = agentId; CompanyId = companyId; ItemId = itemId; SolicitationType = solicitationType; Name = name; DisplayName = displayName; NewValue = newValue; }
public override bool Change(string newValue, SolicitationType solicitationType) { if (this.NextMonitoring.HasValue && DateTime.Now < this.NextMonitoring.Value && solicitationType != SolicitationType.ChangeStatus) { return(false); } var returned = false; var status = SystemServicesController.GetStatus(this.Name, this.DisplayName); if (status.ToString().Equals(newValue)) { return(returned); } if (ServiceControllerStatus.Running.ToString().Equals(newValue) || StatusLinux.Active.ToString().Equals(newValue) || StatusLinux.Failed.ToString().Equals(newValue)) { returned = SystemServicesController.Start(this.Name, this.DisplayName); } else if (ServiceControllerStatus.Stopped.ToString().Equals(newValue) || StatusLinux.Inactive.ToString().Equals(newValue)) { returned = SystemServicesController.Stop(this.Name, this.DisplayName); } var statusAfterCommand = SystemServicesController.GetStatus(this.Name, this.DisplayName); if (returned || !statusAfterCommand.Equals(this.Value)) { this.LastValue = this.Value; this.Value = statusAfterCommand; this.MonitoredAt = DateTime.Now; this.AboutCurrentValue = solicitationType.ToString(); this.NextMonitoring = null; } return(returned); }
public override bool Change(string newValue, SolicitationType solicitationType) { if (this.NextMonitoring.HasValue && DateTime.Now < this.NextMonitoring.Value) { return(false); } if (!string.IsNullOrEmpty(newValue) && !this.Value.Equals(newValue)) { SystemArchivesService.ChangeValue(this.Name, newValue: newValue); this.LastValue = this.Value; this.Value = newValue; this.MonitoredAt = DateTime.Now; this.AboutCurrentValue = solicitationType.ToString(); this.NextMonitoring = null; return(true); } return(false); }
public virtual bool Change(string newValue, SolicitationType solicitationType) { return(false); }