Exemplo n.º 1
0
 public void InsertComunicazione(Comunicazioni entity)
 {
     using (ComunicazioniSQLDb dao = new ComunicazioniSQLDb())
     {
         dao.Insert(entity);
     }
 }
Exemplo n.º 2
0
 public void UpdateAllegati(SendMail.Model.TipoCanale tipoCanale, Comunicazioni comunicazione)
 {
     using (ComunicazioniSQLDb dao = new ComunicazioniSQLDb())
     {
         dao.UpdateAllegati(tipoCanale, comunicazione);
     }
 }
Exemplo n.º 3
0
        public ICollection <Model.ComunicazioniMapping.Comunicazioni> GetComunicazioniSenzaAllegati()
        {
            List <Comunicazioni> lComunicazioni = null;

            using (FAXPECContext dbcontext = new FAXPECContext())
            {
                try
                {
                    List <MAIL_CONTENT> l = (from e in dbcontext.MAIL_CONTENT
                                             join f in dbcontext.COMUNICAZIONI
                                             on e.REF_ID_COM equals f.ID_COM
                                             where (from a in dbcontext.COMUNICAZIONI_ALLEGATI
                                                    where a.REF_ID_COM == f.ID_COM
                                                    select a).Count() == 0
                                             select e).ToList();
                    foreach (MAIL_CONTENT m in l)
                    {
                        Comunicazioni c = AutoMapperConfiguration.fromComunicazioniCompleteToDto(m);
                        lComunicazioni.Add(c);
                    }
                }
                catch
                {
                    lComunicazioni = null;
                }
            }
            return(lComunicazioni);
        }
Exemplo n.º 4
0
        public byte[] GetPdfTpuStampeBUS(string appCode, string stringa_id, int progAllegato, string pathFolder)
        {
            Comunicazioni com = SessionManager <Comunicazioni> .get(stringa_id);

            byte[] resp = null;
            if (com.ComAllegati != null && com.ComAllegati.Count != 0)
            {
                ComAllegato all = com.ComAllegati[progAllegato];

                switch (all.AllegatoExt.ToUpper())
                {
                case "PDF":
                    resp = all.AllegatoFile;
                    break;

                case "PRU":
                    resp = GetPdfTpuStampeBUS(all.AllegatoTpu, all.AllegatoFile, pathFolder);
                    break;

                default:
                    break;
                }
            }

            return(resp);
        }
Exemplo n.º 5
0
 public void UpdateAllegati(SendMail.Model.TipoCanale tipoCanale, Comunicazioni comunicazione)
 {
     using (IComunicazioniDao dao = this.getDaoContext().DaoImpl.ComunicazioniDao)
     {
         dao.UpdateAllegati(tipoCanale, comunicazione);
     }
 }
Exemplo n.º 6
0
 public void InsertComunicazione(Comunicazioni entity)
 {
     using (IComunicazioniDao dao = this.getDaoContext().DaoImpl.ComunicazioniDao)
     {
         dao.Insert(entity);
     }
 }
Exemplo n.º 7
0
        public static MailMessage ConvertToEmail(Comunicazioni comunicazione)
        {
            MailMessage mail = new MailMessage();

            if (comunicazione.MailComunicazione == null)
            {
                throw new InvalidOperationException("Errore nella mail da inviare");
            }
            mail.From = new MailAddress(comunicazione.MailComunicazione.MailSender);

            var to = from refs in comunicazione.MailComunicazione.MailRefs
                     where refs.TipoRef == AddresseeType.TO
                     select refs.MailDestinatario;

            if (to.Count() == 0)
            {
                throw new InvalidOperationException("Nella mail mancano i destinatari");
            }

            MailAddressCollection collection = new MailAddressCollection();

            foreach (string t in to)
            {
                mail.To.Add(new MailAddress(t));
            }
            var cc = from refs in comunicazione.MailComunicazione.MailRefs
                     where refs.TipoRef == AddresseeType.CC
                     select refs.MailDestinatario;

            if (cc.Count() > 0)
            {
                foreach (string c in cc)
                {
                    mail.CC.Add(new MailAddress(c));
                }
            }

            var ccn = from refs in comunicazione.MailComunicazione.MailRefs
                      where refs.TipoRef == AddresseeType.CCN
                      select refs.MailDestinatario;

            if (ccn.Count() > 0)
            {
                foreach (string bcc in ccn)
                {
                    mail.Bcc.Add(bcc);
                }
            }
            if (!String.IsNullOrEmpty(comunicazione.MailComunicazione.MailSubject))
            {
                mail.Subject = comunicazione.MailComunicazione.MailSubject;
            }

            mail.Body         = comunicazione.MailComunicazione.MailText;
            mail.BodyEncoding = Encoding.UTF8;
            mail.IsBodyHtml   = true;
            return(mail);
        }
