using System; using System.Linq; using System.Data; using System.Threading; using Library; using LitJson; 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") { try { string PushData = ""; string PushDataEncrypt = ""; PushData = Newtonsoft.Json.JsonConvert.SerializeObject(obj); function.WriteLog("原始数据:" + PushData, "好哒推送数据日志"); string content = EncryptHelper.Encrypt1(obj, AesSecret); function.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; function.WriteLog("请求参数:" + PushDataEncrypt, "好哒推送数据日志"); function.WriteLog("请求地址:" + NoticeUrl.Replace("{path}", path), "好哒推送数据日志"); string result = function.PostWebRequest(NoticeUrl.Replace("{path}", path), requestJson, "application/json"); function.WriteLog("返回报文:" + result + "\n\n", "好哒推送数据日志"); } catch(Exception ex) { function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString() + "\n\n", "好哒推送数据异常"); } } } }