Log Message: ----------- Control dependent win32 services Modified Files: -------------- pgadmin3: CHANGELOG.txt (r1.200 -> r1.201) pgadmin3/src/schema: pgServer.cpp (r1.59 -> r1.60) pgadmin3/src/ui: ctlSQLResult.cpp (r1.24 -> r1.25)
Index: CHANGELOG.txt =================================================================== RCS file: /projects/pgadmin3/CHANGELOG.txt,v retrieving revision 1.200 retrieving revision 1.201 diff -LCHANGELOG.txt -LCHANGELOG.txt -u -w -r1.200 -r1.201 --- CHANGELOG.txt +++ CHANGELOG.txt @@ -17,6 +17,7 @@ </ul> <br> <ul> + <li>2005-04-04 AP Control dependent win32 services <li>2005-04-01 AP Speed up of column property retrieval <li>2005-04-01 DP 1.2.2 Fix changing of view ownership <li>2005-03-28 AP FK MATCH FULL Index: pgServer.cpp =================================================================== RCS file: /projects/pgadmin3/src/schema/pgServer.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -Lsrc/schema/pgServer.cpp -Lsrc/schema/pgServer.cpp -u -w -r1.59 -r1.60 --- src/schema/pgServer.cpp +++ src/schema/pgServer.cpp @@ -134,6 +134,9 @@ } +#define SERVICEBUFSIZE 10000 + + bool pgServer::StartService() { bool done=false; @@ -145,14 +148,56 @@ { DWORD rc = ::GetLastError(); if (rc == ERROR_SERVICE_ALREADY_RUNNING) + { + GetServerRunning(); return true; - + } // report error wxLogError(__("Failed to start server %s: Errcode=%d\nCheck event log for details."), serviceId.c_str(), rc); } else + { GetServerRunning(); // ignore result, just to wait for startup + + LPENUM_SERVICE_STATUS sbuf = (LPENUM_SERVICE_STATUS) new char[SERVICEBUFSIZE]; + DWORD bytesNeeded, servicesReturned=0; + ::EnumDependentServices(serviceHandle, SERVICE_INACTIVE, sbuf, SERVICEBUFSIZE, &bytesNeeded, &servicesReturned); + if (servicesReturned > 0) + { + DWORD i; + wxString services; + for (i=0 ; i < servicesReturned ; i++) + services += wxT(" ") + wxString(sbuf[i].lpDisplayName) + wxT("\n"); + + wxMessageDialog msg(0, _("There are dependent services configured:\n\n") + + services + _("\nStart dependent services too?"), _("Dependent services running"), + wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT); + + if (msg.ShowModal() == wxID_YES) + { + for (i=0 ; i < servicesReturned ; i++) + { + SC_HANDLE h=::OpenService(scmHandle, sbuf[i].lpServiceName, GENERIC_EXECUTE|GENERIC_READ); + if (h) + { + if (!::StartService(h, 0, 0)) + done=false; + CloseServiceHandle(h); + } + else + done=false; + } + if (!done) + { + wxMessageDialog msg(0, _("One or more dependent services didn't start; see the eventlog for details."), _("Service start problem"), + wxICON_EXCLAMATION |wxOK); + msg.ShowModal(); + done=true; + } + } + } + } } #else wxString res = ExecProcess(serviceId + wxT(" start")); @@ -169,13 +214,51 @@ if (serviceHandle) { SERVICE_STATUS st; + done = (::ControlService(serviceHandle, SERVICE_CONTROL_STOP, &st) != 0); if (!done) { - DWORD rc = ::GetLastError(); + if (::GetLastError() == ERROR_DEPENDENT_SERVICES_RUNNING) + { + LPENUM_SERVICE_STATUS sbuf = (LPENUM_SERVICE_STATUS) new char[SERVICEBUFSIZE]; + DWORD bytesNeeded, servicesReturned=0; + ::EnumDependentServices(serviceHandle, SERVICE_ACTIVE, sbuf, SERVICEBUFSIZE, &bytesNeeded, &servicesReturned); + + done=true; + + if (servicesReturned) + { + DWORD i; + wxString services; + for (i=0 ; i < servicesReturned ; i++) + services += wxT(" ") + wxString(sbuf[i].lpDisplayName) + wxT("\n"); + + wxMessageDialog msg(0, _("There are dependent services running:\n\n") + + services + _("\nStop dependent services?"), _("Dependent services running"), + wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT); + if (msg.ShowModal() != wxID_YES) + return false; + + for (i=0 ; done && i < servicesReturned ; i++) + { + SC_HANDLE h=::OpenService(scmHandle, sbuf[i].lpServiceName, GENERIC_EXECUTE|GENERIC_READ); + if (h) + { + done = (::ControlService(h, SERVICE_CONTROL_STOP, &st) != 0); + CloseServiceHandle(h); + } + else + done=false; + } + if (done) + done = (::ControlService(serviceHandle, SERVICE_CONTROL_STOP, &st) != 0); + } + } // report error + + if (!done) wxLogError(__("Failed to stop server %s: Errcode=%d\nCheck event log for details."), - serviceId.c_str(), rc); + serviceId.c_str(), ::GetLastError()); } } #else Index: ctlSQLResult.cpp =================================================================== RCS file: /projects/pgadmin3/src/ui/ctlSQLResult.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -Lsrc/ui/ctlSQLResult.cpp -Lsrc/ui/ctlSQLResult.cpp -u -w -r1.24 -r1.25 --- src/ui/ctlSQLResult.cpp +++ src/ui/ctlSQLResult.cpp @@ -186,6 +186,7 @@ colTypes.Add(wxT("")); colTypClasses.Add(0L); + Freeze(); InsertColumn(0, _("Row"), wxLIST_FORMAT_RIGHT, 30); colNames.Add(wxT("Row")); @@ -217,6 +218,7 @@ InsertColumn(col+1, colHeader, wxLIST_FORMAT_LEFT, w); } + Thaw(); } long count=0;
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend