Просмотр исходного кода

话务人员数量限制授权(目前设置数为100)

lihai лет назад: 8
Родитель
Сommit
ec9737f41e

+ 1 - 0
CallCenterApi/CallCenterApi.BLL/CallCenterApi.BLL.csproj

@@ -89,6 +89,7 @@
89 89
     <Compile Include="T_Sys_RoleFunction.cs" />
90 90
     <Compile Include="T_Sys_RoleInfo.cs" />
91 91
     <Compile Include="T_Sys_SeatGroup.cs" />
92
+    <Compile Include="T_Sys_SeatPermissionConfig.cs" />
92 93
     <Compile Include="T_Sys_SystemConfig.cs" />
93 94
     <Compile Include="T_Sys_TelTitleData.cs" />
94 95
     <Compile Include="T_Sys_UserAccount.cs" />

+ 170 - 0
CallCenterApi/CallCenterApi.BLL/T_Sys_SeatPermissionConfig.cs

@@ -0,0 +1,170 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Data;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace CallCenterApi.BLL
9
+{
10
+    public partial class T_Sys_SeatPermissionConfig
11
+    {
12
+        private readonly DAL.T_Sys_SeatPermissionConfig dal = new DAL.T_Sys_SeatPermissionConfig();
13
+        public T_Sys_SeatPermissionConfig()
14
+        { }
15
+        #region  BasicMethod
16
+
17
+        /// <summary>
18
+        /// 得到最大ID
19
+        /// </summary>
20
+        public int GetMaxId()
21
+        {
22
+            return dal.GetMaxId();
23
+        }
24
+
25
+        /// <summary>
26
+        /// 是否存在该记录
27
+        /// </summary>
28
+        public bool Exists(int F_Id)
29
+        {
30
+            return dal.Exists(F_Id);
31
+        }
32
+
33
+        /// <summary>
34
+        /// 是否存在该记录
35
+        /// </summary>
36
+        public bool Exists()
37
+        {
38
+            return dal.Exists();
39
+        }
40
+
41
+        /// <summary>
42
+        /// 增加一条数据
43
+        /// </summary>
44
+        public int Add(Model.T_Sys_SeatPermissionConfig model)
45
+        {
46
+            return dal.Add(model);
47
+        }
48
+
49
+        /// <summary>
50
+        /// 更新一条数据
51
+        /// </summary>
52
+        public bool Update(Model.T_Sys_SeatPermissionConfig model)
53
+        {
54
+            return dal.Update(model);
55
+        }
56
+
57
+        /// <summary>
58
+        /// 删除一条数据
59
+        /// </summary>
60
+        public bool Delete(int F_Id)
61
+        {
62
+
63
+            return dal.Delete(F_Id);
64
+        }
65
+        /// <summary>
66
+        /// 删除一条数据
67
+        /// </summary>
68
+        public bool DeleteList(string F_Idlist)
69
+        {
70
+            return dal.DeleteList(F_Idlist);
71
+        }
72
+
73
+        /// <summary>
74
+        /// 得到一个对象实体
75
+        /// </summary>
76
+        public Model.T_Sys_SeatPermissionConfig GetModel(int F_Id)
77
+        {
78
+
79
+            return dal.GetModel(F_Id);
80
+        }
81
+
82
+        /// <summary>
83
+        /// 得到一个对象实体
84
+        /// </summary>
85
+        public Model.T_Sys_SeatPermissionConfig GetModel()
86
+        {
87
+
88
+            return dal.GetModel();
89
+        }
90
+
91
+        /// <summary>
92
+        /// 获得数据列表
93
+        /// </summary>
94
+        public DataSet GetList(string strWhere)
95
+        {
96
+            return dal.GetList(strWhere);
97
+        }
98
+        /// <summary>
99
+        /// 获得前几行数据
100
+        /// </summary>
101
+        public DataSet GetList(int Top, string strWhere, string filedOrder)
102
+        {
103
+            return dal.GetList(Top, strWhere, filedOrder);
104
+        }
105
+        /// <summary>
106
+        /// 获得数据列表
107
+        /// </summary>
108
+        public List<Model.T_Sys_SeatPermissionConfig> GetModelList(string strWhere)
109
+        {
110
+            DataSet ds = dal.GetList(strWhere);
111
+            return DataTableToList(ds.Tables[0]);
112
+        }
113
+        /// <summary>
114
+        /// 获得数据列表
115
+        /// </summary>
116
+        public List<Model.T_Sys_SeatPermissionConfig> DataTableToList(DataTable dt)
117
+        {
118
+            List<Model.T_Sys_SeatPermissionConfig> modelList = new List<Model.T_Sys_SeatPermissionConfig>();
119
+            int rowsCount = dt.Rows.Count;
120
+            if (rowsCount > 0)
121
+            {
122
+                Model.T_Sys_SeatPermissionConfig model;
123
+                for (int n = 0; n < rowsCount; n++)
124
+                {
125
+                    model = dal.DataRowToModel(dt.Rows[n]);
126
+                    if (model != null)
127
+                    {
128
+                        modelList.Add(model);
129
+                    }
130
+                }
131
+            }
132
+            return modelList;
133
+        }
134
+
135
+        /// <summary>
136
+        /// 获得数据列表
137
+        /// </summary>
138
+        public DataSet GetAllList()
139
+        {
140
+            return GetList("");
141
+        }
142
+
143
+        /// <summary>
144
+        /// 分页获取数据列表
145
+        /// </summary>
146
+        public int GetRecordCount(string strWhere)
147
+        {
148
+            return dal.GetRecordCount(strWhere);
149
+        }
150
+        /// <summary>
151
+        /// 分页获取数据列表
152
+        /// </summary>
153
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
154
+        {
155
+            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
156
+        }
157
+        /// <summary>
158
+        /// 分页获取数据列表
159
+        /// </summary>
160
+        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
161
+        //{
162
+        //return dal.GetList(PageSize,PageIndex,strWhere);
163
+        //}
164
+
165
+        #endregion  BasicMethod
166
+        #region  ExtensionMethod
167
+
168
+        #endregion  ExtensionMethod
169
+    }
170
+}

