示例#1
0
 /// <summary>
 ///  创建异常处理集合
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entitys">异常处理集合</param>
 /// <returns></returns>
 public bool EditCollection(ref ValidationErrors validationErrors, IQueryable <SysException> entitys)
 {
     try
     {
         if (entitys != null)
         {
             int count = entitys.Count();
             if (count == 1)
             {
                 return(this.Edit(ref validationErrors, entitys.FirstOrDefault()));
             }
             else if (count > 1)
             {
                 using (TransactionScope transactionScope = new TransactionScope())
                 {
                     repository.Edit(db, entitys);
                     if (count == repository.Save(db))
                     {
                         transactionScope.Complete();
                         return(true);
                     }
                     else
                     {
                         Transaction.Current.Rollback();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
        public virtual bool Edit(ref ValidationErrors errors, SysExceptionModel model)
        {
            try
            {
                tbl_SysException entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Suggestion.Disable);
                    return(false);
                }
                entity.Id         = model.Id;
                entity.HelpLink   = model.HelpLink;
                entity.Message    = model.Message;
                entity.Source     = model.Source;
                entity.StackTrace = model.StackTrace;
                entity.TargetSite = model.TargetSite;
                entity.Data       = model.Data;
                entity.CreateTime = model.CreateTime;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Suggestion.EditFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHandler.WriteException(ex);
                return(false);
            }
        }