示例#1
0
        /// <summary>
        /// Restituisce le informazioni relative al canale di comunicazione passato.
        /// </summary>
        /// <param name="canale">tipo di canale richiesto</param>
        public string GetInfoCanale(TipoCanale canale)
        {
            string info = string.Empty;

            switch (canale)
            {
            case TipoCanale.UNKNOWN:
                break;

            case TipoCanale.FAX:
                info = String.Format("Fax: {0}", Fax);
                break;

            case TipoCanale.MAIL:
                info = String.Format("Mail: {0}", Mail);
                break;

            case TipoCanale.POSTA:
                info = "Posta";
                break;

            case TipoCanale.AMANO:
                info = "A Mano";
                break;

            default:
                break;
            }
            return(info);
        }
示例#2
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);
        }
示例#3
0
        /// <summary>
        /// Ottiene tutte le comunicazioni per canale
        /// </summary>
        /// <param name="tipoCanale"></param>
        /// <returns></returns>
        internal IList <ComunicazioniType> GetComunicazioniByCanale(TipoCanale tipoCanale)
        {
            List <ComunicazioniType> lComunicazioni = null;

            using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
            {
                string query = queryBase;
                switch (tipoCanale)
                {
                case TipoCanale.A_MANO:
                    break;

                case TipoCanale.FAX:
                    break;

                case TipoCanale.MAIL:
                    query += " WHERE v0.mail_com IS NOT NULL";
                    break;

                case TipoCanale.POSTA:
                    break;

                case TipoCanale.UNKNOWN:
                    break;
                }

                oCmd.CommandText = query;

                try
                {
                    using (OracleDataReader r = oCmd.ExecuteReader())
                    {
                        if (r.HasRows)
                        {
                            lComunicazioni = new List <ComunicazioniType>();
                            while (r.Read())
                            {
                                lComunicazioni.Add((ComunicazioniType)r.GetValue(0));
                            }
                        }
                    }
                }
                catch
                {
                    lComunicazioni = null;
                }
            }
            return(lComunicazioni);
        }
示例#4
0
        public void SetStatoComunicazione(TipoCanale tipoCanale, MailStatus statoCom, String utenteOperazione)
        {
            List <ComFlusso> flussoCom = null;

            if (this.ComFlussi == null)
            {
                this.ComFlussi = new Dictionary <TipoCanale, List <ComFlusso> >();
            }

            if (this.ComFlussi.ContainsKey(tipoCanale))
            {
                flussoCom = this.ComFlussi[tipoCanale];
            }

            ComFlusso cf = new ComFlusso();

            cf.Canale             = tipoCanale;
            cf.RefIdComunicazione = this.IdComunicazione;
            if (flussoCom != null)
            {
                cf.StatoComunicazioneOld = this.ComFlussi[tipoCanale].Last().StatoComunicazioneNew;
            }
            else
            {
                cf.StatoComunicazioneOld = MailStatus.UNKNOWN;
            }
            cf.StatoComunicazioneNew = statoCom;
            cf.UtenteOperazione      = utenteOperazione;
            if (flussoCom == null)
            {
                List <ComFlusso> l = new List <ComFlusso>();
                l.Add(cf);
                this.ComFlussi.Add(tipoCanale, l);
            }
            else
            {
                this.ComFlussi[tipoCanale].Add(cf);
            }
        }
示例#5
0
        public Comunicazioni(String annPrt, String numPrt, String tipRic, String strId, String destCodes,
                             String senderMail, TipoCanale canaleType, String mailText, ICollection <ComAllegato> allegati, int folderId, string folderTipo)
            : this(annPrt, numPrt, tipRic, strId, destCodes)
        {
            this.ComFlussi = new Dictionary <TipoCanale, List <ComFlusso> >();
            this.ComFlussi.Add(canaleType, null);
            this.ComAllegati = (List <ComAllegato>)allegati;
            this.FolderTipo  = folderTipo;
            this.FolderId    = folderId;

            switch (canaleType)
            {
            case TipoCanale.MAIL:
                this.MailComunicazione               = new MailContent();
                this.MailComunicazione.MailSender    = senderMail;
                this.MailComunicazione.MailText      = mailText;
                this.MailComunicazione.HasCustomRefs = false;
                break;

            default:
                break;
            }
        }
