using Blue;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
///
/// 获取点云文件(json、bytes)的Url下载地址命令
///
public class PointFileGetUrlCommand : ICommand
{
private string methodName = "/project/pointcloud";
private int sceneID;
private PointFileType fileType;
///
/// 获取点云文件(json、bytes)的Url下载地址命令
///
/// 场景ID
/// 文件类型
public PointFileGetUrlCommand(int sceneId, PointFileType fileType)
{
this.sceneID = sceneId;
this.fileType = fileType;
}
public void OnExcute()
{
this.GetService().GetPointFileDownloadUrl(methodName, sceneID.ToString(), fileType, GetPointFileUrlSuccess);
}
private void GetPointFileUrlSuccess(string message)
{
if (!string.IsNullOrWhiteSpace(message))
{
JObject jobject = JObject.Parse(message);
if (jobject["code"].ToString() == "200")
{
message = jobject["data"].ToString();
if (!string.IsNullOrWhiteSpace(message))
{
PointFileData PointFile = JsonConvert.DeserializeObject(message);
this.GetService().DownloadPointFile(PointFile.url, fileType);
}
}
}
}
}