コード例 #1
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您确定要停止服务吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                try
                {
                    if (mAppHost != null)
                    {
                        WcfServerManage.StopWCFHost();
                        WcfServerManage.UnCreateSuperClient();
                        mAppHost.Close();
                        AddMsg(Color.Blue, DateTime.Now, "基础服务已关闭");
                    }

                    if (mRouterHost != null && mFileRouterHost != null)
                    {
                        mRouterHost.Close();
                        mFileRouterHost.Close();
                        RouterServerManage.Stop();
                        AddMsg(Color.Blue, DateTime.Now, "路由服务已关闭");
                    }

                    if (mFileHost != null)
                    {
                        mFileHost.Close();
                        AddMsg(Color.Blue, DateTime.Now, "文件传输服务已关闭");
                    }

                    if (webapiHost != null)
                    {
                        webapiHost.StopHost();
                        AddMsg(Color.Blue, DateTime.Now, "WebAPI服务已关闭");
                    }
                }
                catch
                {
                    if (mAppHost != null)
                    {
                        mAppHost.Abort();
                    }
                    if (mRouterHost != null)
                    {
                        mRouterHost.Abort();
                    }
                    if (mFileHost != null)
                    {
                        mFileHost.Abort();
                    }
                    if (webapiHost != null)
                    {
                        webapiHost = null;
                    }
                }
                RunState = HostState.NoOpen;
            }
        }
コード例 #2
0
 private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("您确定要退出中间件服务器吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     {
         try
         {
             WcfServerManage.UnCreateSuperClient();
         }
         catch { }
         this.Dispose(true);
     }
 }