using System; using System.Linq; using System.Data; using System.Threading; using Library; using LitJson; using MySystem.Models.Push; using System.Collections.Generic; namespace MySystem { public class PushHelper { public readonly static PushHelper Instance = new PushHelper(); private PushHelper() { } string NoticeUrl = "http://cybsp.888cyb.com/v1/cybsp/{path}/hd"; string AesSecret = "kvS4TIRh7Yulg4nr"; //要执行的方法 public void Do(SortedList obj, string path = "transNotify") { string PushData = ""; string PushDataEncrypt = ""; PushData = Newtonsoft.Json.JsonConvert.SerializeObject(obj); LogHelper.Instance.WriteLog("原始数据:" + PushData, "好哒推送数据日志"); string content = EncryptHelper.Encrypt1(obj, AesSecret); LogHelper.Instance.WriteLog("加密数据:" + content, "好哒推送数据日志"); obj = new SortedList(); obj.Add("type", "好哒商户交易信息"); obj.Add("notice_id", Guid.NewGuid().ToString()); obj.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); obj.Add("content", content); string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj); PushDataEncrypt = requestJson; LogHelper.Instance.WriteLog("请求参数:" + PushDataEncrypt, "好哒推送数据日志"); LogHelper.Instance.WriteLog("请求地址:" + NoticeUrl.Replace("{path}", path), "好哒推送数据日志"); string result = function.PostWebRequest(NoticeUrl.Replace("{path}", path), requestJson, "application/json"); LogHelper.Instance.WriteLog("返回报文:" + result + "\n\n", "好哒推送数据日志"); } } }