Exemplo n.º 1
0
        public int GetCountComunicazioniNonInviate(Model.TipoCanale tipoCanale, string utente)
        {
            List <MailStatus> lStatus = new List <MailStatus>();

            lStatus.Add(MailStatus.SENT);
            return(GetCountComunicazioni(tipoCanale, lStatus, false, utente));
        }
Exemplo n.º 2
0
 public void UpdateAllegati(Model.TipoCanale tipoCanale, Model.ComunicazioniMapping.Comunicazioni comunicazione)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var dbContextTransaction = dbcontext.Database.BeginTransaction())
         {
             try
             {
                 foreach (ComAllegato comAllegato in comunicazione.ComAllegati)
                 {
                     COMUNICAZIONI_ALLEGATI allegato     = AutoMapperConfiguration.FromComAllegatoToDto(comAllegato);
                     COMUNICAZIONI_ALLEGATI allegato_old = dbcontext.COMUNICAZIONI_ALLEGATI.Find(comAllegato.IdAllegato);
                     dbcontext.COMUNICAZIONI_ALLEGATI.Remove(allegato_old);
                     dbcontext.COMUNICAZIONI_ALLEGATI.Add(allegato);
                 }
                 dbcontext.SaveChanges();
                 dbContextTransaction.Commit();
             }
             catch (Exception ex)
             {
                 dbContextTransaction.Rollback();
                 //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;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public ICollection <Model.ComunicazioniMapping.Comunicazioni> GetComunicazioniNonInviate(Model.TipoCanale tipoCanale, int?minRec, int?maxRec, string utente)
        {
            List <MailStatus> lStatus = new List <MailStatus>();

            lStatus.Add(MailStatus.SENT);
            IList <Comunicazioni> lC = GetComunicazioniByNotStatus(tipoCanale, lStatus, false, minRec, maxRec, utente);

            if (lC != null)
            {
                return(lC);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public void UpdateFlussoComunicazione(Model.TipoCanale tipoCanale, Model.ComunicazioniMapping.Comunicazioni comunicazione)
        {
            ComFlusso f = comunicazione.ComFlussi[tipoCanale].OrderBy(x => !x.IdFlusso.HasValue).ThenBy(x => x.IdFlusso).Last();

            using (var dbcontext = new FAXPECContext())
            {
                using (var dbContextTransaction = dbcontext.Database.BeginTransaction())
                {
                    try
                    {
                        if (f.IdFlusso.HasValue)
                        {
                            COMUNICAZIONI_FLUSSO flusso     = AutoMapperConfiguration.FromComFlussoToDto(f);
                            COMUNICAZIONI_FLUSSO old_flusso = dbcontext.COMUNICAZIONI_FLUSSO.Find(f.IdFlusso);
                            dbcontext.COMUNICAZIONI_FLUSSO.Remove(old_flusso);
                            dbcontext.COMUNICAZIONI_FLUSSO.Add(flusso);
                        }
                        else
                        {
                            COMUNICAZIONI_FLUSSO flusso = AutoMapperConfiguration.FromComFlussoToDto(f);
                            dbcontext.COMUNICAZIONI_FLUSSO.Add(flusso);
                        }
                    }
                    catch (Exception ex)
                    {
                        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);
                            COMUNICAZIONI_FLUSSO flusso = AutoMapperConfiguration.FromComFlussoToDto(f);
                            dbcontext.COMUNICAZIONI_FLUSSO.Add(flusso);
                            throw mEx;  //aggiunto il 26/02/2016
                        }
                        else
                        {
                            COMUNICAZIONI_FLUSSO flusso = AutoMapperConfiguration.FromComFlussoToDto(f);
                            dbcontext.COMUNICAZIONI_FLUSSO.Add(flusso);
                            throw ex; //aggiunto il 26/02/2016
                        }
                    }
                    finally
                    {
                        int tot = dbcontext.SaveChanges();
                        if (tot > 0)
                        {
                            dbContextTransaction.Commit();
                        }
                        else
                        {
                            dbContextTransaction.Rollback();
                            throw new Exception("Comunicazione non inserita fermi tutti");
                        }
                    }
                }
            }
        }