Ejemplo n.º 1
0
 public void Insert(List <ActionFolder> af)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var transaction = dbcontext.Database.BeginTransaction())
         {
             foreach (ActionFolder a in af)
             {
                 try
                 {
                     ACTIONS_FOLDERS actionFolder = DaoSQLServerDBHelper.MapToActionFolder(a, true);
                     dbcontext.ACTIONS_FOLDERS.Add(actionFolder);
                     dbcontext.SaveChanges();
                     a.iD = (double)dbcontext.ACTIONS_FOLDERS.Select(x => x.ID).DefaultIfEmpty(0).Max();
                 }
                 catch (Exception ex)
                 {
                     transaction.Rollback();
                     if (ex.GetType() == typeof(ManagedException))
                     {
                         ManagedException mEx = new ManagedException(ex.Message, "ACF_ORA001", string.Empty, string.Empty, ex);
                         ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                         log.Error(er);
                         throw mEx;
                     }
                 }
             }
             transaction.Commit();
         }
     }
 }
Ejemplo n.º 2
0
        internal static ACTIONS_FOLDERS MapToActionFolder(ActionFolder a, bool v)
        {
            ACTIONS_FOLDERS f = new ACTIONS_FOLDERS()
            {
                IDACTION = (double)a.idAction,
                IDFOLDER = a.idFolder
            };

            if (!v)
            {
                f.ID = a.iD;
            }
            return(f);
        }