コード例 #1
0
ファイル: FaRService.svc.cs プロジェクト: majidgorbani/mm
        /// <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);
        }
コード例 #2
0
ファイル: RecipientService.cs プロジェクト: majidgorbani/mm
        /// <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);
        }
コード例 #3
0
ファイル: FaRService.svc.cs プロジェクト: majidgorbani/mm
        /// <summary>
        /// Converts and copies a object from Recipient to a format supported in FaRService, ServiceSupplier.
        /// </summary>
        private IsReachableResponse ConvertReachabilityStatusToIsReachableResponse(ReachabilityStatus reachabilityStatus, IsReachableResponse isReachableResponse, Guid requestId)
        {
            LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.FaR.FaRService: incoming ConvertReachabilityStatusToIsReachableResponse with RequestId: {0}", requestId));
            //Control if pending and senderaccepted is true, user/company have reactivated their mailbox and all persons havent signed, doesnt accept messages until everyone signs.
            if (reachabilityStatus.AccountStatus.Pending && reachabilityStatus.SenderAccepted)
            {
                isReachableResponse.IsReachable = false;
            }
            else
            {
                isReachableResponse.IsReachable = reachabilityStatus.SenderAccepted;
            }

            if (reachabilityStatus.AccountStatus.ServiceSupplier != null)
            {
                var serviceSupplier = new FaR.DataTransferObjects.BusinessObject.ServiceSupplier()
                {
                    Id = reachabilityStatus.AccountStatus.ServiceSupplier.Id,
                    InternalServiceAdress = reachabilityStatus.AccountStatus.ServiceSupplier.InternalServiceAdress,
                    Name          = reachabilityStatus.AccountStatus.ServiceSupplier.Name,
                    ServiceAdress = reachabilityStatus.AccountStatus.ServiceSupplier.ServiceAdress,
                    UIAdress      = reachabilityStatus.AccountStatus.ServiceSupplier.UIAdress
                };

                isReachableResponse.ServiceSupplier = serviceSupplier;
            }

            LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.FaR.FaRService: leaving ConvertReachabilityStatusToIsReachableResponse with RequestId: {0}", requestId));
            return(isReachableResponse);
        }