示例#6
0
        /// <summary>
        /// Ottiene tutte le comunicazioni che hanno un certo status
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        internal IList <ComunicazioniType> GetComunicazioniByStatus(TipoCanale tipoCanale, List <MailStatus> status, bool include, int?minRec, int?maxRec, string utente)
        {
            List <ComunicazioniType> lComunicazioni = new List <ComunicazioniType>();

            using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
            {
                #region "old query"

                /* old query
                 * oCmd.CommandText = "WITH t_flussi AS"
                 + " (SELECT REF_ID_COM"
                 + ", ROW_NUMBER() OVER (ORDER BY REF_ID_COM) AS RN"
                 + " FROM ("
                 + "SELECT DISTINCT REF_ID_COM"
                 + " FROM COMUNICAZIONI_FLUSSO CF"
                 + " WHERE CANALE = '" + tipoCanale.ToString() + "'"
                 + " AND"
                 + ((include == false) ? " NOT" : "")
                 + " EXISTS (SELECT *"
                 + " FROM COMUNICAZIONI_FLUSSO CF0"
                 + " WHERE CF0.REF_ID_COM = CF.REF_ID_COM"
                 + " AND CF0.CANALE = CF.CANALE"
                 + " AND CF0.STATO_COMUNICAZIONE_NEW"
                 + " IN ('" + String.Join("', '", status.Select(s => ((int)s).ToString()).ToArray()) + "'))"
                 + " ORDER BY REF_ID_COM)) "
                 + queryBase
                 + " WHERE v0.com_flussi IS NOT EMPTY"
                 + " AND v0.id_com IN (SELECT ref_id_com FROM t_flussi"
                 +                                        //+ " WHERE "
                 +                                        //+ ((minRec.HasValue) ? (" RN >= " + minRec.Value.ToString()) : " RN >= 0")
                 +                                        //+ ((maxRec.HasValue) ? (" AND RN <= " + maxRec.Value.ToString()) : "")
                 + ")"
                 + (String.IsNullOrEmpty(utente) ? "" : " AND v0.mail_com.mail_sender = '" + utente + "'");
                 */
                #endregion

                StringBuilder sb = new StringBuilder("WITH t_flussi AS")
                                   .Append(" (SELECT DISTINCT IDX, ROW_NUMBER() OVER (ORDER BY IDX) AS RN")
                                   .Append(" FROM (SELECT DISTINCT mc.REF_ID_COM  as IDX FROM COMUNICAZIONI_FLUSSO CF INNER JOIN MAIL_CONTENT MC")
                                   .Append(" on cf.ref_id_com = mc.ref_id_com")
                                   .Append(" WHERE mc.mail_sender = :p_sender and CANALE = :p_canale AND")
                                   .Append(include ? "" : " NOT")
                                   .Append(" EXISTS (SELECT 1")
                                   .Append(" FROM COMUNICAZIONI_FLUSSO CF0")
                                   .Append(" WHERE CF0.REF_ID_COM = CF.REF_ID_COM")
                                   .Append(" AND CF0.CANALE = CF.CANALE")
                                   .Append(" AND CF0.STATO_COMUNICAZIONE_NEW IN (")
                                   .Append(string.Format("'{0}'", string.Join("', '", status.Select(s => ((int)s).ToString()).ToArray())))
                                   .Append(")))")
                                   .Append(" ORDER BY IDX)")
                                   .Append(" SELECT VALUE(v0)")
                                   .Append(" FROM v_comunicazioni_complete_obj v0")
                                   .Append(" WHERE v0.com_flussi IS NOT EMPTY")
                                   .Append(" AND v0.id_com IN (SELECT idx FROM t_flussi")
                                   .Append(" where RN >= :p_minRec")
                                   .Append(" AND RN <= :p_maxRec")
                                   .Append(")");

                oCmd.CommandText = sb.ToString();
                oCmd.BindByName  = true;
                oCmd.Parameters.Add(new OracleParameter
                {
                    Direction     = System.Data.ParameterDirection.Input,
                    OracleDbType  = OracleDbType.Varchar2,
                    ParameterName = "p_sender",
                    Value         = utente
                });
                oCmd.Parameters.Add(new OracleParameter
                {
                    Direction     = System.Data.ParameterDirection.Input,
                    OracleDbType  = OracleDbType.Varchar2,
                    ParameterName = "p_canale",
                    Size          = 20,
                    Value         = tipoCanale.ToString()
                });
                oCmd.Parameters.Add(new OracleParameter
                {
                    Direction     = System.Data.ParameterDirection.Input,
                    OracleDbType  = OracleDbType.Decimal,
                    ParameterName = "p_minRec",
                    Precision     = 10,
                    Scale         = 0,
                    Value         = ((minRec.HasValue) ? minRec.Value : 0)
                });
                oCmd.Parameters.Add(new OracleParameter
                {
                    Direction     = System.Data.ParameterDirection.Input,
                    OracleDbType  = OracleDbType.Decimal,
                    ParameterName = "p_maxRec",
                    Value         = ((maxRec.HasValue) ? maxRec.Value : int.MaxValue)
                });
                try
                {
                    using (OracleDataReader r = oCmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            lComunicazioni.Add((ComunicazioniType)r.GetValue(0));
                        }
                    }
                }
                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);
        }
