Beispiel #1
0
        public static void GetModuleInfo(Action <ModuleInfo, Exception> action, string[] prms)
        {
            RFIDServiceClient client = null;

            try
            {
                string           remoteAddress = ReaderConfig.BuildUrl();
                EndpointAddress  endpoint      = new EndpointAddress(remoteAddress);
                BasicHttpBinding binding       = new BasicHttpBinding(BasicHttpSecurityMode.None);
                //binding.Security = BasicHttpSecurityMode.Transport;
                binding.OpenTimeout            = new TimeSpan(0, 0, 10);
                binding.CloseTimeout           = new TimeSpan(0, 0, 10);
                binding.SendTimeout            = new TimeSpan(0, 0, 10);
                binding.ReceiveTimeout         = new TimeSpan(0, 0, 10);
                binding.MaxReceivedMessageSize = int.MaxValue;
                binding.MaxBufferPoolSize      = int.MaxValue;
                binding.MaxBufferSize          = int.MaxValue;
                client = new RFIDServiceClient(binding, endpoint);

                //client = new RFIDServiceClient();

                action(client.getModuleInfo(prms), null);

                //client.Close();
            }
            catch (Exception ex)
            {
                //client.Abort();
                action(null, ex);
            }
            //finally
            //{

            //    ICommunicationObject comObj = ((ICommunicationObject)client);



            //    if (comObj.State == CommunicationState.Faulted)
            //    {
            //        comObj.Abort();
            //    }
            //    else
            //    {
            //        comObj.Close();
            //    }
            //}
        }
Beispiel #2
0
        public static void querySerialInfo(Action <ModuleInfo, Exception> action, string[] prms)
        {
            RFIDServiceClient client = null;

            try
            {
                client = new RFIDServiceClient();
                action(client.getModuleInfo(prms), null);
            }
            #region excption handling
            catch (CommunicationException e)
            {
                action(null, new Exception(string.Format("服务端程序发生内部错误,错误原因:{0}", e.Message)));
            }
            catch (TimeoutException)
            {
                action(null, new Exception("连接超时,请检查网络或者服务器状态!"));
            }
            catch (Exception e)
            {
                action(null, e);
            }
            finally
            {
                ICommunicationObject comObj = ((ICommunicationObject)client);

                if (comObj.State == CommunicationState.Faulted)
                {
                    comObj.Abort();
                }
                else
                {
                    comObj.Close();
                }
            }
            #endregion
        }