Beispiel #1
0
        public void Use(Action <ISMSMessagingService> action)
        {
            NetTcpBinding        binding     = new NetTcpBinding();
            string               endpointUrl = _config["WCFExternalServices:SMSMessagingService:EndpointAddress"];
            EndpointAddress      endpoint    = new EndpointAddress(endpointUrl);
            ISMSMessagingService client      = ProxyManager <ISMSMessagingService> .GetProxy(nameof(ISMSMessagingService), binding, endpoint);

            var user = new User();

            user.userID = 88;
            client.SetCurrentUserAsync(user).Wait();

            bool success = false;

            try
            {
                action(client);
                ((IClientChannel)client).Close();
                success = true;
            }
            catch (FaultException)
            {
                ((IClientChannel)client).Close();
                throw;
            }
            catch (TimeoutException)
            {
            }
            catch (Exception ex)
            {
                ((IClientChannel)client).Abort();
                throw;
            }
            finally
            {
                if (!success)
                {
                    ((IClientChannel)client).Abort();
                }
                ((IClientChannel)client).Close();
                ((IClientChannel)client).Dispose();
            }
        }
Beispiel #2
0
        public void Use(Action <INotificationService> action)
        {
            //BasicHttpBinding binding = new BasicHttpBinding(); for local and development
            BasicHttpsBinding binding = new BasicHttpsBinding(); //for prodoction

            string               endpointUrl = _config["WCFExternalServices:PushNotificationService:EndpointAddress"];
            EndpointAddress      endpoint    = new EndpointAddress(endpointUrl);
            INotificationService client      = ProxyManager <INotificationService> .GetProxy(nameof(INotificationService), binding, endpoint);

            bool success = false;

            try
            {
                action(client);
                ((IClientChannel)client).Close();
                success = true;
            }
            catch (FaultException)
            {
                ((IClientChannel)client).Close();
                throw;
            }
            catch (TimeoutException)
            {
            }
            catch (Exception)
            {
                ((IClientChannel)client).Abort();
                throw;
            }
            finally
            {
                if (!success)
                {
                    ((IClientChannel)client).Abort();
                }

                ((IClientChannel)client).Close();
                ((IClientChannel)client).Dispose();
            }
        }
        public void Use(Action <IXBManagementService> action)
        {
            NetTcpBinding binding = new NetTcpBinding
            {
                MaxBufferPoolSize      = 5242880,
                MaxBufferSize          = 6553600,
                MaxReceivedMessageSize = 6553600
            };

            binding.ReaderQuotas.MaxArrayLength = 2500000;
            string               endpointUrl = _config["WCFExternalServices:XBManagementService:EndpointAddress"];
            EndpointAddress      endpoint    = new EndpointAddress(endpointUrl);
            IXBManagementService client      = ProxyManager <IXBManagementService> .GetProxy(nameof(IXBManagementService), binding, endpoint);

            User user = _authData.GetXBMUser();

            SessionId = _contextAccessor.HttpContext.Request.Headers["SessionId"].ToString();
            if (!string.IsNullOrEmpty(_contextAccessor.HttpContext.Request.Headers["language"]))
            {
                byte.TryParse(_contextAccessor.HttpContext.Request.Headers["language"], out language);
            }
            if (SessionId == "ba0f312d-8487-445e-aee2-d5877ac1d4de" && Convert.ToBoolean(_config["TestVersion"]))
            {
                clientIP = "169.169.169.166";
            }
            else
            {
                clientIP = _contextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
            }
            bool success = false;
            bool checkCustomerSession = true;

            try
            {
                checkCustomerSession = client.InitAsync(SessionId, language, clientIP, user, (SourceType)_authData.GetSourceType(), ServiceType.CustomerService).Result;
                if (!checkCustomerSession)
                {
                    throw new Exception();
                }
                else
                {
                    action(client);
                    ((IClientChannel)client).Close();
                    success = true;
                }
            }
            catch (FaultException)
            {
                ((IClientChannel)client).Close();
                throw;
            }
            catch (TimeoutException)
            {
            }
            catch (Exception)
            {
                ((IClientChannel)client).Abort();
                throw;
            }
            finally
            {
                if (!success)
                {
                    ((IClientChannel)client).Abort();
                }

                ((IClientChannel)client).Close();
                ((IClientChannel)client).Dispose();
            }
        }