+ 1 - 0
CallCenterApi/CallCenterApi.DAL/CallCenterApi.DAL.csproj

@@ -90,6 +90,7 @@
90 90
     <Compile Include="T_Sys_RoleFunction.cs" />
91 91
     <Compile Include="T_Sys_RoleInfo.cs" />
92 92
     <Compile Include="T_Sys_SeatGroup.cs" />
93
+    <Compile Include="T_Sys_SeatPermissionConfig.cs" />
93 94
     <Compile Include="T_Sys_SystemConfig.cs" />
94 95
     <Compile Include="T_Sys_TelTitleData.cs" />
95 96
     <Compile Include="T_Sys_UserAccount.cs" />

+ 356 - 0
CallCenterApi/CallCenterApi.DAL/T_Sys_SeatPermissionConfig.cs

@@ -0,0 +1,356 @@
1
+using CallCenterApi.DB;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Data;
5
+using System.Data.SqlClient;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+
10
+namespace CallCenterApi.DAL
11
+{
12
+    public partial class T_Sys_SeatPermissionConfig
13
+    {
14
+        public T_Sys_SeatPermissionConfig()
15
+        { }
16
+        #region  BasicMethod
17
+
18
+        /// <summary>
19
+        /// 得到最大ID
20
+        /// </summary>
21
+        public int GetMaxId()
22
+        {
23
+            return DbHelperSQL.GetMaxID("F_Id", "T_Sys_SeatPermissionConfig");
24
+        }
25
+
26
+        /// <summary>
27
+        /// 是否存在该记录
28
+        /// </summary>
29
+        public bool Exists(int F_Id)
30
+        {
31
+            StringBuilder strSql = new StringBuilder();
32
+            strSql.Append("select count(1) from T_Sys_SeatPermissionConfig");
33
+            strSql.Append(" where F_Id=@F_Id");
34
+            SqlParameter[] parameters = {
35
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)
36
+            };
37
+            parameters[0].Value = F_Id;
38
+
39
+            return DbHelperSQL.Exists(strSql.ToString(), parameters);
40
+        }
41
+
42
+
43
+        /// <summary>
44
+        /// 是否存在该记录
45
+        /// </summary>
46
+        public bool Exists()
47
+        {
48
+            StringBuilder strSql = new StringBuilder();
49
+            strSql.Append("select count(1) from T_Sys_SeatPermissionConfig");
50
+            return DbHelperSQL.Exists(strSql.ToString(), null);
51
+        }
52
+
53
+
54
+        /// <summary>
55
+        /// 增加一条数据
56
+        /// </summary>
57
+        public int Add(Model.T_Sys_SeatPermissionConfig model)
58
+        {
59
+            StringBuilder strSql = new StringBuilder();
60
+            strSql.Append("insert into T_Sys_SeatPermissionConfig(");
61
+            strSql.Append("F_MaxSeat,F_PassHash,F_SaltValue,F_SecurityKey)");
62
+            strSql.Append(" values (");
63
+            strSql.Append("@F_MaxSeat,@F_PassHash,@F_SaltValue,@F_SecurityKey)");
64
+            strSql.Append(";select @@IDENTITY");
65
+            SqlParameter[] parameters = {
66
+                    new SqlParameter("@F_MaxSeat", SqlDbType.Int,4),
67
+                    new SqlParameter("@F_PassHash", SqlDbType.NVarChar,500),
68
+                    new SqlParameter("@F_SaltValue", SqlDbType.NVarChar,500),
69
+                    new SqlParameter("@F_SecurityKey", SqlDbType.NVarChar,500)};
70
+            parameters[0].Value = model.F_MaxSeat;
71
+            parameters[1].Value = model.F_PassHash;
72
+            parameters[2].Value = model.F_SaltValue;
73
+            parameters[3].Value = model.F_SecurityKey;
74
+
75
+            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
76
+            if (obj == null)
77
+            {
78
+                return 0;
79
+            }
80
+            else
81
+            {
82
+                return Convert.ToInt32(obj);
83
+            }
84
+        }
85
+        /// <summary>
86
+        /// 更新一条数据
87
+        /// </summary>
88
+        public bool Update(Model.T_Sys_SeatPermissionConfig model)
89
+        {
90
+            StringBuilder strSql = new StringBuilder();
91
+            strSql.Append("update T_Sys_SeatPermissionConfig set ");
92
+            strSql.Append("F_MaxSeat=@F_MaxSeat,");
93
+            strSql.Append("F_PassHash=@F_PassHash,");
94
+            strSql.Append("F_SaltValue=@F_SaltValue,");
95
+            strSql.Append("F_SecurityKey=@F_SecurityKey");
96
+            strSql.Append(" where F_Id=@F_Id");
97
+            SqlParameter[] parameters = {
98
+                    new SqlParameter("@F_MaxSeat", SqlDbType.Int,4),
99
+                    new SqlParameter("@F_PassHash", SqlDbType.NVarChar,500),
100
+                    new SqlParameter("@F_SaltValue", SqlDbType.NVarChar,500),
101
+                    new SqlParameter("@F_SecurityKey", SqlDbType.NVarChar,500),
102
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)};
103
+            parameters[0].Value = model.F_MaxSeat;
104
+            parameters[1].Value = model.F_PassHash;
105
+            parameters[2].Value = model.F_SaltValue;
106
+            parameters[3].Value = model.F_SecurityKey;
107
+            parameters[4].Value = model.F_Id;
108
+
109
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
110
+            if (rows > 0)
111
+            {
112
+                return true;
113
+            }
114
+            else
115
+            {
116
+                return false;
117
+            }
118
+        }
119
+
120
+        /// <summary>
121
+        /// 删除一条数据
122
+        /// </summary>
123
+        public bool Delete(int F_Id)
124
+        {
125
+
126
+            StringBuilder strSql = new StringBuilder();
127
+            strSql.Append("delete from T_Sys_SeatPermissionConfig ");
128
+            strSql.Append(" where F_Id=@F_Id");
129
+            SqlParameter[] parameters = {
130
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)
131
+            };
132
+            parameters[0].Value = F_Id;
133
+
134
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
135
+            if (rows > 0)
136
+            {
137
+                return true;
138
+            }
139
+            else
140
+            {
141
+                return false;
142
+            }
143
+        }
144
+        /// <summary>
145
+        /// 批量删除数据
146
+        /// </summary>
147
+        public bool DeleteList(string F_Idlist)
148
+        {
149
+            StringBuilder strSql = new StringBuilder();
150
+            strSql.Append("delete from T_Sys_SeatPermissionConfig ");
151
+            strSql.Append(" where F_Id in (" + F_Idlist + ")  ");
152
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
153
+            if (rows > 0)
154
+            {
155
+                return true;
156
+            }
157
+            else
158
+            {
159
+                return false;
160
+            }
161
+        }
162
+
163
+
164
+        /// <summary>
165
+        /// 得到一个对象实体
166
+        /// </summary>
167
+        public Model.T_Sys_SeatPermissionConfig GetModel(int F_Id)
168
+        {
169
+
170
+            StringBuilder strSql = new StringBuilder();
171
+            strSql.Append("select  top 1 F_Id,F_MaxSeat,F_PassHash,F_SaltValue,F_SecurityKey from T_Sys_SeatPermissionConfig ");
172
+            strSql.Append(" where F_Id=@F_Id");
173
+            SqlParameter[] parameters = {
174
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)
175
+            };
176
+            parameters[0].Value = F_Id;
177
+
178
+            Model.T_Sys_SeatPermissionConfig model = new Model.T_Sys_SeatPermissionConfig();
179
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
180
+            if (ds.Tables[0].Rows.Count > 0)
181
+            {
182
+                return DataRowToModel(ds.Tables[0].Rows[0]);
183
+            }
184
+            else
185
+            {
186
+                return null;
187
+            }
188
+        }
189
+
190
+        /// <summary>
191
+        /// 得到一个对象实体
192
+        /// </summary>
193
+        public Model.T_Sys_SeatPermissionConfig GetModel()
194
+        {
195
+
196
+            StringBuilder strSql = new StringBuilder();
197
+            strSql.Append("select  top 1 F_Id,F_MaxSeat,F_PassHash,F_SaltValue,F_SecurityKey from T_Sys_SeatPermissionConfig ");
198
+            Model.T_Sys_SeatPermissionConfig model = new Model.T_Sys_SeatPermissionConfig();
199
+            DataSet ds = DbHelperSQL.Query(strSql.ToString());
200
+            if (ds.Tables[0].Rows.Count > 0)
201
+            {
202
+                return DataRowToModel(ds.Tables[0].Rows[0]);
203
+            }
204
+            else
205
+            {
206
+                return null;
207
+            }
208
+        }
209
+
210
+
211
+        /// <summary>
212
+        /// 得到一个对象实体
213
+        /// </summary>
214
+        public Model.T_Sys_SeatPermissionConfig DataRowToModel(DataRow row)
215
+        {
216
+            Model.T_Sys_SeatPermissionConfig model = new Model.T_Sys_SeatPermissionConfig();
217
+            if (row != null)
218
+            {
219
+                if (row["F_Id"] != null && row["F_Id"].ToString() != "")
220
+                {
221
+                    model.F_Id = int.Parse(row["F_Id"].ToString());
222
+                }
223
+                if (row["F_MaxSeat"] != null && row["F_MaxSeat"].ToString() != "")
224
+                {
225
+                    model.F_MaxSeat = int.Parse(row["F_MaxSeat"].ToString());
226
+                }
227
+                if (row["F_PassHash"] != null)
228
+                {
229
+                    model.F_PassHash = row["F_PassHash"].ToString();
230
+                }
231
+                if (row["F_SaltValue"] != null)
232
+                {
233
+                    model.F_SaltValue = row["F_SaltValue"].ToString();
234
+                }
235
+                if (row["F_SecurityKey"] != null)
236
+                {
237
+                    model.F_SecurityKey = row["F_SecurityKey"].ToString();
238
+                }
239
+            }
240
+            return model;
241
+        }
242
+
243
+        /// <summary>
244
+        /// 获得数据列表
245
+        /// </summary>
246
+        public DataSet GetList(string strWhere)
247
+        {
248
+            StringBuilder strSql = new StringBuilder();
249
+            strSql.Append("select F_Id,F_MaxSeat,F_PassHash,F_SaltValue,F_SecurityKey ");
250
+            strSql.Append(" FROM T_Sys_SeatPermissionConfig ");
251
+            if (strWhere.Trim() != "")
252
+            {
253
+                strSql.Append(" where " + strWhere);
254
+            }
255
+            return DbHelperSQL.Query(strSql.ToString());
256
+        }
257
+
258
+        /// <summary>
259
+        /// 获得前几行数据
260
+        /// </summary>
261
+        public DataSet GetList(int Top, string strWhere, string filedOrder)
262
+        {
263
+            StringBuilder strSql = new StringBuilder();
264
+            strSql.Append("select ");
265
+            if (Top > 0)
266
+            {
267
+                strSql.Append(" top " + Top.ToString());
268
+            }
269
+            strSql.Append(" F_Id,F_MaxSeat,F_PassHash,F_SaltValue,F_SecurityKey ");
270
+            strSql.Append(" FROM T_Sys_SeatPermissionConfig ");
271
+            if (strWhere.Trim() != "")
272
+            {
273
+                strSql.Append(" where " + strWhere);
274
+            }
275
+            strSql.Append(" order by " + filedOrder);
276
+            return DbHelperSQL.Query(strSql.ToString());
277
+        }
278
+
279
+        /// <summary>
280
+        /// 获取记录总数
281
+        /// </summary>
282
+        public int GetRecordCount(string strWhere)
283
+        {
284
+            StringBuilder strSql = new StringBuilder();
285
+            strSql.Append("select count(1) FROM T_Sys_SeatPermissionConfig ");
286
+            if (strWhere.Trim() != "")
287
+            {
288
+                strSql.Append(" where " + strWhere);
289
+            }
290
+            object obj = DbHelperSQL.GetSingle(strSql.ToString());
291
+            if (obj == null)
292
+            {
293
+                return 0;
294
+            }
295
+            else
296
+            {
297
+                return Convert.ToInt32(obj);
298
+            }
299
+        }
300
+        /// <summary>
301
+        /// 分页获取数据列表
302
+        /// </summary>
303
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
304
+        {
305
+            StringBuilder strSql = new StringBuilder();
306
+            strSql.Append("SELECT * FROM ( ");
307
+            strSql.Append(" SELECT ROW_NUMBER() OVER (");
308
+            if (!string.IsNullOrEmpty(orderby.Trim()))
309
+            {
310
+                strSql.Append("order by T." + orderby);
311
+            }
312
+            else
313
+            {
314
+                strSql.Append("order by T.F_Id desc");
315
+            }
316
+            strSql.Append(")AS Row, T.*  from T_Sys_SeatPermissionConfig T ");
317
+            if (!string.IsNullOrEmpty(strWhere.Trim()))
318
+            {
319
+                strSql.Append(" WHERE " + strWhere);
320
+            }
321
+            strSql.Append(" ) TT");
322
+            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
323
+            return DbHelperSQL.Query(strSql.ToString());
324
+        }
325
+
326
+        /*
327
+		/// <summary>
328
+		/// 分页获取数据列表
329
+		/// </summary>
330
+		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
331
+		{
332
+			SqlParameter[] parameters = {
333
+					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
334
+					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
335
+					new SqlParameter("@PageSize", SqlDbType.Int),
336
+					new SqlParameter("@PageIndex", SqlDbType.Int),
337
+					new SqlParameter("@IsReCount", SqlDbType.Bit),
338
+					new SqlParameter("@OrderType", SqlDbType.Bit),
339
+					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
340
+					};
341
+			parameters[0].Value = "T_Sys_SeatPermissionConfig";
342
+			parameters[1].Value = "F_Id";
343
+			parameters[2].Value = PageSize;
344
+			parameters[3].Value = PageIndex;
345
+			parameters[4].Value = 0;
346
+			parameters[5].Value = 0;
347
+			parameters[6].Value = strWhere;	
348
+			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
349
+		}*/
350
+
351
+        #endregion  BasicMethod
352
+        #region  ExtensionMethod
353
+
354
+        #endregion  ExtensionMethod
355
+    }
356
+}

