Line function完成

This commit is contained in:
b110212000 2021-09-16 14:06:11 +08:00
parent 777eb0d51b
commit f8015966d8

View File

@ -3185,6 +3185,35 @@ namespace SolarPower.Controllers
throw ex; throw ex;
} }
} }
/// <summary>
/// LineToken
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public string CallLineToken (string message,string LineToken)
{
try
{
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create("https://notify-api.line.me/api/notify?message=" + message);
Postrequest.Method = "POST";
Postrequest.Headers.Add("Authorization", "Bearer " + LineToken);
Postrequest.PreAuthenticate = true;
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
var final = JObject.Parse(responseString);
var get = final["status"].ToString();
if(get != "200")
{
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken發送Line接收失敗");
}
return get;
}
catch (Exception ex)
{
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken:" + ex);
throw ex;
}
}
public async Task<ApiResult<List<string>>> GetShareDevicePowerstationName (int Id) public async Task<ApiResult<List<string>>> GetShareDevicePowerstationName (int Id)
{ {
@ -3245,8 +3274,10 @@ namespace SolarPower.Controllers
try try
{ {
var powerstation = await powerStationRepository.GetOneAsync(Id); var powerstation = await powerStationRepository.GetOneAsync(Id);
await powerStationRepository.StationStatus(Id, 0); await powerStationRepository.StationStatus(Id, 0);
await powerStationRepository.StationStatus(Id, 0,powerstation.SiteDB + "."); await powerStationRepository.StationStatus(Id, 0,powerstation.SiteDB + ".");
//CallLineToken("電站停用了", "7W3TkCpyhfQ28QHCWL2L7s9ygrI63oHRBHUc9Hn2E3A");
apiResult.Msg = "電站停用成功"; apiResult.Msg = "電站停用成功";
apiResult.Code = "0000"; apiResult.Code = "0000";