Exemplo n.º 1
0
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <SysExceptionModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        SysException entity = new SysException();
                        entity.Id         = ResultHelper.NewId;
                        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 = ResultHelper.NowTime;

                        db.SysException.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public BaseResponse <SysManagerUser> editUser(string loginName, ViewModelUserEditReqeust condtion)
        {
            BaseResponse <SysManagerUser> result = new BaseResponse <SysManagerUser>();

            try
            {
                if (!User.IsInRole("admin"))
                {
                    loginName = User.Identity.Name;
                }

                SysManagerUser smu = new SysManagerUser(loginName);
                result.result = smu.saveInfo(condtion);
                result.msg    = "保存成功";
            }
            catch (SysException ex)
            {
                result = ex.getresult(result, true);
            }
            catch (Exception e) {
                result = SysException.getResult(result, e, condtion);
            }

            return(result);
        }
Exemplo n.º 3
0
 //[Dependency]
 //public static ISysExceptionBLL exBLL { get; set; }
 /// <summary>
 /// 加入异常日志
 /// </summary>
 /// <param name="ex">异常</param>
 public static void WriteException(Exception ex)
 {
     try
     {
         SysException model = new SysException()
         {
             Id         = ResultHelper.NewId,
             HelpLink   = ex.HelpLink,
             Message    = ex.Message,
             Source     = ex.Source,
             StackTrace = ex.StackTrace,
             TargetSite = ex.TargetSite.ToString(),
             Data       = ex.Data.ToString(),
             CreateTime = ResultHelper.NowTime
         };
         new SysExceptionRepository().Create(model);
     }
     catch (Exception ep)
     {
         try
         {
             //异常失败写入txt
             string path    = @"~/exceptionLog.txt";
             string txtPath = System.Web.HttpContext.Current.Server.MapPath(path);//获取绝对路径
             using (StreamWriter sw = new StreamWriter(txtPath, true, Encoding.Default))
             {
                 sw.WriteLine((ex.Message + "|" + ex.StackTrace + "|" + ep.Message + "|" + DateTime.Now.ToString()).ToString());
                 sw.Dispose();
                 sw.Close();
             }
             return;
         }
         catch { return; }
     }
 }
Exemplo n.º 4
0
 public bool Create(SysExceptionModel model)
 {
     try
     {
         if (exceptionRepository.IsExist(model.Id))
         {
             return(false);
         }
         SysException entity = new SysException
         {
             Id         = ResultHelper.NewId,
             HelpLink   = model.HelpLink,
             Message    = model.Message,
             Source     = model.Source,
             StackTrace = model.StackTrace,
             TargetSite = model.TargetSite,
             Data       = model.Data,
             CreateTime = model.CreateTime
         };
         return(exceptionRepository.Create(entity) == 1);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Get SysException By Id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public SysException GetSysExceptionById(string Id)
        {
            SysException sysException = new SysException();

            string sql = "SELECT * FROM SysException WHERE Id = '" + Id.ToString() + "'";

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = dbConnection;
            sqlCommand.CommandText = sql;

            SqlDataReader reader = sqlCommand.ExecuteReader();

            if (reader.Read())
            {
                DataReader dataReader = new DataReader(reader);

                sysException.Id         = dataReader.GetString("Id");
                sysException.HelpLink   = dataReader.GetString("HelpLink");
                sysException.Message    = dataReader.GetString("Message");
                sysException.Source     = dataReader.GetString("Source");
                sysException.StackTrace = dataReader.GetString("StackTrace");
                sysException.TargetSite = dataReader.GetString("TargetSite");
                sysException.Data       = dataReader.GetString("Data");
                sysException.CreateTime = dataReader.GetDateTime("CreateTime");
            }
            reader.Close();

            return(sysException);
        }
Exemplo n.º 6
0
        public ActionResult Edit(string id, SysException entity)
        {
            if (entity != null && ModelState.IsValid)
            {   //数据校验
                string currentPerson = GetCurrentPerson();
                //entity.UpdateTime = DateTime.Now;
                //entity.UpdatePerson = currentPerson;

                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",异常处理信息的Id为" + id, "异常处理"
                                                   );       //写入日志
                    return(Json(Suggestion.UpdateSucceed)); //提示更新成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",异常处理信息的Id为" + id + "," + returnValue, "异常处理"
                                                   );                  //写入日志
                    return(Json(Suggestion.UpdateFail + returnValue)); //提示更新失败
                }
            }
            return(Json(Suggestion.UpdateFail + "请核对输入的数据的格式")); //提示输入的数据的格式不对
        }
