新增與名單對比,若有符合則做後續處理
This commit is contained in:
parent
26c69c10b4
commit
6a33a903f5
@ -12,6 +12,7 @@ using Parking_space_WebAPI.Authorization;
|
|||||||
using Mysqlx;
|
using Mysqlx;
|
||||||
using OfficeOpenXml;
|
using OfficeOpenXml;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace Parking_space_WebAPI.Controllers
|
namespace Parking_space_WebAPI.Controllers
|
||||||
{
|
{
|
||||||
@ -274,6 +275,19 @@ namespace Parking_space_WebAPI.Controllers
|
|||||||
// 保存更改
|
// 保存更改
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
// 比對名單,若與名單相符合則上傳至其他API
|
||||||
|
var in_list_data = await _context.yuntech_parking_user_list.FindAsync(violation_car_table.license_plate_number);
|
||||||
|
if (in_list_data != null)
|
||||||
|
{
|
||||||
|
//傳送line
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
|
||||||
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ykmUs2ZECQ9LDiNR4waT8w6NLXjWuYE9P8safG5xTZ6");
|
||||||
|
var content = new Dictionary<string, string>();
|
||||||
|
content.Add("message",in_list_data.user_name+" - "+in_list_data.user_license_plate_number + " 違規轉彎");
|
||||||
|
httpClient.PostAsync("https://notify-api.line.me/api/notify", new FormUrlEncodedContent(content));
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
@ -366,6 +380,19 @@ namespace Parking_space_WebAPI.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// 比對名單,若與名單相符合則上傳至其他API
|
||||||
|
var in_list_data_1 = await _context.yuntech_parking_user_list.FindAsync(license_plate_number);
|
||||||
|
if (in_list_data_1 != null)
|
||||||
|
{
|
||||||
|
//傳送line
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
|
||||||
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ykmUs2ZECQ9LDiNR4waT8w6NLXjWuYE9P8safG5xTZ6");
|
||||||
|
var content = new Dictionary<string, string>();
|
||||||
|
content.Add("message", in_list_data_1.user_name + " - " + in_list_data_1.user_license_plate_number + " 違規轉彎");
|
||||||
|
httpClient.PostAsync("https://notify-api.line.me/api/notify", new FormUrlEncodedContent(content));
|
||||||
|
}
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -390,6 +417,20 @@ namespace Parking_space_WebAPI.Controllers
|
|||||||
data.license_plate_number = license_plate_number;
|
data.license_plate_number = license_plate_number;
|
||||||
_context.violation_car_table.Add(data);
|
_context.violation_car_table.Add(data);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// 比對名單,若與名單相符合則上傳至其他API
|
||||||
|
var in_list_data_1 = await _context.yuntech_parking_user_list.FindAsync(license_plate_number);
|
||||||
|
if (in_list_data_1 != null)
|
||||||
|
{
|
||||||
|
//傳送line
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
|
||||||
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ykmUs2ZECQ9LDiNR4waT8w6NLXjWuYE9P8safG5xTZ6");
|
||||||
|
var content = new Dictionary<string, string>();
|
||||||
|
content.Add("message", in_list_data_1.user_name + " - " + in_list_data_1.user_license_plate_number + " 違規轉彎");
|
||||||
|
httpClient.PostAsync("https://notify-api.line.me/api/notify", new FormUrlEncodedContent(content));
|
||||||
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,6 +452,19 @@ namespace Parking_space_WebAPI.Controllers
|
|||||||
// 保存更改
|
// 保存更改
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 比對名單,若與名單相符合則上傳至其他API
|
||||||
|
var in_list_data = await _context.yuntech_parking_user_list.FindAsync(license_plate_number);
|
||||||
|
if (in_list_data != null)
|
||||||
|
{
|
||||||
|
//傳送line
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
|
||||||
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ykmUs2ZECQ9LDiNR4waT8w6NLXjWuYE9P8safG5xTZ6");
|
||||||
|
var content = new Dictionary<string, string>();
|
||||||
|
content.Add("message", in_list_data.user_name + " - " + in_list_data.user_license_plate_number + " 違規轉彎");
|
||||||
|
httpClient.PostAsync("https://notify-api.line.me/api/notify", new FormUrlEncodedContent(content));
|
||||||
|
}
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user