public void RegisterReplyPlugin(string ServerIdentify, string[] plugin)
        {
            //客户端回调
            IClientService mCallBack = OperationContext.Current.GetCallbackChannel <IClientService>();

            WcfServerManage.RegisterReplyPlugin(mCallBack, ServerIdentify, plugin);
        }
        private void StartAppHost()
        {
            WcfServerManage.hostwcfclientinfoList = new HostWCFClientInfoListHandler(BindGridClient);
            WcfServerManage.hostwcfMsg            = new HostWCFMsgHandler(AddMsg);
            DistributedCacheManage.hostwcfMsg     = new HostWCFMsgHandler(AddMsg);

            mAppHost = new ServiceHost(typeof(WCFHandlerService));


            WcfServerManage.Identify         = identify;
            WcfServerManage.HostName         = HostSettingConfig.GetValue("hostname");
            WcfServerManage.IsDebug          = HostSettingConfig.GetValue("debug") == "1" ? true : false;
            WcfServerManage.IsHeartbeat      = HostSettingConfig.GetValue("heartbeat") == "1" ? true : false;
            WcfServerManage.HeartbeatTime    = Convert.ToInt32(HostSettingConfig.GetValue("heartbeattime"));
            WcfServerManage.IsMessage        = HostSettingConfig.GetValue("message") == "1" ? true : false;
            WcfServerManage.MessageTime      = Convert.ToInt32(HostSettingConfig.GetValue("messagetime"));
            WcfServerManage.IsCompressJson   = HostSettingConfig.GetValue("compress") == "1" ? true : false;
            WcfServerManage.IsEncryptionJson = HostSettingConfig.GetValue("encryption") == "1" ? true : false;
            WcfServerManage.serializeType    = (SerializeType)Convert.ToInt32(HostSettingConfig.GetValue("serializetype"));
            WcfServerManage.IsOverTime       = HostSettingConfig.GetValue("overtime") == "1" ? true : false;
            WcfServerManage.OverTime         = Convert.ToInt32(HostSettingConfig.GetValue("overtimetime"));
            WcfServerManage.StartWCFHost();

            mAppHost.Open();
            WcfServerManage.CreateSuperClient();

            AddMsg(Color.Blue, DateTime.Now, "基础服务启动完成");
        }
예제 #3
0
        public string ProcessRequest(string mProxyID, string controller, string method, string jsondata)
        {
            //WcfServerManage.hostwcfMsg.BeginInvoke(DateTime.Now, mProxyID, null, null);//异步方式不影响后台数据请求
            //Thread.Sleep(40000);//测试并发问题, 此处没有问题

            return(WcfServerManage.ProcessRequest(mProxyID, controller, method, jsondata));
        }
        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;
            }
        }
예제 #5
0
        public string CreateDomain(string ipAddress)
        {
            //客户端回调
            IClientService mCallBack = OperationContext.Current.GetCallbackChannel <IClientService>();

            string ClientID = WcfServerManage.CreateClient(OperationContext.Current.SessionId, ipAddress, DateTime.Now, mCallBack);

            //mCallBackList.Add(mCallBack);
            return(ClientID);
        }
 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);
     }
 }
        public string CreateDomain(string ipAddress)
        {
            //客户端回调
            IClientService mCallBack = OperationContext.Current.GetCallbackChannel <IClientService>();

            string ClientID = WcfServerManage.CreateDomain(OperationContext.Current.SessionId, ipAddress, DateTime.Now, mCallBack);

            //mCallBackList.Add(mCallBack);

            OperationContext.Current.Channel.Closing += new EventHandler(Channel_Closing);
            //OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted);
            return(ClientID);
        }
        //异步请求
        public IAsyncResult BeginProcessRequest(string clientId, string controller, string method, string jsondata, AsyncCallback callback, object asyncState)
        {
            string pluginname = null;
            string cname      = null;

            string[] names = controller.Split(new char[] { '@' });
            if (names.Length == 2)
            {
                pluginname = names[0];
                cname      = names[1];
            }
            HeaderParameter para = HeaderOperater.GetHeaderValue(OperationContext.Current.RequestContext.RequestMessage);

            return(new CompletedAsyncResult <string>(WcfServerManage.ProcessRequest(clientId, pluginname, cname, method, jsondata, para)));
        }
        //服务请求
        public string ProcessRequest(string clientId, string controller, string method, string jsondata)
        {
            string pluginname = null;
            string cname      = null;

            string[] names = controller.Split(new char[] { '@' });
            if (names.Length == 2)
            {
                pluginname = names[0];
                cname      = names[1];
            }
            HeaderParameter para = HeaderOperater.GetHeaderValue(OperationContext.Current.RequestContext.RequestMessage);

            return(WcfServerManage.ProcessRequest(clientId, pluginname, cname, method, jsondata, para));
        }
        public string CreateDomain(string ipAddress)
        {
            //客户端回调
            IClientService  mCallBack = OperationContext.Current.GetCallbackChannel <IClientService>();
            HeaderParameter para      = HeaderOperater.GetHeaderValue(OperationContext.Current.RequestContext.RequestMessage);
            string          ClientID  = WcfServerManage.CreateClient(OperationContext.Current.SessionId, ipAddress, DateTime.Now, mCallBack, para.pluginname, para.replyidentify);

            //异步执行同步缓存
            new Action(delegate()
            {
                if (para.pluginname == "SuperPlugin")
                {
                    //创建连接时候会将上级中间件的缓存同步到下级中间件
                    DistributedCacheManage.SyncAllCache(mCallBack);
                }
            }).BeginInvoke(null, null);

            return(ClientID);
        }
 public string ServerConfig()
 {
     return(WcfServerManage.ServerConfig());
 }
예제 #12
0
 public bool UnDomain(string mProxyID)
 {
     return(WcfServerManage.UnDomain(mProxyID));
 }
 public void SendBroadcast(string jsondata)
 {
     WcfServerManage.SendBroadcast(jsondata);
 }
예제 #14
0
 public bool Heartbeat(string mProxyID)
 {
     return(WcfServerManage.Heartbeat(mProxyID));
 }
예제 #15
0
 public string ProcessRequest(string mProxyID, string controller, string method, string jsondata)
 {
     return(WcfServerManage.ProcessRequest(mProxyID, controller, method, jsondata));
 }
 public bool UnDomain(string clientId)
 {
     //OperationContext.Current.Channel.Close();
     return(WcfServerManage.UnClient(clientId));
 }
예제 #17
0
 public bool Heartbeat(string mProxyID)
 {
     return(WcfServerManage.Heartbeat(OperationContext.Current.SessionId, mProxyID));
 }
 public bool Heartbeat(string clientId)
 {
     return(WcfServerManage.Heartbeat(clientId));
 }
예제 #19
0
 //异步请求
 public IAsyncResult BeginProcessRequest(string mProxyID, string controller, string method, string jsondata, AsyncCallback callback, object asyncState)
 {
     return(new CompletedAsyncResult <string>(WcfServerManage.ProcessRequest(mProxyID, controller, method, jsondata)));
 }