protected override void OnException(ExceptionContext filterContext)
        {
            var err = DataCache.Get <string>("err");

            if (err != filterContext.Exception.Message)//不重复添加异常信息
            {
                Sys.LogEngine log = new Sys.LogEngine();
                log.WriteError(filterContext.Exception);
                DataCache.Set("err", filterContext.Exception.Message, 1);
            }
        }
Exemple #2
0
        /// <summary>
        /// 对象
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isRead">为true改变状态</param>
        /// <returns></returns>
        public static SysMailSender GetObj(string id, bool isRead)
        {
            SysMailSender obj = new SysMailSender();
            OpResult      re  = new OpResult();

            if (isRead)
            {
                var objRece = BaseService <SysMailReceive> .CurrentRepository.QueryEntity.Include(o => o.Attachments).SingleOrDefault(o => o.Id == id);

                if (objRece != null)
                {
                    if (objRece.State == 0)
                    {
                        objRece.State    = 1;
                        objRece.ReadDate = DateTime.Now;
                        re = BaseService <SysMailReceive> .Update(objRece);

                        #region 写入日志
                        Sys.LogEngine log    = new Sys.LogEngine();
                        string        msg    = "成功修改邮件状态!";
                        var           module = Pharos.Sys.LogModule.邮件管理;
                        if (re.Successed)
                        {
                            msg += "<br />Id=" + objRece.Id + ",<br />状态=已读" + "。";
                            log.WriteUpdate(msg, module);
                        }
                        else
                        {
                            msg = "修改邮件状态失败!";
                            log.WriteUpdate(msg, module);
                        }
                        #endregion
                    }
                    objRece.ToCopyProperty(obj);
                    obj.SenderCode  = objRece.SenderCode;
                    obj.SenderName  = objRece.SenderName;
                    obj.Attachments = objRece.Attachments;
                }
            }
            else
            {
                obj = CurrentRepository.QueryEntity.Include(o => o.Attachments).SingleOrDefault(o => o.Id == id);
            }
            return(obj);
        }
        public ActionResult SetState(string[] ids)
        {
            var receives = BaseService <SysMailReceive> .FindList(o => ids.Contains(o.Id) && o.ReceiveCode == Sys.CurrentUser.UserName && o.State == 0);

            foreach (var rece in receives)
            {
                rece.State    = 1;
                rece.ReadDate = DateTime.Now;
            }
            var op = new OpResult();

            if (receives.Any())
            {
                op = BaseService <SysMailReceive> .Update(receives);

                #region 写入日志
                Sys.LogEngine log    = new Sys.LogEngine();
                string        msg    = "成功修改邮件状态!";
                var           module = Pharos.Sys.LogModule.邮件管理;
                if (op.Successed)
                {
                    for (int i = 0; i < receives.Count(); i++)
                    {
                        msg += "<br />Id=" + receives[i].Id + ",<br />状态=已读" + "。";
                        log.WriteUpdate(msg, module);
                        msg = "成功修改邮件状态!";
                    }
                }
                else
                {
                    msg = "修改邮件状态失败!";
                    log.WriteUpdate(msg, module);
                }
                #endregion
            }
            else
            {
                op.Message = "无需要更新的记录";
            }
            return(new JsonNetResult(op));
        }