diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index 60e02b0..1933a14 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -11,6 +11,7 @@ using Repository.Models; using System.Linq; using Microsoft.Extensions.DependencyInjection; using NPOI.SS.Formula.Functions; +using Repository.Helper; namespace Backend.Controllers { @@ -19,11 +20,13 @@ namespace Backend.Controllers private readonly IBackendRepository backendRepository; //private readonly IDeviceImportRepository deviceImportRepository; private readonly INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository; - public NiagaraDataSynchronizeController(IBackendRepository backendRepository, INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository) + private readonly IBackEndConfigHelper backEndConfig; + public NiagaraDataSynchronizeController(IBackendRepository backendRepository, INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository,IBackEndConfigHelper backEndConfig) { this.backendRepository = backendRepository; //this.deviceImportRepository = deviceImportRepository; this.niagaraDataSynchronizeRepository = niagaraDataSynchronizeRepository; + this.backEndConfig = backEndConfig; } public IActionResult Index() @@ -43,16 +46,14 @@ namespace Backend.Controllers try { List ds; - string url_slot = "slot:/TPE/B1|";//三菱 - //string url_slot = "slot:/NTPC/B1|";//wsp + string url_slot = backEndConfig.GetUrlSlot(); string top100 = "";//" top 100 "; webRequestService svc = new webRequestService(); string bql = url_slot + "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("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", bql);//三菱 - //ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp + ds = svc.obixQuery(backEndConfig.GetobixQuery(), bql);//三菱 apiResult.Code = "0000"; apiResult.Data = ds; @@ -112,12 +113,10 @@ namespace Backend.Controllers try { List ds; - string url_slot = "slot:/TPE/B1|";//三菱 - //string url_slot = "slot:/NTPC/B1|";//wsp + string url_slot = backEndConfig.GetUrlSlot(); webRequestService svc = new webRequestService(); - ds = svc.obixHisQuery("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", "http://192.168.0.136:8080/obix/histories", url_slot);//三菱 - //ds = svc.obixHisQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", "http://192.168.0.136:8081/obix/histories", url_slot);//wsp + ds = svc.obixHisQuery(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), url_slot);//三菱 apiResult.Code = "0000"; apiResult.Data = ds; diff --git a/Backend/Startup.cs b/Backend/Startup.cs index 7285fc6..37e1ba6 100644 --- a/Backend/Startup.cs +++ b/Backend/Startup.cs @@ -36,6 +36,10 @@ namespace Backend MySqlDBConfig = new MySqlDBConfig() }; + public BackEndConfig BackEndConfig = new BackEndConfig() + { + NiagaraDataSyncConfig=new NiagaraDataSyncConfig() + }; public Startup(IConfiguration configuration) { Configuration = configuration; @@ -56,6 +60,13 @@ namespace Backend dBConfig.MySqlDBConfig.Database = Configuration.GetValue("DBConfig:MySqlDBConfig:Database"); #endregion MySql DB Config + #region NiagaraDataSync Config + BackEndConfig.NiagaraDataSyncConfig.UrlSlot = Configuration.GetValue("BackEndConfig:NiagaraDataSyncConfig:UrlSlot"); + BackEndConfig.NiagaraDataSyncConfig.ObixQuery= Configuration.GetValue("BackEndConfig:NiagaraDataSyncConfig:ObixQuery"); + BackEndConfig.NiagaraDataSyncConfig.ObixHisBqlQuery = Configuration.GetValue("BackEndConfig:NiagaraDataSyncConfig:ObixHisBqlQuery"); + BackEndConfig.NiagaraDataSyncConfig.ObixHisUrlQuery = Configuration.GetValue("BackEndConfig:NiagaraDataSyncConfig:ObixHisUrlQuery"); + #endregion + } public IConfiguration Configuration { get; } @@ -89,6 +100,13 @@ namespace Backend services.AddTransient(); #endregion DBHelper `J + #region BackEndConfigHelper `J + services.Configure(Configuration.GetSection("BackEndConfig")); + services.AddTransient(); + #endregion DBHelper `J + + + #region Repository `J services.AddTransient(); services.AddTransient(); diff --git a/Backend/appsettings.Development.json b/Backend/appsettings.Development.json index 4dca5d7..d879b34 100644 --- a/Backend/appsettings.Development.json +++ b/Backend/appsettings.Development.json @@ -42,5 +42,17 @@ // "Root": "+plVKQ+enAqt7BYV2uMQng==", // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" //} + }, + "BackEndConfig": { + "NiagaraDataSyncConfig": { + "UrlSlot": "GbZ+gly0WQOx1PO+Y4T1/A==", //WSP + "ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP + "ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP + "ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpObRPTGh1jI6LBqMJk0hrp7UqBfP1mt4ADLSdmf4ubca" //WSP + //"UrlSlot": "+I/QBiWGAk/BQZOwiz16gw==", //三菱 + //"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱 + //"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱 + //"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //三菱 + } } } diff --git a/Backend/appsettings.json b/Backend/appsettings.json index 2034e27..8d796da 100644 --- a/Backend/appsettings.json +++ b/Backend/appsettings.json @@ -16,8 +16,8 @@ "MySqlDBConfig": { "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Port": "js2LutKe+rdjzdxMPQUrvQ==", - "Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱 - //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp + //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱 + "Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } @@ -28,5 +28,17 @@ // "Root": "+plVKQ+enAqt7BYV2uMQng==", // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" //} + }, + "BackEndConfig": { + "NiagaraDataSyncConfig": { + "UrlSlot": "GbZ+gly0WQOx1PO+Y4T1/A==", //WSP + "ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP + "ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP + "ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpObRPTGh1jI6LBqMJk0hrp7UqBfP1mt4ADLSdmf4ubca" //WSP + //"UrlSlot": "+I/QBiWGAk/BQZOwiz16gw==", //三菱 + //"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱 + //"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱 + //"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //三菱 + } } } diff --git a/BackendWorkerService/Program.cs b/BackendWorkerService/Program.cs index b076db2..d773820 100644 --- a/BackendWorkerService/Program.cs +++ b/BackendWorkerService/Program.cs @@ -73,6 +73,13 @@ namespace BackendWorkerService services.AddTransient(); #endregion DBHelper `J + + #region BackEndConfigHelper `J + services.Configure(configuration.GetSection("BackEndConfig")); + services.AddTransient(); + #endregion BackEndConfigHelper `J + + #region Repository `J services.AddTransient(); services.AddTransient(); diff --git a/Repository/Helper/BackEndConfigHelper.cs b/Repository/Helper/BackEndConfigHelper.cs new file mode 100644 index 0000000..d3fd62f --- /dev/null +++ b/Repository/Helper/BackEndConfigHelper.cs @@ -0,0 +1,57 @@ +using Microsoft.Extensions.Options; +using Repository.Models; + +namespace Repository.Helper +{ + public interface IBackEndConfigHelper + { + /// + /// 取得url_slot + /// + /// + string GetUrlSlot(); + + /// + /// 取得obixQuery + /// + /// + string GetobixQuery(); + + string GetobixHisBqlQuery(); + + string GetobixHisUrlQuery(); + } + + + public class BackEndConfigHelper : IBackEndConfigHelper + { + private NiagaraDataSyncConfig _NiagaraDataSyncConfig; + private EDFunction ed; + public BackEndConfigHelper(IOptions BackEndConfig) + { + _NiagaraDataSyncConfig = BackEndConfig.Value.NiagaraDataSyncConfig; + + ed = new EDFunction(); + } + public string GetUrlSlot() + { + return ed.AESDecrypt(_NiagaraDataSyncConfig.UrlSlot); + } + public string GetobixQuery() + { + return ed.AESDecrypt(_NiagaraDataSyncConfig.ObixQuery); + } + + public string GetobixHisBqlQuery() + { + return ed.AESDecrypt(_NiagaraDataSyncConfig.ObixHisBqlQuery); + } + public string GetobixHisUrlQuery() + { + return ed.AESDecrypt(_NiagaraDataSyncConfig.ObixHisUrlQuery); + } + + + } + +} diff --git a/Repository/Models/BackEndConfig.cs b/Repository/Models/BackEndConfig.cs new file mode 100644 index 0000000..f830321 --- /dev/null +++ b/Repository/Models/BackEndConfig.cs @@ -0,0 +1,17 @@ +namespace Repository.Models +{ + public class BackEndConfig + { + public NiagaraDataSyncConfig NiagaraDataSyncConfig { get; set; } + } + + public class NiagaraDataSyncConfig + { + public string UrlSlot { get; set; } + public string ObixQuery { get; set; } + public string ObixHisBqlQuery { get; set; } + public string ObixHisUrlQuery { get; set; } + } + + +}