|
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+using CallCenterApi.DB;
|
|
|
2
|
+using CallCenterApi.Interface.Controllers.Base;
|
|
|
3
|
+using System;
|
|
|
4
|
+using System.Collections.Generic;
|
|
|
5
|
+using System.Data;
|
|
|
6
|
+using System.Data.SqlClient;
|
|
|
7
|
+using System.Linq;
|
|
|
8
|
+using System.Text;
|
|
|
9
|
+using System.Web;
|
|
|
10
|
+using System.Web.Mvc;
|
|
|
11
|
+using CallCenter.Utility;
|
|
|
12
|
+
|
|
|
13
|
+namespace CallCenterApi.Interface.Controllers
|
|
|
14
|
+{
|
|
|
15
|
+ public class BlackManageController : BaseController
|
|
|
16
|
+ {
|
|
|
17
|
+ /// <summary>
|
|
|
18
|
+ /// 添加黑名单
|
|
|
19
|
+ /// </summary>
|
|
|
20
|
+ /// <param name="telphone"></param>
|
|
|
21
|
+ /// <param name="settime"></param>
|
|
|
22
|
+ /// <param name="removetime"></param>
|
|
|
23
|
+ /// <param name="des"></param>
|
|
|
24
|
+ /// <param name="usercode"></param>
|
|
|
25
|
+ /// <returns></returns>
|
|
|
26
|
+ public ActionResult AddBlack(string telphone, string settime, string removetime, string des, string usercode)
|
|
|
27
|
+ {
|
|
|
28
|
+ DateTime btime; DateTime etime;
|
|
|
29
|
+ #region 验证
|
|
|
30
|
+ if (string.IsNullOrWhiteSpace(telphone))
|
|
|
31
|
+ {
|
|
|
32
|
+ return Error("电话号码不能为空");
|
|
|
33
|
+ }
|
|
|
34
|
+ if (string.IsNullOrWhiteSpace(settime))
|
|
|
35
|
+ {
|
|
|
36
|
+ return Error("生效时间不能为空");
|
|
|
37
|
+ }
|
|
|
38
|
+ else if (!DateTime.TryParse(settime, out btime))
|
|
|
39
|
+ {
|
|
|
40
|
+ return Error("生效时间格式不正确");
|
|
|
41
|
+ }
|
|
|
42
|
+ if (string.IsNullOrWhiteSpace(removetime))
|
|
|
43
|
+ {
|
|
|
44
|
+ return Error("失效时间不能为空");
|
|
|
45
|
+ }
|
|
|
46
|
+ else if (!DateTime.TryParse(removetime, out etime))
|
|
|
47
|
+ {
|
|
|
48
|
+ return Error("失效时间格式不正确");
|
|
|
49
|
+ }
|
|
|
50
|
+ if (string.IsNullOrWhiteSpace(usercode))
|
|
|
51
|
+ {
|
|
|
52
|
+ return Error("坐席工号不能为空");
|
|
|
53
|
+ }
|
|
|
54
|
+ #endregion
|
|
|
55
|
+ T_Call_Blacklist dModel = new T_Call_Blacklist();
|
|
|
56
|
+
|
|
|
57
|
+ dModel.F_TelPhone = telphone.Trim();
|
|
|
58
|
+ dModel.F_SetTime = Convert.ToDateTime(settime.Trim());
|
|
|
59
|
+ dModel.F_RemoveTime = Convert.ToDateTime(removetime.Trim());
|
|
|
60
|
+ dModel.F_Describe = des.Trim();
|
|
|
61
|
+ dModel.F_CreateBy = usercode;
|
|
|
62
|
+ dModel.F_CreateTime = DateTime.Now;
|
|
|
63
|
+ dModel.F_IsDelete = false;
|
|
|
64
|
+ int b = Add(dModel);
|
|
|
65
|
+ if (b > 0)
|
|
|
66
|
+ {
|
|
|
67
|
+ return Success("添加成功");
|
|
|
68
|
+ }
|
|
|
69
|
+ else
|
|
|
70
|
+ {
|
|
|
71
|
+ return Error("添加失败");
|
|
|
72
|
+ }
|
|
|
73
|
+ }
|
|
|
74
|
+ /// <summary>
|
|
|
75
|
+ /// 修改黑名单
|
|
|
76
|
+ /// </summary>
|
|
|
77
|
+ /// <param name="blackid"></param>
|
|
|
78
|
+ /// <param name="settime"></param>
|
|
|
79
|
+ /// <param name="removetime"></param>
|
|
|
80
|
+ /// <param name="des"></param>
|
|
|
81
|
+ /// <param name="usercode"></param>
|
|
|
82
|
+ /// <returns></returns>
|
|
|
83
|
+ public ActionResult UpdateBlack(int blackid, string settime, string removetime, string des, string usercode)
|
|
|
84
|
+ {
|
|
|
85
|
+ DateTime btime; DateTime etime;
|
|
|
86
|
+
|
|
|
87
|
+ #region 验证
|
|
|
88
|
+ if (blackid <= 0)
|
|
|
89
|
+ {
|
|
|
90
|
+ return Error("无效ID");
|
|
|
91
|
+ }
|
|
|
92
|
+ if (string.IsNullOrWhiteSpace(settime))
|
|
|
93
|
+ {
|
|
|
94
|
+ return Error("生效时间不能为空");
|
|
|
95
|
+ }
|
|
|
96
|
+ else if (!DateTime.TryParse(settime, out btime))
|
|
|
97
|
+ {
|
|
|
98
|
+ return Error("生效时间格式不正确");
|
|
|
99
|
+ }
|
|
|
100
|
+ if (string.IsNullOrWhiteSpace(removetime))
|
|
|
101
|
+ {
|
|
|
102
|
+ return Error("失效时间不能为空");
|
|
|
103
|
+ }
|
|
|
104
|
+ else if (!DateTime.TryParse(removetime, out etime))
|
|
|
105
|
+ {
|
|
|
106
|
+ return Error("失效时间格式不正确");
|
|
|
107
|
+ }
|
|
|
108
|
+ if (string.IsNullOrWhiteSpace(usercode))
|
|
|
109
|
+ {
|
|
|
110
|
+ return Error("坐席工号不能为空");
|
|
|
111
|
+ }
|
|
|
112
|
+ #endregion
|
|
|
113
|
+ T_Call_Blacklist dModel = GetModel(blackid);
|
|
|
114
|
+ if (dModel == null)
|
|
|
115
|
+ {
|
|
|
116
|
+ return Error("获取对象失败");
|
|
|
117
|
+ }
|
|
|
118
|
+ dModel.F_SetTime = Convert.ToDateTime(settime.Trim());
|
|
|
119
|
+ dModel.F_RemoveTime = Convert.ToDateTime(removetime.Trim());
|
|
|
120
|
+ dModel.F_Describe = des.Trim();
|
|
|
121
|
+ dModel.F_UpdateBy = usercode;
|
|
|
122
|
+ dModel.F_UpdateNum += 1;
|
|
|
123
|
+ dModel.F_UpdateTime = DateTime.Now;
|
|
|
124
|
+
|
|
|
125
|
+ bool b = Update(dModel);
|
|
|
126
|
+ if (b)
|
|
|
127
|
+ {
|
|
|
128
|
+ return Success("编辑成功");
|
|
|
129
|
+ }
|
|
|
130
|
+ else
|
|
|
131
|
+ {
|
|
|
132
|
+ return Error("编辑失败");
|
|
|
133
|
+ }
|
|
|
134
|
+ }
|
|
|
135
|
+ /// <summary>
|
|
|
136
|
+ /// 删除黑名单记录
|
|
|
137
|
+ /// </summary>
|
|
|
138
|
+ /// <param name="ids"></param>
|
|
|
139
|
+ /// <returns></returns>
|
|
|
140
|
+ public ActionResult DelCallBlack(string[] ids,string usercode)
|
|
|
141
|
+ {
|
|
|
142
|
+ if (ids != null && ids.Length > 0)
|
|
|
143
|
+ {
|
|
|
144
|
+ if (string.IsNullOrWhiteSpace(usercode))
|
|
|
145
|
+ {
|
|
|
146
|
+ return Error("坐席工号不能为空");
|
|
|
147
|
+ }
|
|
|
148
|
+ string idd = " ";
|
|
|
149
|
+ foreach (string str in ids)
|
|
|
150
|
+ {
|
|
|
151
|
+ idd += str + ",";
|
|
|
152
|
+ }
|
|
|
153
|
+ if (DeleteList(idd.TrimEnd(','), usercode,DateTime.Now))
|
|
|
154
|
+ {
|
|
|
155
|
+ return Success("删除成功");
|
|
|
156
|
+ }
|
|
|
157
|
+ else
|
|
|
158
|
+ return Error("删除失败");
|
|
|
159
|
+ }
|
|
|
160
|
+ else
|
|
|
161
|
+ {
|
|
|
162
|
+ return Error("请选择要删除的记录");
|
|
|
163
|
+ }
|
|
|
164
|
+ }
|
|
|
165
|
+ /// <summary>
|
|
|
166
|
+ /// 获取黑名单
|
|
|
167
|
+ /// </summary>
|
|
|
168
|
+ /// <param name="blackid"></param>
|
|
|
169
|
+ /// <returns></returns>
|
|
|
170
|
+ public ActionResult GetBlack(int blackid)
|
|
|
171
|
+ {
|
|
|
172
|
+ if (blackid <= 0)
|
|
|
173
|
+ {
|
|
|
174
|
+ return Error("无效ID");
|
|
|
175
|
+ }
|
|
|
176
|
+
|
|
|
177
|
+ T_Call_Blacklist dModel = GetModel(blackid);
|
|
|
178
|
+ if (dModel != null)
|
|
|
179
|
+ {
|
|
|
180
|
+ var newobj = new
|
|
|
181
|
+ {
|
|
|
182
|
+ dModel.F_BlackId,
|
|
|
183
|
+ dModel.F_TelPhone,
|
|
|
184
|
+ dModel.F_SetTime,
|
|
|
185
|
+ dModel.F_RemoveTime,
|
|
|
186
|
+ dModel.F_InterceptNum,
|
|
|
187
|
+ dModel.F_CreateBy,
|
|
|
188
|
+ dModel.F_UpdateNum
|
|
|
189
|
+ };
|
|
|
190
|
+ return Success("获取黑名单成功", newobj);
|
|
|
191
|
+ }
|
|
|
192
|
+ else
|
|
|
193
|
+ {
|
|
|
194
|
+ return Error("获取黑名单失败");
|
|
|
195
|
+ }
|
|
|
196
|
+ }
|
|
|
197
|
+ /// <summary>
|
|
|
198
|
+ /// 获取黑名单列表
|
|
|
199
|
+ /// </summary>
|
|
|
200
|
+ /// <param name="telphone"></param>
|
|
|
201
|
+ /// <param name="starttime"></param>
|
|
|
202
|
+ /// <param name="endtime"></param>
|
|
|
203
|
+ /// <returns></returns>
|
|
|
204
|
+ public ActionResult GetList(string telphone, string starttime, string endtime, string usercode)
|
|
|
205
|
+ {
|
|
|
206
|
+ string sql = " F_IsDelete=0 "; DateTime time;
|
|
|
207
|
+
|
|
|
208
|
+ if (telphone != null && telphone.Trim() != "")
|
|
|
209
|
+ {
|
|
|
210
|
+ sql += " and F_TelPhone like '%" + telphone.Trim() + "%'";
|
|
|
211
|
+ }
|
|
|
212
|
+ if (starttime != null && starttime.Trim() != "" && starttime != "undefined")
|
|
|
213
|
+ {
|
|
|
214
|
+ DateTime.TryParse(starttime, out time);
|
|
|
215
|
+ sql += " and F_SetTime >= '" + time.ToString("yyyy-MM-dd HH:mm:ss") + "' ";
|
|
|
216
|
+ }
|
|
|
217
|
+ if (endtime != null && endtime.Trim() != "" && endtime != "undefined")
|
|
|
218
|
+ {
|
|
|
219
|
+ DateTime.TryParse(endtime, out time);
|
|
|
220
|
+ sql += " and F_RemoveTime <= '" + time.ToString("yyyy-MM-dd HH:mm:ss") + "' ";
|
|
|
221
|
+ }
|
|
|
222
|
+ if (usercode != null && usercode.Trim() != "")
|
|
|
223
|
+ {
|
|
|
224
|
+ sql += " and F_CreateBy ='" + usercode.Trim() + "'";
|
|
|
225
|
+ }
|
|
|
226
|
+ var list = GetModelList(sql);
|
|
|
227
|
+ var newList = list.Select(n =>
|
|
|
228
|
+ {
|
|
|
229
|
+ return new
|
|
|
230
|
+ {
|
|
|
231
|
+ n.F_BlackId,
|
|
|
232
|
+ n.F_TelPhone,
|
|
|
233
|
+ n.F_SetTime,
|
|
|
234
|
+ n.F_RemoveTime,
|
|
|
235
|
+ n.F_InterceptNum,
|
|
|
236
|
+ n.F_CreateBy,
|
|
|
237
|
+ n.F_UpdateNum
|
|
|
238
|
+ };
|
|
|
239
|
+ });
|
|
|
240
|
+ var obj = new
|
|
|
241
|
+ {
|
|
|
242
|
+ state = "success",
|
|
|
243
|
+ message = "获取数据成功",
|
|
|
244
|
+ rows = newList,
|
|
|
245
|
+ total = newList.Count()
|
|
|
246
|
+ };
|
|
|
247
|
+ return Content(obj.ToJson());
|
|
|
248
|
+ }
|
|
|
249
|
+
|
|
|
250
|
+ #region 数据库方法
|
|
|
251
|
+ /// <summary>
|
|
|
252
|
+ /// 是否存在该记录
|
|
|
253
|
+ /// </summary>
|
|
|
254
|
+ private bool Exists(int F_BlackId)
|
|
|
255
|
+ {
|
|
|
256
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
257
|
+ strSql.Append("select count(1) from T_Call_Blacklist");
|
|
|
258
|
+ strSql.Append(" where F_BlackId=@F_BlackId");
|
|
|
259
|
+ SqlParameter[] parameters = {
|
|
|
260
|
+ new SqlParameter("@F_BlackId", SqlDbType.Int,4)
|
|
|
261
|
+ };
|
|
|
262
|
+ parameters[0].Value = F_BlackId;
|
|
|
263
|
+
|
|
|
264
|
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
|
|
|
265
|
+ }
|
|
|
266
|
+ /// <summary>
|
|
|
267
|
+ /// 增加一条数据
|
|
|
268
|
+ /// </summary>
|
|
|
269
|
+ private int Add(T_Call_Blacklist model)
|
|
|
270
|
+ {
|
|
|
271
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
272
|
+ strSql.Append("insert into T_Call_Blacklist(");
|
|
|
273
|
+ strSql.Append("F_CallId,F_TelPhone,F_SetTime,F_RemoveTime,F_Describe,F_InterceptNum,F_CreateBy,F_CreateTime,F_UpdateBy,F_UpdateTime,F_UpdateNum,F_IsDelete,F_DeleteBy,F_DeleteTime)");
|
|
|
274
|
+ strSql.Append(" values (");
|
|
|
275
|
+ strSql.Append("@F_CallId,@F_TelPhone,@F_SetTime,@F_RemoveTime,@F_Describe,@F_InterceptNum,@F_CreateBy,@F_CreateTime,@F_UpdateBy,@F_UpdateTime,@F_UpdateNum,@F_IsDelete,@F_DeleteBy,@F_DeleteTime)");
|
|
|
276
|
+ strSql.Append(";select @@IDENTITY");
|
|
|
277
|
+ SqlParameter[] parameters = {
|
|
|
278
|
+ new SqlParameter("@F_CallId", SqlDbType.VarChar,50),
|
|
|
279
|
+ new SqlParameter("@F_TelPhone", SqlDbType.NVarChar,20),
|
|
|
280
|
+ new SqlParameter("@F_SetTime", SqlDbType.DateTime),
|
|
|
281
|
+ new SqlParameter("@F_RemoveTime", SqlDbType.DateTime),
|
|
|
282
|
+ new SqlParameter("@F_Describe", SqlDbType.NVarChar,1000),
|
|
|
283
|
+ new SqlParameter("@F_InterceptNum", SqlDbType.Int,4),
|
|
|
284
|
+ new SqlParameter("@F_CreateBy", SqlDbType.NVarChar,50),
|
|
|
285
|
+ new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
|
|
|
286
|
+ new SqlParameter("@F_UpdateBy", SqlDbType.NVarChar,50),
|
|
|
287
|
+ new SqlParameter("@F_UpdateTime", SqlDbType.DateTime),
|
|
|
288
|
+ new SqlParameter("@F_UpdateNum", SqlDbType.Int,4),
|
|
|
289
|
+ new SqlParameter("@F_IsDelete", SqlDbType.Bit,1),
|
|
|
290
|
+ new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
|
|
|
291
|
+ new SqlParameter("@F_DeleteTime", SqlDbType.DateTime)};
|
|
|
292
|
+ parameters[0].Value = model.F_CallId;
|
|
|
293
|
+ parameters[1].Value = model.F_TelPhone;
|
|
|
294
|
+ parameters[2].Value = model.F_SetTime;
|
|
|
295
|
+ parameters[3].Value = model.F_RemoveTime;
|
|
|
296
|
+ parameters[4].Value = model.F_Describe;
|
|
|
297
|
+ parameters[5].Value = model.F_InterceptNum;
|
|
|
298
|
+ parameters[6].Value = model.F_CreateBy;
|
|
|
299
|
+ parameters[7].Value = model.F_CreateTime;
|
|
|
300
|
+ parameters[8].Value = model.F_UpdateBy;
|
|
|
301
|
+ parameters[9].Value = model.F_UpdateTime;
|
|
|
302
|
+ parameters[10].Value = model.F_UpdateNum;
|
|
|
303
|
+ parameters[11].Value = model.F_IsDelete;
|
|
|
304
|
+ parameters[12].Value = model.F_DeleteBy;
|
|
|
305
|
+ parameters[13].Value = model.F_DeleteTime;
|
|
|
306
|
+
|
|
|
307
|
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
|
|
|
308
|
+ if (obj == null)
|
|
|
309
|
+ {
|
|
|
310
|
+ return 0;
|
|
|
311
|
+ }
|
|
|
312
|
+ else
|
|
|
313
|
+ {
|
|
|
314
|
+ return Convert.ToInt32(obj);
|
|
|
315
|
+ }
|
|
|
316
|
+ }
|
|
|
317
|
+ /// <summary>
|
|
|
318
|
+ /// 更新一条数据
|
|
|
319
|
+ /// </summary>
|
|
|
320
|
+ private bool Update(T_Call_Blacklist model)
|
|
|
321
|
+ {
|
|
|
322
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
323
|
+ strSql.Append("update T_Call_Blacklist set ");
|
|
|
324
|
+ strSql.Append("F_CallId=@F_CallId,");
|
|
|
325
|
+ strSql.Append("F_TelPhone=@F_TelPhone,");
|
|
|
326
|
+ strSql.Append("F_SetTime=@F_SetTime,");
|
|
|
327
|
+ strSql.Append("F_RemoveTime=@F_RemoveTime,");
|
|
|
328
|
+ strSql.Append("F_Describe=@F_Describe,");
|
|
|
329
|
+ strSql.Append("F_InterceptNum=@F_InterceptNum,");
|
|
|
330
|
+ strSql.Append("F_CreateBy=@F_CreateBy,");
|
|
|
331
|
+ strSql.Append("F_CreateTime=@F_CreateTime,");
|
|
|
332
|
+ strSql.Append("F_UpdateBy=@F_UpdateBy,");
|
|
|
333
|
+ strSql.Append("F_UpdateTime=@F_UpdateTime,");
|
|
|
334
|
+ strSql.Append("F_UpdateNum=@F_UpdateNum,");
|
|
|
335
|
+ strSql.Append("F_IsDelete=@F_IsDelete,");
|
|
|
336
|
+ strSql.Append("F_DeleteBy=@F_DeleteBy,");
|
|
|
337
|
+ strSql.Append("F_DeleteTime=@F_DeleteTime");
|
|
|
338
|
+ strSql.Append(" where F_BlackId=@F_BlackId");
|
|
|
339
|
+ SqlParameter[] parameters = {
|
|
|
340
|
+ new SqlParameter("@F_CallId", SqlDbType.VarChar,50),
|
|
|
341
|
+ new SqlParameter("@F_TelPhone", SqlDbType.NVarChar,20),
|
|
|
342
|
+ new SqlParameter("@F_SetTime", SqlDbType.DateTime),
|
|
|
343
|
+ new SqlParameter("@F_RemoveTime", SqlDbType.DateTime),
|
|
|
344
|
+ new SqlParameter("@F_Describe", SqlDbType.NVarChar,1000),
|
|
|
345
|
+ new SqlParameter("@F_InterceptNum", SqlDbType.Int,4),
|
|
|
346
|
+ new SqlParameter("@F_CreateBy", SqlDbType.NVarChar,50),
|
|
|
347
|
+ new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
|
|
|
348
|
+ new SqlParameter("@F_UpdateBy", SqlDbType.NVarChar,50),
|
|
|
349
|
+ new SqlParameter("@F_UpdateTime", SqlDbType.DateTime),
|
|
|
350
|
+ new SqlParameter("@F_UpdateNum", SqlDbType.Int,4),
|
|
|
351
|
+ new SqlParameter("@F_IsDelete", SqlDbType.Bit,1),
|
|
|
352
|
+ new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
|
|
|
353
|
+ new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
|
|
|
354
|
+ new SqlParameter("@F_BlackId", SqlDbType.Int,4)};
|
|
|
355
|
+ parameters[0].Value = model.F_CallId;
|
|
|
356
|
+ parameters[1].Value = model.F_TelPhone;
|
|
|
357
|
+ parameters[2].Value = model.F_SetTime;
|
|
|
358
|
+ parameters[3].Value = model.F_RemoveTime;
|
|
|
359
|
+ parameters[4].Value = model.F_Describe;
|
|
|
360
|
+ parameters[5].Value = model.F_InterceptNum;
|
|
|
361
|
+ parameters[6].Value = model.F_CreateBy;
|
|
|
362
|
+ parameters[7].Value = model.F_CreateTime;
|
|
|
363
|
+ parameters[8].Value = model.F_UpdateBy;
|
|
|
364
|
+ parameters[9].Value = model.F_UpdateTime;
|
|
|
365
|
+ parameters[10].Value = model.F_UpdateNum;
|
|
|
366
|
+ parameters[11].Value = model.F_IsDelete;
|
|
|
367
|
+ parameters[12].Value = model.F_DeleteBy;
|
|
|
368
|
+ parameters[13].Value = model.F_DeleteTime;
|
|
|
369
|
+ parameters[14].Value = model.F_BlackId;
|
|
|
370
|
+
|
|
|
371
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
372
|
+ if (rows > 0)
|
|
|
373
|
+ {
|
|
|
374
|
+ return true;
|
|
|
375
|
+ }
|
|
|
376
|
+ else
|
|
|
377
|
+ {
|
|
|
378
|
+ return false;
|
|
|
379
|
+ }
|
|
|
380
|
+ }
|
|
|
381
|
+ /// <summary>
|
|
|
382
|
+ /// 删除一条数据
|
|
|
383
|
+ /// </summary>
|
|
|
384
|
+ private bool Delete(int F_BlackId,string usercode,DateTime deltime)
|
|
|
385
|
+ {
|
|
|
386
|
+
|
|
|
387
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
388
|
+ //strSql.Append("delete from T_Call_Blacklist ");
|
|
|
389
|
+ strSql.Append("update T_Call_Blacklist set ");
|
|
|
390
|
+ strSql.Append("F_IsDelete=1,");
|
|
|
391
|
+ strSql.Append("F_DeleteBy=@F_DeleteBy,");
|
|
|
392
|
+ strSql.Append("F_DeleteTime=@F_DeleteTime");
|
|
|
393
|
+ strSql.Append(" where F_BlackId=@F_BlackId");
|
|
|
394
|
+ SqlParameter[] parameters = {
|
|
|
395
|
+ new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
|
|
|
396
|
+ new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
|
|
|
397
|
+ new SqlParameter("@F_BlackId", SqlDbType.Int,4)
|
|
|
398
|
+ };
|
|
|
399
|
+ parameters[0].Value = F_BlackId;
|
|
|
400
|
+
|
|
|
401
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
402
|
+ if (rows > 0)
|
|
|
403
|
+ {
|
|
|
404
|
+ return true;
|
|
|
405
|
+ }
|
|
|
406
|
+ else
|
|
|
407
|
+ {
|
|
|
408
|
+ return false;
|
|
|
409
|
+ }
|
|
|
410
|
+ }
|
|
|
411
|
+ /// <summary>
|
|
|
412
|
+ /// 批量删除数据
|
|
|
413
|
+ /// </summary>
|
|
|
414
|
+ private bool DeleteList(string F_BlackIdlist, string usercode, DateTime deltime)
|
|
|
415
|
+ {
|
|
|
416
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
417
|
+ //strSql.Append("delete from T_Call_Blacklist ");
|
|
|
418
|
+ strSql.Append("update T_Call_Blacklist set ");
|
|
|
419
|
+ strSql.Append("F_IsDelete=1,");
|
|
|
420
|
+ strSql.Append("F_DeleteBy='"+ usercode + "',");
|
|
|
421
|
+ strSql.Append("F_DeleteTime='"+ deltime + "'");
|
|
|
422
|
+ strSql.Append(" where F_BlackId in (" + F_BlackIdlist + ") ");
|
|
|
423
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
|
|
|
424
|
+ if (rows > 0)
|
|
|
425
|
+ {
|
|
|
426
|
+ return true;
|
|
|
427
|
+ }
|
|
|
428
|
+ else
|
|
|
429
|
+ {
|
|
|
430
|
+ return false;
|
|
|
431
|
+ }
|
|
|
432
|
+ }
|
|
|
433
|
+ /// <summary>
|
|
|
434
|
+ /// 得到一个对象实体
|
|
|
435
|
+ /// </summary>
|
|
|
436
|
+ private T_Call_Blacklist GetModel(int F_BlackId)
|
|
|
437
|
+ {
|
|
|
438
|
+
|
|
|
439
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
440
|
+ strSql.Append("select top 1 * from T_Call_Blacklist ");
|
|
|
441
|
+ strSql.Append(" where F_BlackId=@F_BlackId and F_IsDelete=0");
|
|
|
442
|
+ SqlParameter[] parameters = {
|
|
|
443
|
+ new SqlParameter("@F_BlackId", SqlDbType.Int,4)
|
|
|
444
|
+ };
|
|
|
445
|
+ parameters[0].Value = F_BlackId;
|
|
|
446
|
+
|
|
|
447
|
+ T_Call_Blacklist model = new T_Call_Blacklist();
|
|
|
448
|
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
|
|
|
449
|
+ if (ds.Tables[0].Rows.Count > 0)
|
|
|
450
|
+ {
|
|
|
451
|
+ return DataRowToModel(ds.Tables[0].Rows[0]);
|
|
|
452
|
+ }
|
|
|
453
|
+ else
|
|
|
454
|
+ {
|
|
|
455
|
+ return null;
|
|
|
456
|
+ }
|
|
|
457
|
+ }
|
|
|
458
|
+ /// <summary>
|
|
|
459
|
+ /// 得到一个对象实体
|
|
|
460
|
+ /// </summary>
|
|
|
461
|
+ private T_Call_Blacklist DataRowToModel(DataRow row)
|
|
|
462
|
+ {
|
|
|
463
|
+ T_Call_Blacklist model = new T_Call_Blacklist();
|
|
|
464
|
+
|
|
|
465
|
+ if (row != null)
|
|
|
466
|
+ {
|
|
|
467
|
+ if (row["F_BlackId"] != null && row["F_BlackId"].ToString() != "")
|
|
|
468
|
+ {
|
|
|
469
|
+ model.F_BlackId = int.Parse(row["F_BlackId"].ToString());
|
|
|
470
|
+ }
|
|
|
471
|
+ if (row["F_CallId"] != null && row["F_CallId"].ToString() != "")
|
|
|
472
|
+ {
|
|
|
473
|
+ model.F_CallId = row["F_CallId"].ToString();
|
|
|
474
|
+ }
|
|
|
475
|
+ if (row["F_TelPhone"] != null && row["F_TelPhone"].ToString() != "")
|
|
|
476
|
+ {
|
|
|
477
|
+ model.F_TelPhone = row["F_TelPhone"].ToString();
|
|
|
478
|
+ }
|
|
|
479
|
+ if (row["F_SetTime"] != null && row["F_SetTime"].ToString() != "")
|
|
|
480
|
+ {
|
|
|
481
|
+ model.F_SetTime = DateTime.Parse(row["F_SetTime"].ToString());
|
|
|
482
|
+ }
|
|
|
483
|
+ if (row["F_RemoveTime"] != null && row["F_RemoveTime"].ToString() != "")
|
|
|
484
|
+ {
|
|
|
485
|
+ model.F_RemoveTime = DateTime.Parse(row["F_RemoveTime"].ToString());
|
|
|
486
|
+ }
|
|
|
487
|
+ if (row["F_Describe"] != null && row["F_Describe"].ToString() != "")
|
|
|
488
|
+ {
|
|
|
489
|
+ model.F_Describe = row["F_Describe"].ToString();
|
|
|
490
|
+ }
|
|
|
491
|
+ if (row["F_InterceptNum"] != null && row["F_InterceptNum"].ToString() != "")
|
|
|
492
|
+ {
|
|
|
493
|
+ model.F_InterceptNum = int.Parse(row["F_InterceptNum"].ToString());
|
|
|
494
|
+ }
|
|
|
495
|
+ if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
|
|
|
496
|
+ {
|
|
|
497
|
+ model.F_CreateBy = row["F_CreateBy"].ToString();
|
|
|
498
|
+ }
|
|
|
499
|
+ if (row["F_CreateTime"] != null && row["F_CreateTime"].ToString() != "")
|
|
|
500
|
+ {
|
|
|
501
|
+ model.F_CreateTime = DateTime.Parse(row["F_CreateTime"].ToString());
|
|
|
502
|
+ }
|
|
|
503
|
+ if (row["F_UpdateBy"] != null && row["F_UpdateBy"].ToString() != "")
|
|
|
504
|
+ {
|
|
|
505
|
+ model.F_UpdateBy = row["F_UpdateBy"].ToString();
|
|
|
506
|
+ }
|
|
|
507
|
+ if (row["F_UpdateTime"] != null && row["F_UpdateTime"].ToString() != "")
|
|
|
508
|
+ {
|
|
|
509
|
+ model.F_UpdateTime = DateTime.Parse(row["F_UpdateTime"].ToString());
|
|
|
510
|
+ }
|
|
|
511
|
+ if (row["F_UpdateNum"] != null && row["F_UpdateNum"].ToString() != "")
|
|
|
512
|
+ {
|
|
|
513
|
+ model.F_UpdateNum = int.Parse(row["F_UpdateNum"].ToString());
|
|
|
514
|
+ }
|
|
|
515
|
+ if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "")
|
|
|
516
|
+ {
|
|
|
517
|
+ if ((row["F_IsDelete"].ToString() == "1") || (row["F_IsDelete"].ToString().ToLower() == "true"))
|
|
|
518
|
+ {
|
|
|
519
|
+ model.F_IsDelete = true;
|
|
|
520
|
+ }
|
|
|
521
|
+ else
|
|
|
522
|
+ {
|
|
|
523
|
+ model.F_IsDelete = false;
|
|
|
524
|
+ }
|
|
|
525
|
+ }
|
|
|
526
|
+ if (row["F_DeleteBy"] != null && row["F_DeleteBy"].ToString() != "")
|
|
|
527
|
+ {
|
|
|
528
|
+ model.F_DeleteBy = row["F_DeleteBy"].ToString();
|
|
|
529
|
+ }
|
|
|
530
|
+ if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "")
|
|
|
531
|
+ {
|
|
|
532
|
+ model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString());
|
|
|
533
|
+ }
|
|
|
534
|
+ }
|
|
|
535
|
+ return model;
|
|
|
536
|
+ }
|
|
|
537
|
+ /// <summary>
|
|
|
538
|
+ /// 获得数据列表
|
|
|
539
|
+ /// </summary>
|
|
|
540
|
+ /// <param name="strWhere"></param>
|
|
|
541
|
+ /// <returns></returns>
|
|
|
542
|
+ private List<T_Call_Blacklist> GetModelList(string strWhere)
|
|
|
543
|
+ {
|
|
|
544
|
+ DataSet ds = GetList(strWhere);
|
|
|
545
|
+ List<T_Call_Blacklist> modelList = new List<T_Call_Blacklist>();
|
|
|
546
|
+ int rowsCount = ds.Tables[0].Rows.Count;
|
|
|
547
|
+ if (rowsCount > 0)
|
|
|
548
|
+ {
|
|
|
549
|
+ for (int n = 0; n < rowsCount; n++)
|
|
|
550
|
+ {
|
|
|
551
|
+ T_Call_Blacklist model = DataRowToModel(ds.Tables[0].Rows[n]);
|
|
|
552
|
+ modelList.Add(model);
|
|
|
553
|
+ }
|
|
|
554
|
+ }
|
|
|
555
|
+ return modelList;
|
|
|
556
|
+ }
|
|
|
557
|
+ /// <summary>
|
|
|
558
|
+ /// 获得数据列表
|
|
|
559
|
+ /// </summary>
|
|
|
560
|
+ private DataSet GetList(string strWhere)
|
|
|
561
|
+ {
|
|
|
562
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
563
|
+ strSql.Append("select * ");
|
|
|
564
|
+ strSql.Append(" FROM T_Call_Blacklist ");
|
|
|
565
|
+ if (strWhere.Trim() != "")
|
|
|
566
|
+ {
|
|
|
567
|
+ strSql.Append(" where " + strWhere);
|
|
|
568
|
+ }
|
|
|
569
|
+ return DbHelperSQL.Query(strSql.ToString());
|
|
|
570
|
+ }
|
|
|
571
|
+ /// <summary>
|
|
|
572
|
+ /// 获得前几行数据
|
|
|
573
|
+ /// </summary>
|
|
|
574
|
+ private DataSet GetList(int Top, string strWhere, string filedOrder)
|
|
|
575
|
+ {
|
|
|
576
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
577
|
+ strSql.Append("select ");
|
|
|
578
|
+ if (Top > 0)
|
|
|
579
|
+ {
|
|
|
580
|
+ strSql.Append(" top " + Top.ToString());
|
|
|
581
|
+ }
|
|
|
582
|
+ strSql.Append(" * ");
|
|
|
583
|
+ strSql.Append(" FROM T_Call_Blacklist ");
|
|
|
584
|
+ if (strWhere.Trim() != "")
|
|
|
585
|
+ {
|
|
|
586
|
+ strSql.Append(" where " + strWhere);
|
|
|
587
|
+ }
|
|
|
588
|
+ strSql.Append(" order by " + filedOrder);
|
|
|
589
|
+ return DbHelperSQL.Query(strSql.ToString());
|
|
|
590
|
+ }
|
|
|
591
|
+ /// <summary>
|
|
|
592
|
+ /// 获取记录总数
|
|
|
593
|
+ /// </summary>
|
|
|
594
|
+ private int GetRecordCount(string strWhere)
|
|
|
595
|
+ {
|
|
|
596
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
597
|
+ strSql.Append("select count(1) FROM T_Call_Blacklist ");
|
|
|
598
|
+ if (strWhere.Trim() != "")
|
|
|
599
|
+ {
|
|
|
600
|
+ strSql.Append(" where " + strWhere);
|
|
|
601
|
+ }
|
|
|
602
|
+ object obj = DbHelperSQL.GetSingle(strSql.ToString());
|
|
|
603
|
+ if (obj == null)
|
|
|
604
|
+ {
|
|
|
605
|
+ return 0;
|
|
|
606
|
+ }
|
|
|
607
|
+ else
|
|
|
608
|
+ {
|
|
|
609
|
+ return Convert.ToInt32(obj);
|
|
|
610
|
+ }
|
|
|
611
|
+ }
|
|
|
612
|
+ /// <summary>
|
|
|
613
|
+ /// 分页获取数据列表
|
|
|
614
|
+ /// </summary>
|
|
|
615
|
+ private DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
|
|
616
|
+ {
|
|
|
617
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
618
|
+ strSql.Append("SELECT * FROM ( ");
|
|
|
619
|
+ strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
|
|
620
|
+ if (!string.IsNullOrEmpty(orderby.Trim()))
|
|
|
621
|
+ {
|
|
|
622
|
+ strSql.Append("order by T." + orderby);
|
|
|
623
|
+ }
|
|
|
624
|
+ else
|
|
|
625
|
+ {
|
|
|
626
|
+ strSql.Append("order by T.F_BlackId desc");
|
|
|
627
|
+ }
|
|
|
628
|
+ strSql.Append(")AS Row, T.* from T_Call_Blacklist T ");
|
|
|
629
|
+ if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
|
630
|
+ {
|
|
|
631
|
+ strSql.Append(" WHERE " + strWhere);
|
|
|
632
|
+ }
|
|
|
633
|
+ strSql.Append(" ) TT");
|
|
|
634
|
+ strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
|
|
635
|
+ return DbHelperSQL.Query(strSql.ToString());
|
|
|
636
|
+ }
|
|
|
637
|
+ #endregion
|
|
|
638
|
+ }
|
|
|
639
|
+
|
|
|
640
|
+ public class T_Call_Blacklist
|
|
|
641
|
+ {
|
|
|
642
|
+ #region Model
|
|
|
643
|
+ /// <summary>
|
|
|
644
|
+ /// 黑名单id,自增
|
|
|
645
|
+ /// </summary>
|
|
|
646
|
+ public int F_BlackId { get; set; }
|
|
|
647
|
+ /// <summary>
|
|
|
648
|
+ /// 通话记录id
|
|
|
649
|
+ /// </summary>
|
|
|
650
|
+ public string F_CallId { get; set; }
|
|
|
651
|
+ /// <summary>
|
|
|
652
|
+ /// 电话
|
|
|
653
|
+ /// </summary>
|
|
|
654
|
+ public string F_TelPhone { get; set; }
|
|
|
655
|
+ /// <summary>
|
|
|
656
|
+ /// 设置时间
|
|
|
657
|
+ /// </summary>
|
|
|
658
|
+ public DateTime? F_SetTime { get; set; }
|
|
|
659
|
+ /// <summary>
|
|
|
660
|
+ /// 解除时间
|
|
|
661
|
+ /// </summary>
|
|
|
662
|
+ public DateTime? F_RemoveTime { get; set; }
|
|
|
663
|
+ /// <summary>
|
|
|
664
|
+ /// 说明
|
|
|
665
|
+ /// </summary>
|
|
|
666
|
+ public string F_Describe { get; set; }
|
|
|
667
|
+ /// <summary>
|
|
|
668
|
+ /// 拦截次数
|
|
|
669
|
+ /// </summary>
|
|
|
670
|
+ public int? F_InterceptNum { get; set; } = 0;
|
|
|
671
|
+ /// <summary>
|
|
|
672
|
+ ///
|
|
|
673
|
+ /// </summary>
|
|
|
674
|
+ public string F_CreateBy { get; set; }
|
|
|
675
|
+ /// <summary>
|
|
|
676
|
+ ///
|
|
|
677
|
+ /// </summary>
|
|
|
678
|
+ public DateTime? F_CreateTime { get; set; } = DateTime.Now;
|
|
|
679
|
+ /// <summary>
|
|
|
680
|
+ ///
|
|
|
681
|
+ /// </summary>
|
|
|
682
|
+ public string F_UpdateBy { get; set; }
|
|
|
683
|
+ /// <summary>
|
|
|
684
|
+ ///
|
|
|
685
|
+ /// </summary>
|
|
|
686
|
+ public DateTime? F_UpdateTime { get; set; }
|
|
|
687
|
+ /// <summary>
|
|
|
688
|
+ ///
|
|
|
689
|
+ /// </summary>
|
|
|
690
|
+ public int? F_UpdateNum { get; set; } = 0;
|
|
|
691
|
+ /// <summary>
|
|
|
692
|
+ ///
|
|
|
693
|
+ /// </summary>
|
|
|
694
|
+ public bool F_IsDelete { get; set; } = false;
|
|
|
695
|
+ /// <summary>
|
|
|
696
|
+ ///
|
|
|
697
|
+ /// </summary>
|
|
|
698
|
+ public string F_DeleteBy { get; set; }
|
|
|
699
|
+ /// <summary>
|
|
|
700
|
+ ///
|
|
|
701
|
+ /// </summary>
|
|
|
702
|
+ public DateTime? F_DeleteTime { get; set; }
|
|
|
703
|
+ #endregion Model
|
|
|
704
|
+
|
|
|
705
|
+ }
|
|
|
706
|
+}
|