Report_Statistic_Msg.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace CommLib.BdPush
  7. {
  8. /// <summary>
  9. /// 作者:冼树华
  10. /// QQ:56472465
  11. /// 日期:20150-04-29
  12. /// 功能:统计app消息信息
  13. /// 注:支持组播、广播、批量单播。由于数据库中最多记录三个月的统计结果,所以返回结果不分页,返回数据库中所有统计项。
  14. /// </summary>
  15. public class Report_Statistic_Msg : Baidu_Send
  16. {
  17. #region 构造函数
  18. public Report_Statistic_Msg(string secret_key, Baidu_Mod mod)
  19. {
  20. this.httpMehtod = Baidu_Helper.HTTP_POST;
  21. this.url = "http://api.tuisong.baidu.com/rest/3.0/" + Baidu_Helper.REPORT_STATISTIC_MSG;
  22. this.secret_key = secret_key;
  23. this.mod = mod;
  24. }
  25. public Report_Statistic_Msg(string httpMehtod, string secret_key, Baidu_Mod mod)
  26. {
  27. this.httpMehtod = httpMehtod;
  28. this.url = "http://api.tuisong.baidu.com/rest/3.0/" + Baidu_Helper.REPORT_STATISTIC_MSG;
  29. this.secret_key = secret_key;
  30. this.mod = mod;
  31. }
  32. #endregion
  33. #region 重写PushMessage方法
  34. public override string PushMessage()
  35. {
  36. string strResult = "";
  37. //1.创建异步任务
  38. Task<string> task = Baidu_Helper.SendBaidu(this.httpMehtod, this.url, this.secret_key, this.mod);
  39. //2.等待任务完成
  40. task.Wait();
  41. //3.异步任务完成
  42. if (task.IsCompleted)
  43. {
  44. strResult = task.Result.ToString();
  45. }
  46. return strResult;
  47. }
  48. #endregion
  49. }
  50. }