Ejemplo n.º 1
0
        /// <summary>
        /// Validate incoming parameters and call recipient in FaR and check if a person got a mailbox connected.
        /// </summary>
        public IsReachableResponse IsReachable(IsReachableRequest request, string senderOrg)
        {
            //Set a new Id for this request, easier to follow request through logs.
            request.RequestId = Guid.NewGuid();
            LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.FaR.FaRService: incoming IsReachable with RequestId: {0}", request.RequestId));
            IsReachableResponse isReachableResponse = new IsReachableResponse()
            {
                IsReachable = false
            };

            try
            {
                var recipientHelper = new RecipientHelper();

                request.RecipientNumber = recipientHelper.GetRecipientAdress(request.RecipientNumber);
                var validated = recipientHelper.ValidateRecipient(request.RecipientNumber, request.RequestId);

                if (validated)
                {
                    var recipientService = new SE.GOV.MM.Integration.FaR.Service.RecipientService();
                    var response         = IsUserReachableInFaR(request.RecipientNumber, request.RequestId, senderOrg);

                    if (response != null)
                    {
                        var reachabilityStatus = response[0];
                        isReachableResponse = ConvertReachabilityStatusToIsReachableResponse(reachabilityStatus, isReachableResponse, request.RequestId);
                    }
                }
            }
            catch (ArgumentNullException nse)
            {
                string errorMessage = string.Format("SE.GOV.MM.Integration.FaR.FaRService: ArgumentNullException RequestId: {0} ", request.RequestId);
                LogManager.Log(new Log.Log()
                {
                    Message = errorMessage, EventId = EventId.ArgumentException, Exception = nse, Level = Level.Error
                });
                throw nse;
            }
            catch (Exception ex)
            {
                string errorMessage = string.Format("SE.GOV.MM.Integration.FaR.FaRService: Something went wrong in FaRService, RequestId: {0} ", request.RequestId);
                LogManager.Log(new Log.Log()
                {
                    Message = errorMessage, EventId = EventId.GenerelizedException, Exception = ex, Level = Level.Error
                });
                throw ex;
            }

            return(isReachableResponse);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check if a user IsReachable in FaR
        /// </summary>
        public IsReachableResult IsReachable(string recipientNumber, string senderOrg)
        {
            LogManager.LogTrace("SE.GOV.MM.Integration.mm.Service.RecipientService: incoming IsReachable");

            var request = new IsReachableRequest()
            {
                RecipientNumber = recipientNumber
            };
            var result = new IsReachableResponse();
            IsReachableResult    isReachableResult;
            ServiceClient <IFaR> client = null;



            try
            {
                client = new ServiceClient <IFaR>("WSHttpBinding_IFaR");
                // client = new ServiceClient<IFaR>("BasicHttpBinding_IFaR");


                var response = client.Proxy.IsReachable(request, senderOrg);



                result = response;

                isReachableResult = new IsReachableResult()
                {
                    IsReachable = result.IsReachable
                };

                if (result.ServiceSupplier != null)
                {
                    isReachableResult.Id            = result.ServiceSupplier.Id;
                    isReachableResult.Name          = result.ServiceSupplier.Name;
                    isReachableResult.ServiceAdress = result.ServiceSupplier.ServiceAdress;
                    isReachableResult.UIAdress      = result.ServiceSupplier.UIAdress;
                }
            }
            catch (CommunicationException ce)
            {
                LogManager.Log(new Log.Log()
                {
                    Exception = ce, Message = "SE.GOV.MM.Integration.mm.Service.RecipientService: Communication error, getting a response from FaRService.", EventId = EventId.CommunicationExceptionWithFaR, Level = Level.Error
                });
                throw ce;
            }
            catch (Exception ex)
            {
                LogManager.Log(new Log.Log()
                {
                    Exception = ex, Message = "SE.GOV.MM.Integration.mm.Service.RecipientService: Error getting a response from RecipientService.", EventId = EventId.CommunicationExceptionWithFaR, Level = Level.Error
                });
                throw ex;
            }
            finally
            {
                if (client.State != CommunicationState.Faulted)
                {
                    client.Abort();
                }
                client.Close();
                client = null;
            }

            LogManager.LogTrace("SE.GOV.MM.Integration.mm.Service.RecipientService: leaving IsReachable");
            return(isReachableResult);
        }