コード例 #1
0
        public CPWebApiBaseReturnEntity UpdateUserPwd(string OldPwd, string NewPwd)
        {
            base.SetHeader();
            CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity();

            try
            {
                string   userId = CPExpressionHelper.Instance.RunCompile("${CPUser.UserId()}");
                COOrgans organs = COOrgans.Instance();
                COUser   user   = organs.GetUserById(int.Parse(userId), false, false);
                OldPwd = organs.UserPwdEncrypt(OldPwd);
                if (user.UserPwd.Equals(OldPwd, StringComparison.CurrentCultureIgnoreCase) == false)
                {
                    re.Result   = false;
                    re.ErrorMsg = "原密码输入不对,请重新输入!";
                    return(re);
                }
                user.UserPwd = organs.UserPwdEncrypt(NewPwd);
                re.Result    = organs.UpdateUser(user);
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
コード例 #2
0
        public GetUserInfoReturn GetUserInfo([FromBody] GetUserInfoInput input)
        {
            base.SetHeader();
            GetUserInfoReturn re = new GetUserInfoReturn();

            if (this.CheckUserIden(input.CurUserId, input.CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                re.UserCol = COOrgans.Instance().GetUserByUserIds(input.UserIds);
                re.UserCol = re.UserCol.OrderBy(t => t.UserName).ToList();
                re.Result  = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
コード例 #3
0
        public LoginReturn Login(string LoginName, string UserPwd, int DeviceType)
        {
            base.SetHeader();
            LoginReturn re = new LoginReturn();

            re.Result = true;
            try
            {
                string         errorMsg = "";
                COUserIdentity iden     = COOrgans.Instance().Login(LoginName, UserPwd, CPEnum.ConvertDeviceTypeEnum(DeviceType), ref errorMsg);
                if (string.IsNullOrEmpty(errorMsg) == false)
                {
                    re.Result   = false;
                    re.ErrorMsg = errorMsg;
                    return(re);
                }
                re.UserId  = iden.UserId;
                re.UserKey = iden.UserKey;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
コード例 #4
0
        public GetUserByUserNameOrLoginNameReturn GetUserByUserNameOrLoginName(string NameEx, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            NameEx      = CPAppContext.FormatSqlPara(NameEx);
            GetUserByUserNameOrLoginNameReturn re = new GetUserByUserNameOrLoginNameReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                re.UserCol = COOrgans.Instance().GetUserByUserNameOrLoginName(NameEx);
                re.UserCol = re.UserCol.OrderBy(t => t.UserName).ToList();
                re.Result  = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
コード例 #5
0
        public void AfterSave(ICPFormAfterSaveEventArgs e)
        {
            string   UserPwd = e.GetFieldValue("CP_User", "UserPwd", 0);
            COOrgans organs  = COOrgans.Instance();

            UserPwd = organs.UserPwdEncrypt(UserPwd);
            COUser user = organs.GetUserById(int.Parse(e.PKValue), false, false);

            user.UserPwd = UserPwd;
            organs.UpdateUser(user);
        }
コード例 #6
0
        public void AfterSave(ICPFormAfterSaveEventArgs e)
        {
            string                  RoleId      = e.GetFieldValue("CP_Role", "RoleId", 0);
            string                  RoleUserIds = e.GetFieldValue("CP_Role", "RoleUserIds", 0);
            List <string>           col         = RoleUserIds.Split(',').ToList();
            List <CORoleUserRelate> relateCol   = new List <CORoleUserRelate>();

            col.ForEach(t => {
                relateCol.Add(new CORoleUserRelate()
                {
                    RoleId = int.Parse(RoleId), UserId = int.Parse(t)
                });
            });
            COOrgans.Instance().InitRoleUsers(int.Parse(RoleId), relateCol);
        }
コード例 #7
0
        public GetUserByMyDepReturn GetUserByMyDep(int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            GetUserByMyDepReturn re = new GetUserByMyDepReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                string depIds = CPExpressionHelper.Instance.RunCompile("${CPUser.DepIds()}");
                re.UserCol = new List <COUser>();
                depIds.Split(',').ToList().ForEach(t =>
                {
                    if (string.IsNullOrEmpty(t) == false)
                    {
                        List <COUser> col = COOrgans.Instance().GetUserByDepId(int.Parse(t));
                        col.ForEach(u =>
                        {
                            if (re.UserCol.Where(f => f.Id.Equals(u.Id)).Count() <= 0)
                            {
                                re.UserCol.Add(u);
                            }
                        });
                    }
                });

                re.UserCol = re.UserCol.OrderBy(t => t.UserName).ToList();
                re.Result  = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
コード例 #8
0
        public GetAllDepReturn GetAllDep(int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            GetAllDepReturn re = new GetAllDepReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                List <CODep> allDep = COOrgans.Instance().GetAllDep();
                re.DepCol = new List <CODepOrganSel>();
                allDep.Where(t => t.ParentId.Value.Equals(-1)).ToList().ForEach(t =>
                {
                    CODepOrganSel item = new CODepOrganSel();
                    item.Id            = t.Id;
                    item.DepName       = t.DepName;
                    item.ChildDep      = this.GetChildDep(allDep, t.Id);
                    if (item.ChildDep.Count > 0)
                    {
                        item.HasChildDep = true;
                    }
                    else
                    {
                        item.HasChildDep = false;
                    }
                    re.DepCol.Add(item);
                });
                re.Result = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
コード例 #9
0
        public void AfterSave(ICPFormAfterSaveEventArgs e)
        {
            string DepId            = e.GetFieldValue("CP_Dep", "DepId", 0);
            string UserIds          = e.GetFieldValue("CP_Dep", "UserIds", 0);
            string DepMainLeaderId  = e.GetFieldValue("CP_Dep", "DepMainLeaderId", 0);
            string DepViceLeaderIds = e.GetFieldValue("CP_Dep", "DepViceLeaderIds", 0);
            string DepSupervisorId  = e.GetFieldValue("CP_Dep", "DepSupervisorId", 0);

            UserIds += "," + DepMainLeaderId + "," + DepViceLeaderIds + "," + DepSupervisorId;
            List <string>          col          = UserIds.Split(',').ToList();
            List <CODepUserRelate> relateCol    = new List <CODepUserRelate>();
            List <CODepUserRelate> oldRelateCol = COOrgans.Instance().GetDepUserRelate(int.Parse(DepId));
            int showOrder = 10;

            if (oldRelateCol.Count > 0)
            {
                oldRelateCol = oldRelateCol.OrderByDescending(t => t.ShowOrder).ToList();
                showOrder    = oldRelateCol[0].ShowOrder + 10;
            }
            col.ForEach(t => {
                if (string.IsNullOrEmpty(t) == false)
                {
                    List <CODepUserRelate> tmpCol = oldRelateCol.Where(c => c.UserId.Equals(int.Parse(t))).ToList();
                    if (tmpCol.Count > 0)
                    {
                        relateCol.Add(new CODepUserRelate()
                        {
                            DepId = int.Parse(DepId), UserId = int.Parse(t), ShowOrder = tmpCol[0].ShowOrder
                        });
                    }
                    else
                    {
                        relateCol.Add(new CODepUserRelate()
                        {
                            DepId = int.Parse(DepId), UserId = int.Parse(t), ShowOrder = showOrder
                        });
                    }
                }
            });
            COOrgans.Instance().InitDepUsers(int.Parse(DepId), relateCol);
        }
コード例 #10
0
        public CPWebApiBaseReturnEntity SetDepDeleteState(int DepId, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                re.Result = COOrgans.Instance().SetDepDeleteState(DepId);
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }