/// <summary>
 /// 登录后
 /// </summary>
 /// <param name="resultContext">结果上下文</param>
 public override void OnResultExecuted(ResultExecutedContext resultContext)
 {
     //异步处理
     Task.Factory.StartNew(() =>
     {
         try
         {
             JsonResult result = resultContext.Result as JsonResult;
             if (result != null && result.Value != null)
             {
                 PropertyInfo pSuccess  = result.Value.GetType().GetProperty("Success");
                 PropertyInfo pErrMsg   = result.Value.GetType().GetProperty("Message");
                 bool loginSuccess      = pSuccess.GetValue2(result.Value, null).ObjToBool();
                 loginLog.LoginStatus   = loginSuccess ? "登录成功" : "登录失败";
                 loginLog.FailureReason = pErrMsg.GetValue2(result.Value, null).ObjToStr();
             }
             else
             {
                 loginLog.LoginStatus   = "登录失败";
                 loginLog.FailureReason = "无返回结果";
             }
             string errMsg     = string.Empty;
             long loginNum     = CommonOperate.Count <Log_Login>(out errMsg, false, x => x.LoginName == loginLog.LoginName);
             loginLog.LoginNum = (int)loginNum + 1;
             loginLog.Id       = Guid.NewGuid();
             CommonOperate.OperateRecord <Log_Login>(loginLog, Operate.Base.OperateHandle.ModelRecordOperateType.Add, out errMsg, null, false);
         }
         catch { }
     });
 }
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <returns></returns>
        public JsonResult AddDept()
        {
            if (_Request == null)
            {
                _Request = Request;
            }
            string deptname = _Request.QueryEx("deptname").ObjToStr();

            if (string.IsNullOrWhiteSpace(deptname))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "部门名称不能为空"
                }));
            }
            string errMsg = string.Empty;
            long   num    = CommonOperate.Count <OrgM_Dept>(out errMsg, false, x => x.Name == deptname);

            if (num > 0)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "该部门已存在,请不要重复添加"
                }));
            }
            UserInfo  currUser = GetCurrentUser(_Request);
            Guid      moduleId = SystemOperate.GetModuleIdByTableName("OrgM_Dept");
            string    code     = SystemOperate.GetBillCode(moduleId);
            OrgM_Dept dept     = new OrgM_Dept()
            {
                Code           = code,
                Name           = deptname,
                Alias          = deptname,
                IsValid        = true,
                EffectiveDate  = DateTime.Now,
                CreateDate     = DateTime.Now,
                CreateUserId   = currUser.UserId,
                CreateUserName = currUser.EmpName,
                ModifyDate     = DateTime.Now,
                ModifyUserId   = currUser.UserId,
                ModifyUserName = currUser.EmpName
            };
            Guid deptId = CommonOperate.OperateRecord <OrgM_Dept>(dept, ModelRecordOperateType.Add, out errMsg, null, false);

            if (deptId != Guid.Empty)
            {
                SystemOperate.UpdateBillCode(moduleId, code);
                return(Json(new { Success = true, Message = string.Empty, DeptId = deptId, DeptName = deptname }));
            }
            else
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = errMsg
                }));
            }
        }
예제 #3
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <returns></returns>
        public ActionResult AddDept()
        {
            string deptname = Request["deptname"].ObjToStr();

            if (string.IsNullOrWhiteSpace(deptname))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "部门名称不能为空"
                }));
            }
            string errMsg = string.Empty;
            long   num    = CommonOperate.Count <OrgM_Dept>(out errMsg, false, x => x.Name == deptname);

            if (num > 0)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "该部门已存在,请不要重复添加"
                }));
            }
            UserInfo  currUser = GetCurrentUser(Request);
            OrgM_Dept dept     = new OrgM_Dept()
            {
                Name           = deptname,
                Alias          = deptname,
                IsValid        = true,
                EffectiveDate  = DateTime.Now,
                CreateDate     = DateTime.Now,
                CreateUserId   = currUser.UserId,
                CreateUserName = currUser.EmpName,
                ModifyDate     = DateTime.Now,
                ModifyUserId   = currUser.UserId,
                ModifyUserName = currUser.EmpName
            };
            Guid deptId = CommonOperate.OperateRecord <OrgM_Dept>(dept, ModelRecordOperateType.Add, out errMsg, null, false);

            if (deptId != Guid.Empty)
            {
                return(Json(new { Success = true, Message = string.Empty, DeptId = deptId, DeptName = deptname }));
            }
            else
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = errMsg
                }));
            }
        }
