public static PushServicesInfoList GetServices() { PushServicesInfoList s = new PushServicesInfoList(); s.Data = new List <PushServicesInfo>(); foreach (ManagementObject srv in new ManagementObjectSearcher("Select * from Win32_SystemDriver").Get()) { s.Data.Add(ProcessData(srv, true)); } foreach (ManagementObject srv in new ManagementObjectSearcher("Select * from Win32_Service").Get()) { s.Data.Add(ProcessData(srv, false)); } return(s); }
public RESTStatus ListServices(SQLLib sql, object dummy, NetworkConnectionInfo ni, string MachineID) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } string guid = Guid.NewGuid().ToString(); PushData p = new PushData(); p.Action = "services"; p.ReplyID = guid; PushServiceHelper.SendPushService(MachineID, p, 0); PushDataResponse resp = PushServiceHelper.PopResponse(MachineID, 0, guid); if (resp == null) { ni.Error = "No response"; ni.ErrorID = ErrorFlags.NoData; return(RESTStatus.NoContent); } try { ServicesList = JsonConvert.DeserializeObject <PushServicesInfoList>(resp.Data.ToString()); } catch { ni.Error = "Faulty data"; ni.ErrorID = ErrorFlags.NoData; return(RESTStatus.NoContent); } return(RESTStatus.Success); }