diff --git a/BackendWorkerService/Program.cs b/BackendWorkerService/Program.cs index d773820..af122ff 100644 --- a/BackendWorkerService/Program.cs +++ b/BackendWorkerService/Program.cs @@ -83,6 +83,7 @@ namespace BackendWorkerService #region Repository `J services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); #endregion Repository `J diff --git a/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs b/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs index 68920e0..52f2bf5 100644 --- a/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs +++ b/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs @@ -1,5 +1,6 @@ using Backend.Models; using BackendWorkerService.Services.Implement; +using Dapper; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -25,6 +26,7 @@ namespace BackendWorkerService.Quartz.Jobs { private readonly ILogger logger; private readonly IBackgroundServiceRepository backgroundServiceRepository; + private readonly IBackgroundServiceMsSqlRepository backgroundServiceMsSqlRepository; protected readonly IDatabaseHelper _databaseHelper; private readonly ILogger loggers; @@ -32,10 +34,12 @@ namespace BackendWorkerService.Quartz.Jobs public ArchiveElectricMeterDayJob( ILogger logger, IBackgroundServiceRepository backgroundServiceRepository, + IBackgroundServiceMsSqlRepository backgroundServiceMySqlRepository, IDatabaseHelper databaseHelper, ILogger loggers, IBackendRepository backendRepository) { this.logger = logger; this.backgroundServiceRepository = backgroundServiceRepository; + this.backgroundServiceMsSqlRepository = backgroundServiceMySqlRepository; this._databaseHelper = databaseHelper; this.loggers = loggers; } @@ -57,12 +61,12 @@ namespace BackendWorkerService.Quartz.Jobs var electricMeterGuid = variableArchive.Where(x => x.Name == "ElectricMeterGuid").Select(x => x.Value).FirstOrDefault(); #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", sWhere, new { sub_system_guid = electricMeterGuid }); #endregion 找出所有電錶設備 #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", sPointWhere, new { sub_system_guid = electricMeterGuid }); #endregion 找出所有電錶系統的點位 @@ -180,7 +184,51 @@ namespace BackendWorkerService.Quartz.Jobs 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 count_rawdata = @count_rawdata, @@ -228,7 +276,7 @@ namespace BackendWorkerService.Quartz.Jobs COMMIT TRANSACTION;"; await backgroundServiceRepository.ExecuteSql(sql, archiveDayRawDatas); - + await backgroundServiceMsSqlRepository.ExecuteSql(mySql, archiveDayRawDatas); } await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Day", "任務完成"); } @@ -324,7 +372,53 @@ namespace BackendWorkerService.Quartz.Jobs 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 count_rawdata = @count_rawdata, @@ -372,7 +466,8 @@ namespace BackendWorkerService.Quartz.Jobs COMMIT TRANSACTION;"; await backgroundServiceRepository.ExecuteSql(sql, archiveWeekRawDatas); - + await backgroundServiceMsSqlRepository.ExecuteSql(mySql, archiveWeekRawDatas); + } await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Week", "任務完成"); } @@ -470,7 +565,50 @@ namespace BackendWorkerService.Quartz.Jobs 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 count_rawdata = @count_rawdata, @@ -518,6 +656,7 @@ namespace BackendWorkerService.Quartz.Jobs COMMIT TRANSACTION;"; await backgroundServiceRepository.ExecuteSql(sql, archiveMonthRawDatas); + await backgroundServiceMsSqlRepository.ExecuteSql(mySql, archiveMonthRawDatas); } await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Month", "任務完成"); } @@ -532,13 +671,13 @@ namespace BackendWorkerService.Quartz.Jobs #region 補償機制 //取得連線字串 - if(await task_Detail.GetNeedWorkTask("ArchiveElectricMeterDayJob", "Compensate")) + if (await task_Detail.GetNeedWorkTask("ArchiveElectricMeterDayJob", "Compensate")) { try { await task_Detail.InsertWorkTime("ArchiveElectricMeterDayJob", "Compensate", "任務開始"); - ProcEletricMeterService procEletricMeterService = new ProcEletricMeterService(_databaseHelper.GetMSSqlConnectionString()); - procEletricMeterService.ArchiveData(); + ProcEletricMeterService procEletricMeterService = new ProcEletricMeterService(backgroundServiceRepository, backgroundServiceMsSqlRepository); + await procEletricMeterService.ArchiveData(); await task_Detail.InsertWorkTime_End("ArchiveElectricMeterDayJob", "Compensate", "任務完成"); } catch(Exception ex) diff --git a/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs b/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs index b6f1716..2885318 100644 --- a/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs +++ b/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs @@ -16,6 +16,7 @@ using System.Xml; using System.Xml.Serialization; using System.Linq; using NCrontab; +using BackendWorkerService.Services.Implement; namespace BackendWorkerService.Quartz.Jobs { @@ -232,8 +233,8 @@ namespace BackendWorkerService.Quartz.Jobs { "@msgType", observation.Alert.MsgType}, { "@headline", observation.Alert.Info.Headline}, { "@areaDesc", area}, - { "@onset", observation.Alert.Info.Onset}, - { "@expires", observation.Alert.Info.Expires}, + { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")}, + { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")}, { "@created_by", "system"}, { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, }; @@ -317,8 +318,8 @@ namespace BackendWorkerService.Quartz.Jobs { "@areaDesc", area}, { "@urgency",observation.Alert.Info.Urgency}, { "@severity",observation.Alert.Info.Severity}, - { "@onset", observation.Alert.Info.Onset}, - { "@expires", observation.Alert.Info.Expires}, + { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")}, + { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")}, { "@created_by", "system"}, { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, }; @@ -458,7 +459,7 @@ namespace BackendWorkerService.Quartz.Jobs weather_type, get_value 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"; var types = await backendRepository.GetAllAsync(sql); var T = types.Where(a => a.weather_type == "T").FirstOrDefault(); diff --git a/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs b/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs index abd3cbc..43edb68 100644 --- a/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs +++ b/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs @@ -12,6 +12,10 @@ using System.Xml; using System.Net; using System.IO; using Newtonsoft.Json; +using Repository.Helper; +using Repository.BackendRepository.Interface; +using Repository.BackendRepository.Implement; +using System.Threading.Tasks; namespace BackendWorkerService.Services.Implement { @@ -20,23 +24,17 @@ namespace BackendWorkerService.Services.Implement /// public class ProcEletricMeterService { - string Connection1 = string.Empty; - IDbConnection conn; + private readonly IBackgroundServiceRepository backgroundServiceRepository; + private readonly IBackgroundServiceMsSqlRepository backgroundServiceMsSqlRepository; - public ProcEletricMeterService(string Connection_parame = null) + public ProcEletricMeterService(IBackgroundServiceRepository backgroundServiceRepository, + IBackgroundServiceMsSqlRepository backgroundServiceMySqlRepository) { - if (!string.IsNullOrEmpty(Connection_parame)) - { - Connection1 = Connection_parame; - conn = new SqlConnection(Connection_parame); - } - else - { - //Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; - } + this.backgroundServiceRepository = backgroundServiceRepository; + this.backgroundServiceMsSqlRepository = backgroundServiceMySqlRepository; } - public bool ArchiveData() + public async Task ArchiveData() { bool result = false; int repeatTimes = 0; @@ -50,36 +48,68 @@ namespace BackendWorkerService.Services.Implement 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(sqlArchive); - repeatTimes = Convert.ToInt32(variableArchive.Where(x => x.Name == "RepeatTimes").Select(x => x.Value).FirstOrDefault()); - - conn.Close(); - } + var variableArchive = await backgroundServiceRepository.GetAllAsync(sqlArchive); + repeatTimes = Convert.ToInt32(variableArchive.Where(x => x.Name == "RepeatTimes").Select(x => x.Value).FirstOrDefault()); #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(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(sqlObix).ToList(); - 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(); - } + encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(obixApiConfig.UserName + ":" + obixApiConfig.Password)); #endregion 取得obix 設定 //取得錯誤的設備sql format 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 var sql_update_format = @"BEGIN TRANSACTION; @@ -217,269 +247,260 @@ namespace BackendWorkerService.Services.Implement #endregion 時歸檔補償 #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(sql_error_day, new { RepeatTimes = repeatTimes }); + + List> archiveDayRawDatas = new List>(); + if (error_days.Count() > 0) { - //取得所有須補償的設備資訊 - targetTable = "archive_electric_meter_day"; - var sql_error_day = string.Format(sql_error_format, targetTable); - var error_days = conn.Query(sql_error_day, new { RepeatTimes = repeatTimes }).ToList(); - - List> archiveDayRawDatas = new List>(); - if (error_days.Count() > 0) + foreach (var error_day in error_days) { - 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 = $@" + + + + "; + + 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(); - 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 = $@" - - - - "; - - 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 archiveDayRawData = new Dictionary(); - 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); - } - } + reqStream.Write(byteArray, 0, byteArray.Length); } - 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); - conn.Execute(sql_error_update, archiveDayRawDatas); + Dictionary archiveDayRawData = new Dictionary(); + 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 天歸檔補償 #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(sql_error_week, new { RepeatTimes = repeatTimes }); + + List> archiveWeekRawDatas = new List>(); + if (error_weeks.Count() > 0) { - //取得所有須補償的設備資訊 - targetTable = "archive_electric_meter_week"; - var sql_error_week = string.Format(sql_error_format, targetTable); - var error_weeks = conn.Query(sql_error_week, new { RepeatTimes = repeatTimes }).ToList(); - - List> archiveWeekRawDatas = new List>(); - if (error_weeks.Count() > 0) + foreach (var error_week in error_weeks) { - 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 = $@" + + + + "; + + 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(); - 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 = $@" - - - - "; - - 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 archiveWeekRawData = new Dictionary(); - 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); - } - } + reqStream.Write(byteArray, 0, byteArray.Length); } - 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); - conn.Execute(sql_error_update, archiveWeekRawDatas); + Dictionary archiveWeekRawData = new Dictionary(); + 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 週歸檔補償 #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(sql_error_month, new { RepeatTimes = repeatTimes }); + + List> archiveMonthRawDatas = new List>(); + if (error_months.Count() > 0) { - //取得所有須補償的設備資訊 - targetTable = "archive_electric_meter_month"; - var sql_error_month = string.Format(sql_error_format, targetTable); - var error_months = conn.Query(sql_error_month, new { RepeatTimes = repeatTimes }).ToList(); - - List> archiveMonthRawDatas = new List>(); - if (error_months.Count() > 0) + foreach (var error_month in error_months) { - 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 = $@" + + + + "; + + 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(); - 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 = $@" - - - - "; - - 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 archiveMonthRawData = new Dictionary(); - 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); - } - } + reqStream.Write(byteArray, 0, byteArray.Length); } - 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); - conn.Execute(sql_error_update, archiveMonthRawDatas); + Dictionary archiveMonthRawData = new Dictionary(); + 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 月歸檔補償 diff --git a/BackendWorkerService/appsettings.Development.json b/BackendWorkerService/appsettings.Development.json index 0b7f905..c92b558 100644 --- a/BackendWorkerService/appsettings.Development.json +++ b/BackendWorkerService/appsettings.Development.json @@ -7,23 +7,40 @@ } }, "BackgroundServiceCron": { - "ExecutionBackgroundServicePlanJob": "0 0 2 * * ?", - "MessageNotificationJob": "0 0 2 * * ?", - "DataDeliveryJob": "0 0 2 * * ?", - "RegularUpdateDBTableJob": "0 0 2 * * ?", - "ParkingJob": "0 0 2 * * ?", - "ArchiveElectricMeterHourJob": "0 0 2 * * ?", - "ArchiveElectricMeterDayJob": "0 0 2 * * ?", + "ExecutionBackgroundServicePlanJob": "0 0 1 * * ?", + "MessageNotificationJob": "0 0 1 * * ?", + "DataDeliveryJob": "0 0 1 * * ?", + "RegularUpdateDBTableJob": "0 0 1 * * ?", + "ParkingJob": "0 0 1 * * ?", + "ArchiveElectricMeterHourJob": "0 0 1 * * ?", + "ArchiveElectricMeterDayJob": "0 0 1 * * ?", "WeatherAPIJob": "0/5 * * * * ?" }, "DBConfig": { + //"MySqlDBConfig": { + // "Server": "TNi6aupYHPZT8ZU177KTKw==", //172.16.220.251 + // "Port": "mkF51jVbg40V5K5eTh2Ckw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "IV8Ec1Ng2AWAnkBafXy2kg==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //}, "MySqlDBConfig": { - "Server": "TNi6aupYHPZT8ZU177KTKw==", //172.16.220.251 - "Port": "mkF51jVbg40V5K5eTh2Ckw==", - "Database": "VvfWH/59gQguY2eA2xBCug==", - "Root": "IV8Ec1Ng2AWAnkBafXy2kg==", - "Password": "Jue6jMFRi11meN6xbdKwDA==" + "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 + "Port": "js2LutKe+rdjzdxMPQUrvQ==", + //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 + //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp + "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 // "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=", // "Port": "S5cUXKnKOacFtFy9+0dtpw==", @@ -31,13 +48,13 @@ // "Root": "+plVKQ+enAqt7BYV2uMQng==", // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" //} - "MSSqlDBConfig": { - "Server": "zp3Nilx0PISEEC4caZWqCg==", //172.16.220.250 - "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - "Database": "VvfWH/59gQguY2eA2xBCug==", - "Root": "sD8GZ9UPiIQGU6dU011/4A==", - "Password": "Jue6jMFRi11meN6xbdKwDA==" - } + //"MSSqlDBConfig": { + // "Server": "zp3Nilx0PISEEC4caZWqCg==", //172.16.220.250 + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} }, "SMTPConfig": { diff --git a/BackendWorkerService/appsettings.json b/BackendWorkerService/appsettings.json index 619afd3..7271896 100644 --- a/BackendWorkerService/appsettings.json +++ b/BackendWorkerService/appsettings.json @@ -14,13 +14,30 @@ "RegularUpdateDBTableJob": "0 0 2 * * ?" }, "DBConfig": { + //"MySqlDBConfig": { + // "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 + // "Port": "js2LutKe+rdjzdxMPQUrvQ==", + // "Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 + // "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", + // "Password": "FVAPxztxpY4gJJKQ/se4bQ==" + //}, "MySqlDBConfig": { "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "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==", "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": { // "Server": "avZg8PA8C9GVgYZBgEKzCg==", // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", diff --git a/Repository/BackendRepository/Implement/BackgroundServiceMsSqlRepository.cs b/Repository/BackendRepository/Implement/BackgroundServiceMsSqlRepository.cs new file mode 100644 index 0000000..7d5b910 --- /dev/null +++ b/Repository/BackendRepository/Implement/BackgroundServiceMsSqlRepository.cs @@ -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"; + } + + } +} diff --git a/Repository/BackendRepository/Interface/IBackgroundServiceMsSqlRepository.cs b/Repository/BackendRepository/Interface/IBackgroundServiceMsSqlRepository.cs new file mode 100644 index 0000000..9c1af7c --- /dev/null +++ b/Repository/BackendRepository/Interface/IBackgroundServiceMsSqlRepository.cs @@ -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 + { + + } +}