public ServiceUnitStatusViewModel(ServiceUnitStatus status, string hostEndpoint) { Status = status.Status; IsInUpdateList = status.IsInUpdateList; ServiceCode = status.ServiceCode; ServiceProcessName = status.ServiceProcessName; ServiceName = status.ServiceName; HostEndpoint = hostEndpoint; FilesLeft = status.FilesLeft; FilesUpdated = status.FilesUpdated; dependsOn = status.dependsOn; }
public ServiceUnitStatusViewModel(ServiceUnitStatus status, string hostEndpoint) { Status = status.Status; IsInUpdateList = status.IsInUpdateList; ServiceCode = status.ServiceCode; ServiceProcessName = status.ServiceProcessName; ServiceName = status.ServiceName; HostEndpoint = hostEndpoint; FilesLeft = status.FilesLeft; FilesUpdated = status.FilesUpdated; dependsOn = status.dependsOn; }
public List <ServiceUnitStatus> GetServicesStatus() { var map = ServiceMap.LoadSettings(); if (map.Items.Count == 0) { return(new List <ServiceUnitStatus>()); } var servicesBeingUpdated = UpdateServiceManager.Instance.GetNamesOfUpdatingServices(); var statuses = map.Items.Select(i => { var stat = new ServiceUnitStatus { ServiceName = i.ServiceName, IsInUpdateList = servicesBeingUpdated.Contains(i.ServiceName), dependsOn = string.IsNullOrEmpty(i.DependsOn) ? new string[0] : i.DependsOn.Split(new [] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries) }; // получить статус процесса (запущен / остановлен / ...) using (var sc = new ServiceController(i.ServiceName)) { stat.Status = sc.Status; } // получить статус обновления... if (stat.IsInUpdateList) { var updateStatus = serviceStatus.Find(s => s.ServiceName == stat.ServiceName, 2000); if (updateStatus != null) { stat.FilesUpdated = updateStatus.FilesUpdated; stat.FilesLeft = updateStatus.FilesLeft; } } return(stat); }).ToList(); return(statuses); }
public List<ServiceUnitStatus> GetServicesStatus() { var map = ServiceMap.LoadSettings(); if (map.Items.Count == 0) return new List<ServiceUnitStatus>(); var servicesBeingUpdated = UpdateServiceManager.Instance.GetNamesOfUpdatingServices(); var statuses = map.Items.Select(i => { var stat = new ServiceUnitStatus { ServiceName = i.ServiceName, IsInUpdateList = servicesBeingUpdated.Contains(i.ServiceName), dependsOn = string.IsNullOrEmpty(i.DependsOn) ? new string[0] : i.DependsOn.Split(new [] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries) }; // получить статус процесса (запущен / остановлен / ...) using (var sc = new ServiceController(i.ServiceName)) { stat.Status = sc.Status; } // получить статус обновления... if (stat.IsInUpdateList) { var updateStatus = serviceStatus.Find(s => s.ServiceName == stat.ServiceName, 2000); if (updateStatus != null) { stat.FilesUpdated = updateStatus.FilesUpdated; stat.FilesLeft = updateStatus.FilesLeft; } } return stat; }).ToList(); return statuses; }