/// <summary> /// Incoming external calls from client. /// </summary> /// <param name="request"></param> /// <returns></returns> public SendPackageToMailboxResponse SendPackageToMailbox(SendPackageToMailboxRequest request) { request.RequestId = Guid.NewGuid(); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.DeliveryMailbox: incoming SendMessageToMailbox with RequestId: {0}", request.RequestId)); var businessManager = new BusinessManager(); var result = businessManager.SendPackageToMailbox(request.Mail, request.Mailbox, request.RequestId); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.DeliveryMailbox: leaving SendMessageToMailbox with RequestId: {0}", request.RequestId)); return(result); }
/// <summary> /// Sends a mail directly to the mailboxoperator. /// </summary> /// <param name="mailItem"></param> /// <param name="mailBox"></param> /// <param name="requestId"></param> /// <returns></returns> public SendPackageToMailboxResponse SendPackageToMailBox(DataTransferObjects.BusinessObjects.Mail mailItem, MailBox mailBox, Guid requestId) { LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.DataLayer.DataManager: incoming SendPackageToMailBox with RequestId: {0}", requestId)); var sendMessageToMailboxRequest = new SendPackageToMailboxRequest() { Mail = ConvertPackageMailItemToDeliveryMailItem(mailItem), Mailbox = ConvertPackageMailboxToDeliveryMailbox(mailBox) }; var service = new DeliveryMailboxService(); var result = service.SendPackageToMailBox(sendMessageToMailboxRequest, requestId); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.DataLayer.DataManager: leaving SendPackageToMailBox with RequestId: {0}", requestId)); return(result); }
/// <summary> /// Check status of a sent message. /// </summary> public SendPackageToMailboxResponse SendPackageToMailBox(SendPackageToMailboxRequest sendPackageToMailboxRequest, Guid requestId) { LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.DataLayer.Service.DeliveryMailboxService: incoming SendPackageToMailBox with RequestId: {0}", requestId)); DeliveryMailboxClient client = null; SendPackageToMailboxResponse result = null; try { //Call method. client = new DeliveryMailboxClient(); result = client.SendPackageToMailbox(sendPackageToMailboxRequest); } catch (CommunicationException ce) { string errorMessage = string.Format("SE.GOV.MM.Integration.Package.DataLayer.Service.DeliveryMailboxService: Error sending package to DeliveryMailbox, RequestId: {0}", requestId); LogManager.Log(new Log.Log() { EventId = EventId.CommunicationExceptionWithDeliveryMailbox, Exception = ce, Level = Level.Error, Message = errorMessage }); throw ce; } catch (Exception ex) { string errorMessage = string.Format("SE.GOV.MM.Integration.Package.DataLayer.Service.DeliveryMailboxService: Error sending package to DeliveryMailbox, RequestId: {0}", requestId); LogManager.Log(new Log.Log() { EventId = EventId.CommunicationExceptionWithDeliveryMailbox, Exception = ex, Level = Level.Error, Message = errorMessage }); throw ex; } finally { if (client != null && client.State == CommunicationState.Faulted) { client.Abort(); client.Close(); } client = null; } LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.DataLayer.Service.DeliveryMailboxService: leaving SendPackageToMailBox with RequestId: {0}", requestId)); return(result); }