public int getServerServiceId(ServiceControllerEx svc) { int id; SqlCommand command = new SqlCommand(Program.DB.queryGetServerServiceId); command.Parameters.AddWithValue("@server_id", getServerId()); command.Parameters.AddWithValue("@name", svc.DisplayName); DataTable rows = Program.DB.executeQuery(command); if (rows.Rows.Count < 1) { return(0); } DataRow row = rows.Rows[0]; Int32.TryParse(row["id"].ToString(), out id); if (id > 0) { return(id); } return(0); }
private async Task UpdateServices() { var svcs = new List <ServerService>(); foreach (ServiceController sc in ServiceController.GetServices()) { var svc = new ServiceControllerEx(sc); svcs.Add(new ServerService() { name = svc.DisplayName.ToString(), status = svc.Status.ToString(), start_mode = svc.StartupType.ToString() }); } Program.Api.UpdateServerServices(svcs); }