[Frontend][圖資管理] 增加 size 欄位程序調整 | 下載程序調整

This commit is contained in:
dev01 2022-12-14 18:27:51 +08:00
parent e4a3cc9597
commit 4ba52a8a18
4 changed files with 24 additions and 6 deletions

View File

@ -285,20 +285,22 @@
}) })
onEvent("click", "a[id^=oriDwgDown]", function () { onEvent("click", "a[id^=oriDwgDown]", function () {
let dowLoaEle = YT.Alert.Tip("準備下載中...", "show", true);
let rowData = graTable.row($(this).closest("tr")).data(); let rowData = graTable.row($(this).closest("tr")).data();
let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.oriSavName}&oriname=${rowData.oriOrgName}`; let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.oriSavName}&oriname=${rowData.oriOrgName}`;
let extname = rowData.oriOrgName?.split(".").slice(-1) || "dwg"; let extname = rowData.oriOrgName?.split(".").slice(-1) || "dwg";
download(token, apiUrl, rowData.name + "_原設計圖" + "." + extname, function () { download(token, apiUrl, rowData.name + "_原設計圖" + "." + extname, function () {
$(dowLoaEle.ele).YTAlert().hide();
}); });
}) })
onEvent("click", "a[id^=donDwgDown]", function () { onEvent("click", "a[id^=donDwgDown]", function () {
let dowLoaEle = YT.Alert.Tip("準備下載中...", "show", true);
let rowData = graTable.row($(this).closest("tr")).data(); let rowData = graTable.row($(this).closest("tr")).data();
let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.donSavName}&oriname=${rowData.donOrgName}`; let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.donSavName}&oriname=${rowData.donOrgName}`;
let extname = rowData.donOrgName?.split(".").slice(-1) || "dwg"; let extname = rowData.donOrgName?.split(".").slice(-1) || "dwg";
download(token, apiUrl, rowData.name + "_竣工圖" + "." + extname, function () { download(token, apiUrl, rowData.name + "_竣工圖" + "." + extname, function () {
$(dowLoaEle.ele).YTAlert().hide();
}); });
}) })
@ -522,11 +524,11 @@
$("#graPicName").val(res.data?.name); $("#graPicName").val(res.data?.name);
$("#graLayer").text(levelNameByNodeId(res.data?.layer_id)); $("#graLayer").text(levelNameByNodeId(res.data?.layer_id));
if (res.data?.oriSavName != null) { if (res.data?.oriSavName != null) {
fileObj = { name: res.data?.oriOrgName, dataUrl: baseApiUrl + varGraPath + res.data?.oriSavName, savename: res.data?.oriSavName }; fileObj = { name: res.data?.oriOrgName, dataUrl: baseApiUrl + varGraPath + res.data?.oriSavName, savename: res.data?.oriSavName, size:res.data?.oriSize };
uploader["graMyDesignDiagram"][0].dropzone?.displayExistingFile(fileObj); uploader["graMyDesignDiagram"][0].dropzone?.displayExistingFile(fileObj);
} }
if (res.data?.donSavName != null) { if (res.data?.donSavName != null) {
fileObj = { name: res.data?.donOrgName, dataUrl: baseApiUrl + varGraPath + res.data?.donSavName, savename: res.data?.oriSavName }; fileObj = { name: res.data?.donOrgName, dataUrl: baseApiUrl + varGraPath + res.data?.donSavName, savename: res.data?.donSavName, size: res.data?.donSize };
uploader["graMyAsBuilt"][0].dropzone?.displayExistingFile(fileObj); uploader["graMyAsBuilt"][0].dropzone?.displayExistingFile(fileObj);
} }

View File