+ 98 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/SysConfigController.cs

@@ -1,9 +1,12 @@
1 1
 using CallCenter.Utility;
2 2
 using CallCenterApi.Interface.Controllers.Base;
3 3
 using CallCenterApi.Interface.Models.Input;
4
+using CallCenterApi.Model;
4 5
 using System;
5 6
 using System.Collections.Generic;
6 7
 using System.Linq;
8
+using System.Security.Cryptography;
9
+using System.Text;
7 10
 using System.Web;
8 11
 using System.Web.Mvc;
9 12
 
@@ -222,6 +225,100 @@ namespace CallCenterApi.Interface.Controllers
222 225
             return Success("保存成功");
223 226
         }
224 227
         #endregion
225
-        
228
+
229
+        #region 坐席数量限制授权设置
230
+
231
+        /// <summary>
232
+        /// 保存坐席限制数据
233
+        /// </summary>
234
+        /// <returns></returns>
235
+        public ActionResult SaveSeatPermission(T_Sys_SeatPermissionConfig input)
236
+        {
237
+            string saltValue = string.Empty;
238
+            int maxSeat = int.Parse(input.F_MaxSeat.ToString());
239
+            string securityKey = input.F_SecurityKey;
240
+            string passHash = SaltAndHashHelper.GetHashSha256AndSalt(maxSeat + securityKey, out saltValue); //对密码进行加密
241
+
242
+            Model.T_Sys_SeatPermissionConfig model = new Model.T_Sys_SeatPermissionConfig();
243
+            BLL.T_Sys_SeatPermissionConfig bll = new BLL.T_Sys_SeatPermissionConfig();
244
+            if (!bll.Exists())
245
+            {
246
+                model.F_MaxSeat = maxSeat;
247
+                model.F_PassHash = passHash;
248
+                model.F_SaltValue = saltValue;
249
+                model.F_SecurityKey = securityKey;
250
+                int n = bll.Add(model);
251
+                if (n > 0)
252
+                {
253
+                    return Success("添加成功");
254
+                }
255
+                else
256
+                {
257
+                    return Error("添加失败");
258
+                }
259
+            }
260
+            else {
261
+                model = bll.GetModel();
262
+                if (model != null)
263
+                {
264
+                    model.F_MaxSeat = maxSeat;
265
+                    model.F_PassHash = passHash;
266
+                    model.F_SaltValue = saltValue;
267
+                    model.F_SecurityKey = securityKey;
268
+                    if (bll.Update(model))
269
+                    {
270
+                        return Success("修改成功");
271
+                    }
272
+                    else
273
+                    {
274
+                        return Error("修改失败");
275
+                    }
276
+                }
277
+                return Error("信息不存在");
278
+            }
279
+        }
280
+
281
+        public ActionResult ddd()
282
+        {
283
+            if (IsValidSeatPermission())
284
+            {
285
+                return Content("匹配");
286
+            }
287
+            else
288
+            {
289
+                return Content("不匹配");
290
+            }
291
+        }
292
+
293
+        /// <summary>
294
+        /// 判断坐席限制权限
295
+        /// </summary>
296
+        /// <param name="currentSeat">当前坐席数</param>
297
+        /// <returns></returns>
298
+        public bool IsValidSeatPermission()
299
+        {
300
+            Model.T_Sys_SeatPermissionConfig model = new Model.T_Sys_SeatPermissionConfig();
301
+            BLL.T_Sys_SeatPermissionConfig bll = new BLL.T_Sys_SeatPermissionConfig();
302
+            BLL.T_Sys_UserAccount bllU = new BLL.T_Sys_UserAccount();
303
+            int currentSeat = bllU.GetRecordCount(" F_RoleId = 1 OR F_SeatFlag = 1 ");  //坐席角色用户数量 1中心话务员 2标志(0:非话务;1话务标志)
304
+            model = bll.GetModel();
305
+            int maxSeat = int.Parse(model.F_MaxSeat.ToString());
306
+            string securityKey = model.F_SecurityKey;
307
+            string passHash = model.F_PassHash; //对密码进行加密
308
+            string saltValue = model.F_SaltValue;
309
+            string passHashNew = SaltAndHashHelper.GetHashSha256(maxSeat + securityKey, saltValue); //将用户数据的密码采用已知的盐值进行加密
310
+            //校验密码hash值是否一致
311
+            if (maxSeat >= currentSeat)
312
+            {
313
+                return passHashNew.Equals(passHash);
314
+            }
315
+            else
316
+            {
317
+                return false;
318
+            }
319
+        }
320
+
321
+        #endregion
322
+
226 323
     }
