private static bool CheckNeedDownloadFile(string locFilePath, string remoteMd5) { if (File.Exists(locFilePath)) { var md5 = TUtils.ComputeMd5Hash(locFilePath); if (remoteMd5.Equals(md5)) { return(false); } } return(true); }
public static void Test() { var procInfo = new ProcInfo(); procInfo.FileMd5 = TUtils.ComputeMd5Hash(@"E:\BimSrv2\gisserver\webapps\gis\1.dwg"); procInfo.FileName = "1.dwg"; procInfo.FileUrl = "http://127.0.0.1:8080/gis/1.dwg"; var jsonstr = JsonConvert.SerializeObject(procInfo); var base64str = TUtils.EncodeForProcInfo(jsonstr); TCadProxy.OpenCad(base64str); }
public static void OpenCad(string msg) { var origData = TUtils.DecodeForProcInfo(msg); if (string.IsNullOrWhiteSpace(origData)) { MessageBox.Show("数据错误"); return; } var proInfo = JsonToProcInfo(origData); if (proInfo == null) { MessageBox.Show("JSON格式错误"); return; } var cacheDir = Path.GetTempPath(); if (!Directory.Exists(cacheDir)) { Directory.CreateDirectory(cacheDir); } var locFilePath = Path.Combine(cacheDir, proInfo.FileName); var isNeedDl = CheckNeedDownloadFile(locFilePath, proInfo.FileMd5); var dlResult = true; if (isNeedDl) { dlResult = DownloadFileByUrl(proInfo.FileUrl, locFilePath); } if (!dlResult) { return; } TUtils.RunProcess(@"D:\Program\CAD快速看图\CADReader.exe", locFilePath); Thread.Sleep(1000); Application.Exit(); }