示例#7
0
        public Comunicazioni(TipoCanale canaleType, String sottoTitolo, ActiveUp.Net.Mail.Message msg, String utente, int folderId, string folderTipo)
        {
            #region "sottotitolo"

            if (!String.IsNullOrEmpty(sottoTitolo))
            {
                this.RefIdSottotitolo = Convert.ToInt64(sottoTitolo);
            }

            #endregion

            #region "mail"

            MailContent mail = new MailContent();
            this.MailComunicazione = mail;

            #region "sender"

            mail.MailSender = msg.From.Email;

            #endregion

            #region "refs"
            mail.MailRefs = new List <MailRefs>();
            List <MailRefs> lR = new List <MailRefs>();
            var             to = from to0 in msg.To
                                 select new MailRefs
            {
                MailDestinatario = to0.Email,
                TipoRef          = AddresseeType.TO
            };
            if (to.Count() > 0)
            {
                lR.AddRange(to);
            }
            var cc = from cc0 in msg.Cc
                     select new MailRefs
            {
                MailDestinatario = cc0.Email,
                TipoRef          = AddresseeType.CC
            };
            if (cc.Count() > 0)
            {
                lR.AddRange(cc);
            }
            var ccn = from ccn0 in msg.Bcc
                      select new MailRefs
            {
                MailDestinatario = ccn0.Email,
                TipoRef          = AddresseeType.CCN
            };
            if (ccn.Count() > 0)
            {
                lR.AddRange(ccn);
            }
            if (lR.Count > 0)
            {
                mail.MailRefs = lR;
            }

            #endregion

            #region "subject"

            mail.MailSubject = msg.Subject;

            #endregion

            #region "body"

            mail.MailText = !String.IsNullOrEmpty(msg.BodyHtml.Text) ? msg.BodyHtml.Text : msg.BodyText.Text;

            #endregion

            #region "reply"
            if (!String.IsNullOrEmpty(msg.InReplyTo) && !String.IsNullOrEmpty(msg.InReplyTo.Trim()))
            {
                string follows = msg.InReplyTo.Trim();
                if (follows.StartsWith("<"))
                {
                    follows = follows.Substring(1);
                }
                if (follows.EndsWith(">"))
                {
                    follows = follows.Substring(0, follows.Length - 1);
                }
                long?flw    = null;
                long flwout = 0;
                if (long.TryParse(follows.Split('.')[0], out flwout))
                {
                    flw = flwout;
                }
                mail.Follows = flw;
            }
            #endregion
            #endregion

            #region "attachments"

            List <ComAllegato> all = null;
            if (msg.Attachments.Count > 0)
            {
                all = new List <ComAllegato>();

                for (int j = 0; j < msg.Attachments.Count; j++)
                {
                    ActiveUp.Net.Mail.MimePart mp = msg.Attachments[j];
                    ComAllegato a = new ComAllegato();
                    a.IdAllegato   = null;
                    a.AllegatoExt  = System.IO.Path.GetExtension(mp.Filename);
                    a.AllegatoExt  = a.AllegatoExt.Replace(".", string.Empty);
                    a.AllegatoFile = mp.BinaryContent;
                    a.AllegatoName = System.IO.Path.GetFileNameWithoutExtension(mp.Filename);
                    a.T_Progr      = j;
                    a.FlgInsProt   = AllegatoProtocolloStatus.UNKNOWN;
                    a.FlgProtToUpl = AllegatoProtocolloStatus.UNKNOWN;
                    a.RefIdCom     = null;

                    all.Add(a);
                }
            }
            this.ComAllegati = all;

            #endregion

            #region "notifica"

            this.MailNotifica = msg.ReplyTo.Email;

            #endregion

            #region "utente inserimento"

            this.UtenteInserimento = utente;

            #endregion

            #region "flusso comunicazione"

            this.SetStatoComunicazione(canaleType, MailStatus.INSERTED, utente);

            #endregion

            #region Folder
            this.FolderId   = folderId;
            this.FolderTipo = folderTipo;

            #endregion
        }
