From 85b6553db7a529622e35a7a4c27bbd2657e7e21f Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 24 Apr 2023 18:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A9=B2obix=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeController.cs | 27 ++++++++++++++----- Backend/Models/ObixApiConfig.cs | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index af030d6..3ef1717 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -45,16 +45,22 @@ namespace Backend.Controllers try { + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + var variableObix = backendRepository.GetAllAsync(sqlObix).Result; + var obixApiConfig = new Backend.Models.ObixApiConfig(); + EDFunction ed = new EDFunction(); + obixApiConfig.ApiBase = variableObix.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault() + "obix/config/Program/ObixQuery/query/"; + obixApiConfig.UrlSlot = variableObix.Where(x => x.Name == "url_slot").Select(x => x.Value).FirstOrDefault(); + obixApiConfig.TagQuantity = variableObix.Where(x => x.Name == "tag_quantity").Select(x => x.Value).FirstOrDefault(); + List ds; - string url_slot = backEndConfig.GetUrlSlot(); - string tag_quantity = backEndConfig.Getobixtag_quantity(); string top100 = "";//" top 100 "; webRequestService svc = new webRequestService(); - string bql = url_slot + "bql:select " + top100 + " * from baja:Folder "; + string bql = obixApiConfig.UrlSlot + "bql:select " + top100 + " * from baja:Folder "; //ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Arena/Program/ObixQuery/query/", bql); //ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql); - ds = svc.obixQuery(backEndConfig.GetobixQuery(), bql, tag_quantity);//三菱 + ds = svc.obixQuery(obixApiConfig.ApiBase, bql, obixApiConfig.TagQuantity);//三菱 apiResult.Code = "0000"; apiResult.Data = ds; @@ -119,10 +125,19 @@ namespace Backend.Controllers try { List ds; - string url_slot = backEndConfig.GetUrlSlot(); webRequestService svc = new webRequestService(); - ds = svc.obixHisQuery(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), url_slot, backEndConfig.Getobixtag_acc(), backEndConfig.Getobixtag_pass());//三菱 + + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + var variableObix = backendRepository.GetAllAsync(sqlObix).Result; + var obixApiConfig = new Backend.Models.ObixApiConfig(); + EDFunction ed = new EDFunction(); + obixApiConfig.ApiBase = variableObix.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault(); + obixApiConfig.UserName = ed.AESDecrypt(variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault()); + obixApiConfig.Password = ed.AESDecrypt(variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault()); + obixApiConfig.UrlSlot = ed.AESDecrypt(variableObix.Where(x => x.Name == "url_slot").Select(x => x.Value).FirstOrDefault()); + ds = svc.obixHisQuery(obixApiConfig.ApiBase + "obix/config/Program/ObixQuery/query/", obixApiConfig.ApiBase + "obix/histories",obixApiConfig.UrlSlot, obixApiConfig.UserName, + obixApiConfig.Password); apiResult.Code = "0000"; apiResult.Data = ds.Where(x => x.device_building_tag == building.building).ToList(); ; diff --git a/Backend/Models/ObixApiConfig.cs b/Backend/Models/ObixApiConfig.cs index f90749b..df31b04 100644 --- a/Backend/Models/ObixApiConfig.cs +++ b/Backend/Models/ObixApiConfig.cs @@ -10,5 +10,7 @@ namespace Backend.Models public string ApiBase { get; set; } public string UserName { get; set; } public string Password { get; set; } + public string UrlSlot { get; set; } + public string TagQuantity { get; set; } } }