Exemplo n.º 8
0
        public void UpdateFlussoComunicazione(SendMail.Model.TipoCanale tipoCanale, Comunicazioni comunicazione)
        {
            using (IComFlussoDao dao = this.Context.DaoImpl.ComFlussoDao)
            {
                ComFlusso f = comunicazione.ComFlussi[tipoCanale].OrderBy(x => !x.IdFlusso.HasValue).ThenBy(x => x.IdFlusso).Last();
                if (f.IdFlusso.HasValue)
                {
                    try
                    {
                        dao.Update(f);
                    }
                    catch (Exception ex)
                    {
                        //TASK: Allineamento log - Ciro
                        if (!ex.GetType().Equals(typeof(ManagedException)))
                        {
                            ManagedException mEx = new ManagedException("Errore nell\'aggiornamento del flusso della comunicazione." +
                                                                        " Successiva chiamata al metodo di inserimento. Dettaglio: "
                                                                        + ex.Message, "ERR_COM_003", string.Empty, string.Empty, ex.InnerException);
                            mEx.addEnanchedInfosTag("DETAILS", new XElement("info",
                                                                            new XElement("user_msg", "Errore nell\'aggiornamento del flusso della comunicazione." +
                                                                                         " Successiva chiamata al metodo di inserimento. Dettaglio: "
                                                                                         + ex.Message),
                                                                            new XElement("exception",
                                                                                         new XElement("message", ex.Message),
                                                                                         new XElement("source", ex.Source),
                                                                                         new XElement("stack", ex.StackTrace),
                                                                                         new XElement("innerException", ex.InnerException)),
                                                                            new XElement("IdComunicazione", (comunicazione.IdComunicazione != null)?comunicazione.IdComunicazione.ToString():" vuoto. "),
                                                                            new XElement("UniqueId", (comunicazione.UniqueId != null)?comunicazione.UniqueId.ToString():" vuoto. ")).ToString(SaveOptions.DisableFormatting));
                            ErrorLogInfo err = new ErrorLogInfo(mEx);
                            err.objectID = comunicazione.IdComunicazione.ToString();
                            _log.Error(err);
                            dao.Insert(f);
                            throw mEx;  //aggiunto il 26/02/2016
                        }
                        else
                        {
                            dao.Insert(f);
                            throw ex; //aggiunto il 26/02/2016
                        }

                        //Codice Originario

                        //ErrorLogInfo error = new ErrorLogInfo();
                        //error.freeTextDetails = ex.Message;
                        //error.logCode = "ERR_COM_003";
                        //_log.Error(error);
                        //dao.Insert(f);
                    }
                }
                else
                {
                    dao.Insert(f);
                }
            }
        }
