Niagara參數移動至appsetting.json
This commit is contained in:
parent
fb37ac3014
commit
44252d029c
@ -11,6 +11,7 @@ using Repository.Models;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
|
using Repository.Helper;
|
||||||
|
|
||||||
namespace Backend.Controllers
|
namespace Backend.Controllers
|
||||||
{
|
{
|
||||||
@ -19,11 +20,13 @@ namespace Backend.Controllers
|
|||||||
private readonly IBackendRepository backendRepository;
|
private readonly IBackendRepository backendRepository;
|
||||||
//private readonly IDeviceImportRepository deviceImportRepository;
|
//private readonly IDeviceImportRepository deviceImportRepository;
|
||||||
private readonly INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository;
|
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.backendRepository = backendRepository;
|
||||||
//this.deviceImportRepository = deviceImportRepository;
|
//this.deviceImportRepository = deviceImportRepository;
|
||||||
this.niagaraDataSynchronizeRepository = niagaraDataSynchronizeRepository;
|
this.niagaraDataSynchronizeRepository = niagaraDataSynchronizeRepository;
|
||||||
|
this.backEndConfig = backEndConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -43,16 +46,14 @@ namespace Backend.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Device_value> ds;
|
List<Device_value> ds;
|
||||||
string url_slot = "slot:/TPE/B1|";//三菱
|
string url_slot = backEndConfig.GetUrlSlot();
|
||||||
//string url_slot = "slot:/NTPC/B1|";//wsp
|
|
||||||
|
|
||||||
string top100 = "";//" top 100 ";
|
string top100 = "";//" top 100 ";
|
||||||
webRequestService svc = new webRequestService();
|
webRequestService svc = new webRequestService();
|
||||||
string bql = url_slot + "bql:select " + top100 + " * from baja:Folder ";
|
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://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://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(backEndConfig.GetobixQuery(), bql);//三菱
|
||||||
//ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp
|
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = ds;
|
apiResult.Data = ds;
|
||||||
@ -112,12 +113,10 @@ namespace Backend.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<ImpNiaItem> ds;
|
List<ImpNiaItem> ds;
|
||||||
string url_slot = "slot:/TPE/B1|";//三菱
|
string url_slot = backEndConfig.GetUrlSlot();
|
||||||
//string url_slot = "slot:/NTPC/B1|";//wsp
|
|
||||||
|
|
||||||
webRequestService svc = new webRequestService();
|
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(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), 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
|
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = ds;
|
apiResult.Data = ds;
|
||||||
|
@ -36,6 +36,10 @@ namespace Backend
|
|||||||
MySqlDBConfig = new MySqlDBConfig()
|
MySqlDBConfig = new MySqlDBConfig()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public BackEndConfig BackEndConfig = new BackEndConfig()
|
||||||
|
{
|
||||||
|
NiagaraDataSyncConfig=new NiagaraDataSyncConfig()
|
||||||
|
};
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
@ -56,6 +60,13 @@ namespace Backend
|
|||||||
dBConfig.MySqlDBConfig.Database = Configuration.GetValue<string>("DBConfig:MySqlDBConfig:Database");
|
dBConfig.MySqlDBConfig.Database = Configuration.GetValue<string>("DBConfig:MySqlDBConfig:Database");
|
||||||
#endregion MySql DB Config
|
#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; }
|
public IConfiguration Configuration { get; }
|
||||||
@ -89,6 +100,13 @@ namespace Backend
|
|||||||
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
||||||
#endregion DBHelper ª`¤J
|
#endregion DBHelper ª`¤J
|
||||||
|
|
||||||
|
#region BackEndConfigHelper ª`¤J
|
||||||
|
services.Configure<BackEndConfig>(Configuration.GetSection("BackEndConfig"));
|
||||||
|
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
|
||||||
|
#endregion DBHelper ª`¤J
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Repository ª`¤J
|
#region Repository ª`¤J
|
||||||
services.AddTransient<IBackendRepository, BackendRepository>();
|
services.AddTransient<IBackendRepository, BackendRepository>();
|
||||||
services.AddTransient<IFrontendRepository, FrontendRepository>();
|
services.AddTransient<IFrontendRepository, FrontendRepository>();
|
||||||
|
@ -42,5 +42,17 @@
|
|||||||
// "Root": "+plVKQ+enAqt7BYV2uMQng==",
|
// "Root": "+plVKQ+enAqt7BYV2uMQng==",
|
||||||
// "Password": "0O24es2ZRF5uoJ4aU+YCdg=="
|
// "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" //三菱
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
"MySqlDBConfig": {
|
"MySqlDBConfig": {
|
||||||
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
|
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
|
||||||
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
||||||
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱
|
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱
|
||||||
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
||||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||||
}
|
}
|
||||||
@ -28,5 +28,17 @@
|
|||||||
// "Root": "+plVKQ+enAqt7BYV2uMQng==",
|
// "Root": "+plVKQ+enAqt7BYV2uMQng==",
|
||||||
// "Password": "0O24es2ZRF5uoJ4aU+YCdg=="
|
// "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" //三菱
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,13 @@ namespace BackendWorkerService
|
|||||||
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
||||||
#endregion DBHelper ª`¤J
|
#endregion DBHelper ª`¤J
|
||||||
|
|
||||||
|
|
||||||
|
#region BackEndConfigHelper ª`¤J
|
||||||
|
services.Configure<BackEndConfig>(configuration.GetSection("BackEndConfig"));
|
||||||
|
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
|
||||||
|
#endregion BackEndConfigHelper ª`¤J
|
||||||
|
|
||||||
|
|
||||||
#region Repository ª`¤J
|
#region Repository ª`¤J
|
||||||
services.AddTransient<IBackendRepository, BackendRepository>();
|
services.AddTransient<IBackendRepository, BackendRepository>();
|
||||||
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();
|
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();
|
||||||
|
57
Repository/Helper/BackEndConfigHelper.cs
Normal file
57
Repository/Helper/BackEndConfigHelper.cs
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
Repository/Models/BackEndConfig.cs
Normal file
17
Repository/Models/BackEndConfig.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user