/// <summary> /// SendPackageRequest to PackageService for deliver to dispatcher. /// </summary> public SendPackageResult SendPackage(Mail mailItem, MailBox mailBox) { LogManager.LogTrace("SE.GOV.MM.Integration.Outlook.Service.MessageService: incoming SendPackage"); var request = new SendPackageRequest() { Mail = mailItem, MailBox = mailBox }; var result = new SendPackageResult() { MessageSent = true, Recipient = mailItem.Recipient.To }; ServiceClient <IPackage> client = null; try { client = new ServiceClient <IPackage>("WSHttpBinding_IPackage"); //client = new ServiceClient<IPackage>("BasicHttpBinding_IPackage"); var response = client.Proxy.SendPackage(request); result.DeliveryStatus = response.DeliveryStatus; result.RequestId = response.RequestId; result.DistributionId = response.DistributionId; } catch (CommunicationException ce) { client.Abort(); result.MessageSent = false; LogManager.Log(new Log.Log() { Exception = ce, Message = "SE.GOV.MM.Integration.Outlook.Service.PackageService: CommunicationException error sending package to PackageService.", EventId = EventId.CommunicationExceptionWithPackage, Level = Level.Error }); } catch (Exception ex) { client.Abort(); result.MessageSent = false; LogManager.Log(new Log.Log() { Exception = ex, Message = "SE.GOV.MM.Integration.Outlook.Service.PackageService: Exception error sending package to PackageService.", EventId = EventId.CommunicationExceptionWithPackage, Level = Level.Error }); } finally { if (client.State == CommunicationState.Faulted) { client.Abort(); } client = null; } LogManager.LogTrace("SE.GOV.MM.Integration.Outlook.Service.PackageService: leaving SendPackage"); return(result); }
/// <summary> /// Incoming mail that should be sent to mailboxoperator /// </summary> /// <param name="request"></param> /// <returns></returns> public SendPackageResponse SendPackageToMailbox(SendPackageRequest request) { //add a unique id to the request for logging and return to the client. request.RequestId = Guid.NewGuid(); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.PackageService: ===> incoming SendPackageToMailbox with RequestId: {0}", request.RequestId)); var result = _businessManager.SendPackageToMailbox(request.Mail, request.MailBox, request.RequestId); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.PackageService: <=== leaving SendPackageToMailbox with RequestId: {0}", request.RequestId)); return(result); }
/// <summary> /// Incoming mailitem that should be sent to dispatcher. /// </summary> public SendPackageResponse SendPackage(SendPackageRequest request) { //add a unique id to the request for logging and return to the client. request.RequestId = Guid.NewGuid(); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.PackageService: incoming SendPackage with RequestId: {0}", request.RequestId)); var distributionId = _businessManager.SendPackage(request.Mail, request.RequestId); var deliveryStatus = "Pending"; LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.PackageService: leaving SendPackage with RequestId: {0}", request.RequestId)); return(new SendPackageResponse() { RequestId = request.RequestId, DeliveryStatus = deliveryStatus, DistributionId = distributionId }); }