Parcourir la Source

修改缓存为redis,新增查看时间

zhoufan il y a 7 ans
Parent
commit
e88bc1b0bd

+ 101 - 89
API/CallCenterApi/CallCenterApi.BLL/T_Bus_AssignedInfo.cs

@@ -137,100 +137,112 @@ namespace CallCenterApi.BLL
137 137
 			DataSet ds = dal.GetList(strWhere);
138 138
 			return DataTableToList(ds.Tables[0]);
139 139
 		}
140
-		/// <summary>
140
+        /// <summary>
141 141
 		/// 获得数据列表
142 142
 		/// </summary>
143
-		public List<CallCenterApi.Model.T_Bus_AssignedInfo> DataTableToList(DataTable dt)
143
+		public List<CallCenterApi.Model.T_Bus_AssignedInfo> GetModelList(int Top, string strWhere, string filedOrder)
144
+        {
145
+            DataSet ds = dal.GetList(Top,strWhere, filedOrder);
146
+            return DataTableToList(ds.Tables[0]);
147
+        }
148
+        /// <summary>
149
+        /// 获得数据列表
150
+        /// </summary>
151
+        public List<CallCenterApi.Model.T_Bus_AssignedInfo> DataTableToList(DataTable dt)
144 152
 		{
145 153
 			List<CallCenterApi.Model.T_Bus_AssignedInfo> modelList = new List<CallCenterApi.Model.T_Bus_AssignedInfo>();
146 154
 			int rowsCount = dt.Rows.Count;
147
-			if (rowsCount > 0)
148
-			{
149
-				CallCenterApi.Model.T_Bus_AssignedInfo model;
150
-				for (int n = 0; n < rowsCount; n++)
151
-				{
152
-					model = new CallCenterApi.Model.T_Bus_AssignedInfo();
153
-					if(dt.Rows[n]["F_AssignedId"]!=null && dt.Rows[n]["F_AssignedId"].ToString()!="")
154
-					{
155
-						model.F_AssignedId=int.Parse(dt.Rows[n]["F_AssignedId"].ToString());
156
-					}
157
-					if(dt.Rows[n]["F_WorkOrderId"]!=null && dt.Rows[n]["F_WorkOrderId"].ToString()!="")
158
-					{
159
-					model.F_WorkOrderId=dt.Rows[n]["F_WorkOrderId"].ToString();
160
-					}
161
-					if(dt.Rows[n]["F_FlowId"]!=null && dt.Rows[n]["F_FlowId"].ToString()!="")
162
-					{
163
-						model.F_FlowId=int.Parse(dt.Rows[n]["F_FlowId"].ToString());
164
-					}
165
-					if(dt.Rows[n]["F_DeptId"]!=null && dt.Rows[n]["F_DeptId"].ToString()!="")
166
-					{
167
-						model.F_DeptId=int.Parse(dt.Rows[n]["F_DeptId"].ToString());
168
-					}
169
-					if(dt.Rows[n]["F_DeptAddress"]!=null && dt.Rows[n]["F_DeptAddress"].ToString()!="")
170
-					{
171
-					model.F_DeptAddress=dt.Rows[n]["F_DeptAddress"].ToString();
172
-					}
173
-					if(dt.Rows[n]["F_AssignedOpinion"]!=null && dt.Rows[n]["F_AssignedOpinion"].ToString()!="")
174
-					{
175
-					model.F_AssignedOpinion=dt.Rows[n]["F_AssignedOpinion"].ToString();
176
-					}
177
-					if(dt.Rows[n]["F_Remark"]!=null && dt.Rows[n]["F_Remark"].ToString()!="")
178
-					{
179
-					model.F_Remark=dt.Rows[n]["F_Remark"].ToString();
180
-					}
181
-					if(dt.Rows[n]["F_SubmitUserCode"]!=null && dt.Rows[n]["F_SubmitUserCode"].ToString()!="")
182
-					{
183
-					model.F_SubmitUserCode=dt.Rows[n]["F_SubmitUserCode"].ToString();
184
-					}
185
-					if(dt.Rows[n]["F_SubmitDate"]!=null && dt.Rows[n]["F_SubmitDate"].ToString()!="")
186
-					{
187
-						model.F_SubmitDate=DateTime.Parse(dt.Rows[n]["F_SubmitDate"].ToString());
188
-					}
189
-					if(dt.Rows[n]["F_IsRead"]!=null && dt.Rows[n]["F_IsRead"].ToString()!="")
190
-					{
191
-						if((dt.Rows[n]["F_IsRead"].ToString()=="1")||(dt.Rows[n]["F_IsRead"].ToString().ToLower()=="true"))
192
-						{
193
-						model.F_IsRead=true;
194
-						}
195
-						else
196
-						{
197
-							model.F_IsRead=false;
198
-						}
199
-					}
200
-					if(dt.Rows[n]["F_State"]!=null && dt.Rows[n]["F_State"].ToString()!="")
201
-					{
202
-						model.F_State=int.Parse(dt.Rows[n]["F_State"].ToString());
203
-					}
204
-					if(dt.Rows[n]["F_BackReason"]!=null && dt.Rows[n]["F_BackReason"].ToString()!="")
205
-					{
206
-					model.F_BackReason=dt.Rows[n]["F_BackReason"].ToString();
207
-					}
208
-					if(dt.Rows[n]["F_ResultState"]!=null && dt.Rows[n]["F_ResultState"].ToString()!="")
209
-					{
210
-						model.F_ResultState=int.Parse(dt.Rows[n]["F_ResultState"].ToString());
211
-					}
212
-					if(dt.Rows[n]["F_IsApproval"]!=null && dt.Rows[n]["F_IsApproval"].ToString()!="")
213
-					{
214
-						if((dt.Rows[n]["F_IsApproval"].ToString()=="1")||(dt.Rows[n]["F_IsApproval"].ToString().ToLower()=="true"))
215
-						{
216
-						model.F_IsApproval=true;
217
-						}
218
-						else
219
-						{
220
-							model.F_IsApproval=false;
221
-						}
222
-					}
223
-					if(dt.Rows[n]["F_EUserName"]!=null && dt.Rows[n]["F_EUserName"].ToString()!="")
224
-					{
225
-					model.F_EUserName=dt.Rows[n]["F_EUserName"].ToString();
226
-					}
227
-					if(dt.Rows[n]["F_EndDate"]!=null && dt.Rows[n]["F_EndDate"].ToString()!="")
228
-					{
229
-						model.F_EndDate=DateTime.Parse(dt.Rows[n]["F_EndDate"].ToString());
230
-					}
231
-					modelList.Add(model);
232
-				}
233
-			}
155
+            if (rowsCount > 0)
156
+            {
157
+                CallCenterApi.Model.T_Bus_AssignedInfo model;
158
+                for (int n = 0; n < rowsCount; n++)
159
+                {
160
+                    model = new CallCenterApi.Model.T_Bus_AssignedInfo();
161
+                    if (dt.Rows[n]["F_AssignedId"] != null && dt.Rows[n]["F_AssignedId"].ToString() != "")
162
+                    {
163
+                        model.F_AssignedId = int.Parse(dt.Rows[n]["F_AssignedId"].ToString());
164
+                    }
165
+                    if (dt.Rows[n]["F_WorkOrderId"] != null && dt.Rows[n]["F_WorkOrderId"].ToString() != "")
166
+                    {
167
+                        model.F_WorkOrderId = dt.Rows[n]["F_WorkOrderId"].ToString();
168
+                    }
169
+                    if (dt.Rows[n]["F_FlowId"] != null && dt.Rows[n]["F_FlowId"].ToString() != "")
170
+                    {
171
+                        model.F_FlowId = int.Parse(dt.Rows[n]["F_FlowId"].ToString());
172
+                    }
173
+                    if (dt.Rows[n]["F_DeptId"] != null && dt.Rows[n]["F_DeptId"].ToString() != "")
174
+                    {
175
+                        model.F_DeptId = int.Parse(dt.Rows[n]["F_DeptId"].ToString());
176
+                    }
177
+                    if (dt.Rows[n]["F_DeptAddress"] != null && dt.Rows[n]["F_DeptAddress"].ToString() != "")
178
+                    {
179
+                        model.F_DeptAddress = dt.Rows[n]["F_DeptAddress"].ToString();
180
+                    }
181
+                    if (dt.Rows[n]["F_AssignedOpinion"] != null && dt.Rows[n]["F_AssignedOpinion"].ToString() != "")
182
+                    {
183
+                        model.F_AssignedOpinion = dt.Rows[n]["F_AssignedOpinion"].ToString();
184
+                    }
185
+                    if (dt.Rows[n]["F_Remark"] != null && dt.Rows[n]["F_Remark"].ToString() != "")
186
+                    {
187
+                        model.F_Remark = dt.Rows[n]["F_Remark"].ToString();
188
+                    }
189
+                    if (dt.Rows[n]["F_SubmitUserCode"] != null && dt.Rows[n]["F_SubmitUserCode"].ToString() != "")
190
+                    {
191
+                        model.F_SubmitUserCode = dt.Rows[n]["F_SubmitUserCode"].ToString();
192
+                    }
193
+                    if (dt.Rows[n]["F_SubmitDate"] != null && dt.Rows[n]["F_SubmitDate"].ToString() != "")
194
+                    {
195
+                        model.F_SubmitDate = DateTime.Parse(dt.Rows[n]["F_SubmitDate"].ToString());
196
+                    }
197
+                    if (dt.Rows[n]["F_IsRead"] != null && dt.Rows[n]["F_IsRead"].ToString() != "")
198
+                    {
199
+                        if ((dt.Rows[n]["F_IsRead"].ToString() == "1") || (dt.Rows[n]["F_IsRead"].ToString().ToLower() == "true"))
200
+                        {
201
+                            model.F_IsRead = true;
202
+                        }
203
+                        else
204
+                        {
205
+                            model.F_IsRead = false;
206
+                        }
207
+                    }
208
+                    if (dt.Rows[n]["F_State"] != null && dt.Rows[n]["F_State"].ToString() != "")
209
+                    {
210
+                        model.F_State = int.Parse(dt.Rows[n]["F_State"].ToString());
211
+                    }
212
+                    if (dt.Rows[n]["F_BackReason"] != null && dt.Rows[n]["F_BackReason"].ToString() != "")
213
+                    {
214
+                        model.F_BackReason = dt.Rows[n]["F_BackReason"].ToString();
215
+                    }
216
+                    if (dt.Rows[n]["F_ResultState"] != null && dt.Rows[n]["F_ResultState"].ToString() != "")
217
+                    {
218
+                        model.F_ResultState = int.Parse(dt.Rows[n]["F_ResultState"].ToString());
219
+                    }
220
+                    if (dt.Rows[n]["F_IsApproval"] != null && dt.Rows[n]["F_IsApproval"].ToString() != "")
221
+                    {
222
+                        if ((dt.Rows[n]["F_IsApproval"].ToString() == "1") || (dt.Rows[n]["F_IsApproval"].ToString().ToLower() == "true"))
223
+                        {
224
+                            model.F_IsApproval = true;
225
+                        }
226
+                        else
227
+                        {
228
+                            model.F_IsApproval = false;
229
+                        }
230
+                    }
231
+                    if (dt.Rows[n]["F_EUserName"] != null && dt.Rows[n]["F_EUserName"].ToString() != "")
232
+                    {
233
+                        model.F_EUserName = dt.Rows[n]["F_EUserName"].ToString();
234
+                    }
235
+                    if (dt.Rows[n]["F_EndDate"] != null && dt.Rows[n]["F_EndDate"].ToString() != "")
236
+                    {
237
+                        model.F_EndDate = DateTime.Parse(dt.Rows[n]["F_EndDate"].ToString());
238
+                    }
239
+                    if (dt.Rows[n]["F_ReadDate"] != null && dt.Rows[n]["F_ReadDate"].ToString() != "")
240
+                    {
241
+                        model.F_ReadDate = DateTime.Parse(dt.Rows[n]["F_ReadDate"].ToString());
242
+                    }
243
+                    modelList.Add(model);
244
+                }
245
+            }
234 246
 			return modelList;
235 247
 		}
