/// <summary> /// Send mail to mina meddelanden, through webservice. /// </summary> private SendPackageResult sendMailToMinaMeddelanden(Mail mail, IsReachableResult isReachableResult) { var recipientHelper = new RecipientHelper(); mail.Recipient.To = recipientHelper.GetRecipientAdress(mail.Recipient.To); var result = sendMessage(mail, isReachableResult); return(result); }
/// <summary> /// Check if a user IsReachable in FaR /// </summary> public IsReachableResult IsReachable(string recipientNumber) { // LogManager.LogTrace("SE.GOV.MM.Integration.Outlook.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"); var response = client.Proxy.IsReachable(request); 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.Outlook.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.Outlook.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.Outlook.Service.RecipientService: leaving IsReachable"); return(isReachableResult); }
/// <summary> /// Sends mail to Mina meddelanden, uses a configuration property in ConfigurationService if mail should go through a dispatcher or directly to the mailbox. /// </summary> /// <param name="mailHelper"></param> /// <param name="isReachableResult"></param> /// <returns></returns> private SendPackageResult sendMessage(Mail mailItem, IsReachableResult isReachableResult) { var mailHelper = new MailHelper(); var mailBox = mailHelper.GetMailBoxFromIsReachableResult(isReachableResult); var messageService = new SE.GOV.MM.Integration.Outlook.BusinessLayer.Service.PackageService(); SendPackageResult result = null; if (ConfigHelper.ConfigurationEntity.UseExternalDispatcher) { result = messageService.SendPackage(mailItem, mailBox); //result = messageService.SendPackage(mailItem, mailBox); } else { result = messageService.SendPackageToMailBox(mailItem, mailBox); } return(result); }