1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#region
 
using System;
using System.Collections.Generic;
using System.Data;
using CSFrameworkV5.Core;
using CSFrameworkV5.Interfaces;
using CSFrameworkV5.Models;
 
///*************************************************************************/
///*
///* 文件名    :bllUser.cs        
///
///* 程序说明  : 用户管理的业务逻辑层
///               
///* 原创作者  :www.csframework.com 
///* Copyright 2006-2021 wwww.csframework.com, 保留所有权利.
///*
///**************************************************************************/
 
#endregion
 
namespace CSFrameworkV5.Business.BLL_Permission
{
    /// <summary>
    ///     用户管理的业务逻辑层
    /// </summary>
    public class bllUser : bllBaseDataDict
    {
        private IBridge_User _Current;
 
        public bllUser()
        {
            _KeyFieldName = tb_MyUser.__KeyName; //主键字段
            _SummaryTableName = tb_MyUser.__TableName; //表名
            _DataDictBridge =
                BridgeFactory.CreateDataDictBridge(typeof(tb_MyUser));
            _Current = BridgeFactory.CreateUserBridge();
        }
 
        public override bool CheckNoExists(string account)
        {
            return _Current.ExistsUser(account);
        }
 
        public bool CopyPermission(string sourceUser, string targetUser)
        {
            return _Current.CopyPermission(sourceUser, targetUser);
        }
 
        public override bool Delete(string account)
        {
            return _Current.DeleteUser(account);
        }
 
        public bool DeleteUserGroup(string account, string groupCode)
        {
            return _Current.DeleteUserGroup(account, groupCode);
        }
 
        public bool DeleteUserRole(string account, string roleID)
        {
            return _Current.DeleteUserRole(account, roleID);
        }
 
        public bool DestroyRights(string account)
        {
            return _Current.DestroyRights(account);
        }
 
        /// <summary>
        ///     获取指定用户数据
        /// </summary>
        /// <param name="account">用户帐号</param>
        /// <returns></returns>
        public DataTable GetUser(string account)
        {
            return _Current.GetUser(account);
        }
 
        public DataTable GetUserGroups(string user)
        {
            return _Current.GetUserGroups(user);
        }
 
        public DataSet GetUserReportData(DateTime createDateFrom,
            DateTime createDateTo)
        {
            return _Current.GetUserReportData(createDateFrom, createDateTo);
        }
 
        public DataTable GetUserRoles(string currentUser)
        {
            return _Current.GetUserRoles(currentUser);
        }
 
        public DataTable GetUserRoles4Picker(string currentUser, string content)
        {
            return _Current.GetUserRoles4Picker(currentUser, content);
        }
 
        public DataTable GetUserRolesAll(string user)
        {
            return _Current.GetUserRolesAll(user);
        }
 
        /// <summary>
        ///     获取所有用户数据
        /// </summary>
        /// <returns></returns>
        public DataTable GetUsers()
        {
            _SummaryTable = _Current.GetUsers();
            SetDefault(_SummaryTable);
            return _SummaryTable;
        }
 
        /// <summary>
        ///     修改用户密码
        /// </summary>
        /// <param name="account">用户帐号</param>
        /// <param name="pwd">新密码</param>
        /// <returns></returns>
        public bool ModifyPassword(string account, string OldPwd, string NewPwd)
        {
            return _Current.ModifyPassword(account, OldPwd, NewPwd);
        }
 
        public bool insrer(string account, string OldPwd, string NewPwd)
        {
            return _Current.insrer(account, OldPwd, NewPwd);
        }
 
 
        public DataTable Search(string content)
        {
            return _Current.Search(content);
        }
 
        public List<AccountModel> SearchEx(string content, string ignoreGroup)
        {
            return _Current.SearchEx(content, ignoreGroup);
        }
 
        protected override void SetDefault(DataTable data)
        {
            data.Columns[tb_MyUser.IsLocked].DefaultValue = 0;
        }
 
        public bool SetLockState(string account, bool isLock)
        {
            return _Current.SetLockState(account, isLock);
        }
 
        public bool TryLogin(string user, string encodedPwd)
        {
            return _Current.TryLogin(user, encodedPwd);
        }
 
        public static void Validate(LoginUser user)
        {
            var wcf = BridgeFactory.CreateUserBridge();
            if (wcf.ExistsUser(user.Account)) throw new Exception("用户已经存在!");
        }
 
        public static void ValidateLogin(string userID, string password)
        {
            if (userID.Trim() == "") throw new Exception("用户编号不正确或不能为空!");
 
            if (password.Trim() == "") throw new Exception("密码不正确或不能为空!");
        }
    }
}