diff --git a/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs b/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs index 320be3a..abd3cbc 100644 --- a/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs +++ b/BackendWorkerService/Services/Implement/ProcEletricMeterService.cs @@ -130,90 +130,90 @@ namespace BackendWorkerService.Services.Implement COMMIT TRANSACTION;"; #region 時歸檔補償 - using (IDbConnection conn = new SqlConnection(Connection1)) - { - //取得所有須補償的設備資訊 - targetTable = "archive_electric_meter_hour"; - var sql_error_hour = string.Format(sql_error_format, targetTable); - var error_hours = conn.Query(sql_error_hour, new { RepeatTimes = repeatTimes }).ToList(); + //using (IDbConnection conn = new SqlConnection(Connection1)) + //{ + // //取得所有須補償的設備資訊 + // targetTable = "archive_electric_meter_hour"; + // var sql_error_hour = string.Format(sql_error_format, targetTable); + // var error_hours = conn.Query(sql_error_hour, new { RepeatTimes = repeatTimes }).ToList(); - List> archiveHourRawDatas = new List>(); - if (error_hours.Count() > 0) - { - foreach (var error_hour in error_hours) - { - DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); - deviceNumberPoint.DeviceNumber = error_hour.Device_number; - deviceNumberPoint.Point = error_hour.Point; - deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_hour.Device_number, error_hour.Point); + // List> archiveHourRawDatas = new List>(); + // if (error_hours.Count() > 0) + // { + // foreach (var error_hour in error_hours) + // { + // DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); + // deviceNumberPoint.DeviceNumber = error_hour.Device_number; + // deviceNumberPoint.Point = error_hour.Point; + // deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_hour.Device_number, error_hour.Point); - var startTimestamp = string.Format("{0}+08:00", error_hour.Start_timestamp.Replace(" ", "T")); - var endTimestamp = string.Format("{0}+08:00", error_hour.End_timestamp.Replace(" ", "T")); + // var startTimestamp = string.Format("{0}+08:00", error_hour.Start_timestamp.Replace(" ", "T")); + // var endTimestamp = string.Format("{0}+08:00", error_hour.End_timestamp.Replace(" ", "T")); - var historyQueryFilter = $@" - - - - "; + // var historyQueryFilter = $@" + // + // + // + // "; - HttpWebRequest archiveHourRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/"); - //HttpWebRequest archiveHourRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/"); - archiveHourRequest.Method = "POST"; - archiveHourRequest.Headers.Add("Authorization", "Basic " + encoded); - archiveHourRequest.PreAuthenticate = true; + // HttpWebRequest archiveHourRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/"); + // //HttpWebRequest archiveHourRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/"); + // archiveHourRequest.Method = "POST"; + // archiveHourRequest.Headers.Add("Authorization", "Basic " + encoded); + // archiveHourRequest.PreAuthenticate = true; - byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); - using (Stream reqStream = archiveHourRequest.GetRequestStream()) - { - reqStream.Write(byteArray, 0, byteArray.Length); - } + // byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); + // using (Stream reqStream = archiveHourRequest.GetRequestStream()) + // { + // reqStream.Write(byteArray, 0, byteArray.Length); + // } - HttpWebResponse archiveHourResponse = (HttpWebResponse)archiveHourRequest.GetResponse(); - var archiveHourResponseContent = new StreamReader(archiveHourResponse.GetResponseStream()).ReadToEnd(); + // HttpWebResponse archiveHourResponse = (HttpWebResponse)archiveHourRequest.GetResponse(); + // var archiveHourResponseContent = new StreamReader(archiveHourResponse.GetResponseStream()).ReadToEnd(); - xmlDocument.LoadXml(archiveHourResponseContent); - string archiveHourJson = JsonConvert.SerializeXmlNode(xmlDocument); - JObject archiveHourJsonResult = (JObject)JsonConvert.DeserializeObject(archiveHourJson); + // xmlDocument.LoadXml(archiveHourResponseContent); + // string archiveHourJson = JsonConvert.SerializeXmlNode(xmlDocument); + // JObject archiveHourJsonResult = (JObject)JsonConvert.DeserializeObject(archiveHourJson); - if (archiveHourJsonResult.ContainsKey("err")) //抓取錯誤 - { - Dictionary archiveDayRawData = new Dictionary(); - archiveDayRawData.Add("@device_number", error_hour.Device_number); - archiveDayRawData.Add("@point", error_hour.Point); - archiveDayRawData.Add("@start_timestamp", error_hour.Start_timestamp); - archiveDayRawData.Add("@end_timestamp", error_hour.End_timestamp); - archiveDayRawData.Add("@is_complete", 0); - archiveDayRawData.Add("@repeat_times", ++error_hour.Repeat_times); - archiveDayRawData.Add("@fail_reason", archiveHourJson); + // if (archiveHourJsonResult.ContainsKey("err")) //抓取錯誤 + // { + // Dictionary archiveDayRawData = new Dictionary(); + // archiveDayRawData.Add("@device_number", error_hour.Device_number); + // archiveDayRawData.Add("@point", error_hour.Point); + // archiveDayRawData.Add("@start_timestamp", error_hour.Start_timestamp); + // archiveDayRawData.Add("@end_timestamp", error_hour.End_timestamp); + // archiveDayRawData.Add("@is_complete", 0); + // archiveDayRawData.Add("@repeat_times", ++error_hour.Repeat_times); + // archiveDayRawData.Add("@fail_reason", archiveHourJson); - 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")); + // 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")); - archiveHourRawDatas.Add(archiveDayRawData); - } + // archiveHourRawDatas.Add(archiveDayRawData); + // } - if (archiveHourJsonResult.ContainsKey("obj")) //表示可以讀取到內容 - { - var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveHourJsonResult); - if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0) - { - archiveHourRawDatas.AddRange(ArrangeRawDatas); - } - } - } + // if (archiveHourJsonResult.ContainsKey("obj")) //表示可以讀取到內容 + // { + // var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveHourJsonResult); + // if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0) + // { + // archiveHourRawDatas.AddRange(ArrangeRawDatas); + // } + // } + // } - if (archiveHourRawDatas.Count() > 0) - { - var sql_error_update = string.Format(sql_update_format, targetTable); - conn.Execute(sql_error_update, archiveHourRawDatas); - } - } - conn.Close(); - } + // if (archiveHourRawDatas.Count() > 0) + // { + // var sql_error_update = string.Format(sql_update_format, targetTable); + // conn.Execute(sql_error_update, archiveHourRawDatas); + // } + // } + // conn.Close(); + //} #endregion 時歸檔補償 #region 天歸檔補償 diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index 232c9ae..5cebf40 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -190,7 +190,7 @@ namespace FrontendWebApi.ApiControllers ( SELECT * FROM role_auth ra - WHERE ra.role_guid = (SELECT ui.role_guid from userinfo ui where account = '@Account') + WHERE ra.role_guid = (SELECT ui.role_guid from userinfo ui where account = @Account) ) ra left join auth_page ap on ra.AuthCode = ap.AuthCode where ap.AuthType = 1