227 324
 }

+ 15 - 7
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/UserAccountController.cs

@@ -209,15 +209,23 @@ namespace CallCenterApi.Interface.Controllers
209 209
                 {
210 210
                     userAccountModel.F_WorkNumber = input.Usercode.Trim();
211 211
                 }
212
+                SysConfigController sys = new SysConfigController();
213
+                //话务人员限制权限判断
214
+                if (sys.IsValidSeatPermission())
215
+                {
216
+                    var model = sysUserAccountBll.GetModel(input.Usercode);
217
+                    if (model != null)
218
+                        res = Error("当前员工工号存在,请更换!");
212 219
 
213
-                var model = sysUserAccountBll.GetModel(input.Usercode);
214
-                if (model != null)
215
-                    return Error("当前员工工号存在,请更换!");
216
-
217
-                if (sysUserAccountBll.Add(userAccountModel) > 0)
218
-                    res = Success("新增成功!");
220
+                    if (sysUserAccountBll.Add(userAccountModel) > 0)
221
+                        res = Success("新增成功!");
222
+                    else
223
+                        res = Error("新增失败!");
224
+                }
219 225
                 else
220
-                    res = Error("新增失败!");
226
+                {
227
+                    res = Error("话务人员数量已超!");
228
+                }
221 229
             }
