PushHelper.cs 1.9 KB

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