Niagara參數移動至appsetting.json

This commit is contained in:
史萬澤 2023-03-02 14:24:34 +08:00
parent fb37ac3014
commit 44252d029c
7 changed files with 133 additions and 11 deletions

View File

@ -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<Device_value> 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<ImpNiaItem> 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;

View File

@ -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<string>("DBConfig:MySqlDBConfig:Database");
#endregion MySql DB Config
#region NiagaraDataSync Config
BackEndConfig.NiagaraDataSyncConfig.UrlSlot = Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:UrlSlot");
BackEndConfig.NiagaraDataSyncConfig.ObixQuery= Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:ObixQuery");
BackEndConfig.NiagaraDataSyncConfig.ObixHisBqlQuery = Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:ObixHisBqlQuery");
BackEndConfig.NiagaraDataSyncConfig.ObixHisUrlQuery = Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:ObixHisUrlQuery");
#endregion
}
public IConfiguration Configuration { get; }
@ -89,6 +100,13 @@ namespace Backend
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
#endregion DBHelper ª`¤J
#region BackEndConfigHelper ª`¤J
services.Configure<BackEndConfig>(Configuration.GetSection("BackEndConfig"));
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
#endregion DBHelper ª`¤J
#region Repository ª`¤J
services.AddTransient<IBackendRepository, BackendRepository>();
services.AddTransient<IFrontendRepository, FrontendRepository>();

View File

@ -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" //
}
}
}

View File

@ -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" //
}
}
}

View File

@ -73,6 +73,13 @@ namespace BackendWorkerService
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
#endregion DBHelper ª`¤J
#region BackEndConfigHelper ª`¤J
services.Configure<BackEndConfig>(configuration.GetSection("BackEndConfig"));
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
#endregion BackEndConfigHelper ª`¤J
#region Repository ª`¤J
services.AddTransient<IBackendRepository, BackendRepository>();
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();

View File

@ -0,0 +1,57 @@
using Microsoft.Extensions.Options;
using Repository.Models;
namespace Repository.Helper
{
public interface IBackEndConfigHelper
{
/// <summary>
/// 取得url_slot
/// </summary>
/// <returns></returns>
string GetUrlSlot();
/// <summary>
/// 取得obixQuery
/// </summary>
/// <returns></returns>
string GetobixQuery();
string GetobixHisBqlQuery();
string GetobixHisUrlQuery();
}
public class BackEndConfigHelper : IBackEndConfigHelper
{
private NiagaraDataSyncConfig _NiagaraDataSyncConfig;
private EDFunction ed;
public BackEndConfigHelper(IOptions<BackEndConfig> 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);
}
}
}

View File

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