示例#8
0
        public Comunicazioni(TipoCanale canaleType, List <DataRow> _list)
        {
            this.ComFlussi = new Dictionary <TipoCanale, List <ComFlusso> >();
            this.ComFlussi.Add(canaleType, null);
            if (_list[0].Table.Columns.Contains("ANN_PRT"))
            {
                this.annPrt = _list[0].Field <string>("ANN_PRT");
                this.numPrt = _list[0].Field <string>("NUM_PRT");
            }
            if (_list[0].Table.Columns.Contains("COD_IND"))
            {
                this.CodiceIndividuale = _list[0].Field <string>("COD_IND");
            }
            this.ComCode         = _list[0].Field <String>("TIP_RIC");
            this.StringaID       = _list[0].Field <String>("STRINGA_ID");
            this.destinatariCode = _list[0].Field <String>("COD_DESTINATARIO").Split(';');
            string             oggetto = string.Empty;
            List <ComAllegato> lAll    = new List <ComAllegato>();
            StringBuilder      dati    = new StringBuilder();

            System.Collections.Generic.Dictionary <int, string> prus = new System.Collections.Generic.Dictionary <int, string>();
            System.Collections.Generic.Dictionary <int, string> tpus = new System.Collections.Generic.Dictionary <int, string>();

            if (_list == null && _list.Count == 0)
            {
                this.ComAllegati = null;
            }
            else
            {
                for (int i = 0; i < _list.Count; i++)
                {
                    if ((_list[i].Field <String>("NOME_TPU").ToUpper().Trim() == "TESTO_MAIL") || (_list[i].Field <String>("NOME_TPU").ToUpper().Trim() == "TESTO_MAIL_ELE"))
                    {
                        dati.Append(_list[i].Field <String>("DATI_PRU"));
                    }
                    if (_list[i].Field <string>("NOME_TPU").ToUpper().Trim() == "OGGETTO_MAIL_ELE")
                    {
                        oggetto += _list[i].Field <string>("DATI_PRU");
                        continue;
                    }

                    if (!(string.IsNullOrEmpty(_list[i].Field <String>("PROG_PRU")) || _list[i].Field <String>("NOME_TPU").ToLower().Equals("testo_mail") || _list[i].Field <String>("NOME_TPU").ToLower().Equals("testo_mail_ele")))
                    {
                        if (!prus.ContainsKey(int.Parse(_list[i].Field <String>("PROG_TPU").Trim())))
                        {
                            prus.Add(int.Parse(_list[i].Field <String>("PROG_TPU").Trim()), string.Empty);
                            tpus.Add(int.Parse(_list[i].Field <String>("PROG_TPU").Trim()), _list[i].Field <String>("NOME_TPU"));
                        }
                        prus[int.Parse(_list[i].Field <String>("PROG_TPU").Trim())] = prus[int.Parse(_list[i].Field <String>("PROG_TPU").Trim())] + _list[i].Field <String>("DATI_PRU");
                    }
                }

                for (int j = 0; j < tpus.Count; j++)
                {
                    ComAllegato a = new ComAllegato();
                    a.IdAllegato   = null;
                    a.RefIdCom     = null;
                    a.AllegatoTpu  = tpus[j + 1];
                    a.T_Progr      = j;
                    a.AllegatoExt  = "PRU";
                    a.AllegatoFile = Encoding.GetEncoding("ISO-8859-1").GetBytes(prus[j + 1]);
                    a.AllegatoFile = new UTF8Encoding(false).GetBytes(prus[j + 1]);
                    string[] cmp = tpus[j + 1].Split('.');
                    a.AllegatoName = String.Format("{0}_{1}", String.Join(".", cmp, 0, cmp.Length - 1), (j + 1).ToString("D3"));
                    lAll.Add(a);
                }
                this.ComAllegati = lAll;
            }

            switch (canaleType)
            {
            case TipoCanale.MAIL:
                this.MailComunicazione               = new MailContent();
                this.MailComunicazione.MailSender    = _list[0].Field <String>("EMAIL");
                this.MailComunicazione.MailText      = dati.ToString();
                this.MailComunicazione.HasCustomRefs = false;
                if (!string.IsNullOrEmpty(oggetto))
                {
                    this.MailComunicazione.MailSubject = oggetto.Trim();
                }
                break;

            default:
                break;
            }
        }