예제 #1
0
 public void Update(SendMail.Model.RubricaMapping.RubricaContatti entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var transaction = dbcontext.Database.Connection.BeginTransaction())
             try
             {
                 var rubrOld = dbcontext.RUBR_CONTATTI.Where(x => x.ID_CONTACT == entity.IdContact).First();
                 var rubrNew = DaoSQLServerDBHelper.MapToRubrContatti(entity, false);
                 dbcontext.RUBR_CONTATTI.Remove(rubrOld);
                 dbcontext.RUBR_CONTATTI.Add(rubrNew);
                 int res = dbcontext.SaveChanges();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 if (!ex.GetType().Equals(typeof(ManagedException)))
                 {
                     ManagedException mEx = new ManagedException("Errore nell'inserimento del contatto per il contatto " + entity.Mail + " >> ERR_C012 >> Dettagli Errore: " + ex.Message,
                                                                 "SQL_ERR_C012", string.Empty, string.Empty, ex.InnerException);
                     ErrorLogInfo err = new ErrorLogInfo(mEx);
                     _log.Error(err);
                     throw mEx;
                 }
                 else
                 {
                     throw ex;
                 }
             }
     }
 }
예제 #2
0
        public RubricaContatti Clone(RubricaEntita e)
        {
            RubricaContatti c = new RubricaContatti(this);

            c.Entita = e;
            return(c);
        }
예제 #3
0
 public void Insert(SendMail.Model.RubricaMapping.RubricaContatti entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var dbContextTransaction = dbcontext.Database.BeginTransaction())
         {
             try
             {
                 if (entity.Entita != null)
                 {
                     RUBR_ENTITA e = DaoSQLServerDBHelper.MapToRubrEntita(entity.Entita, true);
                     dbcontext.RUBR_ENTITA.Add(e);
                     entity.Entita.IdReferral = (long)e.ID_REFERRAL;
                     entity.RefIdReferral     = (long)e.ID_REFERRAL;
                     RUBR_CONTATTI c = DaoSQLServerDBHelper.MapToRubrContatti(entity, true);
                     entity.IdContact = (long)c.ID_CONTACT;
                     dbcontext.RUBR_CONTATTI.Add(c);
                     dbcontext.SaveChanges();
                     dbContextTransaction.Commit();
                 }
                 else if (entity.Entita == null && entity.RefIdReferral != null)
                 {
                     RUBR_CONTATTI c = DaoSQLServerDBHelper.MapToRubrContatti(entity, true);
                     entity.IdContact = (long)c.ID_CONTACT;
                     dbcontext.RUBR_CONTATTI.Add(c);
                     int righe = dbcontext.SaveChanges();
                     dbContextTransaction.Commit();
                 }
                 else if (entity.Entita == null && entity.RefIdReferral == null)
                 {
                     dbContextTransaction.Rollback();
                     ManagedException mEx = new ManagedException("Errore nell'inserimento del contatto per il contatto " + entity.Mail + " >> ERR_C014 >> Dettagli Errore:  Mancano riferimenti entità",
                                                                 "SQL_ERR_C014", string.Empty, string.Empty, null);
                     ErrorLogInfo err = new ErrorLogInfo(mEx);
                     _log.Error(err);
                     throw mEx;
                 }
             }
             catch (Exception ex)
             {
                 dbContextTransaction.Rollback();
                 if (!ex.GetType().Equals(typeof(ManagedException)))
                 {
                     ManagedException mEx = new ManagedException(ex.Message,
                                                                 "SQL_ERR_C013", string.Empty, string.Empty, ex);
                     ErrorLogInfo err = new ErrorLogInfo(mEx);
                     _log.Error(err);
                     throw mEx;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
     }
 }
예제 #4
0
        public void Insert(SendMail.Model.RubricaMapping.RubricaContatti entity)
        {
            using (OracleCommand ocmd = base.CurrentConnection.CreateCommand())
            {
                base.Context.StartTransaction(this.GetType());

                if (entity.Entita != null)
                {
                    try
                    {
                        this.Context.DaoImpl.RubricaEntitaDao.Insert(entity.Entita);
                        entity.RefIdReferral = entity.Entita.IdReferral;
                    }
                    catch
                    {
                        base.Context.RollBackTransaction(this.GetType());
                        throw;
                    }
                }

                ocmd.CommandText = insertStatement;
                ocmd.BindByName  = true;
                ocmd.Parameters.Clear();
                ocmd.Parameters.AddRange(MapObjectToParams(entity, true));

                try
                {
                    int ret = ocmd.ExecuteNonQuery();
                    entity.IdContact = long.Parse(ocmd.Parameters["pIDCONTACT"].Value.ToString());
                }
                catch (Exception ex)
                {
                    base.Context.RollBackTransaction(this.GetType());
                    //TASK: Allineamento log - Ciro
                    if (!ex.GetType().Equals(typeof(ManagedException)))
                    {
                        ManagedException mEx = new ManagedException(ex.Message,
                                                                    "ORA_ERR012", string.Empty, string.Empty, ex);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);
                        _log.Error(err);
                        throw mEx;
                    }
                    else
                    {
                        throw ex;
                    }
                }

                base.Context.EndTransaction(this.GetType());
            }
        }
예제 #5
0
        public RubricaContatti(RubricaContatti rc)
        {
            if (rc == null)
            {
                return;
            }

            Type t = this.GetType();

            foreach (System.Reflection.PropertyInfo p in t.GetProperties())
            {
                if (p.CanWrite)
                {
                    p.SetValue(this, p.GetValue(rc, null), null);
                }
            }
        }
예제 #6
0
 public void Update(SendMail.Model.RubricaMapping.RubricaContatti entity)
 {
     using (OracleCommand ocmd = base.CurrentConnection.CreateCommand())
     {
         ocmd.CommandText = updateStatement;
         ocmd.Parameters.AddRange(MapObjectToParams(entity, false));
         ocmd.BindByName = true;
         ocmd.Connection = base.CurrentConnection;
         try
         {
             int ret = ocmd.ExecuteNonQuery();
         }
         catch
         {
             //todo
             throw;
         }
     }
 }
예제 #7
0
 public RubricaContatti save(RubricaContatti e)
 {
     return(e);
 }