Merge branch 'master' into kai

This commit is contained in:
Kai 2021-08-26 15:14:39 +08:00
commit 49d748a891
3 changed files with 50 additions and 4 deletions

View File

@ -277,8 +277,8 @@ namespace SolarPower.Controllers
analysisDevice.Series.Add(PR);
DeviceHistoryInfo modelTemperature = new DeviceHistoryInfo();
modelTemperature.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["ModelTemperature"]);
modelTemperature.YaxesKey = "ModelTemperature";
modelTemperature.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["Temperature"]);
modelTemperature.YaxesKey = "Temperature";
modelTemperature.Values = new List<double>();
foreach (var history in temp_item)
{

View File

@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SolarPower.Models;
using SolarPower.Models.Company;
using SolarPower.Models.PowerStation;
@ -12,7 +13,9 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Xml;
namespace SolarPower.Controllers
{
@ -1419,6 +1422,7 @@ namespace SolarPower.Controllers
public async Task<ApiResult<string>> SaveException(ExceptionModal exceptionModal)
{
ApiResult<string> apiResult = new ApiResult<string>();
var url = "10.1.100.138";
try
{
PowerStation powerStation = null;
@ -1447,6 +1451,8 @@ namespace SolarPower.Controllers
"UpperLimit",
};
await powerStationRepository.AddException(Exception, properties, powerStation.SiteDB);
Fetch_PostWithJSONFormat("http://" + url + ":8080/obix/config/Solar/S"+ powerStation.Code+ "01/API/PR_UpperLimit/set", exceptionModal.UpperLimit.ToString());
Fetch_PostWithJSONFormat("http://" + url + ":8080/obix/config/Solar/S" + powerStation.Code + "01/API/PR_LowerLimit/set", exceptionModal.LowerLimit.ToString());
apiResult.Code = "0000";
apiResult.Msg = "新增成功";
@ -1474,6 +1480,9 @@ namespace SolarPower.Controllers
"UpperLimit",
};
await powerStationRepository.UpdateException(Exception, properties, powerStation.SiteDB);
Fetch_PostWithJSONFormat("http://" + url + ":8080/obix/config/Solar/S" + powerStation.Code + "01/API/PR_UpperLimit/set", exceptionModal.UpperLimit.ToString());
Fetch_PostWithJSONFormat("http://" + url + ":8080/obix/config/Solar/S" + powerStation.Code + "01/API/PR_LowerLimit/set", exceptionModal.LowerLimit.ToString());
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
}
@ -2979,5 +2988,42 @@ namespace SolarPower.Controllers
return apiResult;
}
public JObject Fetch_PostWithJSONFormat(string url, string paramter)
{
try
{
string username = "SolarAPI";
string password = "Admin123456";
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(url);
Postrequest.Method = "POST";
Postrequest.Headers.Add("Authorization", "Basic " + encoded);
Postrequest.PreAuthenticate = true;
using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream()))
{
string json = "<real val=\"" + paramter + "\"/>";
streamWriter.Write(json);
}
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseString);
string jsonText = JsonConvert.SerializeXmlNode(xmlDoc);
JObject resultVal = (JObject)JsonConvert.DeserializeObject(jsonText);
return resultVal;
}
catch (Exception ex)
{
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Fetch_PostWithJSONFormat:" + ex );
throw ex;
}
}
}
}

View File

@ -126,7 +126,7 @@
{ key: "Irradiance", title: "日照度", default: true },
{ key: "KWHKWP", title: "發電小時", default: false },
{ key: "PR", title: "PR %", default: false },
{ key: "ModelTemperature", title: "模組溫度", default: false },
{ key: "Temperature", title: "模組溫度", default: false },
{ key: "SolarHour", title: "日照小時", default: false }
]
var PWR_compare_col = [