236 248
 

+ 19 - 11
API/CallCenterApi/CallCenterApi.DAL/T_Bus_AssignedInfo.cs

@@ -83,9 +83,9 @@ namespace CallCenterApi.DAL
83 83
         {
84 84
             StringBuilder strSql = new StringBuilder();
85 85
             strSql.Append("insert into T_Bus_AssignedInfo(");
86
-            strSql.Append("F_WorkOrderId,F_FlowId,F_Area,F_DeptType,F_DeptId,F_DeptAddress,F_OpitionId,F_AssignedOpinion,F_Remark,F_SubmitUserCode,F_SubmitDate,F_IsRead,F_State,F_BackReason,F_ResultState,F_IsApproval,F_EUserName,F_EndDate,F_IsComplete,F_OverDay)");
86
+            strSql.Append("F_WorkOrderId,F_FlowId,F_Area,F_DeptType,F_DeptId,F_DeptAddress,F_OpitionId,F_AssignedOpinion,F_Remark,F_SubmitUserCode,F_SubmitDate,F_IsRead,F_State,F_BackReason,F_ResultState,F_IsApproval,F_EUserName,F_EndDate,F_IsComplete,F_OverDay,F_ReadDate)");
87 87
             strSql.Append(" values (");
88
-            strSql.Append("@F_WorkOrderId,@F_FlowId,@F_Area,@F_DeptType,@F_DeptId,@F_DeptAddress,@F_OpitionId,@F_AssignedOpinion,@F_Remark,@F_SubmitUserCode,@F_SubmitDate,@F_IsRead,@F_State,@F_BackReason,@F_ResultState,@F_IsApproval,@F_EUserName,@F_EndDate,@F_IsComplete,@F_OverDay)");
88
+            strSql.Append("@F_WorkOrderId,@F_FlowId,@F_Area,@F_DeptType,@F_DeptId,@F_DeptAddress,@F_OpitionId,@F_AssignedOpinion,@F_Remark,@F_SubmitUserCode,@F_SubmitDate,@F_IsRead,@F_State,@F_BackReason,@F_ResultState,@F_IsApproval,@F_EUserName,@F_EndDate,@F_IsComplete,@F_OverDay,@F_ReadDate)");
89 89
             strSql.Append(";select @@IDENTITY");
90 90
             SqlParameter[] parameters = {
91 91
                     new SqlParameter("@F_WorkOrderId", SqlDbType.NVarChar,20),
@@ -107,7 +107,9 @@ namespace CallCenterApi.DAL
107 107
                     new SqlParameter("@F_EUserName", SqlDbType.NVarChar,20),
108 108
                     new SqlParameter("@F_EndDate", SqlDbType.DateTime),
109 109
                     new SqlParameter("@F_IsComplete", SqlDbType.Bit,1),
110
-                    new SqlParameter("@F_OverDay", SqlDbType.Int,4)};
110
+                    new SqlParameter("@F_OverDay", SqlDbType.Int,4),
111
+                    new SqlParameter("@F_ReadDate", SqlDbType.DateTime)
112
+            };
111 113
             parameters[0].Value = model.F_WorkOrderId;
112 114
             parameters[1].Value = model.F_FlowId;
113 115
             parameters[2].Value = model.F_Area;
@@ -128,6 +130,7 @@ namespace CallCenterApi.DAL
128 130
             parameters[17].Value = model.F_EndDate;
129 131
             parameters[18].Value = model.F_IsComplete;
130 132
             parameters[19].Value = model.F_OverDay;
133
+            parameters[20].Value = model.F_ReadDate;
131 134
 
