MqLinksHelper.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Threading;
  3. using System.Linq;
  4. using System.Data;
  5. using Library;
  6. using MySystem.Models;
  7. using LitJson;
  8. using System.Collections.Generic;
  9. using System.Security.Cryptography;
  10. namespace MySystem
  11. {
  12. public class MqLinksHelper
  13. {
  14. public readonly static MqLinksHelper Instance = new MqLinksHelper();
  15. private MqLinksHelper()
  16. {
  17. }
  18. string reqUrl = "http://cs.mqlinks.com/txmsgpush";
  19. public string doSomething(string DeviceId, string Amount)
  20. {
  21. string result = "";
  22. try
  23. {
  24. Dictionary<string, object> data = new Dictionary<string, object>();
  25. data.Add("cmd", "voice");
  26. data.Add("msg", "来客八收款" + Amount + "元");
  27. data.Add("msgid", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
  28. Dictionary<string, object> map = new Dictionary<string, object>();
  29. map.Add("sbx_id", DeviceId);
  30. map.Add("agent_id", data);
  31. result = post(map);
  32. }
  33. catch (Exception ex)
  34. {
  35. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "云音响播报异常");
  36. }
  37. return result;
  38. }
  39. private string post(Dictionary<string, object> data)
  40. {
  41. string req = Newtonsoft.Json.JsonConvert.SerializeObject(data);
  42. function.WriteLog("请求地址:" + reqUrl, "云音响播报日志");
  43. function.WriteLog("请求参数:" + req, "云音响播报日志");
  44. string result = function.PostWebRequest(reqUrl, req, "application/json");
  45. function.WriteLog("响应数据:" + result, "云音响播报日志");
  46. return result;
  47. }
  48. }
  49. }