예제 #4
0
 /// <summary>
 /// 操作前验证
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="t"></param>
 /// <param name="errMsg"></param>
 /// <param name="otherParams"></param>
 /// <returns></returns>
 public bool BeforeOperateVerifyOrHandle(ModelRecordOperateType operateType, OrgM_EmpDeptDuty t, out string errMsg, object[] otherParams = null)
 {
     errMsg = string.Empty;
     if (operateType == ModelRecordOperateType.Add || operateType == ModelRecordOperateType.Edit)
     {
         if (t.IsMainDuty) //设置主职岗位
         {
             //判断该员工是否已经存主职岗位设置
             long num = operateType == ModelRecordOperateType.Add ? CommonOperate.Count <OrgM_EmpDeptDuty>(out errMsg, false, x => x.OrgM_EmpId == t.OrgM_EmpId && x.IsMainDuty == true) :
                        CommonOperate.Count <OrgM_EmpDeptDuty>(out errMsg, false, x => x.OrgM_EmpId == t.OrgM_EmpId && x.IsMainDuty == true && x.Id != t.Id);
             if (num > 0)
             {
                 errMsg = "当前员工已设置了主职岗位,请不要重复设置";
                 return(false);
             }
         }
         else
         {
             long num = operateType == ModelRecordOperateType.Add ? CommonOperate.Count <OrgM_EmpDeptDuty>(out errMsg, false, x => x.OrgM_EmpId == t.OrgM_EmpId && x.IsMainDuty == true) :
                        CommonOperate.Count <OrgM_EmpDeptDuty>(out errMsg, false, x => x.OrgM_EmpId == t.OrgM_EmpId && x.IsMainDuty == true && x.Id != t.Id);
             if (num == 0)
             {
                 errMsg = operateType == ModelRecordOperateType.Add ? "当前员工未设置主职岗位,请先设置主职岗位" : "当前更改导致主职岗位缺失,请重新设置";
                 return(false);
             }
         }
     }
     else if (operateType == ModelRecordOperateType.Del)
     {
         OrgM_EmpDeptDuty obj = CommonOperate.GetEntityById <OrgM_EmpDeptDuty>(t.Id, out errMsg);
         if (obj != null && obj.IsMainDuty && obj.OrgM_EmpId.HasValue && obj.OrgM_EmpId.Value != Guid.Empty) //当前删除的是主职岗位
         {
             //判断员工是否存在,员工存在需要先删除员工信息
             long num = CommonOperate.Count <OrgM_Emp>(out errMsg, false, x => x.Id == obj.OrgM_EmpId.Value);
             if (num > 0)
             {
                 errMsg = "删除员工主职岗位前请先删除员工信息";
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #5
0
 /// <summary>
 /// 模块集合操作完成前
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="ts"></param>
 /// <param name="errMsg"></param>
 /// <param name="otherParams"></param>
 /// <returns></returns>
 public bool BeforeOperateVerifyOrHandles(ModelRecordOperateType operateType, List <Sys_Module> ts, out string errMsg, object[] otherParams = null)
 {
     errMsg = string.Empty;
     if (operateType == ModelRecordOperateType.Del)
     {
         string otherErr = string.Empty;
         foreach (Sys_Module t in ts)
         {
             if (!t.IsCustomerModule) //系统模块
             {
                 //非自定义模块不允许删除
                 errMsg += errMsg == string.Empty ? string.Format("模块【{0}】", t.Name) : string.Format(",【{0}】", t.Name);
             }
             else //自定义模块,自定义模块如果有数据则不能删除
             {
                 long count = CommonOperate.Count(out errMsg, t.Id);
                 if (count > 0)
                 {
                     otherErr += otherErr == string.Empty ? string.Format("模块【{0}】有记录【{1}】条", t.Name, count) : string.Format(",【{0}】有记录【{1}】条", t.Name, count);
                 }
             }
         }
         if (errMsg != string.Empty)
         {
             errMsg += "为系统模块,不允许删除!";
         }
         if (otherErr != string.Empty)
         {
             otherErr += ",请清空各自定义模块的数据后再删除!";
         }
         errMsg = errMsg + otherErr;
         if (!string.IsNullOrEmpty(errMsg))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #6
0
 /// <summary>
 /// 模块操作前处理
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="t"></param>
 /// <param name="errMsg"></param>
 /// <param name="otherParams"></param>
 /// <returns></returns>
 public bool BeforeOperateVerifyOrHandle(ModelRecordOperateType operateType, Sys_Module t, out string errMsg, object[] otherParams = null)
 {
     errMsg = string.Empty;
     if (operateType == ModelRecordOperateType.Del)
     {
         //非自定义模块不允许删除
         if (!t.IsCustomerModule)
         {
             errMsg = string.Format("【{0}】为系统模块,不允许删除!", t.Name);
             return(false);
         }
         else //自定义模块如果有数据则不能删除
         {
             long count = CommonOperate.Count(out errMsg, t.Id); //模块中记录数
             if (count > 0)
             {
                 errMsg = string.Format("模块【{0}】中存在【{0}】条记录,请先清空模块数据后再删除!", t.Name, count);
                 return(false);
             }
         }
     }
     return(true);
 }
        /// <summary>
        /// 添加职务
        /// </summary>
        /// <returns></returns>
        public JsonResult AddDuty()
        {
            if (_Request == null)
            {
                _Request = Request;
            }
            Guid deptId = _Request.QueryEx("deptId").ObjToGuid();

            if (deptId == Guid.Empty)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "请先选择部门"
                }));
            }
            OrgM_Dept dept = OrgMOperate.GetDeptById(deptId);

            if (dept == null)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "选择的部门不存在"
                }));
            }
            string dutyname = _Request.QueryEx("dutyname").ObjToStr();

            if (string.IsNullOrWhiteSpace(dutyname))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "职务名称不能为空"
                }));
            }
            string errMsg = string.Empty;
            long   num    = CommonOperate.Count <OrgM_Dept>(out errMsg, false, x => x.Name == dutyname);

            if (num > 0)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "该职务已存在,请不要重复添加"
                }));
            }
            UserInfo  currUser = GetCurrentUser(_Request);
            Guid      moduleId = SystemOperate.GetModuleIdByTableName("OrgM_Duty");
            string    code     = SystemOperate.GetBillCode(moduleId);
            OrgM_Duty duty     = new OrgM_Duty()
            {
                Code           = code,
                Name           = dutyname,
                IsValid        = true,
                EffectiveDate  = DateTime.Now,
                CreateDate     = DateTime.Now,
                CreateUserId   = currUser.UserId,
                CreateUserName = currUser.EmpName,
                ModifyDate     = DateTime.Now,
                ModifyUserId   = currUser.UserId,
                ModifyUserName = currUser.EmpName
            };
            Guid dutyId = CommonOperate.OperateRecord <OrgM_Duty>(duty, ModelRecordOperateType.Add, out errMsg, null, false);

            if (dutyId != Guid.Empty)
            {
                SystemOperate.UpdateBillCode(moduleId, code);
                Guid?parentId = null;
                List <OrgM_DeptDuty> positions = OrgMOperate.GetDeptPositions(deptId);
                if (positions.Count > 0)
                {
                    OrgM_DeptDuty leaderPosition = positions.Where(x => x.IsDeptCharge).FirstOrDefault();
                    if (leaderPosition != null)
                    {
                        parentId = leaderPosition.Id;
                    }
                }
                Guid          gwModuleId   = SystemOperate.GetModuleIdByTableName("OrgM_DeptDuty");
                string        positionCode = SystemOperate.GetBillCode(gwModuleId);
                OrgM_DeptDuty position     = new OrgM_DeptDuty()
                {
                    Code        = positionCode,
                    Name        = string.Format("{0}-{1}", string.IsNullOrEmpty(dept.Alias) ? dept.Name : dept.Alias, dutyname),
                    OrgM_DeptId = deptId,
                    OrgM_DutyId = dutyId,
                    ParentId    = parentId,
                    IsValid     = true
                };
                Guid positionId = CommonOperate.OperateRecord <OrgM_DeptDuty>(position, ModelRecordOperateType.Add, out errMsg, null, false);
                if (positionId != Guid.Empty)
                {
                    SystemOperate.UpdateBillCode(gwModuleId, positionCode);
                }
                return(Json(new { Success = true, Message = string.Empty, DutyId = dutyId }));
            }
            else
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = errMsg
                }));
            }
        }