示例#1
0
        internal static MailDTO Send(MailDTO dto, ProtocolDTO protocolDTO, bool sendPdf = true)
        {
            MailboxDTO mailbox = (MailboxDTO)dto.Mailbox;

            if (mailbox.IsPEC())
            {
                dto.Id = FacadeFactory.Instance.PECMailFacade.SendMail(dto, sendPdf).ToString();
                return(dto);
            }
            else
            {
                if (mailbox.IsPOL())
                {
                    if (protocolDTO == null)
                    {
                        throw new ArgumentNullException("protDTO", "L'invio tramite Poste WEB è possibile solamente se è presente un protocollo da associare");
                    }

                    dto.Id = FacadeFactory.Instance.PosteOnLineRequestFacade.SendLettera(dto, protocolDTO).ToString();
                    return(dto);
                }
                else
                {
                    if (mailbox.IsMessage())
                    {
                        dto.Id = FacadeFactory.Instance.MessageEmailFacade.CreateEmailMessage(dto, sendPdf).Id.ToString();
                        return(dto);
                    }
                }
            }

            var message = string.Format("Mailbox.TypeName \"{0}\" non gestito.", dto.Mailbox.TypeName);

            throw new NotImplementedException(message);
        }
        internal static MailDTO PairToProtocol(MailDTO mailDTO, ProtocolDTO protocolDTO)
        {
            var mailbox = (MailboxDTO)mailDTO.Mailbox;

            if (mailbox.IsPEC())
            {
                FacadeFactory.Instance.PECMailFacade.PairToProtocol(mailDTO, protocolDTO);
                return(mailDTO);
            }
            else if (mailbox.IsPOL())
            {
                //Non eseguo alcuna attività in quanto l'associazione viene già fatta nel metodo di invio POL
                return(mailDTO);
            }
            else if (mailbox.IsMessage())
            {
                MessageEmail    savedMessage       = FacadeFactory.Instance.MessageEmailFacade.GetById(int.Parse(mailDTO.Id));
                DSWMessage      currentMessage     = savedMessage.Message;
                Protocol        protocol           = FacadeFactory.Instance.ProtocolFacade.GetById(protocolDTO.UniqueId.Value);
                ProtocolMessage newProtocolMessage = new ProtocolMessage(ref protocol, ref currentMessage);
                FacadeFactory.Instance.ProtocolMessageFacade.Save(ref newProtocolMessage);
                return(mailDTO);
            }

            var message = string.Format("Mailbox.TypeName \"{0}\" non gestito.", mailDTO.Mailbox.TypeName);

            throw new NotImplementedException(message);
        }
示例#3
0
        internal static void AddPOLRequest(TaskDTO taskDTO, MailDTO mailDTO)
        {
            var header     = FacadeFactory.Instance.TaskHeaderFacade.GetById(taskDTO.Id.Value);
            var polRequest = new POLRequest();

            polRequest.Id = new Guid(mailDTO.Id);

            header.AddPOLRequest(polRequest);
            FacadeFactory.Instance.TaskHeaderFacade.Update(ref header);
        }
示例#4
0
        internal static void AddPECMail(TaskDTO taskDTO, MailDTO mailDTO)
        {
            var header  = FacadeFactory.Instance.TaskHeaderFacade.GetById(taskDTO.Id.Value);
            var pecMail = new PECMail();

            pecMail.Id = int.Parse(mailDTO.Id);

            header.AddPECMail(pecMail);
            FacadeFactory.Instance.TaskHeaderFacade.Update(ref header);
        }
        internal static MailDTO PairToProtocol(MailDTO mailDTO, ProtocolDTO protocolDTO)
        {
            var mailbox = (MailboxDTO)mailDTO.Mailbox;

            if (mailbox.IsPEC())
            {
                FacadeFactory.Instance.PECMailFacade.PairToProtocol(mailDTO, protocolDTO);
                return(mailDTO);
            }

            var message = string.Format("Mailbox.TypeName \"{0}\" non gestito.", mailDTO.Mailbox.TypeName);

            throw new NotImplementedException(message);
        }