Exemplo n.º 9
0
        private IList <Comunicazioni> GetComunicazioniByStatus(TipoCanale tipoCanale, List <MailStatus> status, bool include, int?minRec, int?maxRec, string utente)
        {
            List <Comunicazioni> lComunicazioni = new List <Comunicazioni>();
            int skip = (int)(minRec - 1);
            int take = (int)(maxRec - minRec);

            string[] stati = Enum.GetValues(typeof(MailStatus))
                             .Cast <string>()
                             .Select(x => x.ToString())
                             .ToArray();
            using (FAXPECContext dbcontext = new FAXPECContext())
            {
                List <MAIL_CONTENT> l = new List <MAIL_CONTENT>();
                try
                {
                    l = (from c in dbcontext.COMUNICAZIONI_FLUSSO
                         join m in dbcontext.MAIL_CONTENT
                         on c.REF_ID_COM equals m.REF_ID_COM
                         join cm in dbcontext.COMUNICAZIONI
                         on c.REF_ID_COM equals cm.ID_COM
                         where m.MAIL_SENDER == utente.ToUpper() &&
                         c.CANALE == tipoCanale.ToString() &&
                         (stati.Contains(c.STATO_COMUNICAZIONE_NEW))
                         orderby c.REF_ID_COM
                         select m).Skip(skip).Take(take).ToList();
                    foreach (MAIL_CONTENT com in l)
                    {
                        Comunicazioni coMp = AutoMapperConfiguration.fromComunicazioniCompleteToDto(com);
                        lComunicazioni.Add(coMp);
                    }
                }
                catch (Exception ex)
                {
                    lComunicazioni = null;
                    //TASK: Allineamento log - Ciro
                    if (!ex.GetType().Equals(typeof(ManagedException)))
                    {
                        ManagedException mEx = new ManagedException(ex.Message,
                                                                    "ORA_ERR013", string.Empty, string.Empty, ex.InnerException);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);
                        _log.Error(err);
                        throw mEx;
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
            return(lComunicazioni);
        }
Exemplo n.º 10
0
        public ICollection <Model.ComunicazioniMapping.Comunicazioni> GetAll()
        {
            List <Comunicazioni> l = new List <Comunicazioni>();

            using (FAXPECContext ocmd = new FAXPECContext())
            {
                List <MAIL_CONTENT> list = (from c in ocmd.MAIL_CONTENT
                                            select c).ToList();
                foreach (MAIL_CONTENT c in list)
                {
                    Comunicazioni com = AutoMapperConfiguration.fromComunicazioniCompleteToDto(c);
                    l.Add(com);
                }
            }
            return(l);
        }
Exemplo n.º 11
0
        public void UpdateAllegati(SendMail.Model.TipoCanale tipoCanale, Comunicazioni comunicazione)
        {
            this.Context.StartTransaction(this.GetType());

            try
            {
                using (IComAllegatoDao allDao = this.Context.DaoImpl.ComAllegatoDao)
                {
                    allDao.Update(comunicazione.ComAllegati);
                }
            }
            catch (Exception ex)
            {
                if (this.Context.TransactionRootElement == this.GetType())
                {
                    this.Context.RollBackTransaction(this.GetType());
                }

                //TASK: Allineamento log - Ciro
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ManagedException mEx = new ManagedException(String.Format("Errore update allegati. Dettaglio: {0}", ex.Message),
                                                                "ERR_COM_004",
                                                                string.Empty,
                                                                string.Empty,
                                                                ex.InnerException);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);
                    err.objectID = comunicazione.IdComunicazione.ToString();
                    _log.Error(err);
                    throw mEx;
                }
                //ErrorLogInfo error = new ErrorLogInfo();
                //error.freeTextDetails = ex.Message;
                //error.logCode = "ERR_COM_004";
                //_log.Error(error);
                else
                {
                    throw ex;
                }
            }

            if (this.Context.TransactionRootElement == this.GetType())
            {
                this.Context.EndTransaction(this.GetType());
            }
        }
