コード例 #1
0
        /// <summary>
        /// 执行命令
        /// </summary>
        public void Execute()
        {
            EndpointAddress address = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings["CommandServerAddress"]);
            //EndpointAddress address = new EndpointAddress("net.tcp://192.168.1.253:9010/XAPI/");
            //EndpointAddress address = new EndpointAddress("net.tcp://localhost:9010/XAPI/");

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            using (ChannelFactory <IXapiService> channelFactory = new ChannelFactory <IXapiService>(binding, address))
            {
                IXapiService xapiService = channelFactory.CreateChannel();

                using (xapiService as IDisposable)
                {
                    try
                    {
                        this.returnString = WCFUtil.Invoke <IXapiService, string>(
                            xapiService,
                            proxy => proxy.GetMessage(commandString, (byte)commandType, 0, 0, (byte)returnType, transactionId, 1)
                            );
                    }
                    catch (CustomException ex)
                    {
                        this.returnString = ex.Message;
                    }
                }
            }
        }
コード例 #2
0
ファイル: CommandSet.cs プロジェクト: 842549829/Pool
        /// <summary>
        /// 执行命令
        /// </summary>
        public void Execute()
        {
            if (this.commands.Count == 0)
            {
                this.returnString = "执行失败,指令集中未包含任何指令。";
            }

            this.commandString = this.commandString.TrimEnd(this.separator.ToCharArray());

            EndpointAddress address = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings["CommandServerAddress"]);
            //EndpointAddress address = new EndpointAddress("net.tcp://116.55.243.38:9010/XAPI/");
            //EndpointAddress address = new EndpointAddress("net.tcp://localhost:9010/XAPI/");

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            using (ChannelFactory <IXapiService> channelFactory = new ChannelFactory <IXapiService>(binding, address))
            {
                IXapiService xapiService = channelFactory.CreateChannel();

                using (xapiService as IDisposable)
                {
                    // this.returnString = proxy.GetMessage(commandString, lockfirst, flag, returnType != ReturnResultType.Single ? 1 : 0, 1, transactionId);
                    try
                    {
                        this.returnString = WCFUtil.Invoke <IXapiService, string>(
                            xapiService,
                            proxy => proxy.GetMessage(commandString, (byte)commandType, lockfirst, flag, (byte)returnType, transactionId, 1)

                            );
                    }
                    catch (CustomException ex)
                    {
                        this.returnString = ex.Message;
                    }
                }
            }
        }