diff --git a/Backend/Views/BuildInfo/Index.cshtml b/Backend/Views/BuildInfo/Index.cshtml
index a498f85..29306d2 100644
--- a/Backend/Views/BuildInfo/Index.cshtml
+++ b/Backend/Views/BuildInfo/Index.cshtml
@@ -762,11 +762,14 @@
return;
}
else {
+ $('#floor-modal').modal();
+
$("#BuildName").html(selected_build_guid_top_name);
$("#floor_name_modal").val(rel.data.full_name);
- @*$("#map_file_preview_modal").attr("data-original", rel.data.mapUrl);*@
-
- $('#floor-modal').modal();
+ if (rel.data.mapUrl)
+ loadURLToInputFiled(rel.data.mapUrl, rel.data.initMapName + ".svg");
+ else
+ $('#floor_map_file_modal')[0].value = "";
}
}, 'json');
});
@@ -977,6 +980,27 @@
}
//#endregion
+ function loadURLToInputFiled(url, filesName){
+ getImgURL(url, (imgBlob)=>{
+ // Load img blob to input
+ // WIP: UTF8 character error
+ let fileName = filesName
+ let file = new File([imgBlob], fileName,{type:"image/svg+xml", lastModified:new Date().getTime()}, 'utf-8');
+ let container = new DataTransfer();
+ container.items.add(file);
+ $('#floor_map_file_modal')[0].files = container.files;
+ })
+ }
+ // xmlHTTP return blob respond
+ function getImgURL(url, callback){
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ callback(xhr.response);
+ };
+ xhr.open('GET', url);
+ xhr.responseType = 'blob';
+ xhr.send();
+ }
}
\ No newline at end of file
diff --git a/Backend/Views/NiagaraDataSynchronize/Index.cshtml b/Backend/Views/NiagaraDataSynchronize/Index.cshtml
index 7bd6a7d..b5c5304 100644
--- a/Backend/Views/NiagaraDataSynchronize/Index.cshtml
+++ b/Backend/Views/NiagaraDataSynchronize/Index.cshtml
@@ -140,6 +140,7 @@
//#endregion
function SynchronizeData() {
+ showSpinner();
document.getElementById('loadDataText').innerText = "同步中...";
if (ds.length > 0) {
//比對資料,有差異的話,再同步到device等資料表
@@ -154,12 +155,13 @@
url: url_synchronize_data,
data: JSON.stringify(ds),
cache: false,
- async: false,
+ async: true,
contentType: "application/json; charset=UTF-8",
dataType: 'json',
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
+ showSpinner();
document.getElementById('loadDataText').innerText = "比對資料出錯了!";
return;
}
@@ -208,10 +210,12 @@
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
+ showSpinner();
document.getElementById('loadDataText').innerText = "比對資料出錯了!";
return;
}
+ hideSpinner();
console.log(rel);
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date + ' ' + time;
diff --git a/Backend/Views/Shared/_Layout.cshtml b/Backend/Views/Shared/_Layout.cshtml
index c5d27af..9587242 100644
--- a/Backend/Views/Shared/_Layout.cshtml
+++ b/Backend/Views/Shared/_Layout.cshtml
@@ -27,6 +27,11 @@
+
diff --git a/Backend/wwwroot/css/site.css b/Backend/wwwroot/css/site.css
index dd26b5a..3319720 100644
--- a/Backend/wwwroot/css/site.css
+++ b/Backend/wwwroot/css/site.css
@@ -46,4 +46,35 @@ label.error {
.t-gray {
color:var(--bims-gray) !important;
+}
+
+/* Absolute Center Spinner */
+.loading {
+ position: fixed;
+ z-index: 999;
+ display: block;
+ margin: auto;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ width: 50px;
+ height: 50px;
+}
+
+/* Transparent Overlay */
+.loading:before {
+ content: '';
+ display: block;
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background: radial-gradient(rgba(0, 0, 0, .5), rgba(0, 0, 0, .5));
+ background: -webkit-radial-gradient(rgba(0, 0, 0, .5), rgba(0, 0, 0, .5));
+}
+
+.loading.hide {
+ display: none;
}
\ No newline at end of file
diff --git a/Backend/wwwroot/js/site.js b/Backend/wwwroot/js/site.js
index 0cccb43..51b8b64 100644
--- a/Backend/wwwroot/js/site.js
+++ b/Backend/wwwroot/js/site.js
@@ -222,3 +222,11 @@ function SaveSpinner(status) { //1:Spinner 0:還原儲存
$(document).ready(function () {
});
+
+function showSpinner() {
+ $("#spinner").removeClass("hide");
+}
+
+function hideSpinner() {
+ $("#spinner").addClass("hide");
+}
\ No newline at end of file
diff --git a/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs b/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs
index a574ce1..f1d296f 100644
--- a/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs
+++ b/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs
@@ -786,6 +786,7 @@ namespace BackendWorkerService.Services.Implement
}
catch (Exception exception)
{
+
throw exception;
}
@@ -795,28 +796,98 @@ namespace BackendWorkerService.Services.Implement
private List> ArrangeRawData(DeviceNumberPoint deviceNumberPoint, JObject jsonResult)
{
List> arrangeRawDatas = new List>();
- var histories = jsonResult["obj"]["list"];
- var rawdateCount = Convert.ToInt32(jsonResult["obj"]["int"]["@val"].ToString());
-
- if (rawdateCount == 0)
+ try
{
- return null;
- }
+ var histories = jsonResult["obj"]["list"];
+ var rawdateCount = Convert.ToInt32(jsonResult["obj"]["int"]["@val"].ToString());
- if (histories != null && histories.HasValues)
- {
- if (rawdateCount > 1)
- { //多筆資料
- foreach (var history in histories)
- {
+ if (rawdateCount == 0)
+ {
+ return null;
+ }
+
+ if (histories != null && histories.HasValues)
+ {
+ if (rawdateCount > 1)
+ { //多筆資料
+ foreach (var history in histories)
+ {
+ Dictionary arrangeRawData = new Dictionary();
+ arrangeRawData.Add("@device_number", deviceNumberPoint.DeviceNumber);
+ arrangeRawData.Add("@point", deviceNumberPoint.Point);
+
+ //時間
+ if (history["abstime"] != null && history["abstime"].HasValues)
+ {
+ foreach (var abstime in history["abstime"])
+ {
+ var name = abstime["@name"].ToString();
+ switch (name)
+ {
+ case "start":
+ var startTimstamp = Convert.ToDateTime(abstime["@val"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
+ arrangeRawData.Add("@start_timestamp", startTimstamp);
+ break;
+ case "end":
+ var endTimstamp = Convert.ToDateTime(abstime["@val"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
+ arrangeRawData.Add("@end_timestamp", endTimstamp);
+ break;
+ }
+ }
+ }
+
+ //區間內資料筆數
+ if (history["int"] != null && history["int"].HasValues)
+ {
+ var count = Convert.ToInt32(histories["obj"]["int"]["@val"].ToString());
+ arrangeRawData.Add("@count_rawdata", count);
+ }
+
+ //整合數值(最大、最小、平均、總和)
+ if (history["real"] != null && history["real"].HasValues)
+ {
+ foreach (var real in history["real"])
+ {
+ var name = real["@name"].ToString();
+ switch (name)
+ {
+ case "min":
+ var min = Convert.ToDecimal(real["@val"].ToString());
+ arrangeRawData.Add("@min_rawdata", min);
+ break;
+ case "max":
+ var max = Convert.ToDecimal(real["@val"].ToString());
+ arrangeRawData.Add("@max_rawdata", max);
+ break;
+ case "avg":
+ var avg = Convert.ToDecimal(real["@val"].ToString());
+ arrangeRawData.Add("@avg_rawdata", avg);
+ break;
+ case "sum":
+ var sum = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
+ arrangeRawData.Add("@sum_rawdata", sum);
+ break;
+ }
+ }
+ }
+ arrangeRawData.Add("@is_complete", 1);
+ arrangeRawData.Add("@repeat_times", 0);
+ arrangeRawData.Add("@fail_reason", null);
+ arrangeRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
+
+ arrangeRawDatas.Add(arrangeRawData);
+ }
+ }
+ else
+ { //單筆資料
Dictionary arrangeRawData = new Dictionary();
arrangeRawData.Add("@device_number", deviceNumberPoint.DeviceNumber);
arrangeRawData.Add("@point", deviceNumberPoint.Point);
//時間
- if (history["abstime"] != null && history["abstime"].HasValues)
+ if (histories["obj"]["abstime"] != null && histories["obj"]["abstime"].HasValues)
{
- foreach (var abstime in history["abstime"])
+ foreach (var abstime in histories["obj"]["abstime"])
{
var name = abstime["@name"].ToString();
switch (name)
@@ -834,16 +905,16 @@ namespace BackendWorkerService.Services.Implement
}
//區間內資料筆數
- if (history["int"] != null && history["int"].HasValues)
+ if (histories["obj"]["int"] != null && histories["obj"]["int"].HasValues)
{
var count = Convert.ToInt32(histories["obj"]["int"]["@val"].ToString());
arrangeRawData.Add("@count_rawdata", count);
}
//整合數值(最大、最小、平均、總和)
- if (history["real"] != null && history["real"].HasValues)
+ if (histories["obj"]["real"] != null && histories["obj"]["real"].HasValues)
{
- foreach (var real in history["real"])
+ foreach (var real in histories["obj"]["real"])
{
var name = real["@name"].ToString();
switch (name)
@@ -867,6 +938,7 @@ namespace BackendWorkerService.Services.Implement
}
}
}
+
arrangeRawData.Add("@is_complete", 1);
arrangeRawData.Add("@repeat_times", 0);
arrangeRawData.Add("@fail_reason", null);
@@ -875,77 +947,13 @@ namespace BackendWorkerService.Services.Implement
arrangeRawDatas.Add(arrangeRawData);
}
}
- else
- { //單筆資料
- Dictionary arrangeRawData = new Dictionary();
- arrangeRawData.Add("@device_number", deviceNumberPoint.DeviceNumber);
- arrangeRawData.Add("@point", deviceNumberPoint.Point);
- //時間
- if (histories["obj"]["abstime"] != null && histories["obj"]["abstime"].HasValues)
- {
- foreach (var abstime in histories["obj"]["abstime"])
- {
- var name = abstime["@name"].ToString();
- switch (name)
- {
- case "start":
- var startTimstamp = Convert.ToDateTime(abstime["@val"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- arrangeRawData.Add("@start_timestamp", startTimstamp);
- break;
- case "end":
- var endTimstamp = Convert.ToDateTime(abstime["@val"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- arrangeRawData.Add("@end_timestamp", endTimstamp);
- break;
- }
- }
- }
-
- //區間內資料筆數
- if (histories["obj"]["int"] != null && histories["obj"]["int"].HasValues)
- {
- var count = Convert.ToInt32(histories["obj"]["int"]["@val"].ToString());
- arrangeRawData.Add("@count_rawdata", count);
- }
-
- //整合數值(最大、最小、平均、總和)
- if (histories["obj"]["real"] != null && histories["obj"]["real"].HasValues)
- {
- foreach (var real in histories["obj"]["real"])
- {
- var name = real["@name"].ToString();
- switch (name)
- {
- case "min":
- var min = Convert.ToDecimal(real["@val"].ToString());
- arrangeRawData.Add("@min_rawdata", min);
- break;
- case "max":
- var max = Convert.ToDecimal(real["@val"].ToString());
- arrangeRawData.Add("@max_rawdata", max);
- break;
- case "avg":
- var avg = Convert.ToDecimal(real["@val"].ToString());
- arrangeRawData.Add("@avg_rawdata", avg);
- break;
- case "sum":
- var sum = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
- arrangeRawData.Add("@sum_rawdata", sum);
- break;
- }
- }
- }
-
- arrangeRawData.Add("@is_complete", 1);
- arrangeRawData.Add("@repeat_times", 0);
- arrangeRawData.Add("@fail_reason", null);
- arrangeRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
-
- arrangeRawDatas.Add(arrangeRawData);
- }
+ return arrangeRawDatas;
+ }
+ catch (Exception ex)
+ {
+ return arrangeRawDatas;
}
-
- return arrangeRawDatas;
}
}
}