Exemplo n.º 1
0
        public bool Save()
        {
            bool flag = false;

            using (DbContextTransaction dbContextTransaction = context.Database.BeginTransaction())
            {
                try
                {
                    context.SaveChanges();
                    dbContextTransaction.Commit();
                    flag = true;
                }
                catch (DbUpdateException dbUpdateException1)
                {
                    DbUpdateException dbUpdateException = dbUpdateException1;
                    RPM_Logs          rPMLog            = this;
                    rPMLog.Msg = string.Concat(rPMLog.Msg, dbUpdateException.InnerException);
                    dbContextTransaction.Rollback();
                }
                catch (DbEntityValidationException dbEntityValidationException1)
                {
                    DbEntityValidationException dbEntityValidationException = dbEntityValidationException1;
                    dbContextTransaction.Rollback();
                    foreach (DbEntityValidationResult entityValidationError in dbEntityValidationException.EntityValidationErrors)
                    {
                        foreach (DbValidationError validationError in entityValidationError.ValidationErrors)
                        {
                            RPM_Logs rPMLog1 = this;
                            rPMLog1.Msg = string.Concat(rPMLog1.Msg, string.Format("Property: {0} Error: {1}\n", validationError.PropertyName, validationError.ErrorMessage));
                        }
                    }
                }
            }
            return(flag);
        }
Exemplo n.º 2
0
 private void WriteLog(VMGlobal.LOG_ACTION action, string memo)
 {
     try
     {
         AccountLog log = new AccountLog();
         log.Action = action.ToString();
         log.Memo   = memo;
         using (RPM_Logs rpmLogs = new RPM_Logs())
             rpmLogs.LogAccount(log);
     }
     catch
     {
     }
 }
Exemplo n.º 3
0
        private void WriteLog(VMGlobal.LOG_ACTION action, string memo, Guid Id)
        {
            if (Id != Guid.Empty)
            {
                DbSet <Account> accounts = context.Accounts;
                object[]        id       = new object[] { Id };
                Account         account  = accounts.Find(id);
                memo = string.Concat(string.Format("{0} [{1}]\n", account.ToString(), account.BadgeNumber), memo);
            }
            AccountLog accountLog = new AccountLog()
            {
                Action = action.ToString(),
                Memo   = memo
            };

            using (RPM_Logs rPMLog = new RPM_Logs())
            {
                rPMLog.LogAccount(accountLog);
            }
        }