Exemplo n.º 1
0
        public bool ClientReAttach()
        {
            if (commandClient != null)
            {
                try
                {
                    //RemotingServices.Disconnect(commandClient);
                }
                catch (Exception ex)
                {
                }
            }

            commandClient        = new RemoteCommandClient();
            commandClient.Sender = "WebAdminZ2";
            commandClient.ReceiveCommandResultEvent += new ReceiveCommandResultEventHandler(client_ReceiveCommandResultEvent);
            commandClient.DeviceOfflineEvent        += new DeviceOnlineOfflineEventHandler(client_DeviceOfflineEvent);
            commandClient.DeviceOnlineEvent         += new DeviceOnlineOfflineEventHandler(client_DeviceOnlineEvent);
            commandClient.LogOffEvent += new EventHandler(commandClient_LogOffEvent);
            //ObjRef or = RemotingServices.Marshal(commandClient as MarshalByRefObject);

            if (!remoteCommand.AttachClient(commandClient))
            {
                status = false;
                throw new Exception("重新自动连接失败!");
            }
            else
            {
                status = true;
            }

            return(status);
        }
Exemplo n.º 2
0
        bool CreateCommandClient()
        {
            bool res = false;

            try
            {
                commandClient        = new RemoteCommandClient();
                commandClient.Sender = "WebAdminZ2";
                commandClient.ReceiveCommandResultEvent += new ReceiveCommandResultEventHandler(client_ReceiveCommandResultEvent);
                commandClient.DeviceOfflineEvent        += new DeviceOnlineOfflineEventHandler(client_DeviceOfflineEvent);
                commandClient.DeviceOnlineEvent         += new DeviceOnlineOfflineEventHandler(client_DeviceOnlineEvent);
                commandClient.LogOffEvent += new EventHandler(commandClient_LogOffEvent);
                ObjRef or = RemotingServices.Marshal(commandClient as MarshalByRefObject);

                if (!remoteCommand.AttachClient(commandClient))
                {
                    res = false;
                }
                else
                {
                    res = true;
                }
            }
            catch (Exception ex)
            {
                res = false;
            }

            return(res);
        }
Exemplo n.º 3
0
        RemoteClient1()
        {
            try
            {
                //Reachability.ServerSinkProvider.StartWaitRedirectedMsg();
                remoteCommand        = new RemoteCommand();
                commandClient        = new RemoteCommandClient();
                commandClient.Sender = "WebAdminZ2";
                commandClient.ReceiveCommandResultEvent += new ReceiveCommandResultEventHandler(client_ReceiveCommandResultEvent);
                commandClient.DeviceOfflineEvent        += new DeviceOnlineOfflineEventHandler(client_DeviceOfflineEvent);
                commandClient.DeviceOnlineEvent         += new DeviceOnlineOfflineEventHandler(client_DeviceOnlineEvent);
                commandClient.LogOffEvent += new EventHandler(commandClient_LogOffEvent);
                //ObjRef or = RemotingServices.Marshal(commandClient as MarshalByRefObject);

                if (!remoteCommand.AttachClient(commandClient))
                {
                    status = false;
                    throw new Exception("登录失败,请查看日志!");
                }
                else
                {
                    status = true;
                }
            }
            catch (Exception ex)
            {
                status = false;
                //throw new Exception("连接服务器时出现异常,请重新尝试!异常信息" + ex.Message);
            }
        }
Exemplo n.º 4
0
        RemoteClient()
        {
            try
            {
                if (ConfigurationManager.AppSettings["IsTest"].ToString() == "true")
                {
                    remoteCommand = new RemoteCommand();
                    commandClient = new RemoteCommandClient();
                    return;
                }

                Reachability.ServerSinkProvider.StartWaitRedirectedMsg();
                remoteCommand = new RemoteCommand();

                if (!CreateCommandClient())
                {
                    throw new Exception("创建远程命令对象失败");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }