修改排成程序

This commit is contained in:
dev02 2023-05-04 16:45:05 +08:00
parent 3f45fe7c2c
commit 665f9a69f8
8 changed files with 522 additions and 296 deletions

View File

@ -83,6 +83,7 @@ namespace BackendWorkerService
#region Repository ª`¤J #region Repository ª`¤J
services.AddTransient<IBackendRepository, BackendRepository>(); services.AddTransient<IBackendRepository, BackendRepository>();
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>(); services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();
services.AddTransient<IBackgroundServiceMsSqlRepository, BackgroundServiceMsSqlRepository>();
services.AddTransient<IFrontendRepository, FrontendRepository>(); services.AddTransient<IFrontendRepository, FrontendRepository>();
services.AddTransient<IBaseRepository, BaseRepository>(); services.AddTransient<IBaseRepository, BaseRepository>();
#endregion Repository ª`¤J #endregion Repository ª`¤J

View File

@ -1,5 +1,6 @@
using Backend.Models; using Backend.Models;
using BackendWorkerService.Services.Implement; using BackendWorkerService.Services.Implement;
using Dapper;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -25,6 +26,7 @@ namespace BackendWorkerService.Quartz.Jobs
{ {
private readonly ILogger<ArchiveElectricMeterDayJob> logger; private readonly ILogger<ArchiveElectricMeterDayJob> logger;
private readonly IBackgroundServiceRepository backgroundServiceRepository; private readonly IBackgroundServiceRepository backgroundServiceRepository;
private readonly IBackgroundServiceMsSqlRepository backgroundServiceMsSqlRepository;
protected readonly IDatabaseHelper _databaseHelper; protected readonly IDatabaseHelper _databaseHelper;
private readonly ILogger<Task_Detail> loggers; private readonly ILogger<Task_Detail> loggers;
@ -32,10 +34,12 @@ namespace BackendWorkerService.Quartz.Jobs
public ArchiveElectricMeterDayJob( public ArchiveElectricMeterDayJob(
ILogger<ArchiveElectricMeterDayJob> logger, ILogger<ArchiveElectricMeterDayJob> logger,
IBackgroundServiceRepository backgroundServiceRepository, IBackgroundServiceRepository backgroundServiceRepository,
IBackgroundServiceMsSqlRepository backgroundServiceMySqlRepository,
IDatabaseHelper databaseHelper, ILogger<Task_Detail> loggers, IBackendRepository backendRepository) IDatabaseHelper databaseHelper, ILogger<Task_Detail> loggers, IBackendRepository backendRepository)
{ {
this.logger = logger; this.logger = logger;
this.backgroundServiceRepository = backgroundServiceRepository; this.backgroundServiceRepository = backgroundServiceRepository;
this.backgroundServiceMsSqlRepository = backgroundServiceMySqlRepository;
this._databaseHelper = databaseHelper; this._databaseHelper = databaseHelper;
this.loggers = loggers; this.loggers = loggers;
} }
@ -57,12 +61,12 @@ namespace BackendWorkerService.Quartz.Jobs
var electricMeterGuid = variableArchive.Where(x => x.Name == "ElectricMeterGuid").Select(x => x.Value).FirstOrDefault(); var electricMeterGuid = variableArchive.Where(x => x.Name == "ElectricMeterGuid").Select(x => x.Value).FirstOrDefault();
#region #region
var sWhere = "deleted = 0 AND sub_system_guid = @sub_system_guid"; var sWhere = "deleted = 0 AND device_name_tag = @sub_system_guid";
var electricMeters = await backgroundServiceRepository.GetAllAsync<Device>("device", sWhere, new { sub_system_guid = electricMeterGuid }); var electricMeters = await backgroundServiceRepository.GetAllAsync<Device>("device", sWhere, new { sub_system_guid = electricMeterGuid });
#endregion #endregion
#region #region
var sPointWhere = "deleted = 0 AND sub_system_guid = @sub_system_guid"; var sPointWhere = "deleted = 0 AND device_name_tag = @sub_system_guid";
var points = await backgroundServiceRepository.GetAllAsync<Device_item>("device_item", sPointWhere, new { sub_system_guid = electricMeterGuid }); var points = await backgroundServiceRepository.GetAllAsync<Device_item>("device_item", sPointWhere, new { sub_system_guid = electricMeterGuid });
#endregion #endregion
@ -180,7 +184,51 @@ namespace BackendWorkerService.Quartz.Jobs
if (archiveDayRawDatas.Count() > 0) if (archiveDayRawDatas.Count() > 0)
{ {
var sql = $@"BEGIN TRANSACTION; var sql = $@"
UPDATE archive_electric_meter_day SET
count_rawdata = @count_rawdata,
min_rawdata = @min_rawdata,
max_rawdata = @max_rawdata,
avg_rawdata = @avg_rawdata,
sum_rawdata = @sum_rawdata,
is_complete = @is_complete,
repeat_times = @repeat_times,
fail_reason = @fail_reason,
updated_at = @updated_at
WHERE device_number = @device_number
AND point = @point
AND start_timestamp = @start_timestamp;
INSERT INTO archive_electric_meter_day (
device_number,
point,
start_timestamp,
end_timestamp,
count_rawdata,
min_rawdata,
max_rawdata,
avg_rawdata,
sum_rawdata,
is_complete,
repeat_times,
fail_reason)
SELECT
@device_number,
@point,
@start_timestamp,
@end_timestamp,
@count_rawdata,
@min_rawdata,
@max_rawdata,
@avg_rawdata,
@sum_rawdata,
@is_complete,
@repeat_times,
@fail_reason
WHERE ROW_COUNT() = 0;";
var mySql = $@"BEGIN TRANSACTION;
UPDATE archive_electric_meter_day SET UPDATE archive_electric_meter_day SET
count_rawdata = @count_rawdata, count_rawdata = @count_rawdata,
@ -228,7 +276,7 @@ namespace BackendWorkerService.Quartz.Jobs
COMMIT TRANSACTION;"; COMMIT TRANSACTION;";
await backgroundServiceRepository.ExecuteSql(sql, archiveDayRawDatas); await backgroundServiceRepository.ExecuteSql(sql, archiveDayRawDatas);
await backgroundServiceMsSqlRepository.ExecuteSql(mySql, archiveDayRawDatas);
} }
await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Day", "任務完成"); await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Day", "任務完成");
} }
@ -324,7 +372,53 @@ namespace BackendWorkerService.Quartz.Jobs
if (archiveWeekRawDatas.Count() > 0) if (archiveWeekRawDatas.Count() > 0)
{ {
var sql = $@"BEGIN TRANSACTION; var sql = $@"
UPDATE archive_electric_meter_week SET
count_rawdata = @count_rawdata,
min_rawdata = @min_rawdata,
max_rawdata = @max_rawdata,
avg_rawdata = @avg_rawdata,
sum_rawdata = @sum_rawdata,
is_complete = @is_complete,
repeat_times = @repeat_times,
fail_reason = @fail_reason,
updated_at = @updated_at
WHERE device_number = @device_number
AND point = @point
AND start_timestamp = @start_timestamp;
INSERT INTO archive_electric_meter_week (
device_number,
point,
start_timestamp,
end_timestamp,
count_rawdata,
min_rawdata,
max_rawdata,
avg_rawdata,
sum_rawdata,
is_complete,
repeat_times,
fail_reason)
SELECT
@device_number,
@point,
@start_timestamp,
@end_timestamp,
@count_rawdata,
@min_rawdata,
@max_rawdata,
@avg_rawdata,
@sum_rawdata,
@is_complete,
@repeat_times,
@fail_reason
WHERE ROW_COUNT() = 0;
";
var mySql = $@"BEGIN TRANSACTION;
UPDATE archive_electric_meter_week SET UPDATE archive_electric_meter_week SET
count_rawdata = @count_rawdata, count_rawdata = @count_rawdata,
@ -372,7 +466,8 @@ namespace BackendWorkerService.Quartz.Jobs
COMMIT TRANSACTION;"; COMMIT TRANSACTION;";
await backgroundServiceRepository.ExecuteSql(sql, archiveWeekRawDatas); await backgroundServiceRepository.ExecuteSql(sql, archiveWeekRawDatas);
await backgroundServiceMsSqlRepository.ExecuteSql(mySql, archiveWeekRawDatas);
} }
await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Week", "任務完成"); await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Week", "任務完成");
} }
@ -470,7 +565,50 @@ namespace BackendWorkerService.Quartz.Jobs
if (archiveMonthRawDatas.Count() > 0) if (archiveMonthRawDatas.Count() > 0)
{ {
var sql = $@"BEGIN TRANSACTION; var sql = $@"
UPDATE archive_electric_meter_month SET
count_rawdata = @count_rawdata,
min_rawdata = @min_rawdata,
max_rawdata = @max_rawdata,
avg_rawdata = @avg_rawdata,
sum_rawdata = @sum_rawdata,
is_complete = @is_complete,
repeat_times = @repeat_times,
fail_reason = @fail_reason,
updated_at = @updated_at
WHERE device_number = @device_number
AND point = @point
AND start_timestamp = @start_timestamp;
INSERT INTO archive_electric_meter_month (
device_number,
point,
start_timestamp,
end_timestamp,
count_rawdata,
min_rawdata,
max_rawdata,
avg_rawdata,
sum_rawdata,
is_complete,
repeat_times,
fail_reason)
SELECT
@device_number,
@point,
@start_timestamp,
@end_timestamp,
@count_rawdata,
@min_rawdata,
@max_rawdata,
@avg_rawdata,
@sum_rawdata,
@is_complete,
@repeat_times,
@fail_reason
WHERE ROW_COUNT() = 0;";
var mySql = $@"BEGIN TRANSACTION;
UPDATE archive_electric_meter_month SET UPDATE archive_electric_meter_month SET
count_rawdata = @count_rawdata, count_rawdata = @count_rawdata,
@ -518,6 +656,7 @@ namespace BackendWorkerService.Quartz.Jobs
COMMIT TRANSACTION;"; COMMIT TRANSACTION;";
await backgroundServiceRepository.ExecuteSql(sql, archiveMonthRawDatas); await backgroundServiceRepository.ExecuteSql(sql, archiveMonthRawDatas);
await backgroundServiceMsSqlRepository.ExecuteSql(mySql, archiveMonthRawDatas);
} }
await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Month", "任務完成"); await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Month", "任務完成");
} }
@ -532,13 +671,13 @@ namespace BackendWorkerService.Quartz.Jobs
#region #region
//取得連線字串 //取得連線字串
if(await task_Detail.GetNeedWorkTask("ArchiveElectricMeterDayJob", "Compensate")) if (await task_Detail.GetNeedWorkTask("ArchiveElectricMeterDayJob", "Compensate"))
{ {
try try
{ {
await task_Detail.InsertWorkTime("ArchiveElectricMeterDayJob", "Compensate", "任務開始"); await task_Detail.InsertWorkTime("ArchiveElectricMeterDayJob", "Compensate", "任務開始");
ProcEletricMeterService procEletricMeterService = new ProcEletricMeterService(_databaseHelper.GetMSSqlConnectionString()); ProcEletricMeterService procEletricMeterService = new ProcEletricMeterService(backgroundServiceRepository, backgroundServiceMsSqlRepository);
procEletricMeterService.ArchiveData(); await procEletricMeterService.ArchiveData();
await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Compensate", "任務完成"); await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Compensate", "任務完成");
} }
catch(Exception ex) catch(Exception ex)

View File

@ -16,6 +16,7 @@ using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Linq; using System.Linq;
using NCrontab; using NCrontab;
using BackendWorkerService.Services.Implement;
namespace BackendWorkerService.Quartz.Jobs namespace BackendWorkerService.Quartz.Jobs
{ {
@ -232,8 +233,8 @@ namespace BackendWorkerService.Quartz.Jobs
{ "@msgType", observation.Alert.MsgType}, { "@msgType", observation.Alert.MsgType},
{ "@headline", observation.Alert.Info.Headline}, { "@headline", observation.Alert.Info.Headline},
{ "@areaDesc", area}, { "@areaDesc", area},
{ "@onset", observation.Alert.Info.Onset}, { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")},
{ "@expires", observation.Alert.Info.Expires}, { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")},
{ "@created_by", "system"}, { "@created_by", "system"},
{ "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
}; };
@ -317,8 +318,8 @@ namespace BackendWorkerService.Quartz.Jobs
{ "@areaDesc", area}, { "@areaDesc", area},
{ "@urgency",observation.Alert.Info.Urgency}, { "@urgency",observation.Alert.Info.Urgency},
{ "@severity",observation.Alert.Info.Severity}, { "@severity",observation.Alert.Info.Severity},
{ "@onset", observation.Alert.Info.Onset}, { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")},
{ "@expires", observation.Alert.Info.Expires}, { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")},
{ "@created_by", "system"}, { "@created_by", "system"},
{ "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
}; };
@ -458,7 +459,7 @@ namespace BackendWorkerService.Quartz.Jobs
weather_type, weather_type,
get_value get_value
FROM api_weateher FROM api_weateher
where id in (select MAX(id) from api_weateher where start_time < GETDATE() group by weather_type) where id in (select MAX(id) from api_weateher where start_time < NOW() group by weather_type)
order by start_time desc"; order by start_time desc";
var types = await backendRepository.GetAllAsync<ShowWeather>(sql); var types = await backendRepository.GetAllAsync<ShowWeather>(sql);
var T = types.Where(a => a.weather_type == "T").FirstOrDefault(); var T = types.Where(a => a.weather_type == "T").FirstOrDefault();

View File

@ -12,6 +12,10 @@ using System.Xml;
using System.Net; using System.Net;
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
using Repository.Helper;
using Repository.BackendRepository.Interface;
using Repository.BackendRepository.Implement;
using System.Threading.Tasks;
namespace BackendWorkerService.Services.Implement namespace BackendWorkerService.Services.Implement
{ {
@ -20,23 +24,17 @@ namespace BackendWorkerService.Services.Implement
/// </summary> /// </summary>
public class ProcEletricMeterService public class ProcEletricMeterService
{ {
string Connection1 = string.Empty; private readonly IBackgroundServiceRepository backgroundServiceRepository;
IDbConnection conn; private readonly IBackgroundServiceMsSqlRepository backgroundServiceMsSqlRepository;
public ProcEletricMeterService(string Connection_parame = null) public ProcEletricMeterService(IBackgroundServiceRepository backgroundServiceRepository,
IBackgroundServiceMsSqlRepository backgroundServiceMySqlRepository)
{ {
if (!string.IsNullOrEmpty(Connection_parame)) this.backgroundServiceRepository = backgroundServiceRepository;
{ this.backgroundServiceMsSqlRepository = backgroundServiceMySqlRepository;
Connection1 = Connection_parame;
conn = new SqlConnection(Connection_parame);
}
else
{
//Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString;
}
} }
public bool ArchiveData() public async Task<bool> ArchiveData()
{ {
bool result = false; bool result = false;
int repeatTimes = 0; int repeatTimes = 0;
@ -50,36 +48,68 @@ namespace BackendWorkerService.Services.Implement
try try
{ {
//取得可錯誤次數 //取得可錯誤次數
using (IDbConnection conn = new SqlConnection(Connection1)) var sqlArchive = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'archiveConfig'";
{
var sqlArchive = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'archiveConfig'";
var variableArchive = conn.Query<KeyValue>(sqlArchive); var variableArchive = await backgroundServiceRepository.GetAllAsync<KeyValue>(sqlArchive);
repeatTimes = Convert.ToInt32(variableArchive.Where(x => x.Name == "RepeatTimes").Select(x => x.Value).FirstOrDefault()); repeatTimes = Convert.ToInt32(variableArchive.Where(x => x.Name == "RepeatTimes").Select(x => x.Value).FirstOrDefault());
conn.Close();
}
#region obix #region obix
using (IDbConnection conn = new SqlConnection(Connection1)) var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
{
var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; var variableObix = await backgroundServiceRepository.GetAllAsync<KeyValue>(sqlObix);
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());
var variableObix = conn.Query<KeyValue>(sqlObix).ToList(); encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(obixApiConfig.UserName + ":" + obixApiConfig.Password));
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());
encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(obixApiConfig.UserName + ":" + obixApiConfig.Password));
conn.Close();
}
#endregion obix #endregion obix
//取得錯誤的設備sql format //取得錯誤的設備sql format
var sql_error_format = @"SELECT * FROM {0} WHERE is_complete = 0 AND repeat_times < @RepeatTimes"; var sql_error_format = @"SELECT * FROM {0} WHERE is_complete = 0 AND repeat_times < @RepeatTimes";
//MY 新增/修改sql format
var MYsql_update_format = @"
UPDATE {0} SET
count_rawdata = @count_rawdata,
min_rawdata = @min_rawdata,
max_rawdata = @max_rawdata,
avg_rawdata = @avg_rawdata,
sum_rawdata = @sum_rawdata,
is_complete = @is_complete,
repeat_times = @repeat_times,
fail_reason = @fail_reason,
updated_at = @updated_at
WHERE device_number = @device_number
AND point = @point
AND start_timestamp = @start_timestamp;
INSERT INTO {0} (
device_number,
point,
start_timestamp,
end_timestamp,
count_rawdata,
min_rawdata,
max_rawdata,
avg_rawdata,
sum_rawdata,
is_complete,
repeat_times,
fail_reason)
SELECT
@device_number,
@point,
@start_timestamp,
@end_timestamp,
@count_rawdata,
@min_rawdata,
@max_rawdata,
@avg_rawdata,
@sum_rawdata,
@is_complete,
@repeat_times,
@fail_reason
WHERE ROW_COUNT() = 0;";
//新增/修改sql format //新增/修改sql format
var sql_update_format = @"BEGIN TRANSACTION; var sql_update_format = @"BEGIN TRANSACTION;
@ -217,269 +247,260 @@ namespace BackendWorkerService.Services.Implement
#endregion #endregion
#region #region
using (IDbConnection conn = new SqlConnection(Connection1)) //取得所有須補償的設備資訊
targetTable = "archive_electric_meter_day";
var sql_error_day = string.Format(sql_error_format, targetTable);
var error_days = await backgroundServiceRepository.GetAllAsync<ArchiveElectricMeter>(sql_error_day, new { RepeatTimes = repeatTimes });
List<Dictionary<string, object>> archiveDayRawDatas = new List<Dictionary<string, object>>();
if (error_days.Count() > 0)
{ {
//取得所有須補償的設備資訊 foreach (var error_day in error_days)
targetTable = "archive_electric_meter_day";
var sql_error_day = string.Format(sql_error_format, targetTable);
var error_days = conn.Query<ArchiveElectricMeter>(sql_error_day, new { RepeatTimes = repeatTimes }).ToList();
List<Dictionary<string, object>> archiveDayRawDatas = new List<Dictionary<string, object>>();
if (error_days.Count() > 0)
{ {
foreach (var error_day in error_days) DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint();
deviceNumberPoint.DeviceNumber = error_day.Device_number;
deviceNumberPoint.Point = error_day.Point;
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_day.Device_number, error_day.Point);
var startTimestamp = string.Format("{0}+08:00", error_day.Start_timestamp.Replace(" ", "T"));
var endTimestamp = string.Format("{0}+08:00", error_day.End_timestamp.Replace(" ", "T"));
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
<abstime name='start' val='{startTimestamp}' />
<abstime name='end' val='{endTimestamp}' />
<reltime name='interval' val = 'PT1D' />
</obj>";
HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
//HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
archiveDayRequest.Method = "POST";
archiveDayRequest.Headers.Add("Authorization", "Basic " + encoded);
archiveDayRequest.PreAuthenticate = true;
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
using (Stream reqStream = archiveDayRequest.GetRequestStream())
{ {
DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); reqStream.Write(byteArray, 0, byteArray.Length);
deviceNumberPoint.DeviceNumber = error_day.Device_number;
deviceNumberPoint.Point = error_day.Point;
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_day.Device_number, error_day.Point);
var startTimestamp = string.Format("{0}+08:00", error_day.Start_timestamp.Replace(" ", "T"));
var endTimestamp = string.Format("{0}+08:00", error_day.End_timestamp.Replace(" ", "T"));
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
<abstime name='start' val='{startTimestamp}' />
<abstime name='end' val='{endTimestamp}' />
<reltime name='interval' val = 'PT1D' />
</obj>";
HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
//HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
archiveDayRequest.Method = "POST";
archiveDayRequest.Headers.Add("Authorization", "Basic " + encoded);
archiveDayRequest.PreAuthenticate = true;
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
using (Stream reqStream = archiveDayRequest.GetRequestStream())
{
reqStream.Write(byteArray, 0, byteArray.Length);
}
HttpWebResponse archiveDayResponse = (HttpWebResponse)archiveDayRequest.GetResponse();
var archiveDayResponseContent = new StreamReader(archiveDayResponse.GetResponseStream()).ReadToEnd();
xmlDocument.LoadXml(archiveDayResponseContent);
string archiveDayJson = JsonConvert.SerializeXmlNode(xmlDocument);
JObject archiveDayJsonResult = (JObject)JsonConvert.DeserializeObject(archiveDayJson);
if (archiveDayJsonResult.ContainsKey("err")) //抓取錯誤
{
Dictionary<string, object> archiveDayRawData = new Dictionary<string, object>();
archiveDayRawData.Add("@device_number", error_day.Device_number);
archiveDayRawData.Add("@point", error_day.Point);
archiveDayRawData.Add("@start_timestamp", error_day.Start_timestamp);
archiveDayRawData.Add("@end_timestamp", error_day.End_timestamp);
archiveDayRawData.Add("@is_complete", 0);
archiveDayRawData.Add("@repeat_times", ++error_day.Repeat_times);
archiveDayRawData.Add("@fail_reason", archiveDayJson);
archiveDayRawData.Add("@count_rawdata", 0);
archiveDayRawData.Add("@min_rawdata", 0);
archiveDayRawData.Add("@max_rawdata", 0);
archiveDayRawData.Add("@avg_rawdata", 0);
archiveDayRawData.Add("@sum_rawdata", 0);
archiveDayRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
archiveDayRawDatas.Add(archiveDayRawData);
}
if (archiveDayJsonResult.ContainsKey("obj")) //表示可以讀取到內容
{
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveDayJsonResult);
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
{
archiveDayRawDatas.AddRange(ArrangeRawDatas);
}
}
} }
if (archiveDayRawDatas.Count() > 0) HttpWebResponse archiveDayResponse = (HttpWebResponse)archiveDayRequest.GetResponse();
var archiveDayResponseContent = new StreamReader(archiveDayResponse.GetResponseStream()).ReadToEnd();
xmlDocument.LoadXml(archiveDayResponseContent);
string archiveDayJson = JsonConvert.SerializeXmlNode(xmlDocument);
JObject archiveDayJsonResult = (JObject)JsonConvert.DeserializeObject(archiveDayJson);
if (archiveDayJsonResult.ContainsKey("err")) //抓取錯誤
{ {
var sql_error_update = string.Format(sql_update_format, targetTable); Dictionary<string, object> archiveDayRawData = new Dictionary<string, object>();
conn.Execute(sql_error_update, archiveDayRawDatas); archiveDayRawData.Add("@device_number", error_day.Device_number);
archiveDayRawData.Add("@point", error_day.Point);
archiveDayRawData.Add("@start_timestamp", DateTime.Parse(error_day.Start_timestamp, System.Globalization.CultureInfo.CurrentCulture));
archiveDayRawData.Add("@end_timestamp", DateTime.Parse(error_day.End_timestamp, System.Globalization.CultureInfo.CurrentCulture));
archiveDayRawData.Add("@is_complete", 0);
archiveDayRawData.Add("@repeat_times", ++error_day.Repeat_times);
archiveDayRawData.Add("@fail_reason", archiveDayJson);
archiveDayRawData.Add("@count_rawdata", 0);
archiveDayRawData.Add("@min_rawdata", 0);
archiveDayRawData.Add("@max_rawdata", 0);
archiveDayRawData.Add("@avg_rawdata", 0);
archiveDayRawData.Add("@sum_rawdata", 0);
archiveDayRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
archiveDayRawDatas.Add(archiveDayRawData);
}
if (archiveDayJsonResult.ContainsKey("obj")) //表示可以讀取到內容
{
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveDayJsonResult);
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
{
archiveDayRawDatas.AddRange(ArrangeRawDatas);
}
} }
} }
conn.Close(); if (archiveDayRawDatas.Count() > 0)
{
var Mysql_error_update = string.Format(MYsql_update_format, targetTable);
var sql_error_update = string.Format(sql_update_format, targetTable);
await backgroundServiceMsSqlRepository.ExecuteSql(sql_error_update, archiveDayRawDatas);
await backgroundServiceRepository.ExecuteSql(Mysql_error_update, archiveDayRawDatas);
}
} }
#endregion #endregion
#region #region
using (IDbConnection conn = new SqlConnection(Connection1)) //取得所有須補償的設備資訊
targetTable = "archive_electric_meter_week";
var sql_error_week = string.Format(sql_error_format, targetTable);
var error_weeks = await backgroundServiceRepository.GetAllAsync<ArchiveElectricMeter>(sql_error_week, new { RepeatTimes = repeatTimes });
List<Dictionary<string, object>> archiveWeekRawDatas = new List<Dictionary<string, object>>();
if (error_weeks.Count() > 0)
{ {
//取得所有須補償的設備資訊 foreach (var error_week in error_weeks)
targetTable = "archive_electric_meter_week";
var sql_error_week = string.Format(sql_error_format, targetTable);
var error_weeks = conn.Query<ArchiveElectricMeter>(sql_error_week, new { RepeatTimes = repeatTimes }).ToList();
List<Dictionary<string, object>> archiveWeekRawDatas = new List<Dictionary<string, object>>();
if (error_weeks.Count() > 0)
{ {
foreach (var error_week in error_weeks) DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint();
deviceNumberPoint.DeviceNumber = error_week.Device_number;
deviceNumberPoint.Point = error_week.Point;
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_week.Device_number, error_week.Point);
var startTimestamp = string.Format("{0}+08:00", error_week.Start_timestamp.Replace(" ", "T"));
var endTimestamp = string.Format("{0}+08:00", error_week.End_timestamp.Replace(" ", "T"));
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
<abstime name='start' val='{startTimestamp}' />
<abstime name='end' val='{endTimestamp}' />
<reltime name='interval' val = 'PT7D' />
</obj>";
HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
//HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
archiveWeekRequest.Method = "POST";
archiveWeekRequest.Headers.Add("Authorization", "Basic " + encoded);
archiveWeekRequest.PreAuthenticate = true;
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
using (Stream reqStream = archiveWeekRequest.GetRequestStream())
{ {
DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); reqStream.Write(byteArray, 0, byteArray.Length);
deviceNumberPoint.DeviceNumber = error_week.Device_number;
deviceNumberPoint.Point = error_week.Point;
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_week.Device_number, error_week.Point);
var startTimestamp = string.Format("{0}+08:00", error_week.Start_timestamp.Replace(" ", "T"));
var endTimestamp = string.Format("{0}+08:00", error_week.End_timestamp.Replace(" ", "T"));
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
<abstime name='start' val='{startTimestamp}' />
<abstime name='end' val='{endTimestamp}' />
<reltime name='interval' val = 'PT7D' />
</obj>";
HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
//HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
archiveWeekRequest.Method = "POST";
archiveWeekRequest.Headers.Add("Authorization", "Basic " + encoded);
archiveWeekRequest.PreAuthenticate = true;
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
using (Stream reqStream = archiveWeekRequest.GetRequestStream())
{
reqStream.Write(byteArray, 0, byteArray.Length);
}
HttpWebResponse archiveWeekResponse = (HttpWebResponse)archiveWeekRequest.GetResponse();
var archiveWeekResponseContent = new StreamReader(archiveWeekResponse.GetResponseStream()).ReadToEnd();
xmlDocument.LoadXml(archiveWeekResponseContent);
string archiveWeekJson = JsonConvert.SerializeXmlNode(xmlDocument);
JObject archiveWeekJsonResult = (JObject)JsonConvert.DeserializeObject(archiveWeekJson);
if (archiveWeekJsonResult.ContainsKey("err")) //抓取錯誤
{
Dictionary<string, object> archiveWeekRawData = new Dictionary<string, object>();
archiveWeekRawData.Add("@device_number", error_week.Device_number);
archiveWeekRawData.Add("@point", error_week.Point);
archiveWeekRawData.Add("@start_timestamp", error_week.Start_timestamp);
archiveWeekRawData.Add("@end_timestamp", error_week.End_timestamp);
archiveWeekRawData.Add("@is_complete", 0);
archiveWeekRawData.Add("@repeat_times", ++error_week.Repeat_times);
archiveWeekRawData.Add("@fail_reason", archiveWeekJson);
archiveWeekRawData.Add("@count_rawdata", 0);
archiveWeekRawData.Add("@min_rawdata", 0);
archiveWeekRawData.Add("@max_rawdata", 0);
archiveWeekRawData.Add("@avg_rawdata", 0);
archiveWeekRawData.Add("@sum_rawdata", 0);
archiveWeekRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
archiveWeekRawDatas.Add(archiveWeekRawData);
}
if (archiveWeekJsonResult.ContainsKey("obj")) //表示可以讀取到內容
{
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveWeekJsonResult);
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
{
archiveWeekRawDatas.AddRange(ArrangeRawDatas);
}
}
} }
if (archiveWeekRawDatas.Count() > 0) HttpWebResponse archiveWeekResponse = (HttpWebResponse)archiveWeekRequest.GetResponse();
var archiveWeekResponseContent = new StreamReader(archiveWeekResponse.GetResponseStream()).ReadToEnd();
xmlDocument.LoadXml(archiveWeekResponseContent);
string archiveWeekJson = JsonConvert.SerializeXmlNode(xmlDocument);
JObject archiveWeekJsonResult = (JObject)JsonConvert.DeserializeObject(archiveWeekJson);
if (archiveWeekJsonResult.ContainsKey("err")) //抓取錯誤
{ {
var sql_error_update = string.Format(sql_update_format, targetTable); Dictionary<string, object> archiveWeekRawData = new Dictionary<string, object>();
conn.Execute(sql_error_update, archiveWeekRawDatas); archiveWeekRawData.Add("@device_number", error_week.Device_number);
archiveWeekRawData.Add("@point", error_week.Point);
archiveWeekRawData.Add("@start_timestamp", DateTime.Parse(error_week.Start_timestamp, System.Globalization.CultureInfo.CurrentCulture));
archiveWeekRawData.Add("@end_timestamp", DateTime.Parse(error_week.End_timestamp, System.Globalization.CultureInfo.CurrentCulture));
archiveWeekRawData.Add("@is_complete", 0);
archiveWeekRawData.Add("@repeat_times", ++error_week.Repeat_times);
archiveWeekRawData.Add("@fail_reason", archiveWeekJson);
archiveWeekRawData.Add("@count_rawdata", 0);
archiveWeekRawData.Add("@min_rawdata", 0);
archiveWeekRawData.Add("@max_rawdata", 0);
archiveWeekRawData.Add("@avg_rawdata", 0);
archiveWeekRawData.Add("@sum_rawdata", 0);
archiveWeekRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
archiveWeekRawDatas.Add(archiveWeekRawData);
}
if (archiveWeekJsonResult.ContainsKey("obj")) //表示可以讀取到內容
{
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveWeekJsonResult);
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
{
archiveWeekRawDatas.AddRange(ArrangeRawDatas);
}
} }
} }
conn.Close(); if (archiveWeekRawDatas.Count() > 0)
{
var Mysql_error_update = string.Format(MYsql_update_format, targetTable);
var sql_error_update = string.Format(sql_update_format, targetTable);
await backgroundServiceMsSqlRepository.ExecuteSql(sql_error_update, archiveWeekRawDatas);
await backgroundServiceRepository.ExecuteSql(Mysql_error_update, archiveWeekRawDatas);
}
} }
#endregion #endregion
#region #region
using (IDbConnection conn = new SqlConnection(Connection1)) //取得所有須補償的設備資訊
targetTable = "archive_electric_meter_month";
var sql_error_month = string.Format(sql_error_format, targetTable);
var error_months = await backgroundServiceRepository.GetAllAsync<ArchiveElectricMeter>(sql_error_month, new { RepeatTimes = repeatTimes });
List<Dictionary<string, object>> archiveMonthRawDatas = new List<Dictionary<string, object>>();
if (error_months.Count() > 0)
{ {
//取得所有須補償的設備資訊 foreach (var error_month in error_months)
targetTable = "archive_electric_meter_month";
var sql_error_month = string.Format(sql_error_format, targetTable);
var error_months = conn.Query<ArchiveElectricMeter>(sql_error_month, new { RepeatTimes = repeatTimes }).ToList();
List<Dictionary<string, object>> archiveMonthRawDatas = new List<Dictionary<string, object>>();
if (error_months.Count() > 0)
{ {
foreach (var error_month in error_months) DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint();
deviceNumberPoint.DeviceNumber = error_month.Device_number;
deviceNumberPoint.Point = error_month.Point;
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_month.Device_number, error_month.Point);
var startTimestamp = string.Format("{0}+08:00", error_month.Start_timestamp.Replace(" ", "T"));
var endTimestamp = string.Format("{0}+08:00", error_month.End_timestamp.Replace(" ", "T"));
var startDateTime = Convert.ToDateTime(error_month.Start_timestamp);
var dayInMonth = DateTime.DaysInMonth(startDateTime.Year, startDateTime.Month);
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
<abstime name='start' val='{startTimestamp}' />
<abstime name='end' val='{endTimestamp}' />
<reltime name='interval' val = 'PT{dayInMonth}D' />
</obj>";
HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
//HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
archiveMonthRequest.Method = "POST";
archiveMonthRequest.Headers.Add("Authorization", "Basic " + encoded);
archiveMonthRequest.PreAuthenticate = true;
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
using (Stream reqStream = archiveMonthRequest.GetRequestStream())
{ {
DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); reqStream.Write(byteArray, 0, byteArray.Length);
deviceNumberPoint.DeviceNumber = error_month.Device_number;
deviceNumberPoint.Point = error_month.Point;
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_month.Device_number, error_month.Point);
var startTimestamp = string.Format("{0}+08:00", error_month.Start_timestamp.Replace(" ", "T"));
var endTimestamp = string.Format("{0}+08:00", error_month.End_timestamp.Replace(" ", "T"));
var startDateTime = Convert.ToDateTime(error_month.Start_timestamp);
var dayInMonth = DateTime.DaysInMonth(startDateTime.Year, startDateTime.Month);
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
<abstime name='start' val='{startTimestamp}' />
<abstime name='end' val='{endTimestamp}' />
<reltime name='interval' val = 'PT{dayInMonth}D' />
</obj>";
HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
//HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
archiveMonthRequest.Method = "POST";
archiveMonthRequest.Headers.Add("Authorization", "Basic " + encoded);
archiveMonthRequest.PreAuthenticate = true;
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
using (Stream reqStream = archiveMonthRequest.GetRequestStream())
{
reqStream.Write(byteArray, 0, byteArray.Length);
}
HttpWebResponse archiveMonthResponse = (HttpWebResponse)archiveMonthRequest.GetResponse();
var archiveMonthResponseContent = new StreamReader(archiveMonthResponse.GetResponseStream()).ReadToEnd();
xmlDocument.LoadXml(archiveMonthResponseContent);
string archiveMonthJson = JsonConvert.SerializeXmlNode(xmlDocument);
JObject archiveMonthJsonResult = (JObject)JsonConvert.DeserializeObject(archiveMonthJson);
if (archiveMonthJsonResult.ContainsKey("err")) //抓取錯誤
{
Dictionary<string, object> archiveMonthRawData = new Dictionary<string, object>();
archiveMonthRawData.Add("@device_number", error_month.Device_number);
archiveMonthRawData.Add("@point", error_month.Point);
archiveMonthRawData.Add("@start_timestamp", error_month.Start_timestamp);
archiveMonthRawData.Add("@end_timestamp", error_month.End_timestamp);
archiveMonthRawData.Add("@is_complete", 0);
archiveMonthRawData.Add("@repeat_times", ++error_month.Repeat_times);
archiveMonthRawData.Add("@fail_reason", archiveMonthJson);
archiveMonthRawData.Add("@count_rawdata", 0);
archiveMonthRawData.Add("@min_rawdata", 0);
archiveMonthRawData.Add("@max_rawdata", 0);
archiveMonthRawData.Add("@avg_rawdata", 0);
archiveMonthRawData.Add("@sum_rawdata", 0);
archiveMonthRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
archiveMonthRawDatas.Add(archiveMonthRawData);
}
if (archiveMonthJsonResult.ContainsKey("obj")) //表示可以讀取到內容
{
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveMonthJsonResult);
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
{
archiveMonthRawDatas.AddRange(ArrangeRawDatas);
}
}
} }
if (archiveMonthRawDatas.Count() > 0) HttpWebResponse archiveMonthResponse = (HttpWebResponse)archiveMonthRequest.GetResponse();
var archiveMonthResponseContent = new StreamReader(archiveMonthResponse.GetResponseStream()).ReadToEnd();
xmlDocument.LoadXml(archiveMonthResponseContent);
string archiveMonthJson = JsonConvert.SerializeXmlNode(xmlDocument);
JObject archiveMonthJsonResult = (JObject)JsonConvert.DeserializeObject(archiveMonthJson);
if (archiveMonthJsonResult.ContainsKey("err")) //抓取錯誤
{ {
var sql_error_update = string.Format(sql_update_format, targetTable); Dictionary<string, object> archiveMonthRawData = new Dictionary<string, object>();
conn.Execute(sql_error_update, archiveMonthRawDatas); archiveMonthRawData.Add("@device_number", error_month.Device_number);
archiveMonthRawData.Add("@point", error_month.Point);
archiveMonthRawData.Add("@start_timestamp", DateTime.Parse(error_month.Start_timestamp, System.Globalization.CultureInfo.CurrentCulture));
archiveMonthRawData.Add("@end_timestamp", DateTime.Parse(error_month.End_timestamp, System.Globalization.CultureInfo.CurrentCulture));
archiveMonthRawData.Add("@is_complete", 0);
archiveMonthRawData.Add("@repeat_times", ++error_month.Repeat_times);
archiveMonthRawData.Add("@fail_reason", archiveMonthJson);
archiveMonthRawData.Add("@count_rawdata", 0);
archiveMonthRawData.Add("@min_rawdata", 0);
archiveMonthRawData.Add("@max_rawdata", 0);
archiveMonthRawData.Add("@avg_rawdata", 0);
archiveMonthRawData.Add("@sum_rawdata", 0);
archiveMonthRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
archiveMonthRawDatas.Add(archiveMonthRawData);
}
if (archiveMonthJsonResult.ContainsKey("obj")) //表示可以讀取到內容
{
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveMonthJsonResult);
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
{
archiveMonthRawDatas.AddRange(ArrangeRawDatas);
}
} }
} }
conn.Close(); if (archiveMonthRawDatas.Count() > 0)
{
var Mysql_error_update = string.Format(MYsql_update_format, targetTable);
var sql_error_update = string.Format(sql_update_format, targetTable);
await backgroundServiceMsSqlRepository.ExecuteSql(sql_error_update, archiveMonthRawDatas);
await backgroundServiceRepository.ExecuteSql(MYsql_update_format, archiveMonthRawDatas);
}
} }
#endregion #endregion

View File

@ -7,23 +7,40 @@
} }
}, },
"BackgroundServiceCron": { "BackgroundServiceCron": {
"ExecutionBackgroundServicePlanJob": "0 0 2 * * ?", "ExecutionBackgroundServicePlanJob": "0 0 1 * * ?",
"MessageNotificationJob": "0 0 2 * * ?", "MessageNotificationJob": "0 0 1 * * ?",
"DataDeliveryJob": "0 0 2 * * ?", "DataDeliveryJob": "0 0 1 * * ?",
"RegularUpdateDBTableJob": "0 0 2 * * ?", "RegularUpdateDBTableJob": "0 0 1 * * ?",
"ParkingJob": "0 0 2 * * ?", "ParkingJob": "0 0 1 * * ?",
"ArchiveElectricMeterHourJob": "0 0 2 * * ?", "ArchiveElectricMeterHourJob": "0 0 1 * * ?",
"ArchiveElectricMeterDayJob": "0 0 2 * * ?", "ArchiveElectricMeterDayJob": "0 0 1 * * ?",
"WeatherAPIJob": "0/5 * * * * ?" "WeatherAPIJob": "0/5 * * * * ?"
}, },
"DBConfig": { "DBConfig": {
//"MySqlDBConfig": {
// "Server": "TNi6aupYHPZT8ZU177KTKw==", //172.16.220.251
// "Port": "mkF51jVbg40V5K5eTh2Ckw==",
// "Database": "VvfWH/59gQguY2eA2xBCug==",
// "Root": "IV8Ec1Ng2AWAnkBafXy2kg==",
// "Password": "Jue6jMFRi11meN6xbdKwDA=="
//},
"MySqlDBConfig": { "MySqlDBConfig": {
"Server": "TNi6aupYHPZT8ZU177KTKw==", //172.16.220.251 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "mkF51jVbg40V5K5eTh2Ckw==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VvfWH/59gQguY2eA2xBCug==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
"Root": "IV8Ec1Ng2AWAnkBafXy2kg==", //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Password": "Jue6jMFRi11meN6xbdKwDA==" "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
}, },
"MSSqlDBConfig": {
"Server": "bJm+UAtbeaTjDmp/A5ep2w==", //0.130
"Port": "S5cUXKnKOacFtFy9+0dtpw==",
"Database": "VvfWH/59gQguY2eA2xBCug==", //taipei_dome
"Root": "sD8GZ9UPiIQGU6dU011/4A==",
"Password": "0O24es2ZRF5uoJ4aU+YCdg=="
}
//"MSSqlDBConfig": { //greencloud.fic.com.tw,1433 //"MSSqlDBConfig": { //greencloud.fic.com.tw,1433
// "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=", // "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=",
// "Port": "S5cUXKnKOacFtFy9+0dtpw==", // "Port": "S5cUXKnKOacFtFy9+0dtpw==",
@ -31,13 +48,13 @@
// "Root": "+plVKQ+enAqt7BYV2uMQng==", // "Root": "+plVKQ+enAqt7BYV2uMQng==",
// "Password": "0O24es2ZRF5uoJ4aU+YCdg==" // "Password": "0O24es2ZRF5uoJ4aU+YCdg=="
//} //}
"MSSqlDBConfig": { //"MSSqlDBConfig": {
"Server": "zp3Nilx0PISEEC4caZWqCg==", //172.16.220.250 // "Server": "zp3Nilx0PISEEC4caZWqCg==", //172.16.220.250
"Port": "7puf4kd9qJ/q0fq2QASWeQ==", // "Port": "7puf4kd9qJ/q0fq2QASWeQ==",
"Database": "VvfWH/59gQguY2eA2xBCug==", // "Database": "VvfWH/59gQguY2eA2xBCug==",
"Root": "sD8GZ9UPiIQGU6dU011/4A==", // "Root": "sD8GZ9UPiIQGU6dU011/4A==",
"Password": "Jue6jMFRi11meN6xbdKwDA==" // "Password": "Jue6jMFRi11meN6xbdKwDA=="
} //}
}, },
"SMTPConfig": { "SMTPConfig": {

View File

@ -14,13 +14,30 @@
"RegularUpdateDBTableJob": "0 0 2 * * ?" "RegularUpdateDBTableJob": "0 0 2 * * ?"
}, },
"DBConfig": { "DBConfig": {
//"MySqlDBConfig": {
// "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
// "Port": "js2LutKe+rdjzdxMPQUrvQ==",
// "Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
// "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
// "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
//},
"MySqlDBConfig": { "MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
}, },
"MSSqlDBConfig": {
"Server": "bJm+UAtbeaTjDmp/A5ep2w==", //0.130
"Port": "S5cUXKnKOacFtFy9+0dtpw==",
"Database": "VvfWH/59gQguY2eA2xBCug==", //taipei_dome
"Root": "sD8GZ9UPiIQGU6dU011/4A==",
"Password": "0O24es2ZRF5uoJ4aU+YCdg=="
}
//"MSSqlDBConfig": { //"MSSqlDBConfig": {
// "Server": "avZg8PA8C9GVgYZBgEKzCg==", // "Server": "avZg8PA8C9GVgYZBgEKzCg==",
// "Port": "lJA0KPkG6RvFfTgWiXFyUw==", // "Port": "lJA0KPkG6RvFfTgWiXFyUw==",

View File

@ -0,0 +1,18 @@
using Repository.BackendRepository.Interface;
using Repository.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Repository.BackendRepository.Implement
{
public class BackgroundServiceMsSqlRepository : BackendRepository, IBackgroundServiceMsSqlRepository
{
public BackgroundServiceMsSqlRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
{
UseDB = "MSSQL";
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Repository.BackendRepository.Interface
{
public interface IBackgroundServiceMsSqlRepository : IBackendRepository
{
}
}