地铁二期项目正式开始

SMSManagerController.cs 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. using YTSoft.BaseCallCenter.MVCWeb.Commons;
  9. using YTSoft.BaseCallCenter.MVCWeb.Models;
  10. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  11. {
  12. public class SMSManagerController : Controller
  13. {
  14. BLL.T_SMS_SentSMS smsBLL = new BLL.T_SMS_SentSMS();
  15. public ActionResult SMSSentList()
  16. {
  17. CallScreenModel callScreenModel = new CallScreenModel();
  18. return View(callScreenModel);
  19. }
  20. /// <summary>
  21. /// 获取数据列表
  22. /// </summary>
  23. /// <param name="page">当前页码</param>
  24. /// <param name="limit">每页数据量</param>
  25. /// <param name="sqlWhere">查询条件</param>
  26. /// <returns></returns>
  27. [ActionName("SMSSentData")]
  28. [HttpGet]
  29. public string SMSSentData(DateTime? NowDateTime, int page, int limit, string dateParty,
  30. string phoneNumber, int? status)
  31. {
  32. //数据结果集
  33. ResponseData dataModel = new ResponseData();
  34. string sql = "";
  35. //客户电话
  36. if (!string.IsNullOrEmpty(phoneNumber))
  37. {
  38. sql += " and TelNum like '%" + phoneNumber.Trim() + "%'";
  39. }
  40. //状态
  41. if (status != null)
  42. {
  43. sql += " and State =" + status;
  44. }
  45. if (!string.IsNullOrEmpty(dateParty))
  46. {
  47. string startDate = dateParty.Substring(0, 19);
  48. string endDate = dateParty.Substring(21);
  49. sql += " and SendTime>= '" + startDate + "'";
  50. sql += " and SendTime<= '" + endDate + "'";
  51. }
  52. DataTable dt = new DataTable();
  53. int recordCount = 0;
  54. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  55. dt = BLL.PagerBLL.GetListPager(
  56. "T_SMS_SentSMS",
  57. "SMSID",
  58. " *,CONVERT(varchar,SendTime, 120 ) as SendTimeNew"
  59. + " ,(CASE State WHEN 1 THEN '成功' WHEN '0' THEN '失败' ELSE NULL END) as StateName",
  60. sql,
  61. "ORDER BY SendTime desc",
  62. limit,
  63. page,
  64. true,
  65. out recordCount);
  66. dataModel.code = 0;
  67. dataModel.count = recordCount;
  68. dataModel.data = dt;
  69. return JsonConvert.SerializeObject(dataModel);
  70. }
  71. /// <summary>
  72. /// 舆情发送短信接口
  73. /// </summary>
  74. /// <param name="MessageCount">近24小时内舆情数量</param>
  75. /// <returns></returns>
  76. [ActionName("MessageNotice")]
  77. [HttpGet]
  78. public bool MessageNotice(string MessageContent)
  79. {
  80. //数据结果集
  81. bool SendResult = false;
  82. try
  83. {
  84. string smsUrl = "http://www.jc-chn.cn/smsSend.do?username=hry168&password=c1cafe2731b8d88a0f397667facdfbf2&mobile=1863859958&content=";
  85. System.Web.HttpUtility.UrlEncode("发现负面舆情!" + MessageContent, System.Text.Encoding.UTF8);
  86. Model.T_SMS_SentSMS model = new Model.T_SMS_SentSMS();
  87. model.State = 0;
  88. model.SendTime = DateTime.Now;
  89. model.MaxSendCount = 5;
  90. // model.F_CustomerID = MessageCount;//舆情条数
  91. model.Content = MessageContent;
  92. for (int i = 1; i <= model.MaxSendCount; i++)
  93. {
  94. model.CurSentCount = i;
  95. string addWxResult = HttpHelper.HttpSMSSend(smsUrl);
  96. //判断返回接口是否发送成功!
  97. if (!string.IsNullOrEmpty(addWxResult) && !addWxResult.Contains("-") && int.Parse(addWxResult) > 0)
  98. {
  99. SendResult = true;
  100. model.State = 1;//发送成功
  101. //将短信发送信息存储到内容中
  102. smsBLL.Add(model);
  103. break;
  104. }
  105. //将短信发送信息存储到内容中
  106. smsBLL.Add(model);
  107. }
  108. }
  109. catch (Exception ex)
  110. {
  111. }
  112. return SendResult;
  113. }
  114. }
  115. }