/// <summary> /// 方法:服务启动 /// </summary> private void ServStart() { toolStripStatusLabel2.Text = "服务启动中......"; buttonStart.Enabled = false; button2.Enabled = true; button2.Focus(); Application.DoEvents(); Thread.Sleep(800); //通讯,开始监听 try { svr.Start(); ServerRemoting.Start(); } catch (System.Exception ex) { ex.Message.ErrorLogger(); buttonStart.Enabled = true; button2.Enabled = false; MessageBox.Show("信息:" + ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); //日志记录 ShareData.Log.Warn("开启GSS服务错误", ex); return; } string Sstate = string.Format("{0}/{1}", svr.SessionCount, svr.Capacity); lblServState.Text = Sstate; pictureBox1.Image = global::GSSServer.Properties.Resources.GSSserver_start; notifyIcon1.Icon = ((System.Drawing.Icon)(global::GSSServer.Properties.Resources.GSSserver_Nstart)); notifyIcon1.ShowBalloonTip(5, "GSS", "服务已经启动", ToolTipIcon.Info); notifyIcon1.Text = "服务已经启动"; toolStripStatusLabel2.Text = "服务已经启动"; AppConfig app = new AppConfig(); app.SetTipLanguage(); //日志记录 ShareData.Log.Info("开启GSS服务"); }
/// <summary> /// 方法:服务停止 /// </summary> private void ServStop() { toolStripStatusLabel2.Text = "服务停止中......"; buttonStart.Enabled = true; button2.Enabled = false; buttonStart.Focus(); Application.DoEvents(); Thread.Sleep(600); //通讯停止监听,关闭连接 svr.Stop(); ServerRemoting.Stop(); string Sstate = string.Format("{0}/{1}", svr.SessionCount, svr.Capacity); lblServState.Text = Sstate; pictureBox1.Image = global::GSSServer.Properties.Resources.GSSserver_stop; notifyIcon1.Icon = ((System.Drawing.Icon)(global::GSSServer.Properties.Resources.GSSserver_Nstop)); notifyIcon1.ShowBalloonTip(5, "GSS", "服务已经停止", ToolTipIcon.Info); notifyIcon1.Text = "服务已经停止"; toolStripStatusLabel2.Text = "服务已经停止"; //日志记录 ShareData.Log.Info("停止GSS服务"); }