Exemple #1
0
 private void checkSvcState()
 {
     if (_setClient.State == CommunicationState.Faulted)
     {
         AppLib.WriteLogClientAction(" - restart KDSCommandServiceClient !!!");
         _setClient.Close();
         _setClient = new KDSCommandServiceClient();
     }
 }
Exemple #2
0
        public bool CreateSetChannel()
        {
            bool retVal = false;

            _errMsg = null;
            try
            {
                if ((_setClient != null) && (_setClient.State != CommunicationState.Faulted))
                {
                    _setClient.Close();
                }

                // 2017-10-04 вместо config-файла, создавать биндинги в коде, настройки брать из appSettings
                NetTcpBinding setBinding = new NetTcpBinding(SecurityMode.None, true);
                setBinding.OpenTimeout    = new TimeSpan(0, 0, openTimeoutSeconds);
                setBinding.ReceiveTimeout = new TimeSpan(5, 0, 0);
                setBinding.ReliableSession.InactivityTimeout = new TimeSpan(5, 0, 0);
                string hostName = (string)WpfHelper.GetAppGlobalValue("KDSServiceHostName", "");
                if (hostName.IsNull())
                {
                    throw new Exception("В файле AppSettings.config не указано имя хоста КДС-службы, проверьте наличие ключа KDSServiceHostName");
                }
                string          addr = string.Format("net.tcp://{0}:8734/KDSCommandService", hostName);
                EndpointAddress setEndpointAddress = new EndpointAddress(addr);

                _setClient = new KDSCommandServiceClient(setBinding, setEndpointAddress);

                //_setClient.Open();
                logClientInfo(_setClient);

                retVal = true;
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message;
                throw;
            }

            return(retVal);
        }