Ejemplo n.º 1
0
        DrSrvMgr GetSrvManagerWrapped(string server, DrSrvHelper.SC_MANAGER access)
        {
            var srvMgr = new DrSrvMgr(false);

            srvMgr.EventBeforeOpenSCM                  += DoBeforeOpenSCM;
            srvMgr.EventAfterOpenSCM                   += DoAfterOpenSCM;
            srvMgr.EventBeforeOpenService              += DoBeforeOpenService;
            srvMgr.EventAfterOpenService               += DoAfterOpenService;
            srvMgr.EventWaitExpectedServiceState       += DoWaitExpectedStatus;
            srvMgr.EventBeforeWaitExpectedServiceState += DoBeforeWaitExpectedStatus;
            srvMgr.EventAfterWaitExpectedServiceState  += DoAferWaitExpectedStatus;
            srvMgr.EventBeforeServiceControl           += DoBeforeServiceControl;
            srvMgr.EventAfterServiceControl            += DoAfterServiceControl;
            srvMgr.EventBeforeServiceStart             += DoBeforeServiceStart;
            srvMgr.EventAfterServiceStart              += DoAfterServiceStart;
            srvMgr.EventBeforeCreateService            += DoBeforeCreateService;
            srvMgr.EventAfterCreateService             += DoAfterCreateService;
            srvMgr.EventBeforeServiceDelete            += DoBeforeServiceDelete;
            srvMgr.EventAfterServiceDelete             += DoAfterServiceDelete;
            srvMgr.EventBeforeThrowWin32Error          += DoBeforeThrowWin32Error;

            log.WriteInfo("Open service control manager database on the server '{0}'.", (String.IsNullOrEmpty(server) ? "local" : server));
            if (!srvMgr.OpenSCM(server, access))
            {
                throw new DrTAHelper.DrTAFailedException(srvMgr.LastError, "Cannot open service control manager database on the server '{0}'.", (String.IsNullOrEmpty(server) ? "local" : server));
            }
            return(srvMgr);
        }
Ejemplo n.º 2
0
 private bool waitState(DrSrvMgr srvMgr, string service, DrSrvHelper.SERVICE_CURRENT_STATE state, int timeOut)
 {
     log.WriteInfo("Waits service '{0}' expected '{1}' state. The timeout period is '{2}'.", service, state, timeOut);
     return(srvMgr.ServiceWaitStatus(service, state, timeOut));
 }
Ejemplo n.º 3
0
 private bool delete(DrSrvMgr srvMgr, string service, int timeOut)
 {
     log.WriteInfo("Delete service '{0}'. If service is runnig it will be stopped with all depenedents services. Time wait period is '{1}'", service, timeOut);
     return(srvMgr.ServiceDelete(service, true, timeOut, true));
 }
Ejemplo n.º 4
0
 private bool start(DrSrvMgr srvMgr, string service, int timeOut)
 {
     log.WriteInfo("Start service '{0}'. Time wait period is '{1}'", service, timeOut);
     return(srvMgr.ServiceStart(service, timeOut));
 }
Ejemplo n.º 5
0
 private bool stop(DrSrvMgr srvMgr, string service, int timeOut)
 {
     log.WriteInfo("Stop service '{0}' with dependents. Time wait period is '{1}'", service, timeOut);
     return(srvMgr.ServiceStop(service, timeOut, true));
 }