@ -329,14 +329,17 @@ namespace FrontendWebApi.ApiControllers
//edit file //edit file
//原設計圖修改 //原設計圖修改
var new_guid = Guid.NewGuid(); var new_guid = Guid.NewGuid();
long? fileSize = gm.oriSize ?? null;
//刪除原本檔案 //刪除原本檔案
if (gm.oriSavName != null && gii.oriSavName != gm.oriSavName) if (gm.oriSavName != null && gii.oriSavName != gm.oriSavName)
{ {
FolderFunction folderFunction = new FolderFunction(); FolderFunction folderFunction = new FolderFunction();
folderFunction.DeleteFile(Path.Combine(graphManageFileSaveAsPath, gm.oriSavName)); folderFunction.DeleteFile(Path.Combine(graphManageFileSaveAsPath, gm.oriSavName));
fileSize = null;
} }
string fileName = gii.oriSavName ?? null; string fileName = gii.oriSavName ?? null;
if (gii.oriOrgName != null && gii.oriFile != null) if (gii.oriOrgName != null && gii.oriFile != null)
{ {
fileName = new_guid + "." + gii.oriOrgName.Split('.')[1]; fileName = new_guid + "." + gii.oriOrgName.Split('.')[1];
@ -347,19 +350,24 @@ namespace FrontendWebApi.ApiControllers
{ {
gii.oriFile.CopyTo(stream); gii.oriFile.CopyTo(stream);
} }
fileSize = gii.oriFile.Length;
} }
graph_manage.Add("@oriSize", fileSize);
graph_manage.Add("@oriOrgName", gii.oriOrgName); graph_manage.Add("@oriOrgName", gii.oriOrgName);
graph_manage.Add("@oriSavName", fileName); graph_manage.Add("@oriSavName", fileName);
fileName = gii.donSavName ?? null; fileName = gii.donSavName ?? null;
//竣工圖修改 //竣工圖修改
new_guid = Guid.NewGuid(); new_guid = Guid.NewGuid();
fileSize = gm.donSize ?? null;
//刪除原本檔案 //刪除原本檔案
if (gm.donSavName != null && gii.donSavName != gm.donSavName) if (gm.donSavName != null && gii.donSavName != gm.donSavName)
{ {
var folderFunction = new FolderFunction(); var folderFunction = new FolderFunction();
folderFunction.DeleteFile(Path.Combine(graphManageFileSaveAsPath, gm.donSavName)); folderFunction.DeleteFile(Path.Combine(graphManageFileSaveAsPath, gm.donSavName));
fileSize = null;
} }
if (gii.donOrgName != null && gii.donFile != null) if (gii.donOrgName != null && gii.donFile != null)
@ -372,8 +380,10 @@ namespace FrontendWebApi.ApiControllers
{ {
gii.donFile.CopyTo(stream); gii.donFile.CopyTo(stream);
} }
fileSize = gii.donFile.Length;
} }
graph_manage.Add("@donSize", fileSize);
graph_manage.Add("@donOrgName", gii.donOrgName); graph_manage.Add("@donOrgName", gii.donOrgName);
graph_manage.Add("@donSavName", fileName); graph_manage.Add("@donSavName", fileName);
@ -428,7 +438,7 @@ namespace FrontendWebApi.ApiControllers
} }
Dictionary<string, object> graph_manage = new Dictionary<string, object>(); Dictionary<string, object> graph_manage = new Dictionary<string, object>();
//save file //save file
if (gii.oriOrgName != null || gii.donOrgName != null) if (gii.oriOrgName != null || gii.donOrgName != null)
{ {
@ -448,6 +458,7 @@ namespace FrontendWebApi.ApiControllers
gii.oriFile.CopyTo(stream); gii.oriFile.CopyTo(stream);
} }
graph_manage.Add("@oriSize", gii.oriFile.Length);
graph_manage.Add("@oriOrgName", gii.oriOrgName); graph_manage.Add("@oriOrgName", gii.oriOrgName);
graph_manage.Add("@oriSavName", fileName); graph_manage.Add("@oriSavName", fileName);
} }
@ -465,6 +476,7 @@ namespace FrontendWebApi.ApiControllers
gii.donFile.CopyTo(stream); gii.donFile.CopyTo(stream);
} }
graph_manage.Add("@donSize", gii.donFile.Length);
graph_manage.Add("@donOrgName", gii.donOrgName); graph_manage.Add("@donOrgName", gii.donOrgName);
graph_manage.Add("@donSavName", fileName); graph_manage.Add("@donSavName", fileName);
} }

View File

@ -18,6 +18,8 @@ namespace FrontendWebApi.Models
public string oriSavName { get; set; } public string oriSavName { get; set; }
public string donOrgName { get; set; } public string donOrgName { get; set; }
public string donSavName { get; set; } public string donSavName { get; set; }
public long? oriSize { get; set; }
public long? donSize { get; set; }
} }
public class GraphInsInfo public class GraphInsInfo
@ -35,6 +37,8 @@ namespace FrontendWebApi.Models
public int priority { get; set; } public int priority { get; set; }
public IFormFile oriFile { get; set; } public IFormFile oriFile { get; set; }
public IFormFile donFile { get; set; } public IFormFile donFile { get; set; }
public long? oriSize{ get; set; }
public long? donSize { get; set; }
} }
public class GraphInfo: Actor public class GraphInfo: Actor