private void stopToolStripMenuItem1_Click(object sender, EventArgs e) { SvcController svcC = new SvcController(); int intSvcRunning = svcC.isSvcRunning(); if (intSvcRunning == 0) { AdminLogger.WriteEvent("Trying to stop service.", ZifliForm._DEBUG); try { int intSvcStop = svcC.stopSvc(); } catch { AdminLogger.WriteEvent("Exception occurred stopping service.", ZifliForm._ERR); } } else { AdminLogger.WriteEvent("Service was already stopped.", ZifliForm._ERR); } this.updateLabelsMenus(); }
public static void remotePollTcp(ZifliForm aForm) { remotingController obj = (remotingController) Activator.GetObject(typeof(ZifliService.remotingController), "tcp://localhost:11975/ZifliServer"); try { try { obj.initiatePoll(); aForm.labelResult_Modify(true); } catch { AdminLogger.WriteEvent("Initiate \"out of band\" poll failed.", ZifliForm._ERR); aForm.labelResult_Modify(false); } } catch { AdminLogger.WriteEvent("Failed to achieve IPC channel.", ZifliForm._ERR); } }
private void startToolStripMenuItem1_Click(object sender, EventArgs e) { SvcController svcC = new SvcController(); int intSvcRunning = svcC.isSvcRunning(); int intSvcStart; if (intSvcRunning == 1) { AdminLogger.WriteEvent("Trying to start service.", ZifliForm._DEBUG); try { intSvcStart = svcC.startSvc(); } catch { AdminLogger.WriteEvent("Exception occurred starting service.", ZifliForm._ERR); intSvcStart = 2; } } else { AdminLogger.WriteEvent("Service was already running.", ZifliForm._WARN); intSvcStart = 0; } AdminLogger.WriteEvent("intSvcStart: " + intSvcStart.ToString(), ZifliForm._DEBUG); this.updateLabelsMenus(); }
public int isSvcRunning() { services = ServiceController.GetServices(); foreach (ServiceController service in services) { if (service.ServiceName == "ZifliService") { if (service.Status.ToString() == "Running") { AdminLogger.WriteEvent("Service is running.", ZifliForm._DEBUG); return(0); } else { AdminLogger.WriteEvent("Service must be stopped.", ZifliForm._DEBUG); return(1); } } else { //AdminLogger.WriteEvent("Not the service we're looking for.", // ZifliForm._INFO); } } AdminLogger.WriteEvent("Service is not installed.", ZifliForm._ERR); return(2); }
private void btnPoll_Click(object sender, EventArgs e) { this.labelResult.Text = "Result:"; try { ClientRemoting.remotePollTcp(this); } catch { AdminLogger.WriteEvent("Exception handled trying to poll computer.", ZifliForm._ERR); } }
public static void createChannelTcp() { TcpClientChannel chan = new TcpClientChannel(); ChannelServices.RegisterChannel(chan, false); AdminLogger.WriteEvent("Client channel created.", ZifliForm._DEBUG); /*svcController obj = (svcController)Activator.GetObject( * typeof(ZifliService.svcController), * "tcp://localhost:11975/ZifliService"); * AdminLogger.WriteEvent("Activator established.", * ZifliForm._DEBUG);*/ }
public static void createChannel() { Hashtable ht = new Hashtable(); ht.Add("name", "ZifliClient"); ht.Add("portName", "ZifliClient"); ht.Add("typeFilterLevel", "Full"); //IpcClientChannel chan = new IpcClientChannel( IpcChannel chan = new IpcChannel( ht, new BinaryClientFormatterSinkProvider(ht, null), new BinaryServerFormatterSinkProvider(ht, null)); ChannelServices.RegisterChannel(chan, false); AdminLogger.WriteEvent("Client channel created.", ZifliForm._DEBUG); }
public void updateLabelsMenus() { SvcController svcC = new SvcController(); int intSvcRunning; try { intSvcRunning = svcC.isSvcRunning(); } catch { AdminLogger.WriteEvent("Exception when trying to get service status.", ZifliForm._ERR); intSvcRunning = 2; this.cmsStrip1_disable_start(); this.cmsStrip1_disable_stop(); } AdminLogger.WriteEvent("updateLabelsMenus, intSvcRunning: " + intSvcRunning.ToString(), ZifliForm._DEBUG); if (intSvcRunning == 0) { this.labelStatus.Text = "Service Status: RUNNING"; this.cmsStrip1_disable_start(); this.cmsStrip1_enable_stop(); } else if (intSvcRunning == 1) { this.labelStatus.Text = "Service Status: STOPPED"; this.cmsStrip1_enable_start(); this.cmsStrip1_disable_stop(); } else { this.labelStatus.Text = "Service Status: UNKNOWN"; this.cmsStrip1_disable_start(); this.cmsStrip1_disable_stop(); } }
public int startSvc() { services = ServiceController.GetServices(); foreach (ServiceController service in services) { if (service.ServiceName == "ZifliService") { try { service.Start(); service.WaitForStatus(ServiceControllerStatus.Running); return(0); } catch { AdminLogger.WriteEvent("Failed to start service.", ZifliForm._ERR); return(1); } } } return(2); }