PushHelper.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Linq;
  3. using System.Data;
  4. using System.Threading;
  5. using Library;
  6. using LitJson;
  7. using System.Collections.Generic;
  8. namespace MySystem
  9. {
  10. public class PushHelper
  11. {
  12. public readonly static PushHelper Instance = new PushHelper();
  13. private PushHelper()
  14. {
  15. }
  16. string NoticeUrl = "http://cybsp.888cyb.com/v1/cybsp/bindChangeNotify/hd";
  17. string AesSecret = "kvS4TIRh7Yulg4nr";
  18. //要执行的方法
  19. public void Do(SortedList<string, string> obj)
  20. {
  21. string PushData = "";
  22. string PushDataEncrypt = "";
  23. PushData = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  24. LogHelper.Instance.WriteLog("原始数据:" + PushData, "好哒推送数据日志");
  25. string content = EncryptHelper.Encrypt1(obj, AesSecret);
  26. LogHelper.Instance.WriteLog("加密数据:" + content, "好哒推送数据日志");
  27. obj = new SortedList<string, string>();
  28. obj.Add("type", "好哒商户绑定信息");
  29. obj.Add("notice_id", Guid.NewGuid().ToString());
  30. obj.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
  31. obj.Add("content", content);
  32. string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  33. PushDataEncrypt = requestJson;
  34. LogHelper.Instance.WriteLog("请求参数:" + PushDataEncrypt, "好哒推送数据日志");
  35. LogHelper.Instance.WriteLog("请求地址:" + NoticeUrl, "好哒推送数据日志");
  36. string result = function.PostWebRequest(NoticeUrl, requestJson, "application/json");
  37. LogHelper.Instance.WriteLog("返回报文:" + result + "\n\n", "好哒推送数据日志");
  38. }
  39. }
  40. }