222 230
             return res;
223 231
         }

+ 1 - 0
CallCenterApi/CallCenterApi.Model/CallCenterApi.Model.csproj

@@ -42,6 +42,7 @@
42 42
   </ItemGroup>
43 43
   <ItemGroup>
44 44
     <Compile Include="CallResult.cs" />
45
+    <Compile Include="T_Sys_SeatPermissionConfig.cs" />
45 46
     <Compile Include="WeiBoCommentList.cs" />
46 47
     <Compile Include="PageData.cs" />
47 48
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 61 - 0
CallCenterApi/CallCenterApi.Model/T_Sys_SeatPermissionConfig.cs

@@ -0,0 +1,61 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace CallCenterApi.Model
8
+{
9
+    public partial class T_Sys_SeatPermissionConfig
10
+    {
11
+        public T_Sys_SeatPermissionConfig()
12
+        { }
13
+        #region Model
14
+        private int _f_id;
15
+        private int? _f_maxseat;
16
+        private string _f_passhash;
17
+        private string _f_saltvalue;
18
+        private string _f_securitykey;
19
+        /// <summary>
20
+        /// id,自增
21
+        /// </summary>
22
+        public int F_Id
23
+        {
24
+            set { _f_id = value; }
25
+            get { return _f_id; }
26
+        }
27
+        /// <summary>
28
+        /// 最大坐席数
29
+        /// </summary>
30
+        public int? F_MaxSeat
31
+        {
32
+            set { _f_maxseat = value; }
33
+            get { return _f_maxseat; }
34
+        }
35
+        /// <summary>
36
+        /// 密文字符串
37
+        /// </summary>
38
+        public string F_PassHash
39
+        {
40
+            set { _f_passhash = value; }
41
+            get { return _f_passhash; }
42
+        }
43
+        /// <summary>
44
+        /// 盐值Salt
45
+        /// </summary>
46
+        public string F_SaltValue
47
+        {
48
+            set { _f_saltvalue = value; }
49
+            get { return _f_saltvalue; }
50
+        }
51
+        /// <summary>
52
+        /// 安全码Key值
53
+        /// </summary>
54
+        public string F_SecurityKey
55
+        {
56
+            set { _f_securitykey = value; }
57
+            get { return _f_securitykey; }
58
+        }
59
+        #endregion Model
60
+    }
61
+}

