|
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+using System;
|
|
|
2
|
+using System.Collections.Generic;
|
|
|
3
|
+using System.Linq;
|
|
|
4
|
+using System.Web;
|
|
|
5
|
+using System.Web.Mvc;
|
|
|
6
|
+using CallCenterApi.Interface.Controllers.Base;
|
|
|
7
|
+using System.Data;
|
|
|
8
|
+using CallCenter.Utility;
|
|
|
9
|
+using System.Configuration;
|
|
|
10
|
+using Top.Api;
|
|
|
11
|
+using Top.Api.Request;
|
|
|
12
|
+using Top.Api.Response;
|
|
|
13
|
+using CallCenterApi.Common;
|
|
|
14
|
+using System.Security.Cryptography;
|
|
|
15
|
+using System.Text;
|
|
|
16
|
+using Newtonsoft.Json.Linq;
|
|
|
17
|
+using Newtonsoft.Json;
|
|
|
18
|
+using System.IO;
|
|
|
19
|
+
|
|
|
20
|
+namespace CallCenterApi.Interface.Controllers
|
|
|
21
|
+{
|
|
|
22
|
+ public class MessageController : BaseController
|
|
|
23
|
+ {
|
|
|
24
|
+ // GET: Message
|
|
|
25
|
+ #region 接收短信
|
|
|
26
|
+ //string url = "http://47.92.26.244/sms.aspx?";
|
|
|
27
|
+ //string account = "yhyy"; string password = "yhyy190903";
|
|
|
28
|
+ string url = "";
|
|
|
29
|
+ string accName = ""; string password = "";
|
|
|
30
|
+
|
|
|
31
|
+ // string accName = "13783690587"; string password = "yhyy66";
|
|
|
32
|
+ /// <summary>
|
|
|
33
|
+ /// MD5加密
|
|
|
34
|
+ /// </summary>
|
|
|
35
|
+ /// <param name="txt"></param>
|
|
|
36
|
+ /// <returns></returns>
|
|
|
37
|
+ public static string Md5(string txt)
|
|
|
38
|
+ {
|
|
|
39
|
+ byte[] sor = Encoding.UTF8.GetBytes(txt);
|
|
|
40
|
+ MD5 md5 = MD5.Create();
|
|
|
41
|
+ byte[] result = md5.ComputeHash(sor);
|
|
|
42
|
+ StringBuilder strbul = new StringBuilder(40);
|
|
|
43
|
+ for (int i = 0; i < result.Length; i++)
|
|
|
44
|
+ {
|
|
|
45
|
+ //加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
|
|
|
46
|
+ strbul.Append(result[i].ToString("x2"));
|
|
|
47
|
+ }
|
|
|
48
|
+ return strbul.ToString().ToUpper();
|
|
|
49
|
+ }
|
|
|
50
|
+ /// <summary>
|
|
|
51
|
+ /// 发送短信
|
|
|
52
|
+ /// </summary>
|
|
|
53
|
+ /// <param name="mobile"></param>
|
|
|
54
|
+ /// <param name="time"></param>
|
|
|
55
|
+ /// <param name="timeslot"></param>
|
|
|
56
|
+ /// <param name="department"></param>
|
|
|
57
|
+ /// <param name="doctor"></param>
|
|
|
58
|
+ /// <param name="floor"></param>
|
|
|
59
|
+ /// <param name="name"></param>
|
|
|
60
|
+ /// <param name="content"></param>
|
|
|
61
|
+ /// <param name="type"></param>
|
|
|
62
|
+ /// <returns></returns>
|
|
|
63
|
+
|
|
|
64
|
+ public string SendSMS(string mobile, string sendTime, string content, int sendWay, int MBID)
|
|
|
65
|
+ {
|
|
|
66
|
+ string[] tel = mobile.Split(',');
|
|
|
67
|
+ content += "【周口郸城医院】";
|
|
|
68
|
+ foreach (var item in tel)
|
|
|
69
|
+ {
|
|
|
70
|
+ string param = string.Empty;
|
|
|
71
|
+ string mbid = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
72
|
+ if (!string.IsNullOrEmpty(sendTime))
|
|
|
73
|
+ {
|
|
|
74
|
+ string st = Convert.ToDateTime(sendTime).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
75
|
+ param = "accName=" + accName + "&accPwd=" + Md5(password) + "&aimcodes=" + item.Trim() + "&content=" + content.Trim() + "&schTime=" + st + "&dataType=json& msgId=" + mbid;
|
|
|
76
|
+ }
|
|
|
77
|
+ else
|
|
|
78
|
+ {
|
|
|
79
|
+ param = "accName=" + accName + "&accPwd=" + Md5(password) + "&aimcodes=" + item.Trim() + "&content=" + content.Trim() + "&schTime=" + "&dataType=json& msgId=" + mbid;
|
|
|
80
|
+ }
|
|
|
81
|
+ string Dataaa = HttpMethods.HttpPost(url + "send", param);
|
|
|
82
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(Dataaa);
|
|
|
83
|
+ string replyCode = jo["replyCode"].ToString();
|
|
|
84
|
+ string replyMsg = jo["replyMsg"].ToString();
|
|
|
85
|
+ int code = 0;
|
|
|
86
|
+ int.TryParse(replyCode, out code);
|
|
|
87
|
+ if (sendWay == 0)//立即发送
|
|
|
88
|
+ {
|
|
|
89
|
+ AddSMSList(sendWay, null, DateTime.Now, code, item, content, MBID);
|
|
|
90
|
+ }
|
|
|
91
|
+ else //定时发送
|
|
|
92
|
+ {
|
|
|
93
|
+ AddSMSList(sendWay, Convert.ToDateTime(sendTime), Convert.ToDateTime(sendTime), code, item, content, MBID);
|
|
|
94
|
+ }
|
|
|
95
|
+ }
|
|
|
96
|
+ return "发送成功";
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ public class CreateOrderReturnResult
|
|
|
100
|
+ {
|
|
|
101
|
+ public string state { get; set; }
|
|
|
102
|
+ public string message { get; set; }
|
|
|
103
|
+ public SmS data { get; set; }
|
|
|
104
|
+ }
|
|
|
105
|
+ public class SmS
|
|
|
106
|
+ {
|
|
|
107
|
+ public string returnstatus;
|
|
|
108
|
+ public string message;
|
|
|
109
|
+ public string remainpoint;
|
|
|
110
|
+ public string taskID;
|
|
|
111
|
+ public string successCounts;
|
|
|
112
|
+ }
|
|
|
113
|
+
|
|
|
114
|
+ /// <summary>
|
|
|
115
|
+ /// 新增短信模板
|
|
|
116
|
+ /// </summary>
|
|
|
117
|
+ /// <param name="name"></param>
|
|
|
118
|
+ /// <param name="cont"></param>
|
|
|
119
|
+ /// <param name="mName"></param>
|
|
|
120
|
+ /// <returns></returns>
|
|
|
121
|
+ public ActionResult AddTemplate(string name, string cont)
|
|
|
122
|
+ {
|
|
|
123
|
+
|
|
|
124
|
+ //int userId = CurrentUser.F_UserId;
|
|
|
125
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
126
|
+ if (userId != 0)
|
|
|
127
|
+ {
|
|
|
128
|
+ Model.T_SMS_Template dModel = new Model.T_SMS_Template();
|
|
|
129
|
+ Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
|
130
|
+ string MID = ""; string MName = "";
|
|
|
131
|
+ if (ua != null)
|
|
|
132
|
+ {
|
|
|
133
|
+ MID = ua.F_UserCode;
|
|
|
134
|
+ MName = ua.F_UserName;
|
|
|
135
|
+ }
|
|
|
136
|
+ dModel.Detail = cont.Trim();
|
|
|
137
|
+ dModel.Name = name.Trim();
|
|
|
138
|
+ dModel.MID = MID.Trim();
|
|
|
139
|
+ dModel.MName = MName.Trim();
|
|
|
140
|
+ dModel.CreateDate = DateTime.Now;
|
|
|
141
|
+ dModel.IsEnable = 0;
|
|
|
142
|
+ int b = new BLL.T_SMS_Template().Add(dModel);
|
|
|
143
|
+ if (b > 0)
|
|
|
144
|
+ {
|
|
|
145
|
+ return Success("添加成功");
|
|
|
146
|
+ }
|
|
|
147
|
+ else
|
|
|
148
|
+ {
|
|
|
149
|
+ return Success("添加失败");
|
|
|
150
|
+ }
|
|
|
151
|
+ }
|
|
|
152
|
+ else
|
|
|
153
|
+ return Error("无操作权限!");
|
|
|
154
|
+ }
|
|
|
155
|
+ /// <summary>
|
|
|
156
|
+ /// 修改短信模板
|
|
|
157
|
+ /// </summary>
|
|
|
158
|
+ /// <param name="name"></param>
|
|
|
159
|
+ /// <param name="cont"></param>
|
|
|
160
|
+ /// <param name="mName"></param>
|
|
|
161
|
+ /// <returns></returns>
|
|
|
162
|
+ public ActionResult UpdateTemplate(int id, string name, string cont)
|
|
|
163
|
+ {
|
|
|
164
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
165
|
+ if (userId != 0)
|
|
|
166
|
+ {
|
|
|
167
|
+
|
|
|
168
|
+
|
|
|
169
|
+ if (id <= 0)
|
|
|
170
|
+ return Error("参数错误!");
|
|
|
171
|
+ var model = new BLL.T_SMS_Template().GetModel(id);
|
|
|
172
|
+ if (model == null)
|
|
|
173
|
+ return Error("查询不到此模板!");
|
|
|
174
|
+ Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
|
175
|
+ string MID = ""; string MName = "";
|
|
|
176
|
+ if (ua != null)
|
|
|
177
|
+ {
|
|
|
178
|
+ MID = ua.F_UserCode;
|
|
|
179
|
+ MName = ua.F_UserName;
|
|
|
180
|
+ }
|
|
|
181
|
+ model.Detail = cont.Trim();
|
|
|
182
|
+ model.Name = name.Trim();
|
|
|
183
|
+ model.MID = MID.Trim();
|
|
|
184
|
+ model.MName = MName.Trim();
|
|
|
185
|
+ model.CreateDate = DateTime.Now;
|
|
|
186
|
+ model.IsEnable = 0;
|
|
|
187
|
+ if (new BLL.T_SMS_Template().Update(model))
|
|
|
188
|
+ {
|
|
|
189
|
+ return Success("修改成功");
|
|
|
190
|
+ }
|
|
|
191
|
+ else
|
|
|
192
|
+ {
|
|
|
193
|
+ return Error("修改失败");
|
|
|
194
|
+ }
|
|
|
195
|
+ }
|
|
|
196
|
+ else
|
|
|
197
|
+ return Error("无操作权限!");
|
|
|
198
|
+ }
|
|
|
199
|
+ /// <summary>
|
|
|
200
|
+ /// 删除短信模板
|
|
|
201
|
+ /// </summary>
|
|
|
202
|
+ /// <param name="ids"></param>
|
|
|
203
|
+ /// <returns></returns>
|
|
|
204
|
+ public ActionResult DelTemplate(string[] ids)
|
|
|
205
|
+ {
|
|
|
206
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
207
|
+ if (userId != 0)
|
|
|
208
|
+ {
|
|
|
209
|
+
|
|
|
210
|
+ if (ids != null && ids.Length > 0)
|
|
|
211
|
+ {
|
|
|
212
|
+ bool res = true;
|
|
|
213
|
+ string idd = " ";
|
|
|
214
|
+ foreach (string str in ids)
|
|
|
215
|
+ {
|
|
|
216
|
+ idd += str + ",";
|
|
|
217
|
+ }
|
|
|
218
|
+
|
|
|
219
|
+ if (!string.IsNullOrEmpty(idd.Trim()))
|
|
|
220
|
+ {
|
|
|
221
|
+ if (new BLL.T_SMS_Template().DeleteList(idd.TrimEnd(',')))
|
|
|
222
|
+ {
|
|
|
223
|
+ if (new BLL.T_SMS_Template().DeleteList(idd.TrimEnd(',')))
|
|
|
224
|
+ {
|
|
|
225
|
+
|
|
|
226
|
+ return Success("设置成功");
|
|
|
227
|
+
|
|
|
228
|
+ }
|
|
|
229
|
+ else
|
|
|
230
|
+ {
|
|
|
231
|
+ return Error("设置失败");
|
|
|
232
|
+ }
|
|
|
233
|
+ }
|
|
|
234
|
+ else
|
|
|
235
|
+ {
|
|
|
236
|
+ return Error("设置失败");
|
|
|
237
|
+ }
|
|
|
238
|
+
|
|
|
239
|
+ }
|
|
|
240
|
+ else
|
|
|
241
|
+ {
|
|
|
242
|
+ return Error("请选择工单");
|
|
|
243
|
+ }
|
|
|
244
|
+ }
|
|
|
245
|
+ else
|
|
|
246
|
+ {
|
|
|
247
|
+ return Error("获取参数失败");
|
|
|
248
|
+ }
|
|
|
249
|
+ }
|
|
|
250
|
+ else
|
|
|
251
|
+ {
|
|
|
252
|
+ return Error("无操作权限!");
|
|
|
253
|
+ }
|
|
|
254
|
+ }
|
|
|
255
|
+ /// <summary>
|
|
|
256
|
+ /// 删除短信记录列表
|
|
|
257
|
+ /// </summary>
|
|
|
258
|
+ /// <param name="ids"></param>
|
|
|
259
|
+ /// <returns></returns>
|
|
|
260
|
+ public ActionResult DelSMSList(string[] ids)
|
|
|
261
|
+ {
|
|
|
262
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
263
|
+ if (userId != 0)
|
|
|
264
|
+ {
|
|
|
265
|
+
|
|
|
266
|
+ if (ids != null && ids.Length > 0)
|
|
|
267
|
+ {
|
|
|
268
|
+ bool res = true;
|
|
|
269
|
+ string idd = " ";
|
|
|
270
|
+ foreach (string str in ids)
|
|
|
271
|
+ {
|
|
|
272
|
+ idd += str + ",";
|
|
|
273
|
+ }
|
|
|
274
|
+
|
|
|
275
|
+ if (!string.IsNullOrEmpty(idd.Trim()))
|
|
|
276
|
+ {
|
|
|
277
|
+ if (new BLL.T_SMS_List().DeleteList(idd.TrimEnd(',')))
|
|
|
278
|
+ {
|
|
|
279
|
+ if (new BLL.T_SMS_List().DeleteList(idd.TrimEnd(',')))
|
|
|
280
|
+ {
|
|
|
281
|
+
|
|
|
282
|
+ return Success("设置成功");
|
|
|
283
|
+
|
|
|
284
|
+ }
|
|
|
285
|
+ else
|
|
|
286
|
+ {
|
|
|
287
|
+ return Error("设置失败");
|
|
|
288
|
+ }
|
|
|
289
|
+ }
|
|
|
290
|
+ else
|
|
|
291
|
+ {
|
|
|
292
|
+ return Error("设置失败");
|
|
|
293
|
+ }
|
|
|
294
|
+
|
|
|
295
|
+ }
|
|
|
296
|
+ else
|
|
|
297
|
+ {
|
|
|
298
|
+ return Error("请选择工单");
|
|
|
299
|
+ }
|
|
|
300
|
+ }
|
|
|
301
|
+ else
|
|
|
302
|
+ {
|
|
|
303
|
+ return Error("获取参数失败");
|
|
|
304
|
+ }
|
|
|
305
|
+ }
|
|
|
306
|
+ else
|
|
|
307
|
+ {
|
|
|
308
|
+ return Error("无操作权限!");
|
|
|
309
|
+ }
|
|
|
310
|
+ }
|
|
|
311
|
+
|
|
|
312
|
+ /// <summary>
|
|
|
313
|
+ /// 获取短信模板列表
|
|
|
314
|
+ /// </summary>
|
|
|
315
|
+ /// <returns></returns>
|
|
|
316
|
+ public ActionResult GetTemplateList(string name, string keywords, int page = 1, int pagesize = 5)
|
|
|
317
|
+ {
|
|
|
318
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
319
|
+ if (userId != 0)
|
|
|
320
|
+ {
|
|
|
321
|
+ DataTable dt = new DataTable();
|
|
|
322
|
+ string sql = $" and IsEnable=0";
|
|
|
323
|
+ if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
|
|
|
324
|
+ sql += $" and ( Detail like '%" + keywords.Trim() + "%'or Name like '%" + keywords.Trim() + "%' or MName like '%" + keywords.Trim() + "%' ) ";
|
|
|
325
|
+ if (!string.IsNullOrWhiteSpace(name))//
|
|
|
326
|
+ sql += $" and Name like '%" + name.Trim() + "%'";
|
|
|
327
|
+ // var modellist = new BLL.T_SMS_Template().GetModelList(sql);
|
|
|
328
|
+
|
|
|
329
|
+ int recordCount = 0;
|
|
|
330
|
+ dt = BLL.PagerBLL.GetListPager(
|
|
|
331
|
+ "T_SMS_Template",
|
|
|
332
|
+ "T_SMS_Template.ID",
|
|
|
333
|
+ "*",
|
|
|
334
|
+ sql,
|
|
|
335
|
+ "ORDER BY T_SMS_Template.ID desc",
|
|
|
336
|
+ pagesize,
|
|
|
337
|
+ page,
|
|
|
338
|
+ true,
|
|
|
339
|
+ out recordCount);
|
|
|
340
|
+ List<Model.T_SMS_Template> modlelist = new BLL.T_SMS_Template().DataTableToList(dt);
|
|
|
341
|
+ List<Sms> sms = Template(modlelist);
|
|
|
342
|
+ var obj = new
|
|
|
343
|
+ {
|
|
|
344
|
+ state = "success",
|
|
|
345
|
+ message = "成功",
|
|
|
346
|
+ rows = sms,
|
|
|
347
|
+ total = recordCount
|
|
|
348
|
+
|
|
|
349
|
+ };
|
|
|
350
|
+
|
|
|
351
|
+ return Content(obj.ToJson());
|
|
|
352
|
+ }
|
|
|
353
|
+ else
|
|
|
354
|
+ return Error("无操作权限!");
|
|
|
355
|
+ }
|
|
|
356
|
+ /// <summary>
|
|
|
357
|
+ /// 获取模板详情
|
|
|
358
|
+ /// </summary>
|
|
|
359
|
+ /// <param name="id"></param>
|
|
|
360
|
+ /// <returns></returns>
|
|
|
361
|
+ public ActionResult GetContentTemp(string name)
|
|
|
362
|
+ {
|
|
|
363
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
364
|
+ if (userId != 0)
|
|
|
365
|
+ {
|
|
|
366
|
+ Model.T_SMS_Template dModel = new Model.T_SMS_Template();
|
|
|
367
|
+ string NameTyoe = "";
|
|
|
368
|
+ if (string.IsNullOrEmpty(name.Trim()))
|
|
|
369
|
+ return Error("短信类型不能为空!");
|
|
|
370
|
+ var model = new BLL.T_SMS_Template().GetModelList($"Name like '%" + name.Trim() + "%'").FirstOrDefault();
|
|
|
371
|
+
|
|
|
372
|
+ if (model == null)
|
|
|
373
|
+ return Error("查询不到此模板!");
|
|
|
374
|
+ Sms sms = Template(model);
|
|
|
375
|
+
|
|
|
376
|
+ return Success("获取成功", sms);
|
|
|
377
|
+ }
|
|
|
378
|
+ else
|
|
|
379
|
+ return Error("无操作权限!");
|
|
|
380
|
+ }
|
|
|
381
|
+ public List<Sms> Template(List<Model.T_SMS_Template> sms)
|
|
|
382
|
+ {
|
|
|
383
|
+
|
|
|
384
|
+ List<Sms> SMS = new List<Sms>();
|
|
|
385
|
+ if (sms != null)
|
|
|
386
|
+ {
|
|
|
387
|
+ foreach (var it in sms)
|
|
|
388
|
+ {
|
|
|
389
|
+ Sms t_SMS = new Sms();
|
|
|
390
|
+ t_SMS.ID = it.ID;
|
|
|
391
|
+ t_SMS.Name = it.Name;
|
|
|
392
|
+ t_SMS.Detail = it.Detail;
|
|
|
393
|
+ t_SMS.IsEnable = it.IsEnable;
|
|
|
394
|
+ t_SMS.MID = it.MID;
|
|
|
395
|
+ t_SMS.MName = it.MName;
|
|
|
396
|
+ t_SMS.CreateDate = it.CreateDate;
|
|
|
397
|
+ string NameType = "";
|
|
|
398
|
+ try
|
|
|
399
|
+ {
|
|
|
400
|
+ var dic = new BLL.T_Sys_DictionaryValue().GetModel(int.Parse(it.Name));
|
|
|
401
|
+ if (dic != null)
|
|
|
402
|
+ NameType = dic.F_Name;
|
|
|
403
|
+ }
|
|
|
404
|
+ catch
|
|
|
405
|
+ {
|
|
|
406
|
+ NameType = it.Name;
|
|
|
407
|
+ }
|
|
|
408
|
+ t_SMS.NameType = NameType;
|
|
|
409
|
+ SMS.Add(t_SMS);
|
|
|
410
|
+ }
|
|
|
411
|
+ }
|
|
|
412
|
+
|
|
|
413
|
+ return SMS;
|
|
|
414
|
+ }
|
|
|
415
|
+ public Sms Template(Model.T_SMS_Template sms)
|
|
|
416
|
+ {
|
|
|
417
|
+ Sms t_SMS = new Sms();
|
|
|
418
|
+ t_SMS.ID = sms.ID;
|
|
|
419
|
+ t_SMS.Name = sms.Name;
|
|
|
420
|
+ t_SMS.Detail = sms.Detail;
|
|
|
421
|
+ t_SMS.IsEnable = sms.IsEnable;
|
|
|
422
|
+ t_SMS.MID = sms.MID;
|
|
|
423
|
+ t_SMS.MName = sms.MName;
|
|
|
424
|
+ t_SMS.CreateDate = sms.CreateDate;
|
|
|
425
|
+ string NameType = "";
|
|
|
426
|
+ try
|
|
|
427
|
+ {
|
|
|
428
|
+ var dic = new BLL.T_Sys_DictionaryValue().GetModel(int.Parse(sms.Name));
|
|
|
429
|
+ if (dic != null)
|
|
|
430
|
+ NameType = dic.F_Name;
|
|
|
431
|
+ }
|
|
|
432
|
+ catch
|
|
|
433
|
+ {
|
|
|
434
|
+ NameType = sms.Name;
|
|
|
435
|
+ }
|
|
|
436
|
+ t_SMS.NameType = NameType;
|
|
|
437
|
+ return t_SMS;
|
|
|
438
|
+ }
|
|
|
439
|
+ /// <summary>
|
|
|
440
|
+ /// 获取模板详情
|
|
|
441
|
+ /// </summary>
|
|
|
442
|
+ /// <param name="id"></param>
|
|
|
443
|
+ /// <returns></returns>
|
|
|
444
|
+ public ActionResult GetDetailsTemp(int id)
|
|
|
445
|
+ {
|
|
|
446
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
447
|
+ if (userId != 0)
|
|
|
448
|
+ {
|
|
|
449
|
+ Model.T_SMS_Template dModel = new Model.T_SMS_Template();
|
|
|
450
|
+ string NameTyoe = "";
|
|
|
451
|
+ if (id <= 0)
|
|
|
452
|
+ return Error("参数错误!");
|
|
|
453
|
+ var model = new BLL.T_SMS_Template().GetModel(id);
|
|
|
454
|
+ if (model == null)
|
|
|
455
|
+ return Error("查询不到此模板!");
|
|
|
456
|
+ Sms sms = Template(model);
|
|
|
457
|
+
|
|
|
458
|
+
|
|
|
459
|
+ return Success("获取成功", sms);
|
|
|
460
|
+ }
|
|
|
461
|
+ else
|
|
|
462
|
+ return Error("无操作权限!");
|
|
|
463
|
+ }
|
|
|
464
|
+ public class Sms
|
|
|
465
|
+ {
|
|
|
466
|
+ public int ID
|
|
|
467
|
+ {
|
|
|
468
|
+ get; set;
|
|
|
469
|
+ }
|
|
|
470
|
+ public string Name
|
|
|
471
|
+ {
|
|
|
472
|
+ get; set;
|
|
|
473
|
+ }
|
|
|
474
|
+
|
|
|
475
|
+ public string Detail
|
|
|
476
|
+ {
|
|
|
477
|
+ get; set;
|
|
|
478
|
+ }
|
|
|
479
|
+ public int? IsEnable
|
|
|
480
|
+ {
|
|
|
481
|
+ get; set;
|
|
|
482
|
+ }
|
|
|
483
|
+
|
|
|
484
|
+ public string MID
|
|
|
485
|
+ {
|
|
|
486
|
+ get; set;
|
|
|
487
|
+ }
|
|
|
488
|
+
|
|
|
489
|
+ public string MName
|
|
|
490
|
+ {
|
|
|
491
|
+ get; set;
|
|
|
492
|
+ }
|
|
|
493
|
+ public DateTime? CreateDate
|
|
|
494
|
+ {
|
|
|
495
|
+ get; set;
|
|
|
496
|
+ }
|
|
|
497
|
+ public string NameType
|
|
|
498
|
+ {
|
|
|
499
|
+ get; set;
|
|
|
500
|
+ }
|
|
|
501
|
+ }
|
|
|
502
|
+ /// <summary>
|
|
|
503
|
+ /// 导入excel
|
|
|
504
|
+ /// </summary>
|
|
|
505
|
+ public ActionResult ImportExcel()
|
|
|
506
|
+ {
|
|
|
507
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
508
|
+ if (userId != 0)
|
|
|
509
|
+ {
|
|
|
510
|
+ string usercode = CurrentUser.UserData.F_UserCode;
|
|
|
511
|
+ string ip = DTRequest.GetIP();
|
|
|
512
|
+ if (!string.IsNullOrWhiteSpace(usercode))
|
|
|
513
|
+ {
|
|
|
514
|
+ HttpPostedFile _upFile = RequestString.GetFile("upFile");
|
|
|
515
|
+ if (_upFile != null)
|
|
|
516
|
+ {
|
|
|
517
|
+ int headrow = 0;
|
|
|
518
|
+ #region 上传文件
|
|
|
519
|
+ string filepath = "";
|
|
|
520
|
+ string datepath = DateTime.Now.ToString("yyyyMMddHHMMss");
|
|
|
521
|
+ string aLastName = Path.GetExtension(_upFile.FileName);
|
|
|
522
|
+ string oriname = Path.GetFileNameWithoutExtension(_upFile.FileName);
|
|
|
523
|
+ if (aLastName != ".xls" && aLastName != ".xlsx")
|
|
|
524
|
+ {
|
|
|
525
|
+ return Error("文件类型错误,请选择Excel文件");
|
|
|
526
|
+ }
|
|
|
527
|
+ string newpath = datepath + "_" + _upFile.FileName;
|
|
|
528
|
+ if (!Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData")))
|
|
|
529
|
+ {
|
|
|
530
|
+ Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData"));
|
|
|
531
|
+ }
|
|
|
532
|
+ filepath = this.Request.ApplicationPath + "/ExcelData/" + newpath;
|
|
|
533
|
+ string PhysicalPath = Server.MapPath(filepath);
|
|
|
534
|
+ _upFile.SaveAs(PhysicalPath);
|
|
|
535
|
+ #endregion
|
|
|
536
|
+ #region 添加附件日志
|
|
|
537
|
+ Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
|
|
|
538
|
+ model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
|
|
|
539
|
+ model_T_Sys_Accessories.F_FileName = newpath;//附件名称
|
|
|
540
|
+ model_T_Sys_Accessories.F_FileType = aLastName;//附件类型
|
|
|
541
|
+ model_T_Sys_Accessories.F_FileUrl = filepath;//附件地址
|
|
|
542
|
+ model_T_Sys_Accessories.F_UserCode = usercode;//上传人
|
|
|
543
|
+ int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
|
|
|
544
|
+ #endregion
|
|
|
545
|
+ NPOIHelper np = new NPOIHelper();
|
|
|
546
|
+ DataTable dt = np.ExcelToTable(_upFile, headrow);
|
|
|
547
|
+ string msg = string.Empty;
|
|
|
548
|
+ if (dt == null || dt.Rows.Count == 0)
|
|
|
549
|
+ return Error("文件没有数据");
|
|
|
550
|
+ else
|
|
|
551
|
+ {
|
|
|
552
|
+ Model.T_SMS_Template dModel = new Model.T_SMS_Template();
|
|
|
553
|
+ Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
|
554
|
+ string MID = ""; string MName = "";
|
|
|
555
|
+ if (ua != null)
|
|
|
556
|
+ {
|
|
|
557
|
+ MID = ua.F_UserCode;
|
|
|
558
|
+ MName = ua.F_UserName;
|
|
|
559
|
+ }
|
|
|
560
|
+ dModel.MID = MID.Trim();
|
|
|
561
|
+ dModel.MName = MName.Trim();
|
|
|
562
|
+ dModel.CreateDate = DateTime.Now;
|
|
|
563
|
+ dModel.IsEnable = 0;
|
|
|
564
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
565
|
+ {
|
|
|
566
|
+ #region 数据入库
|
|
|
567
|
+ headrow = headrow + 1;
|
|
|
568
|
+
|
|
|
569
|
+ if (dr["短信类型"].ToString() != "")
|
|
|
570
|
+ {
|
|
|
571
|
+ if (!getunique(dr["短信类型"].ToString()))
|
|
|
572
|
+ {
|
|
|
573
|
+ dModel.Name = dr["短信类型"].ToString();
|
|
|
574
|
+ dModel.Detail = dr["短信内容"].ToString();
|
|
|
575
|
+ var res = new BLL.T_SMS_Template().Add(dModel);
|
|
|
576
|
+ if (res < 0)
|
|
|
577
|
+ {
|
|
|
578
|
+ msg = msg + "第" + headrow + "行,导入失败<br>";
|
|
|
579
|
+ }
|
|
|
580
|
+ }
|
|
|
581
|
+ else
|
|
|
582
|
+ {
|
|
|
583
|
+ msg = msg + "第" + headrow + "行,短信类型重复,未导入<br>";
|
|
|
584
|
+ }
|
|
|
585
|
+ }
|
|
|
586
|
+ else
|
|
|
587
|
+ msg = msg + "第" + headrow + "行,短信类型为空或格式不正确,未导入<br>";
|
|
|
588
|
+ #endregion
|
|
|
589
|
+ }
|
|
|
590
|
+ if (string.IsNullOrEmpty(msg))
|
|
|
591
|
+ return Success("导入成功 ");
|
|
|
592
|
+ else
|
|
|
593
|
+ return Error(msg);
|
|
|
594
|
+ }
|
|
|
595
|
+ }
|
|
|
596
|
+ return Error("数据源上传失败");
|
|
|
597
|
+ }
|
|
|
598
|
+ }
|
|
|
599
|
+ return Error("用户登录失败,请重新登录");
|
|
|
600
|
+ }
|
|
|
601
|
+ /// <summary>
|
|
|
602
|
+ /// 验证短信类型是否唯一
|
|
|
603
|
+ /// </summary>
|
|
|
604
|
+ private bool getunique(string Name)
|
|
|
605
|
+ {
|
|
|
606
|
+ var sql = " IsEnable=0 ";
|
|
|
607
|
+ sql += "and (Name='" + Name + "')";
|
|
|
608
|
+ var count = new BLL.T_SMS_Template().GetModelList(sql).Count();
|
|
|
609
|
+ return count > 0;
|
|
|
610
|
+ }
|
|
|
611
|
+ /// <summary>
|
|
|
612
|
+ /// 新增短信记录
|
|
|
613
|
+ /// </summary>
|
|
|
614
|
+ /// <returns></returns>
|
|
|
615
|
+ public bool AddSMSList(int SendWay, DateTime? DSSendTime, DateTime SendTime, int IsSend,
|
|
|
616
|
+ string Telephone, string Detail, int MBID)
|
|
|
617
|
+ {
|
|
|
618
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
619
|
+ Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
|
620
|
+ string MID = ""; string MName = "";
|
|
|
621
|
+ if (ua != null)
|
|
|
622
|
+ {
|
|
|
623
|
+ MID = ua.F_UserCode;
|
|
|
624
|
+ MName = ua.F_UserName;
|
|
|
625
|
+ }
|
|
|
626
|
+ Model.T_SMS_List dModel = new Model.T_SMS_List();
|
|
|
627
|
+ dModel.SendWay = SendWay;
|
|
|
628
|
+ dModel.DSSendTime = DSSendTime;
|
|
|
629
|
+ dModel.SendTime = SendTime;
|
|
|
630
|
+ dModel.IsSend = IsSend;
|
|
|
631
|
+ dModel.Telephone = Telephone;
|
|
|
632
|
+ dModel.Detail = Detail;
|
|
|
633
|
+ dModel.MBID = MBID;
|
|
|
634
|
+ dModel.MID = MID;
|
|
|
635
|
+ dModel.MName = MName;
|
|
|
636
|
+ dModel.F_IsDelete = 0;
|
|
|
637
|
+ dModel.CreateDate = DateTime.Now;
|
|
|
638
|
+ int b = new BLL.T_SMS_List().Add(dModel);
|
|
|
639
|
+ if (b > 0)
|
|
|
640
|
+ {
|
|
|
641
|
+ return true;
|
|
|
642
|
+ }
|
|
|
643
|
+ else
|
|
|
644
|
+ {
|
|
|
645
|
+ return false;
|
|
|
646
|
+ }
|
|
|
647
|
+ }
|
|
|
648
|
+ /// <summary>
|
|
|
649
|
+ /// 导出短信记录
|
|
|
650
|
+ /// </summary>
|
|
|
651
|
+ /// <param name="stime"></param>
|
|
|
652
|
+ /// <param name="endtime"></param>
|
|
|
653
|
+ /// <returns></returns>
|
|
|
654
|
+ public ActionResult ExitTypelist(string name, string phone, string creatname, int SendWay = -1, int IsSend = -1)
|
|
|
655
|
+ {
|
|
|
656
|
+ DataTable dt = new DataTable();
|
|
|
657
|
+ string sql = $" F_IsDelete=0";
|
|
|
658
|
+ if (!string.IsNullOrEmpty(name))
|
|
|
659
|
+ {
|
|
|
660
|
+ var model = new BLL.T_SMS_Template().GetModelList($"Name like '%" + name.Trim() + "%'").FirstOrDefault();
|
|
|
661
|
+ if (model != null)
|
|
|
662
|
+ {
|
|
|
663
|
+ sql += " and MBID=" + model.ID;
|
|
|
664
|
+ }
|
|
|
665
|
+ }
|
|
|
666
|
+ if (!string.IsNullOrEmpty(phone))
|
|
|
667
|
+ sql += " and Telephone=" + phone;
|
|
|
668
|
+ if (SendWay >= 0)
|
|
|
669
|
+ sql += " and SendWay=" + SendWay;
|
|
|
670
|
+ if (IsSend >= 0)
|
|
|
671
|
+ sql += " and IsSend=" + IsSend;
|
|
|
672
|
+ if (!string.IsNullOrEmpty(creatname))
|
|
|
673
|
+ sql += $" and ( MID like '%" + creatname.Trim() + "%'or MName like '%" + creatname.Trim() + "%') ";
|
|
|
674
|
+ dt.Columns.Add("编号");
|
|
|
675
|
+ dt.Columns.Add("接收号码");
|
|
|
676
|
+ dt.Columns.Add("发送内容");
|
|
|
677
|
+ dt.Columns.Add("发送方式");
|
|
|
678
|
+ dt.Columns.Add("发送状态");
|
|
|
679
|
+ dt.Columns.Add("发送时间");
|
|
|
680
|
+ dt.Columns.Add("短信类型");
|
|
|
681
|
+ dt.Columns.Add("发送人");
|
|
|
682
|
+ var itemlist = new BLL.T_SMS_List().GetModelList(sql + "order by ID desc");
|
|
|
683
|
+ int i = 1;
|
|
|
684
|
+ foreach (var it in itemlist)
|
|
|
685
|
+ {
|
|
|
686
|
+
|
|
|
687
|
+ DataRow drNew = dt.NewRow();
|
|
|
688
|
+ drNew["编号"] = i++;
|
|
|
689
|
+ drNew["接收号码"] = it.Telephone;
|
|
|
690
|
+ drNew["发送内容"] = it.Detail;
|
|
|
691
|
+ if (it.SendWay == 0)
|
|
|
692
|
+ drNew["发送方式"] = "立即发送";
|
|
|
693
|
+ else
|
|
|
694
|
+ drNew["发送方式"] = "定时发送";
|
|
|
695
|
+ drNew["发送时间"] = it.SendTime;
|
|
|
696
|
+ if (it.SendTime < DateTime.Now && it.IsSend == 1)
|
|
|
697
|
+ //if (it.IsSend==1)
|
|
|
698
|
+ drNew["发送状态"] = "已发送";
|
|
|
699
|
+ else
|
|
|
700
|
+ drNew["发送状态"] = "未发送";
|
|
|
701
|
+ if (it.MBID > 0)
|
|
|
702
|
+ {
|
|
|
703
|
+ var model = new BLL.T_SMS_Template().GetModel(int.Parse(it.MBID.ToString()));
|
|
|
704
|
+ if (model != null)
|
|
|
705
|
+ {
|
|
|
706
|
+ drNew["短信类型"] = model.Name;
|
|
|
707
|
+ }
|
|
|
708
|
+ }
|
|
|
709
|
+ drNew["发送人"] = it.MID + "(" + it.MName + ")";
|
|
|
710
|
+ dt.Rows.Add(drNew);
|
|
|
711
|
+ }
|
|
|
712
|
+ NPOIHelper npoi = new NPOIHelper();
|
|
|
713
|
+ if (npoi.ExportToExcel("短信记录", dt) == "")
|
|
|
714
|
+ {
|
|
|
715
|
+ return Success("导出成功");
|
|
|
716
|
+ }
|
|
|
717
|
+ else
|
|
|
718
|
+ {
|
|
|
719
|
+ return Error("导出失败");
|
|
|
720
|
+
|
|
|
721
|
+ }
|
|
|
722
|
+ }
|
|
|
723
|
+ /// <summary>
|
|
|
724
|
+ /// 修改短信记录列表
|
|
|
725
|
+ /// </summary>
|
|
|
726
|
+ /// <returns></returns>
|
|
|
727
|
+ public ActionResult UpdateSMSList(int id, int SendWay, DateTime DSSendTime, DateTime SendTime, int IsSend,
|
|
|
728
|
+ string Telephone, string Detail, int MBID, DateTime CreateDate)
|
|
|
729
|
+ {
|
|
|
730
|
+
|
|
|
731
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
732
|
+ if (userId != 0)
|
|
|
733
|
+ {
|
|
|
734
|
+ if (id <= 0)
|
|
|
735
|
+ return Error("参数错误!");
|
|
|
736
|
+ var model = new BLL.T_SMS_List().GetModel(id);
|
|
|
737
|
+ if (model == null)
|
|
|
738
|
+ return Error("查询不到此模板!");
|
|
|
739
|
+ Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
|
740
|
+ string MID = ""; string MName = "";
|
|
|
741
|
+ if (ua != null)
|
|
|
742
|
+ {
|
|
|
743
|
+ MID = ua.F_UserCode;
|
|
|
744
|
+ MName = ua.F_UserName;
|
|
|
745
|
+ }
|
|
|
746
|
+ model.SendWay = SendWay;
|
|
|
747
|
+ model.DSSendTime = DSSendTime;
|
|
|
748
|
+ model.SendTime = SendTime;
|
|
|
749
|
+ model.IsSend = IsSend;
|
|
|
750
|
+ model.Telephone = Telephone;
|
|
|
751
|
+ model.Detail = Detail;
|
|
|
752
|
+ model.MBID = MBID;
|
|
|
753
|
+ model.MID = MID;
|
|
|
754
|
+ model.MName = MName;
|
|
|
755
|
+ model.CreateDate = DateTime.Now;
|
|
|
756
|
+ bool b = new BLL.T_SMS_List().Update(model);
|
|
|
757
|
+ if (b)
|
|
|
758
|
+ {
|
|
|
759
|
+ return Success("修改成功");
|
|
|
760
|
+ }
|
|
|
761
|
+ else
|
|
|
762
|
+ {
|
|
|
763
|
+ return Error("修改失败");
|
|
|
764
|
+ }
|
|
|
765
|
+ }
|
|
|
766
|
+ else
|
|
|
767
|
+ return Error("无操作权限");
|
|
|
768
|
+
|
|
|
769
|
+ }
|
|
|
770
|
+ /// <summary>
|
|
|
771
|
+ /// 获取短信记录列表
|
|
|
772
|
+ /// </summary>
|
|
|
773
|
+ /// <returns></returns>
|
|
|
774
|
+ public ActionResult GetSMSList(string name, string phone, string creatname, int SendWay = -1, int IsSend = -1, int page = 1, int pagesize = 10)
|
|
|
775
|
+ {
|
|
|
776
|
+ DataTable dt = new DataTable();
|
|
|
777
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
778
|
+ if (userId != 0)
|
|
|
779
|
+ {
|
|
|
780
|
+
|
|
|
781
|
+ string sql = $"and F_IsDelete=0";
|
|
|
782
|
+ if (!string.IsNullOrEmpty(name))
|
|
|
783
|
+ {
|
|
|
784
|
+ var model = new BLL.T_SMS_Template().GetModelList($"Name like '%" + name.Trim() + "%'").FirstOrDefault();
|
|
|
785
|
+ if (model != null)
|
|
|
786
|
+ {
|
|
|
787
|
+ sql += " and MBID=" + model.ID;
|
|
|
788
|
+ }
|
|
|
789
|
+ }
|
|
|
790
|
+ if (!string.IsNullOrEmpty(phone))
|
|
|
791
|
+ sql += " and Telephone like'%" + phone + "%'";
|
|
|
792
|
+ if (SendWay >= 0)
|
|
|
793
|
+ sql += " and SendWay=" + SendWay;
|
|
|
794
|
+ if (IsSend >= 0)
|
|
|
795
|
+ sql += " and IsSend=" + IsSend;
|
|
|
796
|
+ if (!string.IsNullOrEmpty(creatname))
|
|
|
797
|
+ sql += $" and ( MID like '%" + creatname.Trim() + "%'or MName like '%" + creatname.Trim() + "%') ";
|
|
|
798
|
+ int recordCount = 0;
|
|
|
799
|
+ if (!string.IsNullOrWhiteSpace(sql))
|
|
|
800
|
+ {
|
|
|
801
|
+
|
|
|
802
|
+ dt = BLL.PagerBLL.GetListPager(
|
|
|
803
|
+ "T_SMS_List",
|
|
|
804
|
+ "T_SMS_List.ID",
|
|
|
805
|
+ "*",
|
|
|
806
|
+ sql,
|
|
|
807
|
+ "ORDER BY T_SMS_List.ID desc",
|
|
|
808
|
+ pagesize,
|
|
|
809
|
+ page,
|
|
|
810
|
+ true,
|
|
|
811
|
+ out recordCount);
|
|
|
812
|
+ }
|
|
|
813
|
+ var modlelist = new BLL.T_SMS_List().DataTableToList(dt);
|
|
|
814
|
+ //var modellist = new BLL.T_SMS_List().GetModelList(sql);
|
|
|
815
|
+ var obj = new
|
|
|
816
|
+ {
|
|
|
817
|
+ state = "success",
|
|
|
818
|
+ message = "成功",
|
|
|
819
|
+ rows = ModeltoSMSList(modlelist),
|
|
|
820
|
+ total = recordCount
|
|
|
821
|
+ };
|
|
|
822
|
+
|
|
|
823
|
+ return Content(obj.ToJson());
|
|
|
824
|
+ }
|
|
|
825
|
+ else
|
|
|
826
|
+ return Error("无操作权限");
|
|
|
827
|
+
|
|
|
828
|
+ }
|
|
|
829
|
+ public List<SMSList> ModeltoSMSList(List<Model.T_SMS_List> list)
|
|
|
830
|
+ {
|
|
|
831
|
+ List<SMSList> modellist = new List<SMSList>();
|
|
|
832
|
+ foreach (var it in list)
|
|
|
833
|
+ {
|
|
|
834
|
+ SMSList model = new SMSList();
|
|
|
835
|
+ model.ID = it.ID;
|
|
|
836
|
+ if (it.SendWay == 0)
|
|
|
837
|
+ model.SendWay = "立即发送";
|
|
|
838
|
+ else
|
|
|
839
|
+ model.SendWay = "定时发送";
|
|
|
840
|
+ model.DSSendTime = it.DSSendTime?.ToString() ?? "";
|
|
|
841
|
+ model.SendTime = it.SendTime?.ToString() ?? "";
|
|
|
842
|
+ if (it.SendTime < DateTime.Now && it.IsSend == 1)
|
|
|
843
|
+ // if (it.IsSend == 0)
|
|
|
844
|
+ model.IsSend = "已发送";
|
|
|
845
|
+ else
|
|
|
846
|
+ model.IsSend = "未发送";
|
|
|
847
|
+ model.Telephone = it.Telephone;
|
|
|
848
|
+ model.Detail = it.Detail;
|
|
|
849
|
+ if (it.MBID > 0)
|
|
|
850
|
+ {
|
|
|
851
|
+ var MID = new BLL.T_SMS_Template().GetModel(int.Parse(it.MBID.ToString()));
|
|
|
852
|
+ if (MID != null)
|
|
|
853
|
+ {
|
|
|
854
|
+ // model.MBDetail = MID.Name;
|
|
|
855
|
+ int t = 0;
|
|
|
856
|
+ if (Int32.TryParse(MID.Name, out t))
|
|
|
857
|
+ {
|
|
|
858
|
+ var typeName = new BLL.T_Sys_DictionaryValue().GetModel(Convert.ToInt32(MID.Name));
|
|
|
859
|
+ if (typeName != null)
|
|
|
860
|
+ model.MBDetail = typeName.F_Name;
|
|
|
861
|
+ }
|
|
|
862
|
+ }
|
|
|
863
|
+
|
|
|
864
|
+
|
|
|
865
|
+
|
|
|
866
|
+ }
|
|
|
867
|
+ model.MID = it.MID;
|
|
|
868
|
+ model.MName = it.MName;
|
|
|
869
|
+ model.CreateDate = it.CreateDate?.ToString() ?? "";
|
|
|
870
|
+ modellist.Add(model);
|
|
|
871
|
+ }
|
|
|
872
|
+ return modellist;
|
|
|
873
|
+ }
|
|
|
874
|
+ /// <summary>
|
|
|
875
|
+ /// 导入号码
|
|
|
876
|
+ /// </summary>
|
|
|
877
|
+ /// <returns></returns>
|
|
|
878
|
+ public ActionResult ImportSend()
|
|
|
879
|
+ {
|
|
|
880
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
881
|
+ if (userId != 0)
|
|
|
882
|
+ {
|
|
|
883
|
+ string usercode = CurrentUser.UserData.F_UserCode;
|
|
|
884
|
+ string ip = DTRequest.GetIP();
|
|
|
885
|
+ if (!string.IsNullOrWhiteSpace(usercode))
|
|
|
886
|
+ {
|
|
|
887
|
+ HttpPostedFile _upFile = RequestString.GetFile("upFile");
|
|
|
888
|
+ if (_upFile != null)
|
|
|
889
|
+ {
|
|
|
890
|
+ int headrow = 0;
|
|
|
891
|
+ #region 上传文件
|
|
|
892
|
+ string filepath = "";
|
|
|
893
|
+ string datepath = DateTime.Now.ToString("yyyyMMddHHMMss");
|
|
|
894
|
+ string aLastName = Path.GetExtension(_upFile.FileName);
|
|
|
895
|
+ string oriname = Path.GetFileNameWithoutExtension(_upFile.FileName);
|
|
|
896
|
+ if (aLastName != ".xls" && aLastName != ".xlsx")
|
|
|
897
|
+ {
|
|
|
898
|
+ return Error("文件类型错误,请选择Excel文件");
|
|
|
899
|
+ }
|
|
|
900
|
+ string newpath = datepath + "_" + _upFile.FileName;
|
|
|
901
|
+ if (!Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData")))
|
|
|
902
|
+ {
|
|
|
903
|
+ Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData"));
|
|
|
904
|
+ }
|
|
|
905
|
+ filepath = this.Request.ApplicationPath + "/ExcelData/" + newpath;
|
|
|
906
|
+ string PhysicalPath = Server.MapPath(filepath);
|
|
|
907
|
+ _upFile.SaveAs(PhysicalPath);
|
|
|
908
|
+ #endregion
|
|
|
909
|
+ #region 添加附件日志
|
|
|
910
|
+ Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
|
|
|
911
|
+ model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
|
|
|
912
|
+ model_T_Sys_Accessories.F_FileName = newpath;//附件名称
|
|
|
913
|
+ model_T_Sys_Accessories.F_FileType = aLastName;//附件类型
|
|
|
914
|
+ model_T_Sys_Accessories.F_FileUrl = filepath;//附件地址
|
|
|
915
|
+ model_T_Sys_Accessories.F_UserCode = usercode;//上传人
|
|
|
916
|
+ int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
|
|
|
917
|
+ #endregion
|
|
|
918
|
+ NPOIHelper np = new NPOIHelper();
|
|
|
919
|
+ DataTable dt = np.ExcelToTable(_upFile, headrow);
|
|
|
920
|
+ string msg = string.Empty;
|
|
|
921
|
+ string tels = string.Empty;
|
|
|
922
|
+ if (dt == null || dt.Rows.Count == 0)
|
|
|
923
|
+ return Error("文件没有数据");
|
|
|
924
|
+ else
|
|
|
925
|
+ {
|
|
|
926
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
927
|
+ {
|
|
|
928
|
+ #region 数据入库
|
|
|
929
|
+ headrow = headrow + 1;
|
|
|
930
|
+
|
|
|
931
|
+ if (dr["号码"].ToString() != "")
|
|
|
932
|
+ {
|
|
|
933
|
+ if (string.IsNullOrEmpty(tels))
|
|
|
934
|
+ {
|
|
|
935
|
+ tels = dr["号码"].ToString();
|
|
|
936
|
+ }
|
|
|
937
|
+ else
|
|
|
938
|
+ {
|
|
|
939
|
+ tels = tels + "," + dr["号码"].ToString();
|
|
|
940
|
+ }
|
|
|
941
|
+ }
|
|
|
942
|
+ else
|
|
|
943
|
+ msg = msg + "第" + headrow + "行,号码为空或格式不正确,未导入<br>";
|
|
|
944
|
+ #endregion
|
|
|
945
|
+ }
|
|
|
946
|
+ if (string.IsNullOrEmpty(msg))
|
|
|
947
|
+ return Success("获取成功 ", tels);
|
|
|
948
|
+ else
|
|
|
949
|
+ return Error(msg);
|
|
|
950
|
+ }
|
|
|
951
|
+ }
|
|
|
952
|
+ return Error("数据源上传失败");
|
|
|
953
|
+ }
|
|
|
954
|
+ }
|
|
|
955
|
+ return Error("用户登录失败,请重新登录");
|
|
|
956
|
+ }
|
|
|
957
|
+ #endregion
|
|
|
958
|
+
|
|
|
959
|
+ public class SMSList
|
|
|
960
|
+ {
|
|
|
961
|
+ public int ID;
|
|
|
962
|
+ public string SendWay;
|
|
|
963
|
+ public string DSSendTime;
|
|
|
964
|
+ public string SendTime;
|
|
|
965
|
+ public string IsSend;
|
|
|
966
|
+ public string Telephone;
|
|
|
967
|
+ public string Detail;
|
|
|
968
|
+ public string MBDetail;
|
|
|
969
|
+ public string MID;
|
|
|
970
|
+ public string MName;
|
|
|
971
|
+ public string CreateDate;
|
|
|
972
|
+ }
|
|
|
973
|
+ }
|
|
|
974
|
+}
|