示例#6
0
 internal static MailDTO Send(MailDTO dto, bool sendPdf = true)
 {
     return(Send(dto, null, sendPdf));
 }
        public string InsertProtocol(string protocolDTO)
        {
            try
            {
                var protocol = protocolDTO.Deserialize <ProtocolDTO>();
                protocol.IdTenantAOO = ConfigurationHelper.CurrentTenantAOOId;
                switch (protocol.Direction)
                {
                case 1:
                    if (!(protocol.HasRecipients() || protocol.HasRecipientsManual()))
                    {
                        throw new Exception("Nessun destinatario impostato nel DTO passato.");
                    }
                    break;

                case -1:
                    if (!(protocol.HasSenders() || protocol.HasSendersManual()))
                    {
                        throw new Exception("Nessun mittente impostato nel DTO passato.");
                    }
                    break;

                default:
                    throw new Exception("Direction non valida");
                }

                ProtocolDTO result = ProtocolService.InsertInvoice(protocol);
                if (result.IdProtocolKind.HasValue && (short)ProtocolKind.FatturePA == result.IdProtocolKind.Value)
                {
                    MailDTO mailDTO = new MailDTO();
                    mailDTO.Subject = result.Subject;
                    mailDTO.Sender  = new ContactDTO();
                    Container    currentContainer    = FacadeFactory.Instance.ContainerFacade.GetById(protocol.Container.Id.Value, false);
                    ContainerEnv currentContainerEnv = new ContainerEnv(DocSuiteContext.Current, ref currentContainer);
                    if (string.IsNullOrEmpty(currentContainerEnv.InvoicePAContactSDI) || !currentContainerEnv.InvoicePAMailboxSenderId.HasValue)
                    {
                        FileLogger.Warn(LogName.FileLog, string.Concat("Protocollo ", result.Number, " di fattura ", result.InvoiceNumber, " inserito correttamente con invio PEC fallito. [Parametro InvoicePAContactSDI ( ", currentContainerEnv.InvoicePAContactSDI, " ) o InvoicePAMailboxSender ( ", currentContainerEnv.InvoicePAMailboxSenderId, " ) mancante ]"));
                        throw new ApplicationException(string.Concat("Protocollo ", result.Number, " di fattura ", result.InvoiceNumber, " inserito correttamente con invio PEC fallito. [Parametro InvoicePAContactSDI ( ", currentContainerEnv.InvoicePAContactSDI, " ) o InvoicePAMailboxSender ( ", currentContainerEnv.InvoicePAMailboxSenderId, " ) mancante ]"));
                    }
                    mailDTO.AddRecipient(new ContactDTO(currentContainerEnv.InvoicePAContactSDI));
                    PECMailBox mailbox = FacadeFactory.Instance.PECMailboxFacade.GetById(currentContainerEnv.InvoicePAMailboxSenderId.Value);
                    mailDTO.Mailbox             = new MailboxDTO(mailbox.MailBoxName).CopyFrom(mailbox);
                    mailDTO.Sender.EmailAddress = mailbox.MailBoxName;
                    mailDTO.Body = result.Subject;
                    ProtocolDTO mailProtocolDTO = result;
                    mailProtocolDTO.Annexes     = new List <DocumentDTO>().ToArray();
                    mailProtocolDTO.Attachments = new List <DocumentDTO>().ToArray();
                    var inputMail = mailDTO.Serialize();
                    var email     = SendProtocolMail(inputMail, mailProtocolDTO.Serialize());
                }
                return(result.SerializeAsResponse());
            }
            catch (Exception ex)
            {
                var response = new APIResponse <ProtocolDTO>(ex);
                return(response.Serialize());
            }
            finally
            {
                NHibernateSessionManager.Instance.CloseTransactionAndSessions();
            }
        }