PointFileGetUrlCommand.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Blue;
  2. using Newtonsoft.Json.Linq;
  3. using Newtonsoft.Json;
  4. /// <summary>
  5. /// 获取点云文件(json、bytes)的Url下载地址命令
  6. /// </summary>
  7. public class PointFileGetUrlCommand : ICommand
  8. {
  9. private string methodName = "/project/pointcloud";
  10. private int sceneID;
  11. private PointFileType fileType;
  12. /// <summary>
  13. /// 获取点云文件(json、bytes)的Url下载地址命令
  14. /// </summary>
  15. /// <param name="sceneId">场景ID</param>
  16. /// <param name="fileType">文件类型</param>
  17. public PointFileGetUrlCommand(int sceneId, PointFileType fileType)
  18. {
  19. this.sceneID = sceneId;
  20. this.fileType = fileType;
  21. }
  22. public void OnExcute()
  23. {
  24. this.GetService<IPointService>().GetPointFileDownloadUrl(methodName, sceneID.ToString(), fileType, GetPointFileUrlSuccess);
  25. }
  26. private void GetPointFileUrlSuccess(string message)
  27. {
  28. if (!string.IsNullOrWhiteSpace(message))
  29. {
  30. JObject jobject = JObject.Parse(message);
  31. if (jobject["code"].ToString() == "200")
  32. {
  33. message = jobject["data"].ToString();
  34. if (!string.IsNullOrWhiteSpace(message))
  35. {
  36. PointFileData PointFile = JsonConvert.DeserializeObject<PointFileData>(message);
  37. this.GetService<IPointService>().DownloadPointFile(PointFile.url, fileType);
  38. }
  39. }
  40. }
  41. }
  42. }