Нет описания

SMSController.cs 55KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355
  1. 
  2. using CallCenterApi.Interface.Controllers.Base;
  3. using System;
  4. using System.Web.Mvc;
  5. using qcloudsms_csharp;
  6. using qcloudsms_csharp.json;
  7. using qcloudsms_csharp.httpclient;
  8. using System.Data;
  9. using System.Collections.Generic;
  10. using CallCenter.Utility;
  11. namespace CallCenterApi.Interface.Controllers
  12. {
  13. public class SMSController : BaseController
  14. {
  15. #region 接收短信
  16. // 短信应用SDK AppID
  17. int appid = 1400238721;
  18. // 短信应用SDK AppKey
  19. string appkey = "2b2094bcaf2c841fdb50bcaebabf6f54";
  20. // 需要发送短信的手机号码
  21. // int templateId = 392016; // NOTE: 这里的模板ID`7839`只是一个示例,真实的模板ID需要在短信控制台中申请
  22. // 签名
  23. string smsSign = "心连心客服中心"; // NOTE: 这里的签名只是示例,请使用真实的已申请的签名, 签名参数使用的是`签名内容`,而不是`签名ID`
  24. BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  25. #endregion
  26. public ActionResult SMSSend(string name, string phone, string cusphone)
  27. {
  28. int userId = CurrentUser.UserData.F_UserId;
  29. if (userId > 0)
  30. {
  31. Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
  32. if (string.IsNullOrEmpty(name))
  33. return Error("请输入联系人姓名");
  34. if (string.IsNullOrEmpty(phone))
  35. return Error("请输入联系人电话");
  36. if (string.IsNullOrEmpty(cusphone))
  37. return Error("请输入发送号码");
  38. string msg = "您好,感谢您来电反馈,后续详细咨询也可直接拨打市场经理电话:" + phone + ",姓名:" + name + ",祝您生活愉快!";
  39. string[] mag = { name, phone };
  40. SmsSingleSenderResult result = SMSSingleshot(429907, mag, cusphone);
  41. if (result != null)
  42. {
  43. AddSmS(cusphone, msg, userId);
  44. return Success("发送短信", result);
  45. }
  46. else
  47. {
  48. return Error("发送失败,请检查客户电话");
  49. }
  50. }
  51. else
  52. {
  53. return Error("无操作权限");
  54. }
  55. }
  56. public ActionResult GetSmSList(string starttime, string endtime, int pageindex = 1, int pagesize = 10)
  57. {
  58. int userId = CurrentUser.UserData.F_UserId;
  59. if (userId > 0)
  60. {
  61. string sql = "";
  62. DataTable dt = new DataTable();
  63. if (!string.IsNullOrEmpty(starttime))
  64. sql += " and datediff(day,RecvTime,'" + starttime + "')<=0 ";
  65. if (!string.IsNullOrEmpty(endtime))
  66. sql += " and datediff(day,RecvTime,'" + endtime + "')>=0 ";
  67. int recordCount = 0;
  68. dt = BLL.PagerBLL.GetListPager(
  69. "T_SMS_RecvSMS",
  70. "SMSID",
  71. "*",
  72. sql,
  73. "ORDER BY T_SMS_RecvSMS.SMSID desc",
  74. pagesize,
  75. pageindex,
  76. true,
  77. out recordCount);
  78. List<Model.T_SMS_RecvSMS> modlelist = new BLL.T_SMS_RecvSMS().DataTableToList(dt);
  79. if (modlelist.Count > 0)
  80. {
  81. List<RecvSMS> Input = modeltooip(modlelist);
  82. var obj = new
  83. {
  84. state = "success",
  85. message = "成功",
  86. rows = Input,
  87. total = recordCount
  88. };
  89. return Content(obj.ToJson()); ;
  90. }
  91. else
  92. {
  93. return Success("暂无短信"); ;
  94. }
  95. }
  96. else
  97. {
  98. return Error("无操作权限");
  99. }
  100. }
  101. public List<RecvSMS> modeltooip(List<Model.T_SMS_RecvSMS> model)
  102. {
  103. List<RecvSMS> SMS = new List<RecvSMS>();
  104. foreach (var it in model)
  105. {
  106. RecvSMS Recv = new RecvSMS();
  107. Recv.SMSID = it.SMSID;
  108. Recv.CallerNum = it.CallerNum;
  109. Recv.Content = it.Content;
  110. if (it.F_UserID > 0)
  111. {
  112. Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(int.Parse(it.F_UserID.ToString()));
  113. if (ua != null)
  114. {
  115. Recv.F_UserID = ua.F_UserCode + "(" + ua.F_UserName + ")";
  116. }
  117. }
  118. else
  119. {
  120. Recv.F_UserID = "";
  121. }
  122. Recv.RecvTime = it.RecvTime.ToString();
  123. SMS.Add(Recv);
  124. }
  125. return SMS;
  126. }
  127. public class RecvSMS
  128. {
  129. public int SMSID;
  130. public string CallerNum;
  131. public string Content;
  132. public string F_UserID;
  133. public string RecvTime;
  134. }
  135. public bool AddSmS(string tel, string cont, int F_UserID,string RecvModemIMEI="")
  136. {
  137. Model.T_SMS_RecvSMS dModel = new Model.T_SMS_RecvSMS();
  138. dModel.CallerNum = tel.Trim();
  139. dModel.Content = cont.Trim();
  140. dModel.F_UserID = F_UserID;
  141. dModel.RecvTime = DateTime.Now;
  142. dModel.RecvModemIMEI = "";
  143. int b = new BLL.T_SMS_RecvSMS().Add(dModel);
  144. if (b > 0)
  145. {
  146. return true;
  147. }
  148. else
  149. {
  150. return false;
  151. }
  152. }
  153. public ActionResult SMSSendSalesman(string name, string phone, string cusphone)
  154. {
  155. int userId = CurrentUser.UserData.F_UserId;
  156. if (userId > 0)
  157. {
  158. if (string.IsNullOrEmpty(name))
  159. return Error("请输入联系人姓名");
  160. if (string.IsNullOrEmpty(phone))
  161. return Error("请输入联系人电话");
  162. if (string.IsNullOrEmpty(cusphone))
  163. return Error("请输入发送号码");
  164. string msg = "您好,刚有客户意向购买、咨询产品政策问题,客服已做简单解答,但该区域市场详细的产品价格政策及业务情况,还请您及时与客户联系提供具体服务。客户姓名:" + name + ",电话:" + phone + "。祝您工作顺利!";
  165. string[] mag = { name, phone };
  166. SmsSingleSenderResult result = SMSSingleshot(433866, mag, cusphone);
  167. if (result != null)
  168. {
  169. AddSmS(cusphone, msg, userId);
  170. return Success("发送短信", result);
  171. }
  172. else
  173. {
  174. return Error("发送失败,请检查电话");
  175. }
  176. }
  177. else
  178. {
  179. return Error("无操作权限");
  180. }
  181. }
  182. /// <summary>
  183. /// 单发短信
  184. /// </summary>
  185. /// <param name="phone"></param>
  186. /// <param name="cont"></param>
  187. public SmsSingleSenderResult SMSSingleshot(string phone,string cont)
  188. {
  189. try
  190. {
  191. SmsSingleSender ssender = new SmsSingleSender(appid, appkey);
  192. var result = ssender.send(0, "86", phone,
  193. cont, "", "");
  194. Console.WriteLine(result);
  195. return result;
  196. }
  197. catch (JSONException e)
  198. {
  199. Console.WriteLine(e);
  200. return null;
  201. }
  202. catch (HTTPException e)
  203. {
  204. Console.WriteLine(e);
  205. return null;
  206. }
  207. catch (Exception e)
  208. {
  209. Console.WriteLine(e);
  210. return null;
  211. }
  212. }
  213. /// <summary>
  214. /// 单发短信
  215. /// </summary>
  216. /// <param name="phone"></param>
  217. /// <param name="cont"></param>
  218. public SmsSingleSenderResult SMSSingleshot(int templateId, string [] msg,string cusphone)
  219. {
  220. try
  221. {
  222. SmsSingleSender ssender = new SmsSingleSender(appid, appkey);
  223. var result = ssender.sendWithParam("86", cusphone,
  224. templateId, msg, smsSign, "", "");
  225. // SmsSingleSender ssender = new SmsSingleSender(appid, appkey);
  226. // var result = ssender.send(0, "86", phone,
  227. // cont, "", "");
  228. // Console.WriteLine(result);
  229. return result;
  230. }
  231. catch (JSONException e)
  232. {
  233. Console.WriteLine(e);
  234. return null;
  235. }
  236. catch (HTTPException e)
  237. {
  238. Console.WriteLine(e);
  239. return null;
  240. }
  241. catch (Exception e)
  242. {
  243. Console.WriteLine(e);
  244. return null;
  245. }
  246. }
  247. /// <summary>
  248. /// 群发短信
  249. /// </summary>
  250. /// <param name="phone"></param>
  251. /// <param name="cont"></param>
  252. public SmsMultiSenderResult SMSGroupSending(string[] phone, string cont)
  253. {
  254. try
  255. {
  256. SmsMultiSender msender = new SmsMultiSender(appid, appkey);
  257. var result = msender.send(0, "86", phone,
  258. cont, "", "");
  259. Console.WriteLine(result);
  260. return result;
  261. }
  262. catch (JSONException e)
  263. {
  264. Console.WriteLine(e);
  265. return null;
  266. }
  267. catch (HTTPException e)
  268. {
  269. Console.WriteLine(e);
  270. return null;
  271. }
  272. catch (Exception e)
  273. {
  274. Console.WriteLine(e);
  275. return null;
  276. }
  277. }
  278. /// <summary>
  279. /// int beginTime = 1511125600; // 开始时间(UNIX timestamp)
  280. /// int endTime = 1511841600; // 结束时间(UNIX timestamp)
  281. /// int maxNum = 10; // 单次拉取最大量
  282. /// 拉取单个手机回执
  283. /// </summary>
  284. /// <param name="beginTime"></param>
  285. public SmsStatusPullCallbackResult SMSSingleReceipt(int maxNum = 10)
  286. {
  287. try
  288. {
  289. // Note: 短信拉取功能需要联系腾讯云短信技术支持(QQ:3012203387)开通权限
  290. SmsStatusPuller spuller = new SmsStatusPuller(appid, appkey);
  291. // 拉取短信回执
  292. var callbackResult = spuller.pullCallback(maxNum);
  293. Console.WriteLine(callbackResult);
  294. return callbackResult;
  295. }
  296. catch (JSONException e)
  297. {
  298. Console.WriteLine(e);
  299. return null;
  300. }
  301. catch (HTTPException e)
  302. {
  303. Console.WriteLine(e);
  304. return null;
  305. }
  306. catch (Exception e)
  307. {
  308. Console.WriteLine(e);
  309. return null;
  310. }
  311. }
  312. /// <summary>
  313. /// 短信拉取
  314. /// </summary>
  315. /// <returns></returns>
  316. BLL.T_Wo_MaterialManage mmBLL = new BLL.T_Wo_MaterialManage();
  317. public ActionResult SMSReply()
  318. {
  319. Model.T_Wo_MaterialManage dModel = new Model.T_Wo_MaterialManage();
  320. SmsStatusPullReplyResult result = SMSSingleReply(1);
  321. if (result != null)
  322. {
  323. return Success("短信测试", result);
  324. }
  325. else
  326. {
  327. return null;
  328. }
  329. }
  330. BLL.T_Wo_WorkOrder workOrder = new BLL.T_Wo_WorkOrder();
  331. /// <summary>
  332. /// int beginTime = 1511125600; // 开始时间(UNIX timestamp)
  333. /// int endTime = 1511841600; // 结束时间(UNIX timestamp)
  334. /// int maxNum = 10; // 单次拉取最大量
  335. /// 拉取手机回复
  336. /// </summary>
  337. /// <param name="beginTime"></param>
  338. public SmsStatusPullReplyResult SMSSingleReply( int maxNum=1)
  339. {
  340. try
  341. {
  342. SmsStatusPuller spuller = new SmsStatusPuller(appid, appkey);
  343. // 拉取短信回执
  344. var callbackResult = spuller.pullCallback(maxNum);
  345. Console.WriteLine(callbackResult);
  346. // 拉取回复,仅国内短信支持拉取回复状态
  347. var replyResult = spuller.pullReply(maxNum);
  348. if (callbackResult != null )
  349. {
  350. if (callbackResult.callbacks.Count >0)
  351. {
  352. for (int i=0;i< callbackResult.callbacks.Count;i++)
  353. {
  354. if (!string .IsNullOrEmpty (callbackResult.callbacks[i ].sid .Trim ()))
  355. {
  356. Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelSid(callbackResult.callbacks[i].sid.Trim());
  357. if (model !=null )
  358. {
  359. try
  360. {
  361. model.F_SMSReply = int.Parse(replyResult.replys[i].text);
  362. AddSmS(replyResult.replys[i].mobile, replyResult.replys[i].text, 0,"1");
  363. workOrder.Update(model);
  364. string msg = "【心连心客服中心】您好,心连心感谢您的评价,祝您生活愉快!";
  365. SMSSingleshot(replyResult.replys[i].mobile, msg);
  366. string mag = "心连心感谢您的评价,祝你生活愉快!";
  367. AddSmS(replyResult.replys[i].mobile, mag, 0);
  368. }
  369. catch
  370. {
  371. model.F_SMSReply =0;
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. Console.WriteLine(replyResult);
  379. return replyResult;
  380. }
  381. catch (JSONException e)
  382. {
  383. Console.WriteLine(e);
  384. return null;
  385. }
  386. catch (HTTPException e)
  387. {
  388. Console.WriteLine(e);
  389. return null;
  390. }
  391. catch (Exception e)
  392. {
  393. Console.WriteLine(e);
  394. return null;
  395. }
  396. }
  397. // /// <summary>
  398. // /// 新增接收短信
  399. // /// </summary>
  400. // /// <returns></returns>
  401. // public ActionResult AddRecv(string tel,string cont)
  402. // {
  403. // ActionResult res = NoToken("未知错误,请重新登录");
  404. // Model.T_SMS_RecvSMS dModel = new Model.T_SMS_RecvSMS();
  405. // dModel.CallerNum = tel.Trim();
  406. // dModel.Content = cont.Trim();
  407. // dModel.State = 0;
  408. // dModel.RecvTime = DateTime.Now;
  409. // dModel.F_CreateDate = DateTime.Now;
  410. // int b = new BLL.T_SMS_RecvSMS().Add(dModel);
  411. // if (b > 0)
  412. // {
  413. // res = Success("添加成功");
  414. // }
  415. // else
  416. // {
  417. // res = Success("添加失败");
  418. // }
  419. // return res;
  420. // }
  421. #region
  422. //// /// <summary>
  423. //// /// 获取接收短信列表
  424. //// /// </summary>
  425. //// /// <returns></returns>
  426. //// public ActionResult GetRecvList()
  427. //// {
  428. //// ActionResult res = NoToken("未知错误,请重新登录");
  429. //// string sql = "";
  430. //// DataTable dt = new DataTable();
  431. //// string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  432. //// string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  433. //// string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  434. //// string strpageindex = RequestString.GetQueryString("page");
  435. //// int pageindex = 1;
  436. //// string strpagesize = RequestString.GetQueryString("pagesize");
  437. //// int pagesize = 10;
  438. //// if (strtel.Trim() != "" && strtel != "undefined")
  439. //// {
  440. //// sql += " and CallerNum= '" + strtel.Trim() + "' ";
  441. //// }
  442. //// if (strstarttime.Trim() != "" && strstarttime != "undefined")
  443. //// {
  444. //// sql += " and RecvTime >= '" + Convert.ToDateTime(strstarttime.Trim()) + "' ";
  445. //// }
  446. //// if (strendtime.Trim() != "" && strendtime != "undefined")
  447. //// {
  448. //// sql += " and RecvTime <= '" + Convert.ToDateTime(strendtime.Trim()) + "' ";
  449. //// }
  450. //// if (strpageindex.Trim() != "")
  451. //// {
  452. //// pageindex = Convert.ToInt32(strpageindex);
  453. //// }
  454. //// if (strpagesize.Trim() != "")
  455. //// {
  456. //// pagesize = Convert.ToInt32(strpagesize);
  457. //// }
  458. //// int recordCount = 0;
  459. //// dt = BLL.PagerBLL.GetListPager(
  460. //// "T_SMS_RecvSMS",
  461. //// "SMSID",
  462. //// "*",
  463. //// sql,
  464. //// "ORDER BY SMSID desc",
  465. //// pagesize,
  466. //// pageindex,
  467. //// true,
  468. //// out recordCount);
  469. //// var obj = new
  470. //// {
  471. //// state = "success",
  472. //// message = "成功",
  473. //// rows = dt,
  474. //// total = recordCount
  475. //// };
  476. //// res = Content(obj.ToJson());
  477. //// return res;
  478. //// }
  479. //// /// <summary>
  480. //// /// 新增接收短信
  481. //// /// </summary>
  482. //// /// <returns></returns>
  483. //// public ActionResult AddRecv(string tel,string cont)
  484. //// {
  485. //// ActionResult res = NoToken("未知错误,请重新登录");
  486. //// Model.T_SMS_RecvSMS dModel = new Model.T_SMS_RecvSMS();
  487. //// dModel.CallerNum = tel.Trim();
  488. //// dModel.Content = cont.Trim();
  489. //// dModel.State = 0;
  490. //// dModel.RecvTime = DateTime.Now;
  491. //// dModel.F_CreateDate = DateTime.Now;
  492. //// int b = new BLL.T_SMS_RecvSMS().Add(dModel);
  493. //// if (b > 0)
  494. //// {
  495. //// res = Success("添加成功");
  496. //// }
  497. //// else
  498. //// {
  499. //// res = Success("添加失败");
  500. //// }
  501. //// return res;
  502. //// }
  503. //// /// <summary>
  504. //// /// 删除接收短信
  505. //// /// </summary>
  506. //// /// <param name="ids"></param>
  507. //// /// <returns></returns>
  508. //// public ActionResult DelRecv(string[] ids)
  509. //// {
  510. //// ActionResult res = NoToken("未知错误,请重新登录");
  511. //// if (ids != null && ids.Length > 0)
  512. //// {
  513. //// string idd = " ";
  514. //// foreach (string str in ids)
  515. //// {
  516. //// idd += str + ",";
  517. //// }
  518. //// if (new BLL.T_SMS_RecvSMS().DeleteList(idd.TrimEnd(',')))
  519. //// {
  520. //// res = Success("删除成功");
  521. //// }
  522. //// else
  523. //// {
  524. //// res = Error("删除失败");
  525. //// }
  526. //// }
  527. //// else
  528. //// {
  529. //// res = Error("请选择要删除的接收短信");
  530. //// }
  531. //// return res;
  532. //// }
  533. //// #endregion
  534. //// #region 发送短信
  535. //// /// <summary>
  536. //// /// 获取发送短信任务列表
  537. //// /// </summary>
  538. //// /// <returns></returns>
  539. //// public ActionResult GetSendTaskList()
  540. //// {
  541. //// ActionResult res = NoToken("未知错误,请重新登录");
  542. //// string sql = "";
  543. //// DataTable dt = new DataTable();
  544. //// string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  545. //// string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  546. //// string strpageindex = RequestString.GetQueryString("page");
  547. //// int pageindex = 1;
  548. //// string strpagesize = RequestString.GetQueryString("pagesize");
  549. //// int pagesize = 10;
  550. //// if (strstarttime.Trim() != "" && strstarttime != "undefined")
  551. //// {
  552. //// sql += " and F_CreateDate >= '" + Convert.ToDateTime(strstarttime.Trim()) + "' ";
  553. //// }
  554. //// if (strendtime.Trim() != "" && strendtime != "undefined")
  555. //// {
  556. //// sql += " and F_CreateDate <= '" + Convert.ToDateTime(strendtime.Trim()) + "' ";
  557. //// }
  558. //// if (strpageindex.Trim() != "")
  559. //// {
  560. //// pageindex = Convert.ToInt32(strpageindex);
  561. //// }
  562. //// if (strpagesize.Trim() != "")
  563. //// {
  564. //// pagesize = Convert.ToInt32(strpagesize);
  565. //// }
  566. //// int recordCount = 0;
  567. //// dt = BLL.PagerBLL.GetListPager(
  568. //// "T_SMS_SendSMSTask",
  569. //// "SMSID",
  570. //// "*",
  571. //// sql,
  572. //// "ORDER BY SMSID desc",
  573. //// pagesize,
  574. //// pageindex,
  575. //// true,
  576. //// out recordCount);
  577. //// var obj = new
  578. //// {
  579. //// state = "success",
  580. //// message = "成功",
  581. //// rows = dt,
  582. //// total = recordCount
  583. //// };
  584. //// res = Content(obj.ToJson()); ;
  585. //// return res;
  586. //// }
  587. //// /// <summary>
  588. //// /// 新增短信任务
  589. //// /// </summary>
  590. //// /// <returns></returns>
  591. //// public ActionResult AddSendTask()
  592. //// {
  593. //// ActionResult res = NoToken("未知错误,请重新登录");
  594. //// string strid = HttpUtility.UrlDecode(RequestString.GetQueryString("id"));
  595. //// string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  596. //// string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  597. //// string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  598. //// string strstarttime1 = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime1"));
  599. //// string strendtime1 = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime1"));
  600. //// string strstarttime2 = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime2"));
  601. //// string strendtime2 = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime2"));
  602. //// string strsignname = HttpUtility.UrlDecode(RequestString.GetQueryString("signname"));
  603. //// string strtempcode = HttpUtility.UrlDecode(RequestString.GetQueryString("tempcode"));
  604. //// Model.T_SMS_SendSMSTask dModel = new Model.T_SMS_SendSMSTask();
  605. //// if (strid != "")
  606. //// {
  607. //// int id = Int32.Parse(strid);
  608. //// dModel = new BLL.T_SMS_SendSMSTask().GetModel(id);
  609. //// dModel.Name = strname.Trim();
  610. //// if (!string.IsNullOrEmpty(strstarttime))
  611. //// {
  612. //// dModel.StartTime = DateTime.Parse(strstarttime);
  613. //// }
  614. //// else
  615. //// {
  616. //// dModel.StartTime = null;
  617. //// }
  618. //// if (!string.IsNullOrEmpty(strendtime))
  619. //// {
  620. //// dModel.EndTime = DateTime.Parse(strendtime);
  621. //// }
  622. //// else
  623. //// {
  624. //// dModel.EndTime = null;
  625. //// }
  626. //// dModel.PeriodStartTime = strstarttime1;
  627. //// dModel.PeriodEndTime = strendtime1;
  628. //// dModel.PeriodStartTime1 = strstarttime2;
  629. //// dModel.PeriodEndTime1 = strendtime2;
  630. //// dModel.SignName = strsignname;
  631. //// dModel.TempCode = strtempcode;
  632. //// if (dModel.State == 1) { dModel.State = 0; }//短信服务
  633. //// if (new BLL.T_SMS_SendSMSTask().Update(dModel))
  634. //// {
  635. //// res = Success("修改成功");
  636. //// }
  637. //// else
  638. //// {
  639. //// res = Success("修改失败");
  640. //// }
  641. //// }
  642. //// else
  643. //// {
  644. //// dModel.Name = strname.Trim();
  645. //// if (!string.IsNullOrEmpty(strstarttime))
  646. //// {
  647. //// dModel.StartTime = DateTime.Parse(strstarttime);
  648. //// }
  649. //// if (!string.IsNullOrEmpty(strendtime))
  650. //// {
  651. //// dModel.EndTime = DateTime.Parse(strendtime);
  652. //// }
  653. //// dModel.PeriodStartTime = strstarttime1;
  654. //// dModel.PeriodEndTime = strendtime1;
  655. //// dModel.PeriodStartTime1 = strstarttime2;
  656. //// dModel.PeriodEndTime1 = strendtime2;
  657. //// dModel.SignName = strsignname;
  658. //// dModel.TempCode = strtempcode;
  659. //// dModel.State = 0;
  660. //// dModel.F_CreateDate = DateTime.Now;
  661. //// int b = new BLL.T_SMS_SendSMSTask().Add(dModel);
  662. //// if (b > 0)
  663. //// {
  664. //// res = Success("添加成功");
  665. //// }
  666. //// else
  667. //// {
  668. //// res = Success("添加失败");
  669. //// }
  670. //// }
  671. //// return res;
  672. //// }
  673. //// /// <summary>
  674. //// /// 删除短信任务
  675. //// /// </summary>
  676. //// /// <param name="ids"></param>
  677. //// /// <returns></returns>
  678. //// public ActionResult DelSendTask(string[] ids)
  679. //// {
  680. //// ActionResult res = NoToken("未知错误,请重新登录");
  681. //// if (ids != null && ids.Length > 0)
  682. //// {
  683. //// string idd = " ";
  684. //// foreach (string str in ids)
  685. //// {
  686. //// idd += str + ",";
  687. //// }
  688. //// if (new BLL.T_SMS_SendSMSTask().DeleteList(idd.TrimEnd(',')))
  689. //// {
  690. //// res = Success("删除成功");
  691. //// }
  692. //// else
  693. //// {
  694. //// res = Error("删除失败");
  695. //// }
  696. //// }
  697. //// else
  698. //// {
  699. //// res = Error("请选择要删除的短信任务");
  700. //// }
  701. //// return res;
  702. //// }
  703. //// /// <summary>
  704. //// /// 获取发送短信列表
  705. //// /// </summary>
  706. //// /// <returns></returns>
  707. //// public ActionResult GetSendList()
  708. //// {
  709. //// ActionResult res = NoToken("未知错误,请重新登录");
  710. //// string sql = "";
  711. //// DataTable dt = new DataTable();
  712. //// int taskid = 0;
  713. //// string strtaskid = HttpUtility.UrlDecode(RequestString.GetQueryString("id"));
  714. //// string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  715. //// string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  716. //// string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  717. //// string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  718. //// string strpageindex = RequestString.GetQueryString("page");
  719. //// int pageindex = 1;
  720. //// string strpagesize = RequestString.GetQueryString("pagesize");
  721. //// int pagesize = 10;
  722. //// if (strtaskid != "" && strtaskid != "undefined")
  723. //// {
  724. //// taskid = Convert.ToInt32(strtaskid);
  725. //// }
  726. //// if (strtel.Trim() != "" && strtel != "undefined")
  727. //// {
  728. //// sql += " and TelNum= '" + strtel.Trim() + "' ";
  729. //// }
  730. //// if (strstarttime.Trim() != "" && strstarttime != "undefined")
  731. //// {
  732. //// sql += " and F_CreateDate >= '" + Convert.ToDateTime(strstarttime.Trim()) + "' ";
  733. //// }
  734. //// if (strendtime.Trim() != "" && strendtime != "undefined")
  735. //// {
  736. //// sql += " and F_CreateDate <= '" + Convert.ToDateTime(strendtime.Trim()) + "' ";
  737. //// }
  738. //// if (strstate.Trim() != "" && strstate != "undefined")
  739. //// {
  740. //// sql += " and State= '" + strstate.Trim() + "' ";
  741. //// }
  742. //// if (strpageindex.Trim() != "")
  743. //// {
  744. //// pageindex = Convert.ToInt32(strpageindex);
  745. //// }
  746. //// if (strpagesize.Trim() != "")
  747. //// {
  748. //// pagesize = Convert.ToInt32(strpagesize);
  749. //// }
  750. //// int recordCount = 0;
  751. //// dt = BLL.PagerBLL.GetListPager(
  752. //// "T_SMS_SentSMS",
  753. //// "SMSID",
  754. //// "*",
  755. //// sql,
  756. //// "ORDER BY SMSID desc",
  757. //// pagesize,
  758. //// pageindex,
  759. //// true,
  760. //// out recordCount);
  761. //// var obj = new
  762. //// {
  763. //// state = "success",
  764. //// message = "成功",
  765. //// rows = dt,
  766. //// total = recordCount
  767. //// };
  768. //// res = Content(obj.ToJson()); ;
  769. //// return res;
  770. //// }
  771. //// /// <summary>
  772. //// /// 新增短信
  773. //// /// </summary>
  774. //// /// <returns></returns>
  775. //// public ActionResult AddSend(string id,string taskid,string tel,string cont)
  776. //// {
  777. //// ActionResult res = NoToken("未知错误,请重新登录");
  778. //// Model.T_SMS_SentSMS dModel = new Model.T_SMS_SentSMS();
  779. //// if (id != "")
  780. //// {
  781. //// int sid = Int32.Parse(id);
  782. //// dModel = new BLL.T_SMS_SentSMS().GetModel(sid);
  783. //// dModel.TelNum = tel.Trim();
  784. //// dModel.Content = cont;
  785. //// if (new BLL.T_SMS_SentSMS().Update(dModel))
  786. //// {
  787. //// res = Success("修改成功");
  788. //// }
  789. //// else
  790. //// {
  791. //// res = Success("修改失败");
  792. //// }
  793. //// }
  794. //// else
  795. //// {
  796. //// dModel.TaskID = Int32.Parse(taskid);
  797. //// dModel.TelNum = tel.Trim();
  798. //// dModel.Content = cont;
  799. //// dModel.State = 0;
  800. //// dModel.F_CreateDate = DateTime.Now;
  801. //// int b = new BLL.T_SMS_SentSMS().Add(dModel);
  802. //// if (b > 0)
  803. //// {
  804. //// res = Success("添加成功");
  805. //// }
  806. //// else
  807. //// {
  808. //// res = Success("添加失败");
  809. //// }
  810. //// }
  811. //// return res;
  812. //// }
  813. //// /// <summary>
  814. //// /// 删除短信
  815. //// /// </summary>
  816. //// /// <param name="ids"></param>
  817. //// /// <returns></returns>
  818. //// public ActionResult DelSend(string[] ids)
  819. //// {
  820. //// ActionResult res = NoToken("未知错误,请重新登录");
  821. //// if (ids != null && ids.Length > 0)
  822. //// {
  823. //// string idd = " ";
  824. //// foreach (string str in ids)
  825. //// {
  826. //// idd += str + ",";
  827. //// }
  828. //// if (new BLL.T_SMS_SentSMS().DeleteList(idd.TrimEnd(',')))
  829. //// {
  830. //// res = Success("删除成功");
  831. //// }
  832. //// else
  833. //// {
  834. //// res = Error("删除失败");
  835. //// }
  836. //// }
  837. //// else
  838. //// {
  839. //// res = Error("请选择要删除的短信");
  840. //// }
  841. //// return res;
  842. //// }
  843. //// /// <summary>
  844. //// /// 导入短信
  845. //// /// </summary>
  846. //// /// <returns></returns>
  847. //// public ActionResult ImportSend()
  848. //// {
  849. //// ActionResult res = NoToken("未知错误,请重新登录");
  850. //// if (Request.IsAuthenticated)
  851. //// {
  852. //// int userId = CurrentUser.UserData.F_UserId;
  853. //// if (userId != 0)
  854. //// {
  855. //// Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  856. //// if (userModel != null)
  857. //// {
  858. //// HttpPostedFile _upfile = RequestString.GetFile("upFile");
  859. //// int taskid = RequestString.GetInt("taskid", 0);
  860. //// int headrow = 1;
  861. //// NPOIHelper np = new NPOIHelper();
  862. //// DataTable dt = np.ExcelToTable(_upfile, headrow);
  863. //// string msg = string.Empty;
  864. //// foreach (DataRow dr in dt.Rows)
  865. //// {
  866. //// headrow = headrow + 1;
  867. //// if (dr[0].ToString() != "" && dr[1].ToString() != "")
  868. //// {
  869. //// Model.T_SMS_SentSMS dModel = new Model.T_SMS_SentSMS();
  870. //// dModel.TaskID = taskid;
  871. //// dModel.TelNum = dr[0].ToString();
  872. //// dModel.Content = dr[1].ToString();
  873. //// dModel.State = 0;
  874. //// dModel.F_UserID = userModel.F_UserId;
  875. //// dModel.F_Name = userModel.F_UserName;
  876. //// dModel.F_CreateDate = DateTime.Now;
  877. //// if (new BLL.T_SMS_SentSMS().Add(dModel) > 0)
  878. //// {
  879. //// msg = msg + "第" + headrow + "行,导入失败<br>";
  880. //// }
  881. //// }
  882. //// else
  883. //// {
  884. //// msg = msg + "第"+ headrow+"行,手机号或者内容为空,未导入<br>";
  885. //// }
  886. //// }
  887. //// if (string.IsNullOrEmpty(msg))
  888. //// {
  889. //// res = Error(msg);
  890. //// }
  891. //// }
  892. //// }
  893. //// }
  894. //// return res;
  895. //// }
  896. //// #endregion
  897. //// #region 短信服务
  898. //// /// <summary>
  899. //// /// 获取发送短信列表
  900. //// /// </summary>
  901. //// /// <returns></returns>
  902. //// public ActionResult GetSendTaskListByJob(string state, string count)
  903. //// {
  904. //// ActionResult res = NoToken("未知错误,请重新登录");
  905. //// DataTable dt = new DataTable();
  906. //// string str = "";
  907. //// if (!string.IsNullOrEmpty(count))
  908. //// {
  909. //// int ct = Int32.Parse(count);
  910. //// str = "top " + ct;
  911. //// }
  912. //// dt = DB.DbHelperSQL.Query(" select " + str + " * from T_SMS_SendSMSTask where isnull(State,0)='" + state + "' and getdate() between isnull(StartTime,'1900-01-01 00:00:00') and isnull(EndTime,'9999-12-31 23:59:59') order by F_CreateDate ").Tables[0];
  913. //// res = Success("成功", dt);
  914. //// return res;
  915. //// }
  916. //// /// <summary>
  917. //// /// 获取发送短信列表
  918. //// /// </summary>
  919. //// /// <returns></returns>
  920. //// public ActionResult GetSendListByJob(string taskid, string count)
  921. //// {
  922. //// ActionResult res = NoToken("未知错误,请重新登录");
  923. //// DataTable dt = new DataTable();
  924. //// string str = "";
  925. //// if (!string.IsNullOrEmpty(count))
  926. //// {
  927. //// int ct = Int32.Parse(count);
  928. //// str = "top " + ct;
  929. //// }
  930. //// //dt = DB.DbHelperSQL.Query(" select top "+ ct+ " s.*,t.PeriodStartTime,t.PeriodStartTime1,t.PeriodEndTime,t.PeriodEndTime1 from T_SMS_SentSMS s left join T_SMS_SendSMSTask t on s.TaskID=t.SMSID where isnull(s.State,0)=0 and getdate() between t.StartTime and t.EndTime order by s.F_CreateDate ").Tables[0];
  931. //// dt = DB.DbHelperSQL.Query(" select " + str + " * from T_SMS_SentSMS where TaskID='" + taskid + "' and isnull(State,0)='0' order by F_CreateDate ").Tables[0];
  932. //// res = Success("成功", dt);
  933. //// return res;
  934. //// }
  935. //// /// <summary>
  936. //// /// 执行发送短信
  937. //// /// </summary>
  938. //// /// <returns></returns>
  939. //// public ActionResult ExecSMSByJob(string taskid, string count)
  940. //// {
  941. //// ActionResult res = NoToken("未知错误,请重新登录");
  942. //// DataTable dt = new DataTable();
  943. //// string tels = string.Empty;
  944. //// string errtels = string.Empty;
  945. //// string isdel = string.Empty;
  946. //// string str = string.Empty;
  947. //// if (!string.IsNullOrEmpty(count))
  948. //// {
  949. //// int ct = Int32.Parse(count);
  950. //// str = "top " + ct;
  951. //// }
  952. //// var task = new BLL.T_SMS_SendSMSTask().GetModel(Int32.Parse(taskid));
  953. //// if (task != null)
  954. //// {
  955. //// bool bl = true;
  956. //// DateTime dte = DateTime.Now;
  957. //// if (task.StartTime != null)
  958. //// {
  959. //// bl = dte >= task.StartTime.Value;
  960. //// }
  961. //// if (bl && task.EndTime != null)
  962. //// {
  963. //// bl = dte <= task.EndTime.Value;
  964. //// }
  965. //// if (bl)
  966. //// {
  967. //// //dt = DB.DbHelperSQL.Query(" select top "+ ct+ " s.*,t.PeriodStartTime,t.PeriodStartTime1,t.PeriodEndTime,t.PeriodEndTime1 from T_SMS_SentSMS s left join T_SMS_SendSMSTask t on s.TaskID=t.SMSID where isnull(s.State,0)=0 and getdate() between t.StartTime and t.EndTime order by s.F_CreateDate ").Tables[0];
  968. //// dt = DB.DbHelperSQL.Query(" select " + str + " * from T_SMS_SentSMS where TaskID='" + task.SMSID + "' and isnull(State,0)=0 order by F_CreateDate ").Tables[0];
  969. //// foreach (DataRow dr in dt.Rows)
  970. //// {
  971. //// string err = SendSMS(dr["TelNum"].ToString(), dr["Content"].ToString(), task.SignName, task.TempCode);
  972. //// if (err == "")
  973. //// {
  974. //// UpdateSendState(dr["SMSID"].ToString());
  975. //// if (string.IsNullOrEmpty(tels))
  976. //// {
  977. //// tels = dr["TelNum"].ToString();
  978. //// }
  979. //// else
  980. //// {
  981. //// tels = tels + "," + dr["TelNum"].ToString();
  982. //// }
  983. //// }
  984. //// else
  985. //// {
  986. //// if (string.IsNullOrEmpty(tels))
  987. //// {
  988. //// errtels = dr["TelNum"].ToString();
  989. //// }
  990. //// else
  991. //// {
  992. //// errtels = errtels + "," + dr["TelNum"].ToString();
  993. //// }
  994. //// }
  995. //// }
  996. //// isdel = "0";
  997. //// }
  998. //// else
  999. //// {
  1000. //// isdel = "1";
  1001. //// }
  1002. //// }
  1003. //// else
  1004. //// {
  1005. //// isdel = "1";
  1006. //// }
  1007. //// res = Success("成功", new { suc = tels, err = errtels, isdel = isdel });
  1008. //// return res;
  1009. //// }
  1010. //// /// <summary>
  1011. //// /// 根据结束时间结束任务
  1012. //// /// </summary>
  1013. //// /// <returns></returns>
  1014. //// public ActionResult EndSMSTask()
  1015. //// {
  1016. //// ActionResult res = NoToken("未知错误,请重新登录");
  1017. //// string str = string.Empty;
  1018. //// string strerr = string.Empty;
  1019. //// BLL.T_SMS_SendSMSTask bll = new BLL.T_SMS_SendSMSTask();
  1020. //// var list = bll.GetModelList(" isnull(State,0)=1 ");
  1021. //// foreach (var l in list)
  1022. //// {
  1023. //// if (l.EndTime <= DateTime.Now)
  1024. //// {
  1025. //// l.State = 9;
  1026. //// if (bll.Update(l))
  1027. //// {
  1028. //// if (string.IsNullOrEmpty(str))
  1029. //// {
  1030. //// str = l.SMSID.ToString();
  1031. //// }
  1032. //// else
  1033. //// {
  1034. //// str = str + "," + l.SMSID.ToString();
  1035. //// }
  1036. //// }
  1037. //// else
  1038. //// {
  1039. //// if (string.IsNullOrEmpty(strerr))
  1040. //// {
  1041. //// strerr = l.SMSID.ToString();
  1042. //// }
  1043. //// else
  1044. //// {
  1045. //// strerr = strerr + "," + l.SMSID.ToString();
  1046. //// }
  1047. //// }
  1048. //// }
  1049. //// }
  1050. //// res = Success("成功", new { suc = str, err = strerr});
  1051. //// return res;
  1052. //// }
  1053. //// /// <summary>
  1054. //// /// 短信服务停止后重置正在执行的任务
  1055. //// /// </summary>
  1056. //// /// <returns></returns>
  1057. //// public ActionResult ResetSMSTask()
  1058. //// {
  1059. //// ActionResult res = NoToken("未知错误,请重新登录");
  1060. //// string str = string.Empty;
  1061. //// string strerr = string.Empty;
  1062. //// BLL.T_SMS_SendSMSTask bll = new BLL.T_SMS_SendSMSTask();
  1063. //// var list = bll.GetModelList(" isnull(State,0)=1 ");
  1064. //// foreach (var l in list)
  1065. //// {
  1066. //// l.State = 0;
  1067. //// if (bll.Update(l))
  1068. //// {
  1069. //// if (string.IsNullOrEmpty(str))
  1070. //// {
  1071. //// str = l.SMSID.ToString();
  1072. //// }
  1073. //// else
  1074. //// {
  1075. //// str = str + "," + l.SMSID.ToString();
  1076. //// }
  1077. //// }
  1078. //// else
  1079. //// {
  1080. //// if (string.IsNullOrEmpty(strerr))
  1081. //// {
  1082. //// strerr = l.SMSID.ToString();
  1083. //// }
  1084. //// else
  1085. //// {
  1086. //// strerr = strerr + "," + l.SMSID.ToString();
  1087. //// }
  1088. //// }
  1089. //// }
  1090. //// res = Success("成功", new { suc = str, err = strerr });
  1091. //// return res;
  1092. //// }
  1093. //// /// <summary>
  1094. //// /// 更新短信发送状态
  1095. //// /// </summary>
  1096. //// /// <returns></returns>
  1097. //// public ActionResult UpdateSendTaskState(string id, string state)
  1098. //// {
  1099. //// ActionResult res = NoToken("未知错误,请重新登录");
  1100. //// Model.T_SMS_SendSMSTask dModel = new Model.T_SMS_SendSMSTask();
  1101. //// if (id != "")
  1102. //// {
  1103. //// int sid = Int32.Parse(id);
  1104. //// dModel = new BLL.T_SMS_SendSMSTask().GetModel(sid);
  1105. //// if (dModel != null)
  1106. //// {
  1107. //// dModel.State = Int32.Parse(state);
  1108. //// if (new BLL.T_SMS_SendSMSTask().Update(dModel))
  1109. //// {
  1110. //// res = Success("修改成功");
  1111. //// }
  1112. //// else
  1113. //// {
  1114. //// res = Success("修改失败");
  1115. //// }
  1116. //// }
  1117. //// }
  1118. //// return res;
  1119. //// }
  1120. //// /// <summary>
  1121. //// /// 更新短信发送状态
  1122. //// /// </summary>
  1123. //// /// <returns></returns>
  1124. //// public ActionResult UpdateSendState(string id)
  1125. //// {
  1126. //// ActionResult res = NoToken("未知错误,请重新登录");
  1127. //// Model.T_SMS_SentSMS dModel = new Model.T_SMS_SentSMS();
  1128. //// if (id != "")
  1129. //// {
  1130. //// int sid = Int32.Parse(id);
  1131. //// dModel = new BLL.T_SMS_SentSMS().GetModel(sid);
  1132. //// if (dModel != null && dModel.State == 0)
  1133. //// {
  1134. //// dModel.State = 1;
  1135. //// dModel.SendTime = DateTime.Now;
  1136. //// if (new BLL.T_SMS_SentSMS().Update(dModel))
  1137. //// {
  1138. //// res = Success("修改成功");
  1139. //// }
  1140. //// else
  1141. //// {
  1142. //// res = Success("修改失败");
  1143. //// }
  1144. //// }
  1145. //// }
  1146. //// return res;
  1147. //// }
  1148. //// #endregion
  1149. //// #region 发送短信接口
  1150. //// /// <summary>
  1151. //// /// 发送短信接口
  1152. //// /// </summary>
  1153. //// /// <returns></returns>
  1154. //// public ActionResult SentSMS()
  1155. //// {
  1156. //// //调用示例--/sms/sendsms?tel=15512345678,15812341234&cont={"name":"张三","time":"11:00"}&signname=活动验证&tempcode=SMS_40865007
  1157. //// ActionResult res = NoToken("未知错误,请重新登录");
  1158. //// string signname = HttpUtility.UrlDecode(RequestString.GetQueryString("signname"));//"活动验证";
  1159. //// string tempcode = HttpUtility.UrlDecode(RequestString.GetQueryString("tempcode"));//"SMS_40865007";
  1160. //// string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));//多个用 , 隔开
  1161. //// string cont = HttpUtility.UrlDecode(RequestString.GetQueryString("cont"));
  1162. //// string err = SendSMS(tel, cont, signname, tempcode);
  1163. //// if (err == "")
  1164. //// {
  1165. //// res = Success("成功");
  1166. //// }
  1167. //// else
  1168. //// {
  1169. //// res = Error(err);
  1170. //// }
  1171. //// return res;
  1172. //// }
  1173. //// /// <summary>
  1174. //// /// 发送短信
  1175. //// /// </summary>
  1176. //// /// <param name="tel"></param>
  1177. //// /// <param name="cont"></param>
  1178. //// /// <param name="signname"></param>
  1179. //// /// <param name="tempcode"></param>
  1180. //// /// <returns></returns>
  1181. //// public string SendSMS(string tel, string cont, string signname, string tempcode)
  1182. //// {
  1183. //// string res = string.Empty;
  1184. //// string url = ConfigurationManager.AppSettings["url"];
  1185. //// string key = ConfigurationManager.AppSettings["key"];
  1186. //// string secret = ConfigurationManager.AppSettings["secret"];
  1187. //// try
  1188. //// {
  1189. //// ITopClient client = new DefaultTopClient(url, key, secret);
  1190. //// AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
  1191. //// req.Extend = "123456";//公共回传参数
  1192. //// req.SmsType = "normal";//短信类型,传入值请填写normal
  1193. //// req.SmsFreeSignName = signname;//签名
  1194. //// req.SmsParam = cont; //短信模参数示例: "{\"name\":\"张三\",\"time\":\"11:00\"}";
  1195. //// req.RecNum = tel; //短信接收号码
  1196. //// req.SmsTemplateCode = tempcode;//短信模板ID
  1197. //// AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
  1198. //// if (!rsp.IsError)
  1199. //// {
  1200. //// if (!rsp.Result.Success)
  1201. //// {
  1202. //// res = rsp.Result.Msg;
  1203. //// }
  1204. //// }
  1205. //// else
  1206. //// {
  1207. //// if (!string.IsNullOrEmpty(rsp.SubErrMsg))
  1208. //// {
  1209. //// res = rsp.SubErrMsg;
  1210. //// }
  1211. //// else
  1212. //// {
  1213. //// res = rsp.ErrMsg;
  1214. //// }
  1215. //// }
  1216. //// }
  1217. //// catch
  1218. //// {
  1219. //// res = "接口异常!";
  1220. //// }
  1221. //// return res;
  1222. //// }
  1223. #endregion
  1224. }
  1225. }