Exemplo n.º 7
0
        public ActionResult Create(SysException entity)
        {
            if (entity != null && ModelState.IsValid)
            {
                string currentPerson = GetCurrentPerson();
                entity.CreateTime   = DateTime.Now;
                entity.CreatePerson = currentPerson;

                entity.Id = Result.GetNewId();
                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",异常处理的信息的Id为" + entity.Id, "异常处理"
                                                   );//写入日志
                    return(Json(Suggestion.InsertSucceed));
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",异常处理的信息," + returnValue, "异常处理"
                                                   );                  //写入日志
                    return(Json(Suggestion.InsertFail + returnValue)); //提示插入失败
                }
            }

            return(Json(Suggestion.InsertFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对
        }
Exemplo n.º 8
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.Sys.SysExceptionModel model, params string[] updateProperties)
        {
            SysException entity = m_Rep.GetById(model.Id);

            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                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;
            }
            else
            {
                Type type  = typeof(Apps.Models.Sys.SysExceptionModel);
                Type typeE = typeof(Apps.Models.SysException);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 删除对象集合
        /// </summary>
        /// <param name="db">数据库</param>
        /// <param name="deleteCollection">集合</param>
        public int Delete(AppDBContainer db, string id)
        {
            SysException entity = db.SysException.SingleOrDefault(x => x.Id == id);

            db.SysException.Remove(entity);
            return(db.SaveChanges());
        }
Exemplo n.º 10
0
        public async Task <IActionResult> HardDelete(int id = 0)
        {
            Result result = new Result(false, "Unable to delete post at this time.");

            if (id != 0)
            {
                try
                {
                    await _post.DeletePostAsync(id);

                    result.Succeeded = true;
                    result.Message   = "Post deleted.";
                }
                catch (Exception ex)
                {
                    result.Message = "Unable to delete post at this time.";

                    SysException exception = new SysException(ex)
                    {
                        Url = UrlHelper.GetRequestUrl(HttpContext)
                    };
                }
            }

            return(Json(new { result }));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 将异常信息写入数据库,或者文本文件
        /// </summary>
        /// <param name="ex"></param>
        public static void WriteExceptions(Exception ex)
        {
            bool exceptionEnabled = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ExceptionEnabled"]);

            if (!exceptionEnabled)
            {
                return;
            }
            //此处实现异常的记录

            SysException sysException = new SysException();

            sysException.CreateTime = DateTime.Now;
            sysException.Remark     = ex.StackTrace;
            sysException.Message    = ex.Message;
            sysException.LeiXing    = "异常";
            sysException.Result     = (ex.InnerException == null) ? string.Empty : ex.InnerException.Message;
            sysException.Id         = Result.GetNewId();

            using (SysExceptionBLL sysExceptionRepository = new SysExceptionBLL())
            {
                ValidationErrors validationErrors = new ValidationErrors();
                sysExceptionRepository.Create(ref validationErrors, sysException);
                return;
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// 创建一个对象
 /// </summary>
 /// <param name="db">数据库</param>
 /// <param name="entity">实体</param>
 public int Create(SysException entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysException.Add(entity);
         return(db.SaveChanges());
     }
 }
Exemplo n.º 13
0
 public int Create(SysException entity)
 {
     using (var db = new SysMgr_DBEntities())
     {
         db.Set <SysException>().Add(entity);
         return(db.SaveChanges());
     }
 }
Exemplo n.º 14
0
 public static bool Insert(SysException sysException)
 {
     using (var context = db.Context())
     {
         return(context.Insert <SysException>("SysException", sysException)
                .Execute() > 0);
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// 创建一个实体
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Create(SysException entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.SysException.Add(entity);
         return(db.SaveChanges());
     }
 }
        public ActionResult DeleteConfirmed(string id)
        {
            SysException sysExceptionModel = db.SysException.Find(id);

            db.SysException.Remove(sysExceptionModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 17
0
 public int Delete(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         SysException entity = db.SysException.SingleOrDefault(a => a.Id == id);
         db.SysException.Remove(entity);
         return(db.SaveChanges());
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// 创建一个对象
 /// </summary>
 /// <param name="db">数据库</param>
 /// <param name="entity">实体</param>
 public int Create(SysException entity)
 {
     using (AppDBContainer db = new AppDBContainer())
     {
         //db.SysExceptions.AddObject(entity);
         db.SysException.Add(entity);
         return(db.SaveChanges());
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// 删除对象集合
 /// </summary>
 /// <param name="db">数据库</param>
 /// <param name="entity">集合</param>
 public int Delete(string id)
 {
     using (DBContainer db = new DBContainer())
     {
         SysException entity = db.SysException.SingleOrDefault(a => a.Id == id);
         db.Set <SysException>().Remove(entity);
         return(Convert.ToInt32(db.SaveChanges() > 0));
     }
 }
 public ActionResult Edit([Bind(Include = "Id,HelpLink,Message,Source,StackTrace,TargetSite,Data,CreateTime")] SysException sysExceptionModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sysExceptionModel).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sysExceptionModel));
 }
        public ActionResult Create([Bind(Include = "Id,HelpLink,Message,Source,StackTrace,TargetSite,Data,CreateTime")] SysException sysExceptionModel)
        {
            if (ModelState.IsValid)
            {
                db.SysException.Add(sysExceptionModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sysExceptionModel));
        }
        public JsonResult Delete(FormCollection postedFormData, [System.Web.Http.FromBody] SysExceptionMaintenanceDTO sysExceptionDTO)
        {
            TransactionalInformation transaction;

            SysExceptionMaintenanceViewModel sysExceptionMaintenanceViewModel = new SysExceptionMaintenanceViewModel();

            SysException sysException = new SysException();

            ModelStateHelper.UpdateViewModel(sysExceptionDTO, sysException);

            SysExceptionApplicationService sysExceptionApplicationService = new SysExceptionApplicationService(sysExceptionDataService);

            sysExceptionApplicationService.DeleteSysExceptionById(sysException.Id, out transaction);

            sysExceptionMaintenanceViewModel.SysException     = sysException;
            sysExceptionMaintenanceViewModel.ReturnStatus     = transaction.ReturnStatus;
            sysExceptionMaintenanceViewModel.ReturnMessage    = transaction.ReturnMessage;
            sysExceptionMaintenanceViewModel.ValidationErrors = transaction.ValidationErrors;


            if (transaction.ReturnStatus == false)
            {
                //var Json = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);
                //return badresponse;

                //return Json(new
                //{
                //    ReturnStatus = sysExceptionMaintenanceViewModel.ReturnStatus,
                //    ViewModel = sysExceptionMaintenanceViewModel,
                //    ValidationErrors = sysExceptionMaintenanceViewModel.ValidationErrors,
                //    //MessageBoxView = Helpers.MvcHelpers.RenderPartialView(this, "_MessageBox", sysExceptionMaintenanceViewModel),
                //    //JsonRequestBehavior.AllowGet
                //});

                return(Json(0, JsonRequestBehavior.AllowGet));
            }
            else
            {
                //var response = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.Created, customerMaintenanceViewModel);
                //return response;

                //return Json(new
                //{
                //    ReturnStatus = sysExceptionMaintenanceViewModel.ReturnStatus,
                //    ViewModel = sysExceptionMaintenanceViewModel,
                //    ValidationErrors = sysExceptionMaintenanceViewModel.ValidationErrors,
                //    //MessageBoxView = Helpers.MvcHelpers.RenderPartialView(this, "_MessageBox", sysExceptionMaintenanceViewModel),
                //    JsonRequestBehavior.AllowGet
                //});

                return(Json(1, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 23
0
        public static bool Update(SysException sysException)
        {
            using (var context = db.Context())
            {
                return(context.Update <SysException>("SysException", sysException)
                       .AutoMap(x => x.Id)

                       .Where("Id", sysException.Id)

                       .Execute() > 0);
            }
        }
Exemplo n.º 24
0
 public bool IsExist(string id)
 {
     using (DBContainer db = new DBContainer())
     {
         SysException entity = GetById(id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 25
0
        public async Task <IActionResult> Delete(DeletePostViewModel model)
        {
            Result result = new Result(false, "Unable to delete post at this time.");

            if (ModelState.IsValid)
            {
                Post post = await _post.GetPostAndCommentsAsync(model.Id);

                post.IsActive            = false;
                post.RowModifiedBy       = Convert.ToInt32(_userManager.GetUserId(User));
                post.RowModifiedDateTime = DateTime.Now;

                if (post.Comments != null && post.Comments.Count() != 0)
                {
                    foreach (var comment in post.Comments)
                    {
                        comment.IsActive            = false;
                        comment.RowModifiedBy       = post.RowModifiedBy;
                        comment.RowModifiedDateTime = post.RowModifiedDateTime;

                        if (comment.Replies != null && comment.Replies.Count() != 0)
                        {
                            foreach (var reply in comment.Replies)
                            {
                                reply.IsActive            = false;
                                reply.RowModifiedBy       = post.RowModifiedBy;
                                reply.RowModifiedDateTime = post.RowModifiedDateTime;
                            }
                        }
                    }
                }

                try
                {
                    await _post.EditPostAsync(post);

                    result.Succeeded = true;
                    result.Message   = "Post deleted.";
                }
                catch (Exception ex)
                {
                    result.Message = "Unable to delete post at this time.";

                    SysException exception = new SysException(ex)
                    {
                        Url = UrlHelper.GetRequestUrl(HttpContext)
                    };
                }
            }

            return(Json(result));
        }
Exemplo n.º 26
0
 /// <summary>
 /// 创建一个异常处理
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个异常处理</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, SysException entity)
 {
     try
     {
         return(repository.Create(entity) == 1);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Exemplo n.º 27
0
        public BaseResponse <List <SysCatTree> > getTreelist(string fun)
        {
            BaseResponse <List <SysCatTree> > result = new BaseResponse <List <SysCatTree> >();

            try
            {
                result.result = SysCatTree.getTreeList(fun);
            }
            catch (Exception e) {
                result = SysException.getResult(result, e, fun);
            }
            return(result);
        }
Exemplo n.º 28
0
        public BaseResponse <BaseResponseList <SysUserLog> > searchUserLog(ViewModelMsgSearchUserLogReqeust condtion)
        {
            BaseResponse <BaseResponseList <SysUserLog> > result = new BaseResponse <BaseResponseList <SysUserLog> >();

            try
            {
                result.result = SysUserLog.searchLog(condtion);
            }
            catch (Exception e) {
                SysException.getResult(result, e, condtion);
            }
            return(result);
        }
Exemplo n.º 29
0
        public BaseResponse <BaseResponseList <SysManagerUser> > searchUserList(ViewModelSearchUserBaseRequest condtion)
        {
            BaseResponse <BaseResponseList <SysManagerUser> > res = new BaseResponse <BaseResponseList <SysManagerUser> >();

            try
            {
                res.result = SysManagerUser.searchUserList(condtion);
            }
            catch (Exception e) {
                res = SysException.getResult(res, e, condtion);
            }
            return(res);
        }
Exemplo n.º 30
0
        public BaseResponse <BaseResponseList <SysExcptionLog> > searchExceptionLog(VMMsgSearchExceptionLogRequest condtion)
        {
            BaseResponse <BaseResponseList <SysExcptionLog> > result = new BaseResponse <BaseResponseList <SysExcptionLog> >();

            try
            {
                result.result = SysExcptionLog.searchLog(condtion);
            }
            catch (Exception e) {
                result = SysException.getResult(result, e, condtion);
            }
            return(result);
        }
Exemplo n.º 31
0
 /// <summary>
 /// 创建一个异常处理
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个异常处理</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, SysException entity)
 {
     try
     {
         repository.Create(entity);
         return true;
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         //ExceptionsHander.WriteExceptions(ex);
     }
     return false;
 }
Exemplo n.º 32
0
 /// <summary>
 /// 编辑一个异常处理
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entity">一个异常处理</param>
 /// <returns></returns>
 public bool Edit(ref ValidationErrors validationErrors, SysException entity)
 {
     try
     {
         repository.Edit(db, entity);
         repository.Save(db);
         return true;
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return false;
 }