GetTencentAddressInfoService.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Threading;
  6. using MySystem.Models;
  7. using Library;
  8. using LitJson;
  9. namespace MySystem
  10. {
  11. /// <summary>
  12. /// 获取腾讯地图地址
  13. /// </summary>
  14. public class GetTencentAddressInfoService
  15. {
  16. public readonly static GetTencentAddressInfoService Instance = new GetTencentAddressInfoService();
  17. private GetTencentAddressInfoService()
  18. { }
  19. public void Start()
  20. {
  21. Thread th = new Thread(GetTencentAddress);
  22. th.IsBackground = true;
  23. th.Start();
  24. }
  25. public void GetTencentAddress()
  26. {
  27. while (true)
  28. {
  29. try
  30. {
  31. string data = RedisDbconn.Instance.RPop<string>("GetTencentAddressInfoQueue");
  32. JsonData jsonObj = JsonMapper.ToObject(data);
  33. string Address = jsonObj["Data"]["Address"].ToString();
  34. string Key = Library.ConfigurationManager.AppSettings["TencentKey"].ToString();
  35. var info = function.GetWebRequest("https://apis.map.qq.com/ws/geocoder/v1/?address=" + Address + "&key=" + Key);
  36. }
  37. catch (Exception ex)
  38. {
  39. function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具执行扣费异常");
  40. }
  41. Thread.Sleep(100000);
  42. }
  43. }
  44. }
  45. }