/// <summary> /// 重启服务 /// </summary> void resetService() { CommiServer.GlobalServer.Stop(); this.srvTrans.Close(); CommiManager.GlobalManager.ClearCommand(); ThreadManager.AbortAll(); CommiManager.GlobalManager.ResetClient(); DeviceEatery.ResetQueue(); DeviceDoor.ResetQueue(); DeviceChannel.ResetQueue(); channelmgr.ResetRecord(); monimgr.Resetdev(); Monitor.Enter(argsExtendList); argsExtendList.Clear(); Monitor.PulseAll(argsExtendList); Monitor.Exit(argsExtendList); isRunExtend = false; isResetService = false; ServiceController ctrl = new ServiceController("Granity服务守护"); LogMessage("自动重启Granity文件服务", null, EventLogEntryType.Information); ctrl.ExecuteCommand(200); return; CommiServer commisrv = CommiServer.GlobalServer; commisrv.Stop(); this.srvTrans.Close(); if (ThreadManager.IsResetNeed || isResetService) { CommiManager.GlobalManager.ClearCommand(); ThreadManager.AbortAll(); CommiManager.GlobalManager.ResetClient(); DeviceEatery.ResetQueue(); DeviceDoor.ResetQueue(); DeviceChannel.ResetQueue(); channelmgr.ResetRecord(); monimgr.Resetdev(); Monitor.Enter(argsExtendList); argsExtendList.Clear(); Monitor.PulseAll(argsExtendList); Monitor.Exit(argsExtendList); isRunExtend = false; isResetService = false; } Thread.Sleep(new TimeSpan(0, 1, 0)); SvrFileTrans svrfile = new SvrFileTrans(); svrfile.ExtendHandle += new EventHandler<ExtendEventArgs>(svrfile_ExtendHandle); commisrv.Start(this.port, svrfile); this.srvTrans = svrfile; NameValueCollection data = new NameValueCollection(); data["服务"] = this.ServiceName; data["端口"] = this.port.ToString(); LogMessage("自动重启Granity文件服务", data, EventLogEntryType.Information); }
/// <summary> /// 服务启动 /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { string port = ConfigurationManager.AppSettings[this.ServiceName]; if(!string.IsNullOrEmpty(port)) try { this.port = Convert.ToInt32(port); } catch { } SvrFileTrans svrfile = new SvrFileTrans(); svrfile.ExtendHandle += new EventHandler<ExtendEventArgs>(svrfile_ExtendHandle); CommiServer commisrv = CommiServer.GlobalServer; commisrv.ErrorHandle += new EventHandler<ErrorRequestEventArgs>(commisrv_ErrorHandle); commisrv.Start(this.port, svrfile); this.srvTrans = svrfile; NameValueCollection data = new NameValueCollection(); data["服务"] = this.ServiceName; data["端口"] = this.port.ToString(); LogMessage("启动Granity文件服务", data, EventLogEntryType.Information); }
/// <summary> /// 服务启动 /// </summary> /// <param name="args"></param> private void btStart_Click(object sender, EventArgs e) { this.btStart.Enabled = false; string port = ConfigurationManager.AppSettings[this.ServiceName]; if (!string.IsNullOrEmpty(port)) try { this.port = Convert.ToInt32(port); } catch { } SvrFileTrans svrfile = new SvrFileTrans(); svrfile.ExtendHandle += new EventHandler<ExtendEventArgs>(svrfile_ExtendHandle); CommiServer commisrv = CommiServer.GlobalServer; commisrv.ErrorHandle += new EventHandler<ErrorRequestEventArgs>(commisrv_ErrorHandle); commisrv.Start(this.port, svrfile); this.srvTrans = svrfile; this.timer.Start(); NameValueCollection data = new NameValueCollection(); data["服务"] = this.ServiceName; data["端口"] = this.port.ToString(); LogMessage("启动Granity文件服务", data, EventLogEntryType.Information); this.btStop.Enabled = true; }