132 135
             object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
133 136
             if (obj == null)
@@ -165,7 +168,8 @@ namespace CallCenterApi.DAL
165 168
             strSql.Append("F_EUserName=@F_EUserName,");
166 169
             strSql.Append("F_EndDate=@F_EndDate,");
167 170
             strSql.Append("F_IsComplete=@F_IsComplete,");
168
-            strSql.Append("F_OverDay=@F_OverDay");
171
+            strSql.Append("F_OverDay=@F_OverDay,");
172
+            strSql.Append("F_ReadDate=@F_ReadDate");
169 173
             strSql.Append(" where F_AssignedId=@F_AssignedId");
170 174
             SqlParameter[] parameters = {
171 175
                     new SqlParameter("@F_WorkOrderId", SqlDbType.NVarChar,20),
@@ -188,6 +192,7 @@ namespace CallCenterApi.DAL
188 192
                     new SqlParameter("@F_EndDate", SqlDbType.DateTime),
189 193
                     new SqlParameter("@F_IsComplete", SqlDbType.Bit,1),
190 194
                     new SqlParameter("@F_OverDay", SqlDbType.Int,4),
195
+                    new SqlParameter("@F_ReadDate", SqlDbType.DateTime),
191 196
                     new SqlParameter("@F_AssignedId", SqlDbType.Int,4)};
192 197
             parameters[0].Value = model.F_WorkOrderId;
193 198
             parameters[1].Value = model.F_FlowId;
@@ -209,7 +214,8 @@ namespace CallCenterApi.DAL
209 214
             parameters[17].Value = model.F_EndDate;
210 215
             parameters[18].Value = model.F_IsComplete;
211 216
             parameters[19].Value = model.F_OverDay;
212
-            parameters[20].Value = model.F_AssignedId;
217
+            parameters[20].Value = model.F_ReadDate;
218
+            parameters[21].Value = model.F_AssignedId;
213 219
 
214 220
             int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
215 221
             if (rows > 0)
@@ -271,7 +277,7 @@ namespace CallCenterApi.DAL
271 277
         {
272 278
 
273 279
             StringBuilder strSql = new StringBuilder();
274
-            strSql.Append("select  top 1 F_AssignedId,F_WorkOrderId,F_FlowId,F_Area,F_DeptType,F_DeptId,F_DeptAddress,F_OpitionId,F_AssignedOpinion,F_Remark,F_SubmitUserCode,F_SubmitDate,F_IsRead,F_State,F_BackReason,F_ResultState,F_IsApproval,F_EUserName,F_EndDate,F_IsComplete,F_OverDay from T_Bus_AssignedInfo ");
280
+            strSql.Append("select  top 1 * from T_Bus_AssignedInfo ");
275 281
             strSql.Append(" where F_AssignedId=@F_AssignedId");
276 282
             SqlParameter[] parameters = {
277 283
                     new SqlParameter("@F_AssignedId", SqlDbType.Int,4)
@@ -404,6 +410,10 @@ namespace CallCenterApi.DAL
404 410
                 {
405 411
                     model.F_OverDay = int.Parse(row["F_OverDay"].ToString());
406 412
                 }
413
+                if (row["F_ReadDate"] != null && row["F_ReadDate"].ToString() != "")
414
+                {
415
+                    model.F_ReadDate = DateTime.Parse(row["F_ReadDate"].ToString());
416
+                }
407 417
             }
408 418
             return model;
409 419
         }
@@ -415,7 +425,7 @@ namespace CallCenterApi.DAL
415 425
         {
416 426
 
417 427
             StringBuilder strSql = new StringBuilder();
418
-            strSql.Append("select  top 1 F_AssignedId,F_WorkOrderId,F_FlowId,F_DeptId,F_DeptAddress,F_AssignedOpinion,F_Remark,F_SubmitUserCode,F_SubmitDate,F_IsRead,F_State,F_BackReason,F_ResultState,F_IsApproval,F_EUserName,F_EndDate,F_Area,F_DeptType,F_OpitionId,F_IsComplete,F_OverDay from T_Bus_AssignedInfo ");
428
+            strSql.Append("select  top 1 * from T_Bus_AssignedInfo ");
419 429
             strSql.Append(" where F_WorkOrderId=@F_WorkOrderId");
420 430
             strSql.Append(" order by F_AssignedId desc");
421 431
             SqlParameter[] parameters = {
@@ -439,8 +449,7 @@ namespace CallCenterApi.DAL
439 449
 		public DataSet GetList(string strWhere)
440 450
         {
441 451
             StringBuilder strSql = new StringBuilder();
442
-            strSql.Append("select F_AssignedId,F_WorkOrderId,F_FlowId,F_Area,F_DeptType,F_DeptId,F_DeptAddress,F_OpitionId,F_AssignedOpinion,F_Remark,F_SubmitUserCode,F_SubmitDate,F_IsRead,F_State,F_BackReason,F_ResultState,F_IsApproval,F_EUserName,F_EndDate,F_IsComplete,F_OverDay ");
443
-            strSql.Append(" FROM T_Bus_AssignedInfo ");
452
+            strSql.Append("select * FROM T_Bus_AssignedInfo ");
444 453
             if (strWhere.Trim() != "")
445 454
             {
446 455
                 strSql.Append(" where " + strWhere);
@@ -459,8 +468,7 @@ namespace CallCenterApi.DAL
459 468
             {
460 469
                 strSql.Append(" top " + Top.ToString());
461 470
             }
462
-            strSql.Append(" F_AssignedId,F_WorkOrderId,F_FlowId,F_Area,F_DeptType,F_DeptId,F_DeptAddress,F_OpitionId,F_AssignedOpinion,F_Remark,F_SubmitUserCode,F_SubmitDate,F_IsRead,F_State,F_BackReason,F_ResultState,F_IsApproval,F_EUserName,F_EndDate,F_IsComplete,F_OverDay ");
463
-            strSql.Append(" FROM T_Bus_AssignedInfo ");
471
+            strSql.Append(" * FROM T_Bus_AssignedInfo ");
464 472
             if (strWhere.Trim() != "")
465 473
             {
466 474
                 strSql.Append(" where " + strWhere);

+ 22 - 14
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/AuthorizeAttribute.cs

@@ -28,22 +28,30 @@ namespace CallCenterApi.Interface
28 28
                 var action = actionDescriptor.ActionName;
29 29
                 var token = filterContext.HttpContext.Request["token"];
30 30
 
31
-                var userData = CacheHelper.Get<Dictionary<string, string>>(token);
32
-                var roleId = Utils.StrToInt(userData["F_RoleID"], 0);
33
-                var role = new BLL.T_Sys_RoleInfo().GetModel(roleId);
34
-                if (role != null)
31
+                //var userData = CacheHelper.Get<Dictionary<string, string>>(token);
32
+                var userDatastr = RedisHelper.StringGet(token);
33
+                if (userDatastr != null)
35 34
                 {
36
-                    isAuth = true;
37
-                    //var roleFunctionList = roleFunctionBLL.GetModelList(" F_RoleId=" + role.F_RoleId);
38
-                    ////var str = string.Join(",", roleFunctionList.Select(x => x.F_FunctionId).ToArray());
39
-                    //var moduleFunction = new BLL.T_Sys_Function().GetModel(roleId);
40
-                    //if (moduleFunction != null)
35
+                    Dictionary<string, string> userData = new Dictionary<string, string>();
36
+                    userData = userDatastr.ToString().ToObject<Dictionary<string, string>>();
37
+                    var roleId = Utils.StrToInt(userData["F_RoleID"], 0);
38
+
39
+                    //var roleId = Utils.StrToInt(userData["F_RoleID"], 0);
40
+                    //var role = new BLL.T_Sys_RoleInfo().GetModel(roleId);
41
+                    //if (role != null)
41 42
                     //{
42
-                    //    var single = roleFunctionList.SingleOrDefault(x => x.F_FunctionId == moduleFunction.F_FunctionId);
43
-                    //    if (single != null)
44
-                    //    {
45
-                    //        isAuth = true;
46
-                    //    }
43
+                    //    isAuth = true;
44
+                    //    //var roleFunctionList = roleFunctionBLL.GetModelList(" F_RoleId=" + role.F_RoleId);
45
+                    //    ////var str = string.Join(",", roleFunctionList.Select(x => x.F_FunctionId).ToArray());
46
+                    //    //var moduleFunction = new BLL.T_Sys_Function().GetModel(roleId);
47
+                    //    //if (moduleFunction != null)
48
+                    //    //{
49
+                    //    //    var single = roleFunctionList.SingleOrDefault(x => x.F_FunctionId == moduleFunction.F_FunctionId);
50
+                    //    //    if (single != null)
51
+                    //    //    {
52
+                    //    //        isAuth = true;
53
+                    //    //    }
54
+                    //    //}
47 55
                     //}
48 56
                 }
49 57
             }

+ 3 - 0
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

@@ -23,4 +23,7 @@
23 23
   <add key="WechatOpenid" value="openid222" />
24 24
   <!-- 设置微信appsecret -->
25 25
   <add key="WechatAppsecret" value="appsecret111" />
26
+  <!-- ================== 4:Redis配置 ================== -->
27
+  <add key="Redis_Server" value="192.168.4.18"/>
28
+  <add key="Redis_Port" value="6379"/>
26 29
 </appSettings>

+ 37 - 0
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/HomeController.cs

@@ -246,6 +246,43 @@ namespace CallCenterApi.Interface.Controllers
246 246
             return View("Index");
247 247
         }
248 248
 
249
+        public ActionResult GetRedis(string key)
250
+        {
251
+            List<object> caches = new List<object>();
252
+            var keys = RedisHelper.GetKeyList(string.IsNullOrEmpty(key) ? "" : key);
253
+
254
+            foreach (var k in keys)
255
+            {
256
+                caches.Add(new
257
+                {
258
+                    key = k,
259
+                    value = RedisHelper.StringGet(k),
260
+                    outtime = RedisHelper.GetKeyOutTime(k)
261
+                });
262
+            }
263
+            return Success("成功", caches);
264
+        }
265
+
266
+        public ActionResult UpdateRedis(string key, string value, int second = 10)
267
+        {
268
+            List<object> caches = new List<object>();
269
+            var keys = RedisHelper.GetKeyList(string.IsNullOrEmpty(key) ? "" : key);
270
+
271
+            foreach (var k in keys)
272
+            {
273
+                RedisHelper.StringSet(k, value, new TimeSpan(0, 0, second));
274
+            }
275
+            return Success("成功");
276
+        }
277
+
278
+        public ActionResult DeleteRedis(string key)
279
+        {
280
+            List<object> caches = new List<object>();
281
+            var keys = RedisHelper.GetKeyList(string.IsNullOrEmpty(key) ? "" : key);
282
+
283
+            long n = RedisHelper.KeysDelete(keys);
284
+            return Success("成功", n);
285
+        }
249 286
 
250 287
     }
251 288
 }

+ 9 - 4
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/Login/LoginController.cs

@@ -81,13 +81,17 @@ namespace CallCenterApi.Interface.Controllers
81 81
                                 F_State = 0
82 82
                             });
