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; } } }