Esempio n. 1
0
        /// <summary>
        /// 处理巡检异常
        /// </summary>
        /// <param name="result">巡检结果</param>
        /// <param name="ExceptionDispose">处理记录实体对象</param>
        public void DisposeException(T_InspectionResult result, T_InspectionExceptionDispose ExceptionDispose)
        {
            //使用事务进行数据库操作
            using (var tran = this.nContext.Database.BeginTransaction())
            {
                try
                {
                    //更新巡检结果
                    base.Update(result);

                    //添加巡检异常处理记录
                    IInspectionExceptionDisposeBLL exceptionBll = BLLFactory <IInspectionExceptionDisposeBLL> .GetBLL("InspectionExceptionDisposeBLL");

                    var eDispose = exceptionBll.GetEntity(dq => dq.ExceptionResultId == result.Id);
                    if (eDispose == null)
                    {
                        exceptionBll.Save(ExceptionDispose);
                    }
                    else
                    {
                        eDispose.DisposeDesc = ExceptionDispose.DisposeDesc;
                        eDispose.DisposeTime = DateTime.Now;
                        exceptionBll.Update(eDispose);
                    }
                    exceptionBll.Save(ExceptionDispose);
                    //提交事务
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                }
            }
        }
        public ApiResultModel DisposeException(DisposerModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //获取要处理的巡检异常
                    IInspectionResultBLL resultBll = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL");

                    T_InspectionResult result = resultBll.GetEntity(m => m.Id == model.Id);
                    if (result != null)
                    {
                        //修改处理状态并添加处理记录
                        result.DisposeStatus = ConstantParam.DISPOSED;
                        T_InspectionExceptionDispose exceptionDispose = new T_InspectionExceptionDispose()
                        {
                            DisposeDesc       = model.DisposeDesc,
                            DisposeUserId     = user.Id,
                            ExceptionResultId = model.Id,
                            DisposeTime       = DateTime.Now
                        };
                        //保存到数据库
                        resultBll.DisposeException(result, exceptionDispose);
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.EXCEPTION_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Esempio n. 3
0
 /// <summary>
 /// 处理巡检异常
 /// </summary>
 /// <param name="result">巡检结果</param>
 /// <param name="ExceptionDispose">处理记录实体对象</param>
 public void DisposeException(T_InspectionResult result, T_InspectionExceptionDispose ExceptionDispose)
 {
     this._Dal.DisposeException(result, ExceptionDispose);
 }