修改getmenu
This commit is contained in:
parent
25945aad63
commit
3f45fe7c2c
@ -130,90 +130,90 @@ namespace BackendWorkerService.Services.Implement
|
|||||||
COMMIT TRANSACTION;";
|
COMMIT TRANSACTION;";
|
||||||
|
|
||||||
#region 時歸檔補償
|
#region 時歸檔補償
|
||||||
using (IDbConnection conn = new SqlConnection(Connection1))
|
//using (IDbConnection conn = new SqlConnection(Connection1))
|
||||||
{
|
//{
|
||||||
//取得所有須補償的設備資訊
|
// //取得所有須補償的設備資訊
|
||||||
targetTable = "archive_electric_meter_hour";
|
// targetTable = "archive_electric_meter_hour";
|
||||||
var sql_error_hour = string.Format(sql_error_format, targetTable);
|
// var sql_error_hour = string.Format(sql_error_format, targetTable);
|
||||||
var error_hours = conn.Query<ArchiveElectricMeter>(sql_error_hour, new { RepeatTimes = repeatTimes }).ToList();
|
// var error_hours = conn.Query<ArchiveElectricMeter>(sql_error_hour, new { RepeatTimes = repeatTimes }).ToList();
|
||||||
|
|
||||||
List<Dictionary<string, object>> archiveHourRawDatas = new List<Dictionary<string, object>>();
|
// List<Dictionary<string, object>> archiveHourRawDatas = new List<Dictionary<string, object>>();
|
||||||
if (error_hours.Count() > 0)
|
// if (error_hours.Count() > 0)
|
||||||
{
|
// {
|
||||||
foreach (var error_hour in error_hours)
|
// foreach (var error_hour in error_hours)
|
||||||
{
|
// {
|
||||||
DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint();
|
// DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint();
|
||||||
deviceNumberPoint.DeviceNumber = error_hour.Device_number;
|
// deviceNumberPoint.DeviceNumber = error_hour.Device_number;
|
||||||
deviceNumberPoint.Point = error_hour.Point;
|
// deviceNumberPoint.Point = error_hour.Point;
|
||||||
deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", error_hour.Device_number, 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 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 endTimestamp = string.Format("{0}+08:00", error_hour.End_timestamp.Replace(" ", "T"));
|
||||||
|
|
||||||
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
|
// var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
|
||||||
<abstime name='start' val='{startTimestamp}' />
|
// <abstime name='start' val='{startTimestamp}' />
|
||||||
<abstime name='end' val='{endTimestamp}' />
|
// <abstime name='end' val='{endTimestamp}' />
|
||||||
<reltime name='interval' val = 'PT1H' />
|
// <reltime name='interval' val = 'PT1H' />
|
||||||
</obj>";
|
// </obj>";
|
||||||
|
|
||||||
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/{deviceNumberPoint.FullDeviceNumberPoint}/~historyRollup/");
|
||||||
//HttpWebRequest archiveHourRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
// //HttpWebRequest archiveHourRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/FIC_Center/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||||
archiveHourRequest.Method = "POST";
|
// archiveHourRequest.Method = "POST";
|
||||||
archiveHourRequest.Headers.Add("Authorization", "Basic " + encoded);
|
// archiveHourRequest.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
archiveHourRequest.PreAuthenticate = true;
|
// archiveHourRequest.PreAuthenticate = true;
|
||||||
|
|
||||||
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
|
// byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
|
||||||
using (Stream reqStream = archiveHourRequest.GetRequestStream())
|
// using (Stream reqStream = archiveHourRequest.GetRequestStream())
|
||||||
{
|
// {
|
||||||
reqStream.Write(byteArray, 0, byteArray.Length);
|
// reqStream.Write(byteArray, 0, byteArray.Length);
|
||||||
}
|
// }
|
||||||
|
|
||||||
HttpWebResponse archiveHourResponse = (HttpWebResponse)archiveHourRequest.GetResponse();
|
// HttpWebResponse archiveHourResponse = (HttpWebResponse)archiveHourRequest.GetResponse();
|
||||||
var archiveHourResponseContent = new StreamReader(archiveHourResponse.GetResponseStream()).ReadToEnd();
|
// var archiveHourResponseContent = new StreamReader(archiveHourResponse.GetResponseStream()).ReadToEnd();
|
||||||
|
|
||||||
xmlDocument.LoadXml(archiveHourResponseContent);
|
// xmlDocument.LoadXml(archiveHourResponseContent);
|
||||||
string archiveHourJson = JsonConvert.SerializeXmlNode(xmlDocument);
|
// string archiveHourJson = JsonConvert.SerializeXmlNode(xmlDocument);
|
||||||
JObject archiveHourJsonResult = (JObject)JsonConvert.DeserializeObject(archiveHourJson);
|
// JObject archiveHourJsonResult = (JObject)JsonConvert.DeserializeObject(archiveHourJson);
|
||||||
|
|
||||||
if (archiveHourJsonResult.ContainsKey("err")) //抓取錯誤
|
// if (archiveHourJsonResult.ContainsKey("err")) //抓取錯誤
|
||||||
{
|
// {
|
||||||
Dictionary<string, object> archiveDayRawData = new Dictionary<string, object>();
|
// Dictionary<string, object> archiveDayRawData = new Dictionary<string, object>();
|
||||||
archiveDayRawData.Add("@device_number", error_hour.Device_number);
|
// archiveDayRawData.Add("@device_number", error_hour.Device_number);
|
||||||
archiveDayRawData.Add("@point", error_hour.Point);
|
// archiveDayRawData.Add("@point", error_hour.Point);
|
||||||
archiveDayRawData.Add("@start_timestamp", error_hour.Start_timestamp);
|
// archiveDayRawData.Add("@start_timestamp", error_hour.Start_timestamp);
|
||||||
archiveDayRawData.Add("@end_timestamp", error_hour.End_timestamp);
|
// archiveDayRawData.Add("@end_timestamp", error_hour.End_timestamp);
|
||||||
archiveDayRawData.Add("@is_complete", 0);
|
// archiveDayRawData.Add("@is_complete", 0);
|
||||||
archiveDayRawData.Add("@repeat_times", ++error_hour.Repeat_times);
|
// archiveDayRawData.Add("@repeat_times", ++error_hour.Repeat_times);
|
||||||
archiveDayRawData.Add("@fail_reason", archiveHourJson);
|
// archiveDayRawData.Add("@fail_reason", archiveHourJson);
|
||||||
|
|
||||||
archiveDayRawData.Add("@count_rawdata", 0);
|
// archiveDayRawData.Add("@count_rawdata", 0);
|
||||||
archiveDayRawData.Add("@min_rawdata", 0);
|
// archiveDayRawData.Add("@min_rawdata", 0);
|
||||||
archiveDayRawData.Add("@max_rawdata", 0);
|
// archiveDayRawData.Add("@max_rawdata", 0);
|
||||||
archiveDayRawData.Add("@avg_rawdata", 0);
|
// archiveDayRawData.Add("@avg_rawdata", 0);
|
||||||
archiveDayRawData.Add("@sum_rawdata", 0);
|
// archiveDayRawData.Add("@sum_rawdata", 0);
|
||||||
archiveDayRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
// archiveDayRawData.Add("@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|
||||||
archiveHourRawDatas.Add(archiveDayRawData);
|
// archiveHourRawDatas.Add(archiveDayRawData);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (archiveHourJsonResult.ContainsKey("obj")) //表示可以讀取到內容
|
// if (archiveHourJsonResult.ContainsKey("obj")) //表示可以讀取到內容
|
||||||
{
|
// {
|
||||||
var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveHourJsonResult);
|
// var ArrangeRawDatas = ArrangeRawData(deviceNumberPoint, archiveHourJsonResult);
|
||||||
if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
|
// if (ArrangeRawDatas != null && ArrangeRawDatas.Count() > 0)
|
||||||
{
|
// {
|
||||||
archiveHourRawDatas.AddRange(ArrangeRawDatas);
|
// archiveHourRawDatas.AddRange(ArrangeRawDatas);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (archiveHourRawDatas.Count() > 0)
|
// if (archiveHourRawDatas.Count() > 0)
|
||||||
{
|
// {
|
||||||
var sql_error_update = string.Format(sql_update_format, targetTable);
|
// var sql_error_update = string.Format(sql_update_format, targetTable);
|
||||||
conn.Execute(sql_error_update, archiveHourRawDatas);
|
// conn.Execute(sql_error_update, archiveHourRawDatas);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
conn.Close();
|
// conn.Close();
|
||||||
}
|
//}
|
||||||
#endregion 時歸檔補償
|
#endregion 時歸檔補償
|
||||||
|
|
||||||
#region 天歸檔補償
|
#region 天歸檔補償
|
||||||
|
@ -190,7 +190,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
(
|
(
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM role_auth ra
|
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
|
) ra
|
||||||
left join auth_page ap on ra.AuthCode = ap.AuthCode
|
left join auth_page ap on ra.AuthCode = ap.AuthCode
|
||||||
where ap.AuthType = 1
|
where ap.AuthType = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user