Exemplo n.º 12
0
        public Model.ComunicazioniMapping.Comunicazioni GetComunicazioneByIdMail(long idMail)
        {
            Comunicazioni comunicazione = new Comunicazioni();

            using (var dbcontext = new FAXPECContext())
            {
                try
                {
                    MAIL_CONTENT content = dbcontext.MAIL_CONTENT.Where(x => x.ID_MAIL == idMail).FirstOrDefault();
                    if (content != null && content.ID_MAIL > 0)
                    {
                        comunicazione = AutoMapperConfiguration.fromComunicazioniCompleteToDto(content);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return(comunicazione);
        }
Exemplo n.º 13
0
 public void Update(Comunicazioni entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
        public void Insert(Comunicazioni entity)
        {
            try
            {
                using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
                {
                    oCmd.CommandText = cmdInsertComunicazione;
                    oCmd.BindByName  = true;
                    oCmd.CommandType = System.Data.CommandType.StoredProcedure;
                    if (entity.RefIdSottotitolo.HasValue)
                    {
                        oCmd.Parameters.Add("v_ref_id_sottotitolo", entity.RefIdSottotitolo.Value);
                    }
                    else
                    {
                        oCmd.Parameters.Add("v_ref_id_sottotitolo", null);
                    }

                    if (entity.ComFlussi == null)
                    {
                        oCmd.Parameters.Add("v_ref_id_canale", ((int)(SendMail.Model.TipoCanale.MAIL)));
                    }
                    else
                    {
                        oCmd.Parameters.Add("v_ref_id_canale", ((int)(entity.ComFlussi.Last().Key)));
                    }

                    oCmd.Parameters.Add("v_flg_notifica", Convert.ToInt32(entity.IsToNotify).ToString());
                    oCmd.Parameters.Add("v_mail_notifica", entity.MailNotifica);
                    oCmd.Parameters.Add("v_ute_ins", entity.UtenteInserimento);
                    oCmd.Parameters.Add("v_orig_uid", entity.OrigUID);
                    oCmd.Parameters.Add("v_unique_id_mapper", entity.UniqueId);

                    OracleParameter pAllegati = new OracleParameter("v_allegati", OracleDbType.Object);
                    pAllegati.UdtTypeName = "COM_ALLEGATO_LIST_TYPE";
                    oCmd.Parameters.Add(pAllegati);
                    // aggiunta gestione protocollo
                    OracleParameter pProtocollo = new OracleParameter("V_PROT_LIST", OracleDbType.Object);
                    pProtocollo.UdtTypeName = "COM_PROTOCOLLO_LIST_TYPE";
                    ComProtocolloListTypeFactory protFac  = new ComProtocolloListTypeFactory();
                    ComProtocolloListType        protList = null;
                    if (entity.ComunicazioniProtocollo == null)
                    {
                        protList = ComProtocolloListType.Null;
                    }
                    else
                    {
                        protList = (ComProtocolloListType)protFac.CreateObject();
                        List <ComProtocolloType> l = new List <ComProtocolloType>();
                        l.Add(new ComProtocolloType(entity.ComunicazioniProtocollo));
                        protList.ComProtocolli = l.ToArray();
                    }
                    pProtocollo.Value = protList;
                    oCmd.Parameters.Add(pProtocollo);
                    // fine aggiunta
                    if (entity is ComunicazioniType)
                    {
                        pAllegati.Value = ((ComunicazioniType)entity).COM_ALLEGATI;
                    }
                    else
                    {
                        ComAllegatoListType allList = null;
                        if (entity.ComAllegati == null || entity.ComAllegati.Count == 0)
                        {
                            allList = ComAllegatoListType.Null;
                        }
                        else
                        {
                            ComAllegatoListTypeFactory allFac = new ComAllegatoListTypeFactory();
                            allList = (ComAllegatoListType)allFac.CreateObject();

                            if (entity.ComAllegati.All(x => x is ComAllegatoType))
                            {
                                allList.ComAllegati = entity.ComAllegati.Cast <ComAllegatoType>().ToArray();
                            }
                            else
                            {
                                allList.ComAllegati = entity.ComAllegati
                                                      .Select <ComAllegato, ComAllegatoType>(x => new ComAllegatoType(x)).ToArray();
                            }
                        }
                        pAllegati.Value = allList;
                    }

                    if (entity.MailComunicazione == null)
                    {
                        oCmd.Parameters.Add("v_mail_sender", null);
                        oCmd.Parameters.Add("v_mail_subject", null);
                        oCmd.Parameters.Add("v_mail_text", null);
                    }
                    else
                    {
                        oCmd.Parameters.Add("v_mail_sender", entity.MailComunicazione.MailSender);
                        oCmd.Parameters.Add("v_mail_subject", entity.MailComunicazione.MailSubject);
                        oCmd.Parameters.Add("v_mail_text", OracleDbType.Clob, entity.MailComunicazione.MailText, System.Data.ParameterDirection.Input);
                    }

                    oCmd.Parameters.Add("v_follows", entity.MailComunicazione.Follows);
                    oCmd.Parameters.Add("V_FOLDERID", entity.FolderId);
                    oCmd.Parameters.Add("V_FOLDERTIPO", entity.FolderTipo);
                    OracleParameter pContatti = new OracleParameter("v_rubrica_contatti_list", OracleDbType.Object);
                    pContatti.UdtTypeName = "FAXPEC.RUBR_CONTATTI_LIST_TYPE";
                    oCmd.Parameters.Add(pContatti);

                    RubricaContattiListTypeFactory contFac  = new RubricaContattiListTypeFactory();
                    RubricaContattiListType        contList = null;

                    if (entity.RubricaEntitaUsed == null || entity.RubricaEntitaUsed.Count == 0)
                    {
                        contList = RubricaContattiListType.Null;
                    }
                    else
                    {
                        contList = (RubricaContattiListType)contFac.CreateObject();
                        contList.RubricaContatti = (from r in entity.RubricaEntitaUsed
                                                    select new RubricaContattiType()
                        {
                            IdContact = r.IdEntUsed,
                            Mail = r.Mail,
                            TIPO_REF = r.TipoContatto.ToString()
                        }).ToArray();
                    }

                    pContatti.Value = contList;
                    oCmd.BindByName = true;
                    oCmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                //TASK: Allineamento log - Ciro
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ManagedException mEx = new ManagedException("Errore inserimento comunicazione. Dettaglio: " + ex.Message,
                                                                "ERR_COM_032",
                                                                string.Empty,
                                                                string.Empty,
                                                                ex.InnerException);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);
                    err.objectID = (entity.IdComunicazione != null) ? entity.IdComunicazione.ToString() : "";
                    _log.Error(err);
                    throw mEx;
                }
                else
                {
                    throw ex;
                }
                //ErrorLogInfo error = new ErrorLogInfo();
                //error.freeTextDetails = ex.Message;
                //error.logCode = "ERR_COM_032";
                //_log.Error(error);
            }
        }
Exemplo n.º 15
0
        public ComunicazioniType(Comunicazioni c)
            : base(c)
        {
            if (c == null || c.IsValid == false)
            {
                this.m_IsNull = true;
                return;
            }

            this.m_AZ_PROTIsNull            = false;
            this.m_ID_COMIsNull             = !c.IdComunicazione.HasValue;
            this.m_IN_OUTIsNull             = (c.TipoCom == TipoComunicazione.UNKNOWN);
            this.m_REF_ID_SOTTOTITOLOIsNull = !c.RefIdSottotitolo.HasValue;

            this.m_FLG_NOTIFICA = Convert.ToInt32(c.IsToNotify).ToString();

            ComFlussoListType cl;

            if (c.ComFlussi == null)
            {
                cl = ComFlussoListType.Null;
            }
            else
            {
                cl = new ComFlussoListType();

                var fl = c.ComFlussi.SelectMany(f => f.Value);
                if (fl.Count() > 0)
                {
                    cl.ComFlusso = fl.Select(f => (ComFlussoType)f).ToArray();
                }
            }
            this.m_COM_FLUSSI = cl;

            ComFlussoListType clProt;

            if (c.ComFlussiProtocollo == null)
            {
                clProt = ComFlussoListType.Null;
            }
            else
            {
                clProt = new ComFlussoListType();
                if (c.ComFlussiProtocollo.Count > 0)
                {
                    clProt.ComFlusso = c.ComFlussiProtocollo.Select(cfp => (ComFlussoType)cfp).ToArray();
                }
            }
            this.m_COM_FLUSSI_PROT = clProt;

            ComAllegatoListType cal;

            if (c.ComAllegati == null)
            {
                cal = ComAllegatoListType.Null;
            }
            else
            {
                cal             = new ComAllegatoListType();
                cal.ComAllegati = c.ComAllegati.Select(ca => new ComAllegatoType(ca)).ToArray();
            }
            this.m_COM_ALLEGATI = cal;

            MailContentType mc;

            if (c.MailComunicazione == null)
            {
                mc = MailContentType.Null;
            }
            else
            {
                mc = new MailContentType(c.MailComunicazione);
            }
            this.m_MAIL_COM = mc;

            this.m_AZ_PROT = Convert.ToInt32(c.DaProtocollare);
            this.m_IN_OUT  = (int)c.TipoCom;
        }