+ 1 - 0
CallCenterCommon/CallCenter.Utility/CallCenter.Utility.csproj

@@ -76,6 +76,7 @@
76 76
     <Compile Include="FileUp.cs" />
77 77
     <Compile Include="Linq\LinqExtend.cs" />
78 78
     <Compile Include="Linq\PredicateExtensionses.cs" />
79
+    <Compile Include="SaltAndHashHelper.cs" />
79 80
     <Compile Include="Time\DateTimeConvert.cs" />
80 81
     <Compile Include="VerifyCode\VerifyCode.cs" />
81 82
     <Compile Include="WeiBo\WeiBoLog.cs" />

+ 46 - 0
CallCenterCommon/CallCenter.Utility/SaltAndHashHelper.cs

@@ -0,0 +1,46 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Security.Cryptography;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace CallCenter.Utility
9
+{
10
+    public class SaltAndHashHelper
11
+    {
12
+        /// <summary>
13
+        /// 对用户输入的密码进行加密
14
+        /// </summary>
15
+        /// <param name="passWord">输入的明文密码</param>
16
+        /// <param name="salt">加密过程中产生的盐值</param>
17
+        /// <returns>加密后的密码值</returns>
18
+        public static string GetHashSha256AndSalt(string passWord, out string salt)
19
+        {
20
+            //首先生成随机加密盐
21
+            RandomNumberGenerator saltNumber = new RNGCryptoServiceProvider();
22
+            byte[] s = new byte[256];
23
+            saltNumber.GetBytes(s);
24
+            salt = Convert.ToBase64String(s); //将盐值转化为字符串
25
+            return GetHashSha256(passWord, salt);//针对盐值和密码一起应用hash加密函数,得到明文密码
26
+        }
27
+        /// <summary>
28
+        /// 对用户输入的密码采用指定的盐值进行加密
29
+        /// </summary>
30
+        /// <param name="passWord">输入的明文密码</param>
31
+        /// <param name="salt">指定的盐值</param>
32
+        /// <returns>加密后的密码值</returns>
33
+        public static string GetHashSha256(string passWord, string salt)
34
+        {
35
+            byte[] bytes = Encoding.Unicode.GetBytes(salt + passWord); //将盐值和密码进行组合
36
+            SHA256Managed hashstring = new SHA256Managed();
37
+            byte[] hash = hashstring.ComputeHash(bytes);//针对组合后的数据应用hash函数
38
+            string hashString = string.Empty;
39
+            foreach (byte x in hash)
40
+            {
41
+                hashString += String.Format("{0:x2}", x);
42
+            }
43
+            return hashString; //得到加密后的密文字符串
44
+        }
45
+    }
46
+}