83 83
                             var token = FormsPrincipal<Dictionary<string, string>>.GetCookieValue(Dic["F_UserCode"], Dic);
84
+
85
+                            ////放入缓存
86
+                            //CacheHelper.Insert(token, Dic, 1440, System.Web.Caching.CacheItemPriority.NotRemovable, onRemove);
87
+                            //放入redis缓存
88
+                            RedisHelper.StringSet(token, Dic.ToJson(), new TimeSpan(24, 0, 0));
89
+
84 90
                             result = Success("登录成功", new
85 91
                             {
86 92
                                 token = token
87 93
                             });
88
-                            //放入缓存
89
-                            CacheHelper.Insert(token, Dic, 1440);
90
-                            
94
+
91 95
                         }
92 96
                         else
93 97
                         {
@@ -154,7 +158,8 @@ namespace CallCenterApi.Interface.Controllers
154 158
         {
155 159
             if (Request.IsAuthenticated)
156 160
             {
157
-                CacheHelper.Remove(token);
161
+                //CacheHelper.Remove(token);
162
+                RedisHelper.KeyDelete(token);
158 163
             }
159 164
             return Success("退出成功");
160 165
         }

+ 20 - 0
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -1416,6 +1416,26 @@ namespace CallCenterApi.Interface.Controllers.workorder
1416 1416
                                 {
1417 1417
                                     jbsql += " and F_DeptId='" + userModel.F_DeptId + "'";
1418 1418
                                     fksql += " and F_BackDeptId='" + userModel.F_DeptId + "'";
1419
+
1420
+                                    //string dwsql = "select top 1 * from T_Bus_AssignedInfo where F_WorkOrderId ='" + strworkorderid + "' and F_DeptId='" + userModel.F_DeptId + "' order by F_SubmitDate desc";
1421
+                                    var dwdt= new BLL.T_Bus_AssignedInfo().GetModelList(0,"F_WorkOrderId ='" + strworkorderid + "' and F_DeptId='" + userModel.F_DeptId + "'", "F_SubmitDate desc").FirstOrDefault();
1422
+                                    if (dwdt != null && dwdt.F_IsRead == false)
1423
+                                    {
1424
+                                        dwdt.F_IsRead = true;
1425
+                                        dwdt.F_ReadDate = DateTime.Now;
1426
+                                        new BLL.T_Bus_AssignedInfo().Update(dwdt);
1427
+                                    }
1428
+
1429
+                                    //if (dt.Rows[0]["F_IsProtect"] != null && dt.Rows[0]["F_IsProtect"].ToString() != "")
1430
+                                    //{
1431
+                                    //    if ((dt.Rows[0]["F_IsProtect"].ToString() == "1") || (dt.Rows[0]["F_IsProtect"].ToString().ToLower() == "true"))
1432
+                                    //    {
1433
+                                    //        dt.Rows[0]["F_CusName"] = "";
1434
+                                    //        dt.Rows[0]["F_CusPhone"] = "";
1435
+                                    //        dt.Rows[0]["F_ConName"] = "";
1436
+                                    //        dt.Rows[0]["F_ConPhone"] = "";
1437
+                                    //    }
1438
+                                    //}
1419 1439
                                 }
1420 1440
 
1421 1441
                                 #region 声音路径

+ 5 - 4
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs

@@ -1,8 +1,7 @@
1
-using CallCenterApi.Common;
1
+using CallCenter.Utility;
2 2
 using CallCenterApi.Interface.Models.Common;
3 3
 using System;
4 4
 using System.Collections.Generic;
5
-using System.Linq;
6 5
 using System.Web;
7 6
 using System.Web.Mvc;
8 7
 using System.Web.Routing;
@@ -31,8 +30,10 @@ namespace CallCenterApi.Interface
31 30
             if (string.IsNullOrWhiteSpace(token)) return;
32 31
             try
33 32
             {
34
-                //获取缓存
35
-                var dict = CacheHelper.Get(token);
33
+                ////获取缓存
34
+                //var dict = CacheHelper.Get(token);
35
+                //获取redis缓存
36
+                var dict = RedisHelper.StringGet(token);
36 37
                 if (dict == null) return;
37 38
                 Dictionary<string, string> userData = null;
38 39
                 //获取FormsAuthenticationTicket对象

+ 3 - 5
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Web.config

@@ -10,11 +10,9 @@
10 10
     <add key="ClientValidationEnabled" value="true"/>
11 11
     <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
12 12
     <add key="DESKey" value="123456789"/>
13
-    <!--中鑫之宝短信配置-->
14
-    <add key="smsurl" value="http://api.1086sms.com/api/"/>
15
-    <add key="smsusername" value="zxzb"/>
16
-    <add key="smspassword" value="zxzb123"/>
17
-    <add key="smssign" value="中鑫之宝"/>
13
+    <!-- ================== Redis配置 ================== -->
14
+    <add key="Redis_Server" value="192.168.4.18"/>
15
+    <add key="Redis_Port" value="6379"/>
18 16
   </appSettings>
19 17
   <connectionStrings>
20 18
     <add name="ConnectionString" connectionString="Data Source=192.168.4.18;User ID=sa;pwd=800100;Initial Catalog=HBSZRX;"/>

+ 9 - 0
API/CallCenterApi/CallCenterApi.Model/T_Bus_AssignedInfo.cs

@@ -23,6 +23,7 @@ namespace CallCenterApi.Model
23 23
         private string _f_submitusercode;
24 24
         private DateTime? _f_submitdate;
25 25
         private bool _f_isread;
26
+        private DateTime? _f_readdate;
26 27
         private int? _f_state;
27 28
         private string _f_backreason;
28 29
         private int? _f_resultstate;
@@ -136,6 +137,14 @@ namespace CallCenterApi.Model
136 137
             get { return _f_isread; }
137 138
         }
138 139
         /// <summary>
140
+        /// 查看时间
141
+        /// </summary>
142
+        public DateTime? F_ReadDate
143
+        {
144
+            set { _f_readdate = value; }
145
+            get { return _f_readdate; }
146
+        }
147
+        /// <summary>
139 148
         /// 是否处理(0:未处理,1:已处理,2:退回)
140 149
         /// </summary>
141 150
         public int? F_State

+ 5 - 0
API/CallCenterCommon/CallCenter.Utility/CallCenter.Utility.csproj

@@ -54,10 +54,14 @@
54 54
       <HintPath>..\..\packages\NPOI.2.3.0\lib\net40\NPOI.OpenXmlFormats.dll</HintPath>
55 55
       <Private>True</Private>
56 56
     </Reference>
57
+    <Reference Include="StackExchange.Redis, Version=1.2.6.0, Culture=neutral, processorArchitecture=MSIL">
58
+      <HintPath>..\..\packages\StackExchange.Redis.1.2.6\lib\net45\StackExchange.Redis.dll</HintPath>
59
+    </Reference>
57 60
     <Reference Include="System" />
58 61
     <Reference Include="System.Configuration" />
59 62
     <Reference Include="System.Core" />
60 63
     <Reference Include="System.Drawing" />
64
+    <Reference Include="System.IO.Compression" />
61 65
     <Reference Include="System.Web" />
62 66
     <Reference Include="System.Xml.Linq" />
63 67
     <Reference Include="System.Data.DataSetExtensions" />
@@ -74,6 +78,7 @@
74 78
     <Compile Include="EncryptHelper.cs" />
75 79
     <Compile Include="FileUp.cs" />
76 80
     <Compile Include="Linq\PredicateExtensionses.cs" />
81
+    <Compile Include="RedisHelper.cs" />
77 82
     <Compile Include="Time\DateTimeConvert.cs" />
78 83
     <Compile Include="VerifyCode\VerifyCode.cs" />
79 84
     <Compile Include="Zip\GZip.cs" />

+ 790 - 0
API/CallCenterCommon/CallCenter.Utility/RedisHelper.cs

@@ -0,0 +1,790 @@
1
+using System;
2
+using StackExchange.Redis;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using Newtonsoft.Json;
6
+using System.Collections;
7
+
8
+namespace CallCenter.Utility
9
+{
10
+    public class RedisHelper
11
+    {
12
+        #region 
13
+        //执行顺序---静态字段---静态构造函数---构造函数
14
+        private static ConnectionMultiplexer redis;
15
+
16
+        static RedisHelper()
17
+        {
18
+            if (redis == null || !redis.IsConnected)
19
+            {
20
+                redis = ConnectionMultiplexer.Connect(Configs.GetValue("Redis_Server") + ":" + Configs.GetValue("Redis_Port"));
21
+                //redis = ConnectionMultiplexer.Connect("192.168.4.18, abortConnect=false");
22
+            }
23
+        }
24
+
25
+        #endregion
26
+
27
+        #region redis 字符串(string)操作
28
+
29
+        /// <summary>
30
+        /// 设置指定键的值
31
+        /// </summary>
32
+        /// <param name="key"></param>
33
+        /// <param name="value"></param>
34
+        /// <returns></returns>
35
+        public static bool StringSet(string key, string value)
36
+        {
37
+            return redis.GetDatabase().StringSet(key, value);
38
+        }
39
+
40
+        /// <summary>
41
+        /// 获取指定键的值
42
+        /// </summary>
43
+        /// <param name="key"></param>
44
+        /// <returns></returns>
45
+        public static object StringGet(string key)
46
+        {
47
+            var rt = redis.GetDatabase().StringGet(key);
48
+
49
+            if (rt.IsNull)
50
+            {
51
+                return null;
52
+            }
53
+            else
54
+            {
55
+                return rt;
56
+            }
57
+        }
58
+
59
+        /// <summary>
60
+        /// 获取存储在键上的字符串的子字符串
61
+        /// </summary>
62
+        /// <param name="key"></param>
63
+        /// <param name="start"></param>
64
+        /// <param name="end"></param>
65
+        /// <returns></returns>
66
+        public static object StringGet(string key, int start, int end)
67
+        {
68
+            var rt = redis.GetDatabase().StringGetRange(key, start, end);
69
+            if (rt.IsNull)
70
+            {
71
+                return null;
72
+            }
73
+            else
74
+            {
75
+                return rt;
76
+            }
77
+        }
78
+
79
+        /// <summary>
80
+        /// 设置键的字符串值并返回其旧值
81
+        /// </summary>
82
+        /// <param name="key"></param>
83
+        /// <param name="value"></param>
84
+        /// <returns></returns>
85
+        public static object StringGetAndSet(string key, string value)
86
+        {
87
+            var rt = redis.GetDatabase().StringGetSet(key, value);
88
+            if (rt.IsNull)
89
+            {
90
+                return null;
91
+            }
92
+            else
93
+            {
94
+                return rt;
95
+            }
96
+        }
97
+
98
+        /// <summary>
99
+        /// 返回在键处存储的字符串值中偏移处的位值
100
+        /// </summary>
101
+        /// <param name="key"></param>
102
+        /// <param name="offset"></param>
103
+        /// <returns></returns>
104
+        public static bool StringGetBit(string key, long offset)
105
+        {
106
+            return redis.GetDatabase().StringGetBit(key, offset);
107
+        }
108
+
109
+        /// <summary>
110
+        /// 获取所有给定键的值
111
+        /// </summary>
112
+        /// <param name="keys"></param>
113
+        /// <returns></returns>
114
+        public static List<object> StringMultiGet(string[] keys)
115
+        {
116
+            List<object> list = new List<object>();
117
+            for (int i = 0; i < keys.Length; i++)
118
+            {
119
+                list.Add(redis.GetDatabase().StringGet(keys[i]));
120
+            }
121
+            return list;
122
+        }
123
+
124
+        /// <summary>
125
+        /// 存储在键上的字符串值中设置或清除偏移处的位
126
+        /// </summary>
127
+        /// <param name="key"></param>
128
+        /// <param name="offset"></param>
129
+        /// <param name="value"></param>
130
+        /// <returns></returns>
131
+        public static bool StringSetBit(string key, long offset)
132
+        {
133
+            return redis.GetDatabase().StringSetBit(key, offset, true);
134
+        }
135
+
136
+        /// <summary>
137
+        /// 使用键和到期时间来设置值
138
+        /// </summary>
139
+        /// <param name="key"></param>
140
+        /// <param name="value"></param>
141
+        /// <param name="expiry"></param>
142
+        /// <returns></returns>
143
+        public static bool StringSet(string key, string value, TimeSpan expiry)
144
+        {
145
+            return redis.GetDatabase().StringSet(key, value, expiry);
146
+        }
147
+
148
+        /// <summary>
149
+        /// 设置键的值,仅当键不存在时
150
+        /// </summary>
151
+        /// <param name="key"></param>
152
+        /// <param name="value"></param>
153
+        /// <returns></returns>
154
+        public static void StringSetIfAbsent(string key, string value)
155
+        {
156
+            if (redis.GetDatabase().StringGet(key) == RedisValue.Null)
157
+            {
158
+                redis.GetDatabase().StringSet(key, value);
159
+            }
160
+        }
161
+
162
+        /// <summary>
163
+        /// 在指定偏移处开始的键处覆盖字符串的一部分
164
+        /// </summary>
165
+        /// <param name="key">键值</param>
166
+        /// <param name="value">值</param>
167
+        /// <param name="offset">偏移量</param>
168
+        /// <returns></returns>
169
+        public static object StringSet(string key, long offset, string value)
170
+        {
171
+            return redis.GetDatabase().StringSetRange(key, offset, value);
172
+        }
173
+
174
+        /// <summary>
175
+        /// 获取存储在键中的值的长度
176
+        /// </summary>
177
+        /// <param name="key">键值</param>
178
+        /// <returns></returns>
179
+        public static long StringSize(string key)
180
+        {
181
+            return redis.GetDatabase().StringLength(key);
182
+        }
183
+
184
+        /// <summary>
185
+        /// 为多个键分别设置它们的值
186
+        /// </summary>
187
+        /// <param name="keys"></param>
188
+        /// <returns></returns>
189
+        public static void StringMultiSet(Dictionary<string, string> dic)
190
+        {
191
+            foreach (KeyValuePair<string, string> key in dic)
192
+            {
193
+                redis.GetDatabase().StringSet(key.Key, key.Value);
194
+            }
195
+        }
196
+
197
+        /// <summary>
198
+        /// 为多个键分别设置它们的值,仅当键不存在时
199
+        /// </summary>
200
+        /// <param name="keys">键值集合</param>
201
+        /// <returns></returns>
202
+        public static void StringMultiSetIfAbsent(Dictionary<string, string> dic)
203
+        {
204
+            foreach (KeyValuePair<string, string> key in dic)
205
+            {
206
+                //判断键值是否存在
207
+                if (redis.GetDatabase().StringGet(key.Key) == RedisValue.Null)
208
+                {
209
+                    redis.GetDatabase().StringSet(key.Key, key.Value);
210
+                }
211
+            }
212
+        }
213
+
214
+        /// <summary>
215
+        /// 将键的整数值按给定的数值增加
216
+        /// </summary>
217
+        /// <param name="key">键值</param>
218
+        /// <param name="value">给定的数值</param>
219
+        /// <returns></returns>
220
+        public static double StringIncrement(string key, double value)
221
+        {
222
+            return redis.GetDatabase().StringIncrement(key, value);
223
+        }
224
+
225
+        /// <summary>
226
+        /// 在key键对应值的右面追加值value
227
+        /// </summary>
228
+        /// <param name="key"></param>
229
+        /// <param name="value"></param>
230
+        /// <returns></returns>
231
+        public static long StringAppend(string key, string value)
232
+        {
233
+            return redis.GetDatabase().StringAppend(key, value);
234
+        }
235
+
236
+        /// <summary>
237
+        /// 删除某个键值
238
+        /// </summary>
239
+        /// <param name="key"></param>
240
+        /// <returns></returns>
241
+        public static bool StringDelete(string key)
242
+        {
243
+            return false;
244
+        }
245
+
246
+        #endregion
247
+
248
+        #region redis 哈希/散列/字典(Hash)操作
249
+
250
+        /// <summary>
251
+        /// 删除指定的哈希字段
252
+        /// </summary>
253
+        /// <param name="key"></param>
254
+        /// <param name="field"></param>
255
+        /// <returns></returns>
256
+        public static bool HashDelete(string key, string field)
257
+        {
258
+            return redis.GetDatabase().HashDelete(key, field);
259
+        }
260
+
261
+        /// <summary>
262
+        /// 判断是否存在散列字段
263
+        /// </summary>
264
+        /// <param name=""></param>
265
+        /// <param name=""></param>
266
+        /// <returns></returns>
267
+        public static bool HashHasKey(string key, string field)
268
+        {
269
+            return redis.GetDatabase().HashExists(key, field);
270
+        }
271
+
272
+        /// <summary>
273
+        /// 获取存储在指定键的哈希字段的值
274
+        /// </summary>
275
+        /// <param name="key"></param>
276
+        /// <param name="field"></param>
277
+        /// <returns></returns>
278
+        public static object HashGet(string key, string field)
279
+        {
280
+            return redis.GetDatabase().HashGet(key, field);
281
+        }
282
+
283
+        /// <summary>
284
+        /// 获取存储在指定键的哈希中的所有字段和值
285
+        /// </summary>
286
+        /// <param name="key"></param>
287
+        /// <returns></returns>
288
+        public static Dictionary<string, object> HashGetAll(string key)
289
+        {
290
+            Dictionary<string, object> dic = new Dictionary<string, object>();
291
+            var collection = redis.GetDatabase().HashGetAll(key);
292
+            foreach (var item in collection)
293
+            {
294
+                dic.Add(item.Name, item.Value);
295
+            }
296
+            return dic;
297
+        }
298
+
299
+        /// <summary>
300
+        /// 将哈希字段的浮点值按给定数值增加
301
+        /// </summary>
302
+        /// <param name="key"></param>
303
+        /// <param name="field"></param>
304
+        /// <param name="value">给定的数值</param>
305
+        /// <returns></returns>
306
+        public static double HashIncrement(string key, string field, double value)
307
+        {
308
+            return redis.GetDatabase().HashIncrement(key, field, value);
309
+        }
310
+
311
+        /// <summary>
312
+        /// 获取哈希中的所有字段
313
+        /// </summary>
314
+        /// <param name="key"></param>
315
+        /// <returns></returns>
316
+        public static string[] HashKeys(string key)
317
+        {
318
+            return redis.GetDatabase().HashKeys(key).ToStringArray();
319
+        }
320
+
321
+        /// <summary>
322
+        /// 获取散列中的字段数量
323
+        /// </summary>
324
+        /// <param name="key"></param>
325
+        /// <returns></returns>
326
+        public static long HashSize(string key)
327
+        {
328
+            return redis.GetDatabase().HashLength(key);
329
+        }
330
+
331
+        /// <summary>
332
+        /// 获取所有给定哈希字段的值
333
+        /// </summary>
334
+        /// <param name="key"></param>
335
+        /// <param name="hashKeys"></param>
336
+        /// <returns></returns>
337
+        public static List<object> HashMultiGet(string key, List<string> hashKeys)
338
+        {
339
+            List<object> result = new List<object>();
340
+            foreach (string field in hashKeys)
341
+            {
342
+                result.Add(redis.GetDatabase().HashGet(key, field));
343
+            }
344
+            return result;
345
+        }
346
+
347
+        /// <summary>
348
+        /// 为多个哈希字段分别设置它们的值
349
+        /// </summary>
350
+        /// <param name="key"></param>
351
+        /// <param name="dic"></param>
352
+        /// <returns></returns>
353
+        public static void HashPutAll(string key, Dictionary<string, string> dic)
354
+        {
355
+            List<HashEntry> list = new List<HashEntry>();
356
+            for (int i = 0; i < dic.Count; i++)
357
+            {
358
+                KeyValuePair<string, string> param = dic.ElementAt(i);
359
+                list.Add(new HashEntry(param.Key, param.Value));
360
+            }
361
+            redis.GetDatabase().HashSet(key, list.ToArray());
362
+        }
363
+
364
+        /// <summary>
365
+        /// 设置散列字段的字符串值
366
+        /// </summary>
367
+        /// <param name="key"></param>
368
+        /// <param name="field"></param>
369
+        /// <param name="value"></param>
370
+        /// <returns></returns>
371
+        public static void HashPut(string key, string field, string value)
372
+        {
373
+            redis.GetDatabase().HashSet(key, new HashEntry[] { new HashEntry(field, value) });
374
+        }
375
+
376
+        /// <summary>
377
+        /// 仅当字段不存在时,才设置散列字段的值
378
+        /// </summary>
379
+        /// <param name="key"></param>
380
+        /// <param name="fiels"></param>
381
+        /// <param name="value"></param>
382
+        /// <returns></returns>
383
+        public static void HashPutIfAbsent(string key, string field, string value)
384
+        {
385
+            if (!HashHasKey(key, field))
386
+            {
387
+                redis.GetDatabase().HashSet(key, new HashEntry[] { new HashEntry(field, value) });
388
+            }
389
+        }
390
+
391
+        /// <summary>
392
+        /// 获取哈希中的所有值
393
+        /// </summary>
394
+        /// <param name="key"></param>
395
+        /// <returns></returns>
396
+        public static string[] HashValues(string key)
397
+        {
398
+            return redis.GetDatabase().HashValues(key).ToStringArray();
399
+        }
400
+
401
+        /// <summary>
402
+        /// redis中获取指定键的值并返回对象
403
+        /// </summary>
404
+        /// <typeparam name="T"></typeparam>
405
+        /// <param name="key"></param>
406
+        /// <returns></returns>
407
+        public static T GetHashValue<T>(string key)
408
+        {
409
+            HashEntry[] array = redis.GetDatabase().HashGetAll(key);
410
+            Dictionary<string, object> dic = new Dictionary<string, object>();
411
+            for (int i = 0; i < array.Length; i++)
412
+            {
413
+                dic.Add(array[i].Name, array[i].Value);
414
+            }
415
+            if (dic.Count > 0)
416
+            {
417
+                string strJson = JsonConvert.SerializeObject(dic);
418
+                return JsonConvert.DeserializeObject<T>(strJson);
419
+            }
420
+            else
421
+            {
422
+                return default(T);
423
+            }
424
+        }
425
+
426
+        /// <summary>
427
+        /// 把指定对象存储在键值为key的redis中
428
+        /// </summary>
429
+        /// <typeparam name="T"></typeparam>
430
+        /// <param name="t"></param>
431
+        /// <param name="key"></param>
432
+        public static void SetHashValue<T>(T t, string key)
433
+        {
434
+            string strJson = JsonConvert.SerializeObject(t);
435
+            Dictionary<string, string> param = JsonConvert.DeserializeObject<Dictionary<string, string>>(strJson);
436
+            HashPutAll(key, param);
437
+        }
438
+
439
+        #endregion
440
+
441
+        #region redis 列表(List)操作
442
+
443
+        /// <summary>
444
+        /// 从左向右存压栈
445
+        /// </summary>
446
+        /// <param name="key"></param>
447
+        /// <param name="value"></param>
448
+        /// <returns></returns>
449
+        public static long ListLeftPush(string key, string value)
450
+        {
451
+            return redis.GetDatabase().ListLeftPush(key, value);
452
+        }
453
+
454
+        /// <summary>
455
+        /// 从左出栈
456
+        /// </summary>
457
+        /// <param name="key"></param>
458
+        /// <returns></returns>
459
+        public static object ListLeftPop(string key)
460
+        {
461
+            return redis.GetDatabase().ListLeftPop(key);
462
+        }
463
+
464
+        /// <summary>
465
+        /// 队/栈长
466
+        /// </summary>
467
+        /// <param name="key"></param>
468
+        /// <returns></returns>
469
+        public static long ListSize(string key)
470
+        {
471
+            return redis.GetDatabase().ListLength(key);
472
+        }
473
+
474
+        /// <summary>
475
+        /// 范围检索,返回List
476
+        /// </summary>
477
+        /// <param name="key"></param>
478
+        /// <param name="start"></param>
479
+        /// <param name="end"></param>
480
+        /// <returns></returns>
481
+        public static string[] ListRange(string key, int start, int end)
482
+        {
483
+            return redis.GetDatabase().ListRange(key, start, end).ToStringArray();
484
+        }
485
+
486
+        /// <summary>
487
+        /// 移除key中值为value的i个,返回删除的个数;如果没有这个元素则返回0 
488
+        /// </summary>
489
+        /// <param name="key"></param>
490
+        /// <param name="i"></param>
491
+        /// <param name="value"></param>
492
+        /// <returns></returns>
493
+        public static long ListRemove(string key, string value)
494
+        {
495
+            return redis.GetDatabase().ListRemove(key, value);
496
+        }
497
+
498
+        /// <summary>
499
+        /// 检索
500
+        /// </summary>
501
+        /// <param name="key"></param>
502
+        /// <param name="index"></param>
503
+        /// <returns></returns>
504
+        public static object ListIndex(string key, long index)
505
+        {
506
+            return redis.GetDatabase().ListGetByIndex(key, index);
507
+        }
508
+
509
+        /// <summary>
510
+        /// 赋值
511
+        /// </summary>
512
+        /// <param name="key"></param>
513
+        /// <param name="index"></param>
514
+        /// <param name="value"></param>
515
+        /// <returns></returns>
516
+        public static void ListSet(string key, int index, string value)
517
+        {
518
+            redis.GetDatabase().ListSetByIndex(key, index, value);
519
+        }
520
+
521
+        /// <summary>
522
+        /// 裁剪,删除除了[start,end]以外的所有元素 
523
+        /// </summary>
524
+        /// <param name="key"></param>
525
+        /// <param name="start"></param>
526
+        /// <param name="end"></param>
527
+        /// <returns></returns>
528
+        public static void ListTrim(string key, int start, int end)
529
+        {
530
+            redis.GetDatabase().ListTrim(key, start, end);
531
+        }
532
+
533
+        /// <summary>
534
+        /// 将源key的队列的右边的一个值删除,然后塞入目标key的队列的左边,返回这个值
535
+        /// </summary>
536
+        /// <param name="sourceKey"></param>
537
+        /// <param name="destinationKey"></param>
538
+        /// <returns></returns>
539
+        public static object ListRightPopAndLeftPush(string sourceKey, string destinationKey)
540
+        {
541
+            return redis.GetDatabase().ListRightPopLeftPush(sourceKey, destinationKey);
542
+        }
543
+
544
+        #endregion
545
+
546
+        #region redis 集合(Set)操作
547
+
548
+        /// <summary>
549
+        /// 集合添加元素
550
+        /// </summary>
551
+        /// <param name="key"></param>
552
+        /// <param name="value"></param>
553
+        public static void SetAdd(string key, string value)
554
+        {
555
+            redis.GetDatabase().SetAdd(key, value);
556
+        }
557
+
558
+        /// <summary>
559
+        /// 集合组合操作
560
+        /// </summary>
561
+        /// <param name="point">操作标示:0--并集;1--交集;2--差集</param>
562
+        /// <param name="firstKey">第一个集合的键值</param>
563
+        /// <param name="secondKey">第二个集合的键值</param>
564
+        public static string[] SetCombine(int point, string firstKey, string secondKey)
565
+        {
566
+            RedisValue[] array;
567
+            switch (point)
568
+            {
569
+                case 0:
570
+                    array = redis.GetDatabase().SetCombine(SetOperation.Union, firstKey, secondKey);
571
+                    break;
572
+                case 1:
573
+                    array = redis.GetDatabase().SetCombine(SetOperation.Intersect, firstKey, secondKey);
574
+                    break;
575
+                case 2:
576
+                    array = redis.GetDatabase().SetCombine(SetOperation.Difference, firstKey, secondKey);
577
+                    break;
578
+                default:
579
+                    array = new RedisValue[0];
580
+                    break;
581
+            }
582
+            return array.ToStringArray();
583
+        }
584
+
585
+        /// <summary>
586
+        /// 
587
+        /// </summary>
588
+        /// <param name="key"></param>
589
+        /// <param name="value"></param>
590
+        /// <returns></returns>
591
+        public static bool SetContains(string key, string value)
592
+        {
593
+            return redis.GetDatabase().SetContains(key, value);
594
+        }
595
+
596
+        /// <summary>
597
+        /// 返回对应键值集合的长度
598
+        /// </summary>
599
+        /// <param name="key"></param>
600
+        /// <returns></returns>
601
+        public static long SetLength(string key)
602
+        {
603
+            return redis.GetDatabase().SetLength(key);
604
+        }
605
+
606
+        /// <summary>
607
+        /// 根据键值返回集合中所有的value
608
+        /// </summary>
609
+        /// <param name="key"></param>
610
+        /// <returns></returns>
611
+        public static string[] SetMembers(string key)
612
+        {
613
+            return redis.GetDatabase().SetMembers(key).ToStringArray();
614
+        }
615
+
616
+        /// <summary>
617
+        /// 将成员从源集移动到目标集
618
+        /// </summary>
619
+        /// <param name="sourceKey">源集key</param>
620
+        /// <param name="destinationKey">目标集key</param>
621
+        /// <param name="value"></param>
622
+        public static bool SetMove(string sourceKey, string destinationKey, string value)
623
+        {
624
+            return redis.GetDatabase().SetMove(sourceKey, destinationKey, value);
625
+        }
626
+
627
+        /// <summary>
628
+        /// 移除集合中指定键值随机元素
629
+        /// </summary>
630
+        /// <param name="key"></param>
631
+        public static string SetPop(string key)
632
+        {
633
+            return redis.GetDatabase().SetPop(key);
634
+        }
635
+
636
+        /// <summary>
637
+        /// 返回集合中指定键值随机元素
638
+        /// </summary>
639
+        /// <param name="key"></param>
640
+        /// <returns></returns>
641
+        public static string SetRandomMember(string key)
642
+        {
643
+            return redis.GetDatabase().SetRandomMember(key);
644
+        }
645
+
646
+        /// <summary>
647
+        /// 
648
+        /// </summary>
649
+        /// <param name="key"></param>
650
+        /// <param name="count"></param>
651
+        public static string[] SetRandomMembers(string key, long count)
652
+        {
653
+            return redis.GetDatabase().SetRandomMembers(key, count).ToStringArray();
654
+        }
655
+
656
+        /// <summary>
657
+        /// 移除集合中指定key值和value
658
+        /// </summary>
659
+        /// <param name="key"></param>
660
+        /// <param name="value"></param>
661
+        public static void SetRemove(string key, string value)
662
+        {
663
+            redis.GetDatabase().SetRemove(key, value);
664
+        }
665
+
666
+        /// <summary>
667
+        /// 
668
+        /// </summary>
669
+        /// <param name="key"></param>
670
+        public static void SetScan(string key)
671
+        {
672
+            redis.GetDatabase().SetScan(key);
673
+        }
674
+
675
+        #endregion
676
+
677
+        #region redis 有序集合(sorted set)操作
678
+
679
+        public static void Method(string key, string value, double score)
680
+        {
681
+            redis.GetDatabase().SortedSetAdd(key, new SortedSetEntry[] { new SortedSetEntry(value, score) });
682
+        }
683
+
684
+        #endregion
685
+
686
+        #region redis 键(Key)操作
687
+
688
+        /// <summary>
689
+        /// 获取 Key
690
+        /// </summary>
691
+        /// <param name="redisKey"></param>
692
+        /// <returns></returns>
693
+        //public static IEnumerable<RedisKey> GetKeyList(string redisKey)
694
+        //{
695
+        //    var server = redis.GetServer(Configs.GetValue("Redis_Server"), Configs.GetValue("Redis_Port"));
696
+        //    return server.Keys(pattern: "*"+ redisKey + "*");
697
+        //}
698
+        public static List<string> GetKeyList(string redisKey)
699
+        {
700
+            var server = redis.GetServer(Configs.GetValue("Redis_Server"), Int32.Parse(Configs.GetValue("Redis_Port")));
701
+            List<string> keylist = new List<string>();
702
+            var redisenum = server.Keys(pattern: "*" + redisKey + "*");
703
+            foreach (var r in redisenum.ToList())
704
+            {
705
+                keylist.Add(r.ToString());
706
+            }
707
+            return keylist;
708
+        }
709
+
710
+        /// <summary>
711
+        /// 移除指定 Key
712
+        /// </summary>
713
+        /// <param name="redisKey"></param>
714
+        /// <returns></returns>
715
+        public static bool KeyDelete(string redisKey)
716
+        {
717
+            return redis.GetDatabase().KeyDelete(redisKey);
718
+        }
719
+
720
+        /// <summary>
721
+        /// 移除指定 Key
722
+        /// </summary>
723
+        /// <param name="redisKey"></param>
724
+        /// <returns></returns>
725
+        //public static long KeysDelete(IEnumerable<RedisKey> redisKeys)
726
+        //{
727
+        //    return redis.GetDatabase().KeyDelete(redisKeys.ToArray());
728
+        //}
729
+        public static long KeysDelete(List<string> redisKeys)
730
+        {
731
+            int n = 0;
732
+            foreach (var r in redisKeys)
733
+            {
734
+                if (redis.GetDatabase().KeyDelete(r))
735
+                {
736
+                    n++;
737
+                }
738
+            }
739
+            return n;
740
+        }
741
+
742
+        /// <summary>
743
+        /// 校验 Key 是否存在
744
+        /// </summary>
745
+        /// <param name="redisKey"></param>
746
+        /// <returns></returns>
747
+        public static bool KeyExists(string redisKey)
748
+        {
749
+            return redis.GetDatabase().KeyExists(redisKey);
750
+        }
751
+
752
+        /// <summary>
753
+        /// 重命名 Key
754
+        /// </summary>
755
+        /// <param name="redisKey"></param>
756
+        /// <param name="redisNewKey"></param>
757
+        /// <returns></returns>
758
+        public static bool KeyRename(string redisKey, string redisNewKey)
759
+        {
760
+            return redis.GetDatabase().KeyRename(redisKey, redisNewKey);
761
+        }
762
+
763
+        /// <summary>
764
+        /// 设置 Key 的时间
765
+        /// </summary>
766
+        /// <param name="redisKey"></param>
767
+        /// <param name="expiry"></param>
768
+        /// <returns></returns>
769
+        public static bool KeyExpire(string redisKey, TimeSpan? expiry)
770
+        {
771
+            return redis.GetDatabase().KeyExpire(redisKey, expiry);
772
+        }
773
+
774
+        #endregion
775
+
776
+        /// <summary>
777
+        /// 获取key过期时间
778
+        /// </summary>
779
+        /// <param name="redisKey"></param>
780
+        /// <returns></returns>
781
+        public static string GetKeyOutTime(string redisKey)
782
+        {
783
+            var server = redis.GetServer(Configs.GetValue("Redis_Server"), Int32.Parse(Configs.GetValue("Redis_Port")));
784
+            var timeNow = server.Time().ToUniversalTime();
785
+            var time = redis.GetDatabase().KeyTimeToLive(redisKey);
786
+            var expire = time == null ? (DateTime?)null : timeNow.Add(time.Value); //返回UTC时间。
787
+            return expire.Value.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss");
788
+        }
789
+    }
790
+}

+ 1 - 0
API/CallCenterCommon/CallCenter.Utility/packages.config

@@ -4,4 +4,5 @@
4 4
   <package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
5 5
   <package id="NPOI" version="2.3.0" targetFramework="net45" />
6 6
   <package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
7
+  <package id="StackExchange.Redis" version="1.2.6" targetFramework="net45" />
7 8
 </packages>