first commit carviolation 後端專案上傳

This commit is contained in:
keke 2023-08-03 10:47:34 +08:00
commit 93f1fb558e
154 changed files with 12852 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

242
.gitignore vendored Normal file
View File

@ -0,0 +1,242 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Xx]64/
[Xx]86/
[Bb]uild/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Un-comment the next line if you do not want to checkin
# your web deploy settings because they may include unencrypted
# passwords
#*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# LightSwitch generated files
GeneratedArtifacts/
ModelManifest.xml
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/

View File

@ -0,0 +1,305 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Traffic.Data.Enums;
using Traffic.Data.ViewModels;
using Traffic.Service.Filter;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/user")]
[Authorize]
[ApiController]
[ServiceFilter(typeof(LogFilter))]
public class AccountController : ControllerBase
{
private readonly IAccountService _service;
private readonly ILogger _logger;
public AccountController(IAccountService service, ILogger<AccountController> logger)
{
_service = service;
_logger = logger;
}
/// <summary>
/// 取得 使用者資訊
/// </summary>
/// <param name="id">使用者 Id</param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetAccountUser(int id)
{
try
{
var result = _service.GetAccountUser(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得 UserData 列表
/// </summary>
/// <param name="searchModel"></param>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("GetUserDataList")]
public IActionResult GetUserDataList([FromQuery] SearchModelViewModel searchModel, int? Id)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetUserDataList(model, Id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增使用者
/// </summary>
/// <param name="account">新增的使用者資訊</param>
/// <returns></returns>
/// <remarks>管理者Admin RoleCodeId = 0, 一般User RoleCodeId = 1</remarks>
[HttpPost("PostUserDataList")]
public IActionResult InserAccountUser(UserData account)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var mID = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.InserAccountUser(mID, account);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 管理者修改使用者狀態
/// </summary>
/// <param name="id"></param>
/// <param name="status">狀態</param>
/// <returns></returns>
/// <remarks> 0:Disable, 1:Enable</remarks>
[HttpPut("PutUserStatus/{id}")]
public IActionResult PutUserStatus(int id, int status)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.PutUserbyAdmin(byWho, id, status);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 管理者修改使用者
/// </summary>
/// <param name="id"></param>
/// <param name="account">管理者欲修改的使用者資訊</param>
/// <returns></returns>
/// <remarks>管理者Admin RoleCodeId = 0, 一般User RoleCodeId = 1</remarks>
[HttpPut("PutUserData/{id}")]
public IActionResult UpdateAccountbyAdmin(int id, UserData account)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
account.Id = id;
var result = _service.UpdateAccountbyAdmin(byWho, account);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 管理者修改使用者密碼
/// </summary>
/// <param name="id">使用者Id</param>
/// <returns></returns>
/// <remarks>管理者Admin RoleCodeId = 0, 一般User RoleCodeId = 1</remarks>
[HttpPut("PutUserPassword/{id}")]
public IActionResult UpdateAccountPasswordbyAdmin(int id)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.UpdateAccountPasswordbyAdmin(id, byWho);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
///// <summary>
///// 使用者修改自己的帳號資訊
///// </summary>
///// <param name="account">使用者自己欲修改的資訊</param>
///// <returns></returns>
//[HttpPut("")]
//public IActionResult UpdateAccountbyUser(UserData account)
//{
// var userIdentity = (ClaimsIdentity)User.Identity;
// var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
// var result = _service.UpdateAccountbyUser(byWho, account);
// return result.Success ? Ok(result) : BadRequest(result);
//}
/// <summary>
/// 修改密碼
/// </summary>
/// <param name="account">修改前後的密碼</param>
/// <returns></returns>
[HttpPut("PutUserPassword")]
public IActionResult UpdateAccountPassword(UserData account)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
var byWhoAccount = new ParserForUserFromClaim(userIdentity).GetAccount();
account.Id = byWho;
account.Account = byWhoAccount;
var result = _service.UpdateAccountPasswordByUser(byWho, account);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception ex)
{
return BadRequest(ex.ToString());
}
}
/// <summary>
/// 刪除使用者帳號
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete("DeleteUserData")]
public IActionResult DeleteUserData(int id)
{
try
{
return Ok(_service.DeleteUserData(id));
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 是否存在此User
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
[HttpGet("GetExistUser")]
public IActionResult GetExistUser(string account)
{
try
{
var result = _service.GetExistUser(account);
return Ok(new { Result = result });
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得使用者名稱列表
/// </summary>
/// <returns></returns>
[HttpGet("GetUserNameList")]
public IActionResult GetUserNameList()
{
try
{
var result = _service.GetUserNameList();
return Ok(new { Result = result });
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得使用者站點列表
/// </summary>
/// <returns></returns>
[HttpGet("GetUserSite")]
public IActionResult GetUserSite()
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var id = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.GetUserSite(id);
return Ok(new { Result = result });
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得使用者站點資訊列表
/// </summary>
/// <returns></returns>
[HttpGet("GetUserSiteInfo")]
public IActionResult GetUserSiteInfo()
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var id = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.GetUserSiteInfo(id);
return Ok(new { Result = result });
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,137 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Filter;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
/// <summary>
/// 公佈欄管理
/// </summary>
[Route("api/announce")]
[Authorize]
[ApiController]
[ServiceFilter(typeof(LogFilter))]
public class AnnounceController : ControllerBase
{
private readonly IAnnounceService _service;
public AnnounceController(IAnnounceService service)
{
_service = service;
}
/// <summary>
/// 取得公告列表
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetAnnounces([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetAnnounces(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得公告 by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetAnnounce(int id)
{
try
{
var result = new Response();
result.Result = _service.GetAnnounceById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增公告
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("")]
public IActionResult InsertAnnounce(AnnounceInsertViewModel vm)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.InsertAnnounce(byWho, vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改公告
/// </summary>
/// <param name="id">公告的流水號</param>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("{id}")]
public IActionResult UpdateAnnounce(int id, AnnounceInsertViewModel vm)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var byWho = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = _service.UpdatAnnounce(id, vm, byWho);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除公告
/// </summary>
/// <param name="id">公告的流水號</param>
/// <returns></returns>
[HttpDelete("{id}")]
public IActionResult DeleteAnnounce(int id)
{
try
{
var result = _service.DeleteAnnounce(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,162 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
/// <summary>
/// 廠商資料設定
/// </summary>
[Route("api/companyInformation")]
[Authorize]
[ApiController]
public class CompanyInformationController : ControllerBase
{
private readonly ICompanyInformationService _service;
public CompanyInformationController(ICompanyInformationService service)
{
_service = service;
}
/// <summary>
/// 取得廠商資料設定列表
/// </summary>
[AllowAnonymous]
[HttpGet("all")]
public IActionResult GetCompanyInformations()
{
try
{
var result = new Response();
result.Result = _service.GetCompanyInformations();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得廠商資料設定列表 (Email 空白的不顯示)
/// </summary>
[AllowAnonymous]
[HttpGet("all/emailNotNull")]
public IActionResult GetCompanyInformationsEmailNotNull()
{
try
{
var result = new Response();
result.Result = _service.GetCompanyInformationsEmailNotNull();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得廠商資料設定列表
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetCompanyInformations([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetCompanyInformations(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得廠商資料 by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetCompanyInformation(int id)
{
try
{
var result = new Response();
result.Result = _service.GetCompanyInformationById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增廠商資料設定
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("")]
public IActionResult InsertCompanyInformation(CompanyInformationViewModel vm)
{
try
{
var result = _service.InsertCompanyInformation(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改廠商資料設定
/// </summary>
/// <param name="id">廠商資料的流水號</param>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("{id}")]
public IActionResult UpdateCompanyInformation(int id, CompanyInformationViewModel vm)
{
try
{
var result = _service.UpdatCompanyInformation(id, vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除廠商資料
/// </summary>
/// <param name="id">廠商資料的流水號</param>
/// <returns></returns>
[HttpDelete("{id}")]
public IActionResult DeleteCompanyInformation(int id)
{
try
{
var result = _service.DeleteCompanyInformation(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,441 @@
using ClosedXML.Excel;
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
/// <summary>
/// 事件
/// </summary>
[Route("api/event")]
[Authorize]
[ApiController]
public class EventController : ControllerBase
{
private readonly IEventService _service;
private readonly IFileService _fileService;
private readonly IEventTypeService _eventTypeService;
public EventController(IFileService fileService, IEventService service, IEventTypeService eventTypeService)
{
_fileService = fileService;
_service = service;
_eventTypeService = eventTypeService;
}
/// <summary>
/// 取得事件列表 Term = 車牌號碼(Number)
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
/// <remarks>Term = 車牌號碼(Number)</remarks>
[HttpGet("")]
public IActionResult GetEvents([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetEventsByCar(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
///// <summary>
///// 取得某站點的事件列表
///// </summary>
///// <param name="siteId"></param>
///// <param name="searchModel"></param>
///// <returns></returns>
///// <remarks>Term = 車牌號碼(Number)</remarks>
//[HttpGet("siteId/{siteId}")]
//public IActionResult GetEventBySites(string siteId, [FromQuery] SearchModelViewModel searchModel)
//{
// var result = new Response();
// var model = Util.GetSearchModel(searchModel);
// result.Result = _service.GetEventBySites(siteId, model);
// return Ok(result);
//}
/// <summary>
/// 取得開單畫面的事件
/// </summary>
/// <param name="eventType">違規項目</param>
/// <param name="startTime">起始時間</param>
/// <param name="endTime">結束時間</param>
/// <param name="site">站點</param>
/// <param name="status">狀態</param>
/// <param name="time">違停時間</param>
/// <param name="speed">速度</param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpGet("eventType/{eventType}")]
public IActionResult GetEventByEventType(string eventType, string startTime, string endTime, string site = "ALL", string status = "ALL", string time = "ALL", string speed = "ALL", string method = "0")
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var id = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = new Response();
startTime = startTime.Replace("undefined", "00:00:00");
endTime = endTime.Replace("undefined", "23:59:59");
//if (startTime == endTime || (startTime.Length == 10 && endTime.Length == 10))
//{
// startTime = startTime.Substring(0, 10) + " 00:00:00";
// endTime = endTime.Substring(0, 10) + " 23:59:59";
//}
var events = _service.GetEventsByEventType(id, eventType, startTime, endTime, site, status, time, speed);
if (events == null)
{
var res = new TradeResultModel();
res.Success = false;
res.Message = "查詢筆數過多,請重新查詢。";
return BadRequest(res);
}
var eventTypeViewModel = _eventTypeService.GetEventTypeByEventType(eventType);
var eventName = string.Empty;
if (eventTypeViewModel != null)
{
eventName = eventTypeViewModel.EventName;
};
result.Result = events;
if (method == "1")
{
var url = _fileService.ExportEvent(
Convert.ToDateTime(startTime).ToString("yyMMdd"),
Convert.ToDateTime(endTime).ToString("yyMMdd"),
eventName, events);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得今年累計處理案件數 (punished = 1)
/// </summary>
/// <returns></returns>
[HttpGet("count/thisYear")]
public IActionResult GetThisYearEventsCount()
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var account = new ParserForUserFromClaim(userIdentity).GetAccount();
var result = new Response
{
Result = _service.GetThisYearEventsCount(account)
};
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得本月新增案件數量
/// </summary>
/// <returns></returns>
[HttpGet("count/thisMonth")]
public IActionResult GetThisMonthEventsCount()
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var account = new ParserForUserFromClaim(userIdentity).GetAccount();
var result = new Response
{
Result = _service.GetThisMonthEventsCount(account)
};
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得處理進度 by 時間區間
/// </summary>
/// <returns></returns>
/// <remarks>時間格式 yyyy-MM-dd</remarks>
[HttpGet("count/interval")]
public IActionResult GetEventsby(string startDatetime, string endDatetime)
{
try
{
var result = new Response();
result.Result = _service.GetEventsCount(startDatetime, endDatetime);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得事件 by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetEvent(int id)
{
try
{
var result = new Response();
result.Result = _service.GetEventById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
///// <summary>
///// 新增事件
///// </summary>
///// <param name="vm"></param>
///// <returns></returns>
//[HttpPost("")]
//public IActionResult InsertEvent(EventViewModel vm)
//{
// var result = _service.InsertEvent(vm);
// return result.Success ? Ok(result) : BadRequest(result);
//}
///// <summary>
///// 修改事件
///// </summary>
///// <param name="id">事件的流水號</param>
///// <param name="vm"></param>
///// <returns></returns>
//[HttpPut("{id}")]
//public IActionResult UpdateEvent(int id, EventViewModel vm)
//{
// var result = _service.UpdatEvent(id, vm);
// return result.Success ? Ok(result) : BadRequest(result);
//}
/// <summary>
/// 修改事件 成 CheckPunish (確認開單)
/// </summary>
/// <param name="eventId">事件的流水號</param>
/// <param name="law">違規法條</param>
/// <returns></returns>
[HttpPut("{eventId}/checkPunish")]
public IActionResult UpdatEventCheckPunish(int eventId, string law)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var account = new ParserForUserFromClaim(userIdentity).GetAccount();
var result = _service.UpdatEventCheckPunish(account, eventId, "1", law);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 批次確認開單
/// </summary>
/// <param name="eventId"></param>
/// <param name="law">違規法條</param>
/// <returns></returns>
[HttpPut("muti/checkPunish")]
public IActionResult UpdatEventCheckPunish(List<int> eventId, string law)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var account = new ParserForUserFromClaim(userIdentity).GetAccount();
var result = _service.UpdatEventCheckPunishList(account, eventId, "1", law);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
///// <summary>
///// 修改事件 取消開單
///// </summary>
///// <param name="id">事件的流水號</param>
///// <returns></returns>
//[HttpPut("{id}/checkPunishRollback")]
//public IActionResult UpdatEventCheckPunishRollback(int id)
//{
// var userIdentity = (ClaimsIdentity)User.Identity;
// var account = new ParserForUserFromClaim(userIdentity).GetAccount();
// var result = _service.UpdatEventCheckPunish(account, id, "0");
// return result.Success ? Ok(result) : BadRequest(result);
//}
/// <summary>
/// 修改事件 成 不開單
/// </summary>
/// <param name="eventId">事件的流水號</param>
/// <param name="reason"></param>
/// <returns></returns>
[HttpPut("{eventId}/nopunish")]
public IActionResult UpdatEventNoPunish(int eventId, string reason)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var account = new ParserForUserFromClaim(userIdentity).GetAccount();
var result = _service.UpdatEventNoPunish(account, eventId, reason);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取消開單
/// </summary>
/// <param name="eventId">事件的流水號</param>
/// <returns></returns>
[HttpPut("{eventId}/cancel")]
public IActionResult UpdatEventCancel(int eventId)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var account = new ParserForUserFromClaim(userIdentity).GetAccount();
var result = _service.UpdatEventCancel(account, eventId);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
///// <summary>
///// 刪除事件
///// </summary>
///// <param name="id">事件的流水號</param>
///// <returns></returns>
//[HttpDelete("{id}")]
//public IActionResult DeleteEvent(int id)
//{
// var result = _service.DeleteEvent(id);
// return result.Success ? Ok(result) : BadRequest(result);
//}
/// <summary>
/// 修改事件的車子類型
/// </summary>
/// <param name="eventId">事件的流水號</param>
/// <param name="vehicleType"></param>
/// <returns></returns>
[HttpPut("{eventId}/vehicleType")]
public IActionResult UpdateEventVehicleType(int eventId, string vehicleType)
{
try
{
var result = _service.UpdatEventVehicleType(eventId, vehicleType);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改事件的車牌號碼
/// </summary>
/// <param name="eventId">事件的流水號</param>
/// <param name="vehicleNumber"></param>
/// <returns></returns>
[HttpPut("{eventId}/vehicleNumber")]
public IActionResult UpdateEventVehicleNumber(int eventId, string vehicleNumber)
{
try
{
var result = _service.UpdatEventVehicleNumber(eventId, vehicleNumber);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改事件的車牌號碼和車子類型
/// </summary>
/// <param name="eventId">事件的流水號</param>
/// <param name="vehicleType"></param>
/// <param name="vehicleNumber"></param>
/// <returns></returns>
[HttpPut("{eventId}/vehicle")]
public IActionResult UpdateEventVehicle(int eventId, string vehicleType, string vehicleNumber)
{
try
{
var result = _service.UpdatEventVehicle(eventId, vehicleType, vehicleNumber);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
[HttpGet("vehicle/all")]
public IActionResult GetVehicleTypes()
{
try
{
var result = new Response();
result.Result = _service.GetVehicleTypes();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,166 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
/// <summary>
/// 違規事件
/// </summary>
[Route("api/eventType")]
[Authorize]
[ApiController]
public class EventTypeController : ControllerBase
{
private readonly IEventTypeService _service;
public EventTypeController(IEventTypeService service)
{
_service = service;
}
/// <summary>
/// 取得所有違規列表 (EventType)
/// </summary>
/// <returns></returns>
[HttpGet("all")]
public IActionResult GetEventTypes()
{
try
{
var result = new Response();
result.Result = _service.GetEventTypes();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得所有違規列表 (EventType1)
/// </summary>
/// <returns></returns>
[HttpGet("1/all")]
public IActionResult GetEventType1s()
{
try
{
var result = new Response();
result.Result = _service.GetEventType1s();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得 EventType 列表
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetEventTypes([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetEventTypes(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得 EventType by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetEventType(int id)
{
try
{
var result = new Response();
result.Result = _service.GetEventTypeById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增 EventType
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("")]
public IActionResult InsertEventType(EventTypeViewModel vm)
{
try
{
var result = _service.InsertEventType(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改 EventType
/// </summary>
/// <param name="id">EventType 的流水號</param>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("{id}")]
public IActionResult UpdateEventType(int id, EventTypeViewModel vm)
{
try
{
var result = _service.UpdatEventType(id, vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除 EventType
/// </summary>
/// <param name="id">EventType 的流水號</param>
/// <returns></returns>
[HttpDelete("{id}")]
public IActionResult DeleteEventType(int id)
{
try
{
var result = _service.DeleteEventType(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,108 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Helpers;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/login")]
[ApiController]
public class LoginController : ControllerBase
{
private readonly ILoginService _service;
private readonly JwtHelpers _jwt;
private IHttpContextAccessor _accessor;
private readonly IConfiguration _configuration;
public LoginController(ILoginService service, JwtHelpers jwt, IHttpContextAccessor accessor, IConfiguration configuration)
{
_service = service;
_jwt = jwt;
_accessor = accessor;
_configuration = configuration;
}
/// <summary>
/// 登入
/// </summary>
/// <param name="loginData"></param>
/// <returns></returns>
[HttpPost("PostLogin")]
public LoginResultModel PostLogin(LoginViewModel loginData)
{
var ip = _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString();
var result = new LoginResultModel();
var user = this._service.Login(loginData.Account, loginData.Password, ip);
if (user == null)
{
result.Success = false;
result.Message = "查無此使用者,請洽管理員。";
return result;
}
if (user.Status == 0)
{
result.Success = false;
result.Message = "此使用者已被禁用,請洽管理員。";
return result;
}
if ((DateTime.Now - user.ChangePwdOn).Days > Convert.ToInt16(_configuration["User:NeedChangePwdDay"]))
{
result.Success = false;
result.Message = $"已超過{_configuration["User:NeedChangePwdDay"]}天未更改密碼,請洽管理員。";
return result;
}
var errorCount = Convert.ToInt16(_configuration["User:LoginErrorCount"]);
if (user.ErrorCount > errorCount)
{
result.Success = false;
result.Message = $"輸入密碼已累積超過錯誤{errorCount}次,請洽管理員。";
return result;
}
if (user.ErrorCount != 0)
{
result.Success = false;
result.Message = $"輸入密碼已累積錯誤{user.ErrorCount}次。";
return result;
}
if ((DateTime.Now - user.ChangePwdOn).Days > Convert.ToInt16(_configuration["User:AlarmChangePwdDay"]))
{
result.Success = true;
result.Message = $"已超過{_configuration["User:AlarmChangePwdDay"]}天未更改密碼,請立即更改密碼。";
result.Token = this._jwt.GenerateToken(user);
result.Role = user.Role;
result.Name = user.Name;
result.Id = user.Id;
return result;
}
if (loginData.Password == "000000")
{
result.Success = true;
result.Message = $"請立即更改密碼。";
result.Token = this._jwt.GenerateToken(user);
result.Role = user.Role;
result.Name = user.Name;
result.Id = user.Id;
return result;
}
result.Success = true;
result.Message = "success!";
result.Token = this._jwt.GenerateToken(user);
result.Role = user.Role;
result.Name = user.Name;
result.Id = user.Id;
return result;
}
}
}

View File

@ -0,0 +1,71 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/malfunction")]
[Authorize]
[ApiController]
public class MalfunctionController : ControllerBase
{
private readonly IMalfunctionService _service;
public MalfunctionController(IMalfunctionService service)
{
_service = service;
}
///// <summary>
///// 取得設備狀態
///// </summary>
///// <returns></returns>
//[HttpGet("old")]
//public IActionResult GetMalfunctionsOld()
//{
// try
// {
// var userIdentity = (ClaimsIdentity)User.Identity;
// var userid = new ParserForUserFromClaim(userIdentity).GetUserId();
// var result = new Response();
// result.Result = _service.GetMalfunctionsOld(userid);
// return Ok(result);
// }
// catch (Exception ex)
// {
// return BadRequest();
// }
//}
/// <summary>
/// 取得設備狀態
/// </summary>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetMalfunctions()
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var userid = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = new Response();
result.Result = _service.GetMalfunctions(userid);
return Ok(result);
}
catch (Exception ex)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,147 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
/// <summary>
/// 不開單原因設定
/// </summary>
[Route("api/notPunish")]
[Authorize]
[ApiController]
public class NotPunishController : ControllerBase
{
private readonly INotPunishService _service;
public NotPunishController(INotPunishService service)
{
_service = service;
}
/// <summary>
/// 取得所有不開單原因
/// </summary>
/// <returns></returns>
[HttpGet("all")]
public IActionResult GetNotPunishs()
{
try
{
var result = new Response();
result.Result = _service.GetNotPunishs();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得不開單原因列表by條件
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetNotPunishs([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetNotPunishs(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得不開單原因 by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetNotPunish(int id)
{
try
{
var result = new Response();
result.Result = _service.GetNotPunishById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增不開單原因
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("")]
public IActionResult InsertNotPunish(NotPunishViewModel vm)
{
try
{
var result = _service.InsertNotPunish(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改不開單原因
/// </summary>
/// <param name="id">不開單原因的流水號</param>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("{id}")]
public IActionResult UpdateNotPunish(int id, NotPunishViewModel vm)
{
try
{
var result = _service.UpdatNotPunish(id, vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除不開單原因
/// </summary>
/// <param name="id">不開單原因的流水號</param>
/// <returns></returns>
[HttpDelete("{id}")]
public IActionResult DeleteNotPunish(int id)
{
try
{
var result = _service.DeleteNotPunish(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,145 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/group")]
[Authorize]
[ApiController]
public class PoliceStationController : ControllerBase
{
private readonly IPoliceStationService _service;
public PoliceStationController(IPoliceStationService service)
{
_service = service;
}
/// <summary>
/// 取得 PoliceStation 列表
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("GetGroupDataList")]
public IActionResult GetPoliceStations([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = new SearchModel
{
Term = searchModel.Term,
Page = Convert.ToInt32(string.IsNullOrWhiteSpace(searchModel.Page) ? "1" : searchModel.Page),
PageSize = Convert.ToInt32(string.IsNullOrWhiteSpace(searchModel.PageSize) ? "1" : searchModel.PageSize),
IsAsc = searchModel.IsAsc == "true" ? true : false,
Order = string.IsNullOrWhiteSpace(searchModel.Order) ? "id" : searchModel.Order,
};
result.Result = _service.GetPoliceStations(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得 PoliceStation by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("GetGroupData/{id}")]
public IActionResult GetPoliceStation(int id)
{
try
{
var result = new Response();
result.Result = _service.GetPoliceStationById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
[HttpGet("GetGroupNameList")]
public IActionResult GetGroupNameList()
{
try
{
var result = new Response();
result.Result = _service.GetGroupNameList();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增 PoliceStation
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("PostGroupData")]
public IActionResult InsertPoliceStation(PoliceStationViewModel vm)
{
try
{
var result = _service.InsertPoliceStation(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改 PoliceStation
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("PutGroupData")]
public IActionResult UpdatePoliceStation(PoliceStationViewModel vm)
{
try
{
var result = _service.UpdatPoliceStation(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除 PoliceStation
/// </summary>
/// <param name="id">PoliceStation 的流水號</param>
/// <returns></returns>
[HttpDelete("DeleteGroupData/{id}")]
public IActionResult DeletePoliceStation(int id)
{
try
{
var result = _service.DeletePoliceStation(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,142 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RepairController : ControllerBase
{
private readonly IRepairService _service;
public RepairController(IRepairService service)
{
_service = service;
}
/// <summary>
/// 取得所有線上報修
/// </summary>
/// <returns></returns>
[HttpGet("all")]
public IActionResult GetRepairs()
{
try
{
var result = new Response();
result.Result = _service.GetRepairs();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得線上報修列表by條件
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetRepairs([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetRepairs(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得線上報修by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetRepair(int id)
{
try
{
var result = new Response();
result.Result = _service.GetRepairById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增線上報修
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("")]
public IActionResult InsertRepair(RepairViewModel vm)
{
try
{
var result = _service.InsertRepair(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改線上報修
/// </summary>
/// <param name="id">線上報修的流水號</param>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("{id}")]
public IActionResult UpdateRepair(int id, RepairViewModel vm)
{
try
{
var result = _service.UpdatRepair(id, vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除線上報修
/// </summary>
/// <param name="id">線上報修的流水號</param>
/// <returns></returns>
[HttpDelete("{id}")]
public IActionResult DeleteRepair(int id)
{
try
{
var result = _service.DeleteRepair(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,300 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/report")]
[Authorize]
[ApiController]
public class ReportController : ControllerBase
{
private readonly IFileService _fileService;
private readonly IReportService _service;
public ReportController(IFileService fileService, IReportService service)
{
_fileService = fileService;
_service = service;
}
/// <summary>
/// 取得 API 資料顯示 的 TableName
/// </summary>
[HttpGet("tycg/tableName")]
public IActionResult GetTycgLog()
{
try
{
var data = _service.GetTycgTableName();
var result = new Response
{
Result = data
};
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得 API 資料顯示
/// </summary>
/// <param name="tycgTableName"></param>
/// <param name="searchModel"></param>
/// <param name="method"></param>
/// <returns></returns>
/// <remarks>需要給Table名稱
/// tycg_logases
/// tycg_logbigcarviolation
/// tycg_logchecked
/// tycg_logcrossroad
/// tycg_logmalfunctionhttp
/// tycg_logrejected
/// tycg_logtraffichttp
/// tycg_loguploaded</remarks>
[HttpGet("tycg")]
public IActionResult GetTycgLog(string tycgTableName, [FromQuery] SearchModelViewModel searchModel, string method = "0")
{
try
{
if (method == "1")
{
var data = _service.GetTycgLogAll(tycgTableName);
var url = _fileService.ExportGetTycgLog(tycgTableName, data);
return Ok(url);
}
else
{
SearchModel model = Util.GetSearchModel(searchModel);
var data = _service.GetTycgLog(tycgTableName, model);
var result = new Response
{
Result = data
};
return !string.IsNullOrWhiteSpace(tycgTableName) ? Ok(result) : BadRequest("請輸入 TableName");
}
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 違規事件統計站店違規數統計表
/// </summary>
/// <param name="viewModel"></param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpPost("site/eventTypes")]
public IActionResult GetEvent(SiteAndEventTypeViewModel viewModel, string method = "0")
{
try
{
var data = _service.GetReportSiteEventTypes(viewModel.Sites, viewModel.EventTypes, viewModel.StartTime, viewModel.EndTime);
var result = new Response
{
Result = data
};
if (method == "1")
{
var start = viewModel.StartTime.Replace("undefined", "00:00:00");
var end = viewModel.EndTime.Replace("undefined", "23:59:59");
var url = _fileService.ExportGetSiteEvent(
Convert.ToDateTime(start).ToString("yyMMdd"),
Convert.ToDateTime(end).ToString("yyMMdd"),
data);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 違規類型統計表 違規停車
/// </summary>
/// <param name="viewModel"></param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpPost("eventType/1")]
public IActionResult GetEventType1(ReportRequestViewModel viewModel, string method = "0")
{
try
{
var data = _service.GetEventType1(viewModel);
var result = new Response
{
Result = data
};
if (method == "1")
{
var url = _fileService.ExportGetEventType1(
Convert.ToDateTime(viewModel.StartDate).ToString("yyMMdd"),
Convert.ToDateTime(viewModel.EndDate).ToString("yyMMdd"),
data);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 違規類型統計表 區間測速
/// </summary>
/// <param name="viewModel"></param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpPost("eventType/2")]
public IActionResult GetEventType2(ReportRequestViewModel viewModel, string method = "0")
{
try
{
var data = _service.GetEventType2(viewModel);
var result = new Response
{
Result = data
};
if (method == "1")
{
var url = _fileService.ExportGetEventType2(
Convert.ToDateTime(viewModel.StartDate).ToString("yyMMdd"),
Convert.ToDateTime(viewModel.EndDate).ToString("yyMMdd"),
data);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 違規類型統計表 未依標線行駛_路口淨空_闖紅燈 未保持路口淨空
/// </summary>
/// <param name="viewModel"></param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpPost("eventType/34")]
public IActionResult GetEventType34(ReportRequestViewModel viewModel, string method = "0")
{
try
{
var data = _service.GetEventType34(viewModel);
var result = new Response
{
Result = data
};
if (method == "1")
{
var url = _fileService.ExportGetEventType34(
Convert.ToDateTime(viewModel.StartDate).ToString("yyMMdd"),
Convert.ToDateTime(viewModel.EndDate).ToString("yyMMdd"),
data);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 違規類型統計表 大貨車禁行
/// </summary>
/// <param name="viewModel"></param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpPost("eventType/6")]
public IActionResult GetEventType6(ReportRequestViewModel viewModel, string method = "0")
{
try
{
var data = _service.GetEventType6(viewModel);
var result = new Response
{
Result = data
};
if (method == "1")
{
var url = _fileService.ExportGetEventType6(
Convert.ToDateTime(viewModel.StartDate).ToString("yyMMdd"),
Convert.ToDateTime(viewModel.EndDate).ToString("yyMMdd"),
data);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 設備故障報表
/// </summary>
/// <param name="viewModel"></param>
/// <param name="method">0 : 查詢, 1:匯出</param>
/// <returns></returns>
[HttpPost("malfunction")]
public IActionResult GetMalfunction(ReportRequestViewModel viewModel, string method = "0")
{
try
{
var data = _service.GetMalfunction(viewModel);
var result = new Response
{
Result = data
};
if (method == "1")
{
var url = _fileService.ExportGetMalfunction(
Convert.ToDateTime(viewModel.StartDate).ToString("yyMMdd"),
Convert.ToDateTime(viewModel.EndDate).ToString("yyMMdd"),
data);
return Ok(url);
}
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,123 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/role")]
[Authorize]
[ApiController]
public class RoleController : ControllerBase
{
private readonly IRoleService _service;
public RoleController(IRoleService service)
{
this._service = service;
}
[HttpPost("PostRoleDataList")]
public IActionResult PostRoleDataList(RoleData roleData)
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var mID = new ParserForUserFromClaim(userIdentity).GetUserId();
return Ok(_service.PostRoleDataList(mID, roleData));
}
catch (Exception)
{
return BadRequest();
}
}
[HttpGet("GetRoleDataList")]
public IActionResult GetRoleDataList([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = new SearchModel
{
Term = searchModel.Term,
Page = Convert.ToInt32(string.IsNullOrWhiteSpace(searchModel.Page) ? "1" : searchModel.Page),
PageSize = Convert.ToInt32(string.IsNullOrWhiteSpace(searchModel.PageSize) ? "1" : searchModel.PageSize),
IsAsc = searchModel.IsAsc == "true" ? true : false,
Order = string.IsNullOrWhiteSpace(searchModel.Order) ? "id" : searchModel.Order,
};
result.Result = _service.GetRoleDataList(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
[HttpGet("GetRoleInfoList")]
public IActionResult GetRoleInfoList()
{
try
{
var result = new Response();
result.Result = _service.GetRoleInfoList();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
[HttpGet("GetRolePermissionInfo/{id}")]
public IActionResult GetRolePermissionInfo(int? Id)
{
try
{
return Ok(new { Result = _service.GetRolePermissionInfo(Id) });
}
catch (Exception)
{
return BadRequest();
}
}
[HttpGet("GetAllPagePermission/{id}")]
public IActionResult GetAllPagePermission(int id)
{
try
{
var re = new Response();
re.Result = _service.GetAllPagePermission(id);
return Ok(re);
}
catch (Exception)
{
return BadRequest();
}
}
[HttpPut("PutPageRoleStatus")]
public IActionResult PutPageRoleStatus(PagePermissionData pagePermission)
{
try
{
return Ok(new { Result = _service.PutPageRoleStatus(pagePermission) });
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,210 @@
using LiangLiSystem.Services.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
/// <summary>
/// 行政區管理
/// </summary>
[Route("api/siteInformation")]
[Authorize]
[ApiController]
public class SiteInformationController : ControllerBase
{
private readonly ISiteInformationService _service;
public SiteInformationController(ISiteInformationService service)
{
_service = service;
}
/// <summary>
/// 取得所有行政區列表 by 員警
/// </summary>
[HttpGet("user")]
public IActionResult GetSiteInformationsByUser()
{
try
{
var userIdentity = (ClaimsIdentity)User.Identity;
var userId = new ParserForUserFromClaim(userIdentity).GetUserId();
var result = new Response();
result.Result = _service.GetSiteInformationsByUser(userId);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得所有行政區列表
/// </summary>
[AllowAnonymous]
[HttpGet("emailNoNull")]
public IActionResult GetSiteInformationsEmailNoNull()
{
try
{
var result = new Response();
result.Result = _service.GetSiteInformations().Where(i => !string.IsNullOrWhiteSpace(i.CompanyEmail));
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得所有行政區列表
/// </summary>
[AllowAnonymous]
[HttpGet("all")]
public IActionResult GetSiteInformations()
{
try
{
var result = new Response();
result.Result = _service.GetSiteInformations();
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得行政區列表 by EventType
/// </summary>
/// <param name="eventTypes"></param>
/// <returns></returns>
[HttpPost("eventType")]
public IActionResult GetSiteInformationsByEventTypes(List<string> eventTypes)
{
try
{
var result = new Response
{
Result = _service.GetSiteInformationsByEventTypes(eventTypes)
};
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得行政區列表 by 條件
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet("")]
public IActionResult GetSiteInformations([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = Util.GetSearchModel(searchModel);
result.Result = _service.GetSiteInformations(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 取得行政區 by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
public IActionResult GetSiteInformation(int id)
{
try
{
var result = new Response();
result.Result = _service.GetSiteInformationById(id);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 新增行政區
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("")]
public IActionResult InsertSiteInformation(SiteInformationViewModel vm)
{
try
{
var result = _service.InsertSiteInformation(vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 修改行政區
/// </summary>
/// <param name="id">行政區的流水號</param>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPut("{id}")]
public IActionResult UpdateSiteInformation(int id, SiteInformationViewModel vm)
{
try
{
var result = _service.UpdatSiteInformation(id, vm);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
/// <summary>
/// 刪除行政區
/// </summary>
/// <param name="id">行政區的流水號</param>
/// <returns></returns>
[HttpDelete("{id}")]
public IActionResult DeleteSiteInformation(int id)
{
try
{
var result = _service.DeleteSiteInformation(id);
return result.Success ? Ok(result) : BadRequest(result);
}
catch (Exception)
{
return BadRequest();
}
}
}
}

View File

@ -0,0 +1,87 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Traffic.Data.ViewModels;
using Traffic.Service.Interfaces;
namespace Traffic.Api.Controllers
{
[Route("api/system")]
[Authorize]
[ApiController]
public class SystemController : ControllerBase
{
private readonly IPageListService _service;
public SystemController(IPageListService service)
{
this._service = service;
}
[HttpGet("GetPageDataList")]
public IActionResult GetPageDataList([FromQuery] SearchModelViewModel searchModel)
{
try
{
var result = new Response();
var model = new SearchModel
{
Term = searchModel.Term,
Page = Convert.ToInt32(string.IsNullOrWhiteSpace(searchModel.Page) ? "1" : searchModel.Page),
PageSize = Convert.ToInt32(string.IsNullOrWhiteSpace(searchModel.PageSize) ? "1" : searchModel.PageSize),
IsAsc = searchModel.IsAsc == "true" ? true : false,
Order = string.IsNullOrWhiteSpace(searchModel.Order) ? "id" : searchModel.Order
};
result.Result = _service.GetPageDataList(model);
return Ok(result);
}
catch (Exception)
{
return BadRequest();
}
}
[HttpPost("PostPageListData")]
public IActionResult PostPageListData(PageData pageData)
{
try
{
return Ok(_service.PostPageDataList(pageData));
}
catch (Exception)
{
return BadRequest();
}
}
[HttpPut("PutPageData")]
public IActionResult PutPageData(PageData pageData)
{
try
{
return Ok(_service.PutPageData(pageData));
}
catch (Exception)
{
return BadRequest();
}
}
[HttpDelete("DeletePageData")]
public IActionResult DeletePageData(int id)
{
try
{
return Ok(_service.DeletePageData(id));
}
catch (Exception)
{
return BadRequest();
}
}
}
}

24
Traffic.Api/NLog.config Normal file
View File

@ -0,0 +1,24 @@
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
<!--[變數] 文字樣板 -->
<variable name="Layout" value="${longdate} | ${level:uppercase=true} | ${logger} | ${message} ${newline}"/>
<variable name="LayoutFatal" value="${longdate} | ${level:uppercase=true} | ${logger} | ${message} | ${exception:format=tostring} ${newline}"/>
<!--[變數] 檔案位置 -->
<variable name="LogTxtLocation" value="${basedir}/App_Data/Logs/${shortdate}/${logger}.txt"/>
<variable name="LogTxtLocationFatal" value="${basedir}/App_Data/Logs/${shortdate}/FatalFile.txt"/>
<!--[設定] 寫入目標-->
<targets>
<target name="File" xsi:type="File" fileName="${LogTxtLocation}" layout="${Layout}" />
<target name="FileFatal" xsi:type="File" fileName="${LogTxtLocationFatal}" layout="${LayoutFatal}"/>
</targets>
<!--[設定] 紀錄規則-->
<rules>
<logger name="*" levels="Trace,Debug,Info,Warn" writeTo="File" />
<logger name="*" levels="Trace,Debug,Info,Warn,Error,Fatal" writeTo="FileFatal" />
</rules>
</nlog>

65
Traffic.Api/Program.cs Normal file
View File

@ -0,0 +1,65 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Traffic.Api
{
public class Program
{
//Trace 0 LogTrace() Logs messages only for tracing purposes for the developers.
// 此類 Log 通常用於開發階段,讓開發人員檢查資料使用,可能會包含一些帳號密碼等敏感資料,不適合也不應該出現在正式環境的 Log 中。 (預設不會輸出)
//Debug 1 LogDebug() Logs messages for short-term debugging purposes. 預設不會輸出
// 這類型的 Log 是為了在正式環境除錯使用,但平常不應該開啟,避免 Log 量太大,反而會造成正式環境的問題。 (預設不會輸出)
//Information 2 LogInformation() Logs messages for the flow of the application.
// 常見的 Log 類型,主要是紀錄程試運行的流程。
//Warning 3 LogWarning() Logs messages for abnormal or unexpected events in the application flow.
// 紀錄可預期的錯誤或者效能不佳的事件;不改不會死,但改了會更好的問題。
//Error 4 LogError() Logs error messages.
// 紀錄非預期的錯誤,不該發生但卻發生,應該要避免重複發生的錯誤事件。
//Critical 5 LogCritical() Logs failures messages that require immediate attention.
// 只要發生就準備見上帝的錯誤事件,例如會導致網站重啟,系統崩潰的事件。
public static void Main(string[] args)
{
// NLog: setup the logger first to catch all errors
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
logger.Debug("init main");
BuildWebHost(args).Build().Run();
}
catch (Exception ex)
{
//NLog: catch setup errors
logger.Error(ex, "Stopped program because of exception");
throw;
}
finally
{
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
NLog.LogManager.Shutdown();
}
}
public static IWebHostBuilder BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog(); // NLog: setup NLog for Dependency injection
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5301",
"sslPort": 44306
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Traffic.Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

192
Traffic.Api/Startup.cs Normal file
View File

@ -0,0 +1,192 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Traffic.Repository.Infrastructures;
using Traffic.Service.Filter;
using Traffic.Service.Helpers;
using Traffic.Service.Implements;
using Traffic.Service.Interfaces;
namespace Traffic.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSingleton<JwtHelpers>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<ConnectionFactory>();
services.AddScoped<IUnitOfWork, UnitOfWork>();
services.AddScoped<ILoginService, LoginService>();
services.AddScoped<IAccountService, AccountService>();
services.AddScoped<ICompanyInformationService, CompanyInformationService>();
services.AddScoped<IPoliceStationService, PoliceStationService>();
services.AddScoped<IEventTypeService, EventTypeService>();
services.AddScoped<IAnnounceService, AnnounceService>();
services.AddScoped<IRoleService, RoleService>();
services.AddScoped<IPageListService, PageListService>();
services.AddScoped<INotPunishService, NotPunishService>();
services.AddScoped<ISiteInformationService, SiteInformationService>();
services.AddScoped<IEventService, EventService>();
services.AddScoped<IMalfunctionService, MalfunctionService>();
services.AddScoped<IReportService, ReportService>();
services.AddScoped<IRepairService, RepairService>();
services.AddScoped<IFileService, FileService>();
services.AddScoped<IMailService, MailService>();
services.AddScoped<LogFilter>();
services.AddLogging(builder =>
{
builder.AddConfiguration(Configuration.GetSection("Logging"))
.AddFilter("Microsoft", LogLevel.Warning)
.AddConsole()
.AddDebug();
});
SetCors(services);
SetSwagger(services);
SetJwtBearer(services);
}
private static void SetCors(IServiceCollection services)
{
services.AddCors(o => o.AddPolicy("Traffic", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
}
private static void SetJwtBearer(IServiceCollection services)
{
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
// 當驗證失敗時,回應標頭會包含 WWW-Authenticate 標頭,這裡會顯示失敗的詳細錯誤原因
options.IncludeErrorDetails = true; // 預設值為 true有時會特別關閉
options.TokenValidationParameters = new TokenValidationParameters
{
// 透過這項宣告,就可以從 "sub" 取值並設定給 User.Identity.Name
NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
// 透過這項宣告,就可以從 "roles" 取值,並可讓 [Authorize] 判斷角色
RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role",
// 一般我們都會驗證 Issuer
ValidateIssuer = true,
ValidIssuer = "Traffic",
// 通常不太需要驗證 Audience
ValidateAudience = false,
//ValidAudience = "JwtAuthDemo", // 不驗證就不需要填寫
// 一般我們都會驗證 Token 的有效期間
ValidateLifetime = true,
// 如果 Token 中包含 key 才需要驗證,一般都只有簽章而已
ValidateIssuerSigningKey = false,
// "1234567890123456" 應該從 IConfiguration 取得
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("wgQWt6kNQR3dyYoCopq1"))
};
});
}
private static void SetSwagger(IServiceCollection services)
{
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Traffic.Api", Version = "v1" });
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = $@"JWT Authorization header using the Bearer scheme. \r\n\r\n
Enter 'Bearer' [space] and then your token in the text input below. \r\n\r\n
Example: 'Bearer 12345abcdef'",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});
//Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
c.AddSecurityRequirement(new OpenApiSecurityRequirement()
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
},
Scheme = "oauth2",
Name = "Bearer",
In = ParameterLocation.Header,
},
new List<string>()
}
});
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Traffic.Api v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseCors("Traffic");
app.UseAuthentication();//先驗證
app.UseAuthorization(); //再授權
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

View File

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>C:\Users\littlec315\Desktop\個人\專案\桃園違規開單系統\.net 5\Traffic\Traffic.Api\Traffic.Api.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.95.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
<PackageReference Include="NLog" Version="4.7.12" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Traffic.Data\Traffic.Data.csproj" />
<ProjectReference Include="..\Traffic.Repository\Traffic.Repository.csproj" />
<ProjectReference Include="..\Traffic.Service\Traffic.Service.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Traffic.Api</name>
</assembly>
<members>
<member name="M:Traffic.Api.Controllers.AccountController.InserAccountUser(Traffic.Data.ViewModels.AccountInsertViewModel)">
<summary>
新增使用者
</summary>
<param name="account"></param>
<returns></returns>
</member>
<member name="M:Traffic.Api.Controllers.LoginController.PostLogin(Traffic.Data.ViewModels.LoginViewModel)">
<summary>
登入
</summary>
<param name="loginData"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,43 @@
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Trace"
}
},
"ConnectionStrings": {
"DefaultConnection": "server=127.0.0.1;port=3306;user id=root;password=123456;database=traffic;charset=utf8;"
},
"JwtSettings": {
"Issuer": "Traffic",
"SignKey": "wgQWt6kNQR3dyYoCopq1"
},
"User": {
"LoginErrorCount": "3",
"AlarmChangePwdDay": "80",
"NeedChangePwdDay": "90"
},
"EventStatus": {
"Count": "300",
"Cancel": "C:\\File\\Cancel\\",
"Upload": "C:\\uploadFile\\",
"ExportExcel": "C:\\localFile\\",
"ExportExcelUrl": "http://localhost/LocalFile/",
"ImagePath": "C:\\localFile\\Images\\",
"VideoPath": "C:\\localFile\\Videos\\"
},
"Mode": {
"IsTest": "True"
},
"Repair": {
"Email": "littlec315@gmail.com"
},
"MailServer": {
"IsTest": "True",
"Host": "smtp.gmail.com",
"Port": 587,
"Account": "tycg@rage.com.tw",
"Password": "Traffic1118!@#$"
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Traffic.Data.Enums
{
public enum Auth
{
Admin = 1,
User = 2,
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Enums
{
public enum EnumVehicleType
{
[Description("兩輪車")]
Motorcycle = 1,
[Description("汽車")]
Car = 2,
[Description("大車")]
Cart = 3,
[Description("貨車")]
Truck = 4,
[Description("大卡車")]
BigTruck = 5,
[Description("大客車")]
Coach = 6,
[Description("堆高機")]
Stacker = 7,
[Description("水泥攪拌車")]
CementMixer = 8,
[Description("計程車")]
Taxi = 9,
[Description("人")]
people = 10,
[Description("其他")]
Other = -1,
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
namespace Traffic.Data.Enums
{
public enum Message
{
[Description("取得成功")]
GetSuccess,
[Description("取得失敗")]
GetFail,
[Description("新增成功。")]
InsertSuccess,
[Description("新增失敗。")]
InsertFail,
[Description("修改成功。")]
UpdateSuccess,
[Description("修改失敗。")]
UpdateFail,
[Description("刪除成功。")]
DeleteSuccess,
[Description("刪除失敗。")]
DeleteFail,
[Description("註冊成功。")]
RegisterSuccess,
[Description("註冊失敗。")]
RegisterFail,
[Description("Page Size 或 Page Number 需大於 0")]
PageMustBeGreaterThan0,
[Description("查無此帳號,請重新選擇。")]
NoThisAccount,
[Description("已存在此帳號。")]
ThisAccountAlreadyExists,
[Description("請選擇身分別。")]
PleaseChooseRole,
[Description("不存在此權限, 請再確認一次。")]
ThisAccountNoAuth,
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace Traffic.Data.Models
{
public class AccountGroup
{
public int Id { get; set; }
public string GroupName { get; set; }
public string CreatorId { get; set; }
public DateTime CreatedOn { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class AccountPwd
{
public int Id { get; set; }
public string Account { get; set; }
public string Password { get; set; }
public DateTime CreatedOn { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
namespace Traffic.Data.Models
{
public class AccountRole
{
public int Id { get; set; }
public string RoleName { get; set; }
public int CreatorId { get; set; }
public DateTime CreatedOn { get; set; }
}
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class AccountUser
{
public int Id { get; set; }
public string Account { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public int RoleCodeId { get; set; }
public int PoliceStationId { get; set; }
public int CreatorId { get; set; }
public DateTime CreatedOn { get; set; }
public int UpdatorId { get; set; }
public DateTime UpdatedOn { get; set; }
public int ErrorCount { get; set; }
public DateTime ChangePwdOn { get; set; }
public int Status { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class AccountUserSite
{
/// <summary>
/// 流水號
/// </summary>
public int Id { get; set; }
/// <summary>
/// 違規代碼
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 違規名稱
/// </summary>
public int SiteId { get; set; }
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class Announce
{
/// <summary>
/// 流水號
/// </summary>
public int Id { get; set; }
/// <summary>
/// 標題
/// </summary>
public string Title { get; set; }
/// <summary>
/// 內文
/// </summary>
public string Content { get; set; }
/// <summary>
/// 起始時間
/// </summary>
public DateTime StartOn { get; set; }
/// <summary>
/// 狀態
/// </summary>
public int Status { get; set; }
public int CreatorId { get; set; }
public DateTime CreatedOn { get; set; }
public int UpdatorId { get; set; }
public DateTime UpdatedOn { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class CompanyInformation
{
/// <summary>
/// 流水號
/// </summary>
public int Id { get; set; }
/// <summary>
/// 廠商代碼
/// </summary>
public string CompanyCode { get; set; }
/// <summary>
/// 廠商名稱
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// 廠商Email
/// </summary>
public string Email { get; set; }
}
}

View File

@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class Event
{
public int Id { get; set; }
public string SiteID { get; set; }
public string EventID { get; set; }
public string Channel { get; set; }
public string Slot { get; set; }
public string Number { get; set; }
public string PlateNumber { get; set; }
public string EventType { get; set; }
public string VehicleType { get; set; }
public string Distance { get; set; }
public string Speed { get; set; }
public string TotalPassTime { get; set; }
public string LimitTon { get; set; }
public string Ton { get; set; }
public string InTime { get; set; }
public string AlarmTime { get; set; }
public string OutTime { get; set; }
public string LPRTime { get; set; }
public string IMGPath1 { get; set; }
public string IMGPath2 { get; set; }
public string IMGPath3 { get; set; }
public string IMGPath4 { get; set; }
public string IMGPath5 { get; set; }
public string IMGPath6 { get; set; }
public string VideoPath1 { get; set; }
public string VideoPath2 { get; set; }
public string IsStay { get; set; }
public string Unsure { get; set; }
public string CheckPunish { get; set; }
public string Punished { get; set; }
public string Rejected { get; set; }
public string CompanyCode { get; set; }
public string Ps { get; set; }
public string HandlingTime { get; set; }
public string UploadTime { get; set; }
public string Account { get; set; }
}
public class JoinEventSite
{
public int Id { get; set; }
public string County { get; set; }
public string Area { get; set; }
public string SiteId { get; set; }
public string SiteName { get; set; }
public string EventType { get; set; }
public string VehicleType { get; set; }
public string Laws { get; set; }
public string SiteID { get; set; }
public string EventID { get; set; }
public string Channel { get; set; }
public string Slot { get; set; }
public string Number { get; set; }
public string PlateNumber { get; set; }
public string Distance { get; set; }
public string Speed { get; set; }
public string TotalPassTime { get; set; }
public string LimitTon { get; set; }
public string Ton { get; set; }
public string InTime { get; set; }
public string AlarmTime { get; set; }
public string OutTime { get; set; }
public string LPRTime { get; set; }
public string IMGPath1 { get; set; }
public string IMGPath2 { get; set; }
public string IMGPath3 { get; set; }
public string IMGPath4 { get; set; }
public string IMGPath5 { get; set; }
public string IMGPath6 { get; set; }
public string VideoPath1 { get; set; }
public string VideoPath2 { get; set; }
public string IsStay { get; set; }
public string Unsure { get; set; }
public string CheckPunish { get; set; }
public string Punished { get; set; }
public string Rejected { get; set; }
public string CompanyCode { get; set; }
public string Ps { get; set; }
public string HandlingTime { get; set; }
public string UploadTime { get; set; }
public string Account { get; set; }
}
public class JoinEventSiteAndUser
{
public int Id { get; set; }
public string UserID { get; set; }
public string County { get; set; }
public string Area { get; set; }
public string SiteId { get; set; }
public string SiteName { get; set; }
public string EventType { get; set; }
public string VehicleType { get; set; }
public string Laws { get; set; }
public string SiteID { get; set; }
public string EventID { get; set; }
public string Channel { get; set; }
public string Slot { get; set; }
public string Number { get; set; }
public string PlateNumber { get; set; }
public string Distance { get; set; }
public string Speed { get; set; }
public string TotalPassTime { get; set; }
public string LimitTon { get; set; }
public string Ton { get; set; }
public string InTime { get; set; }
public string AlarmTime { get; set; }
public string OutTime { get; set; }
public string LPRTime { get; set; }
public string IMGPath1 { get; set; }
public string IMGPath2 { get; set; }
public string IMGPath3 { get; set; }
public string IMGPath4 { get; set; }
public string IMGPath5 { get; set; }
public string IMGPath6 { get; set; }
public string VideoPath1 { get; set; }
public string VideoPath2 { get; set; }
public string IsStay { get; set; }
public string Unsure { get; set; }
public string CheckPunish { get; set; }
public string Punished { get; set; }
public string Rejected { get; set; }
public string CompanyCode { get; set; }
public string Ps { get; set; }
public string HandlingTime { get; set; }
public string UploadTime { get; set; }
public string Account { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class EventTypeData
{
/// <summary>
/// 流水號
/// </summary>
public int Id { get; set; }
/// <summary>
/// 違規代碼
/// </summary>
public string EventType { get; set; }
/// <summary>
/// 違規名稱
/// </summary>
public string EventName { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class ExceptionNumber
{
public int Id { get; set; }
public string Number { get; set; }
public string Date { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class JoinRolePageInfo
{
public int RoleId { get; set; }
public int PageId { get; set; }
public string RoleName { get; set; }
public string PageName { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class JoinRolePageList
{
public int? RoleId { get; set; }
public int PageId { get; set; }
public string PageModule { get; set; }
public string PageName { get; set; }
public string PageURL { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class Log_Mapping
{
public int Id { get; set; }
public string LogName { get; set; }
public string APIName { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class Malfunction
{
public int UserId { get; set; }
public string County { get; set; }
public string Area { get; set; }
public string Siteid { get; set; }
public string SiteName { get; set; }
public string EventType { get; set; }
public string CompanyCode { get; set; }
public string DeviceType { get; set; }
public string DeviceID { get; set; }
public string Message { get; set; }
public int Timestamp { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class NotPunish
{
public int Id { get; set; }
public int EventTypeId { get; set; }
public int NotPunishType { get; set; }
public string NotPunishReason { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class PageList
{
public int Id { get; set; }
public string PageModule { get; set; }
public string PageName { get; set; }
public string PageURL { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class PoliceStation
{
public int Id { get; set; }
public string Area { get; set; }
public string StationName { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class Repair
{
public int Id { get; set; }
public int QuestionType { get; set; }
public string SendTo { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class RolePage
{
public int Id { get; set; }
public int RoleId { get; set; }
public int PageId { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class SiteInformation
{
public int Id { get; set; }
public string County { get; set; }
public string Area { get; set; }
public string SiteID { get; set; }
public string SiteName { get; set; }
public string EventType { get; set; }
public string Ip { get; set; }
public string DbName { get; set; }
public string TableName { get; set; }
public string User { get; set; }
public string Password { get; set; }
public int FinalRecord { get; set; }
public string Target { get; set; }
public string ClusterHead { get; set; }
public int ARHFinalRecord { get; set; }
public string Laws { get; set; }
public string CompanyCode { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class Tycg
{
public int Id { get; set; }
public Int64 Timestamp { get; set; }
public int Trendflags { get; set; }
public int Status { get; set; }
public string Value { get; set; }
public string Trendflags_Tag { get; set; }
public string Status_tag { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class UserLoginLog
{
public int Id { get; set; }
public int UserId { get; set; }
public string LoginIP { get; set; }
public DateTime LoginOn { get; set; }
public int Status { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class VehicleTypeTable
{
/// <summary>
/// 流水號
/// </summary>
public int Id { get; set; }
/// <summary>
/// 車型代碼
/// </summary>
public string VehicleType { get; set; }
/// <summary>
/// 車型名稱
/// </summary>
public string VehicleName { get; set; }
}
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class AccountUpdatePasswordViewModel
{
[Required(ErrorMessage = "您必須輸入舊密碼")]
public string OldPassword { get; set; }
[MinLength(8, ErrorMessage = "請輸入至少8個字元")]
[Required(ErrorMessage = "您必須輸入新密碼")]
public string NewPassword { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class UserSiteViewModel
{
/// <summary>
/// 流水號
/// </summary>
[JsonPropertyName("Id")]
public int Id { get; set; }
/// <summary>
/// 違規名稱
/// </summary>
[JsonPropertyName("SiteId")]
public string SiteId { get; set; }
/// <summary>
/// 違規名稱
/// </summary>
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class AccountUserViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Account")]
public string Account { get; set; }
[JsonPropertyName("Name")]
public string Name { get; set; }
[JsonPropertyName("Email")]
public string Email { get; set; }
[JsonPropertyName("Phone")]
public string Phone { get; set; }
[JsonPropertyName("Role")]
public int Role { get; set; }
[JsonPropertyName("ErrorCount")]
public int ErrorCount { get; set; }
[JsonPropertyName("PoliceStation")]
public PoliceStationViewModel PoliceStation { get; set; }
[JsonPropertyName("Site")]
public List<UserSiteViewModel> Site { get; set; }
[JsonPropertyName("ChangePwdOn")]
public DateTime ChangePwdOn { get; set; }
[JsonPropertyName("Status")]
public int Status { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class AnnounceInsertViewModel
{
/// <summary>
/// 標題
/// </summary>
[JsonPropertyName("Title")]
public string Title { get; set; }
/// <summary>
/// 內文
/// </summary>
[JsonPropertyName("Content")]
public string Content { get; set; }
/// <summary>
/// 起始時間
/// </summary>
[JsonPropertyName("StartOn")]
public string StartOn { get; set; }
/// <summary>
/// 狀態
/// </summary>
[JsonPropertyName("Status")]
public int Status { get; set; }
}
}

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class AnnounceViewModel
{
/// <summary>
/// 流水號
/// </summary>
[JsonPropertyName("Id")]
public int Id { get; set; }
/// <summary>
/// 標題
/// </summary>
[JsonPropertyName("Title")]
public string Title { get; set; }
/// <summary>
/// 內文
/// </summary>
[JsonPropertyName("Content")]
public string Content { get; set; }
/// <summary>
/// 起始時間
/// </summary>
[JsonPropertyName("StartOn")]
public string StartOn { get; set; }
/// <summary>
/// 狀態
/// </summary>
[JsonPropertyName("Status")]
public int Status { get; set; }
[JsonPropertyName("CreatorId")]
public int CreatorId { get; set; }
[JsonPropertyName("CreatedOn")]
public DateTime CreatedOn { get; set; }
[JsonPropertyName("UpdatorId")]
public int UpdatorId { get; set; }
[JsonPropertyName("UpdatedOn")]
public DateTime UpdatedOn { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class CompanyInformationViewModel
{
/// <summary>
/// 廠商代碼
/// </summary>
[JsonPropertyName("Id")]
public int Id { get; set; }
/// <summary>
/// 廠商代碼
/// </summary>
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
/// <summary>
/// 廠商名稱
/// </summary>
[JsonPropertyName("CompanyName")]
public string CompanyName { get; set; }
/// <summary>
/// 廠商Email
/// </summary>
[JsonPropertyName("Email")]
public string Email { get; set; }
}
}

View File

@ -0,0 +1,130 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Traffic.Service.Interfaces
{
public class ReportSiteEventTypesViewModel
{
public List<EachSiteEventTypesViewModel> EachSiteEventTypesViewModel { get; set; }
public List<EachEventTypesSiteViewModel> EachEventTypesSiteViewModel { get; set; }
}
public class EachSiteEventTypesViewModel
{
///// <summary>
///// 流水號
///// </summary>
//[JsonPropertyName("Id")]
//public int Id { get; set; }
/// <summary>
/// 站點
/// </summary>
[JsonPropertyName("SiteId")]
public string SiteId { get; set; }
/// <summary>
/// 站點名稱
/// </summary>
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
/// <summary>
/// 違規總數
/// </summary>
[JsonPropertyName("EventTotalCount")]
public int EventTotalCount { get; set; }
/// <summary>
/// 未舉發數量
/// </summary>
[JsonPropertyName("NoStatusCount")]
public int NoStatusCount { get; set; }
/// <summary>
/// 已舉發數量
/// </summary>
[JsonPropertyName("CheckPunishCount")]
public int CheckPunishCount { get; set; }
/// <summary>
/// 不開單數量
/// </summary>
[JsonPropertyName("NoPunishCount")]
public int NoPunishCount { get; set; }
///// <summary>
///// 取消開單數量
///// </summary>
//[JsonPropertyName("CancelPunishCount")]
//public int CancelPunishCount { get; set; }
/// <summary>
/// 被駁回數量
/// </summary>
[JsonPropertyName("RejectedCount")]
public int RejectedCount { get; set; }
/// <summary>
/// 已開單數量
/// </summary>
[JsonPropertyName("PunishCount")]
public int PunishCount { get; set; }
}
public class EachEventTypesSiteViewModel
{
///// <summary>
///// 流水號
///// </summary>
//[JsonPropertyName("Id")]
//public int Id { get; set; }
/// <summary>
/// EventName
/// </summary>
[JsonPropertyName("EventName")]
public string EventName { get; set; }
/// <summary>
/// 違規總數
/// </summary>
[JsonPropertyName("EventTotalCount")]
public int EventTotalCount { get; set; }
/// <summary>
/// 未舉發數量
/// </summary>
[JsonPropertyName("NoStatusCount")]
public int NoStatusCount { get; set; }
/// <summary>
/// 已舉發數量
/// </summary>
[JsonPropertyName("CheckPunishCount")]
public int CheckPunishCount { get; set; }
/// <summary>
/// 不開單數量
/// </summary>
[JsonPropertyName("NoPunishCount")]
public int NoPunishCount { get; set; }
///// <summary>
///// 取消開單數量
///// </summary>
//[JsonPropertyName("CancelPunishCount")]
//public int CancelPunishCount { get; set; }
/// <summary>
/// 被駁回數量
/// </summary>
[JsonPropertyName("RejectedCount")]
public int RejectedCount { get; set; }
/// <summary>
/// 已開單數量
/// </summary>
[JsonPropertyName("PunishCount")]
public int PunishCount { get; set; }
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class EventCountViewModel
{
/// <summary>
/// 流水號
/// </summary>
[JsonPropertyName("TotalCount")]
public int TotalCount { get; set; }
/// <summary>
/// 確認開單
/// </summary>
[JsonPropertyName("PunishedCount")]
public int PunishedCount { get; set; }
/// <summary>
/// 待確認開單
/// </summary>
[JsonPropertyName("CheckPunishedCount")]
public int CheckPunishedCount { get; set; }
/// <summary>
/// IsStayCount
/// </summary>
[JsonPropertyName("IsStayCount")]
public int IsStayCount { get; set; }
/// <summary>
/// UnsureCount
/// </summary>
[JsonPropertyName("UnsureCount")]
public int UnsureCount { get; set; }
/// <summary>
/// 駁回
/// </summary>
[JsonPropertyName("RejectedCount")]
public int RejectedCount { get; set; }
/// <summary>
/// 未開單
/// </summary>
[JsonPropertyName("NoStatusCount")]
public int NoStatusCount { get; set; }
/// <summary>
/// 不開單
/// </summary>
[JsonPropertyName("NoPunishedCount")]
public int NoPunishedCount { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class EventTypeViewModel
{
/// <summary>
/// 流水號
/// </summary>
[JsonPropertyName("Id")]
public int Id { get; set; }
/// <summary>
/// 違規代碼
/// </summary>
[JsonPropertyName("EventType")]
public string EventType { get; set; }
/// <summary>
/// 違規名稱
/// </summary>
[JsonPropertyName("EventName")]
public string EventName { get; set; }
}
}

View File

@ -0,0 +1,204 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class EventViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("SiteID")]
public string SiteID { get; set; }
[JsonPropertyName("EventID")]
public string EventID { get; set; }
[JsonPropertyName("Channel")]
public string Channel { get; set; }
[JsonPropertyName("Slot")]
public string Slot { get; set; }
[JsonPropertyName("Number")]
public string Number { get; set; }
[JsonPropertyName("PlateNumber")]
public string PlateNumber { get; set; }
[JsonPropertyName("EventType")]
public string EventType { get; set; }
[JsonPropertyName("VehicleType")]
public string VehicleType { get; set; }
[JsonPropertyName("VehicleName")]
public string VehicleName { get; set; }
[JsonPropertyName("Distance")]
public string Distance { get; set; }
[JsonPropertyName("Speed")]
public string Speed { get; set; }
[JsonPropertyName("TotalPassTime")]
public string TotalPassTime { get; set; }
[JsonPropertyName("LimitTon")]
public string LimitTon { get; set; }
[JsonPropertyName("Ton")]
public string Ton { get; set; }
[JsonPropertyName("InTime")]
public string InTime { get; set; }
[JsonPropertyName("AlarmTime")]
public string AlarmTime { get; set; }
[JsonPropertyName("OutTime")]
public string OutTime { get; set; }
[JsonPropertyName("LPRTime")]
public string LPRTime { get; set; }
[JsonPropertyName("IMGPath1")]
public string IMGPath1 { get; set; }
[JsonPropertyName("IMGPath2")]
public string IMGPath2 { get; set; }
[JsonPropertyName("IMGPath3")]
public string IMGPath3 { get; set; }
[JsonPropertyName("IMGPath4")]
public string IMGPath4 { get; set; }
[JsonPropertyName("IMGPath5")]
public string IMGPath5 { get; set; }
[JsonPropertyName("IMGPath6")]
public string IMGPath6 { get; set; }
[JsonPropertyName("VideoPath1")]
public string VideoPath1 { get; set; }
[JsonPropertyName("VideoPath2")]
public string VideoPath2 { get; set; }
[JsonPropertyName("IsStay")]
public string IsStay { get; set; }
[JsonPropertyName("Unsure")]
public string Unsure { get; set; }
[JsonPropertyName("CheckPunish")]
public string CheckPunish { get; set; }
[JsonPropertyName("Punished")]
public string Punished { get; set; }
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
[JsonPropertyName("Ps")]
public string Ps { get; set; }
[JsonPropertyName("HandlingTime")]
public string HandlingTime { get; set; }
[JsonPropertyName("UploadTime")]
public string UploadTime { get; set; }
[JsonPropertyName("Rejected")]
public string Rejected { get; set; }
[JsonPropertyName("Account")]
public string Account { get; set; }
}
public class EventSearchByNumberViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Number")]
public string Number { get; set; }
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
[JsonPropertyName("EventName")]
public string EventName { get; set; }
[JsonPropertyName("InTime")]
public string InTime { get; set; }
[JsonPropertyName("Status")]
public string Status { get; set; }
}
public class JoinEventSiteAndUserViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("UserID")]
public string UserID { get; set; }
[JsonPropertyName("County")]
public string County { get; set; }
[JsonPropertyName("Area")]
public string Area { get; set; }
[JsonPropertyName("SiteId")]
public string SiteId { get; set; }
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
[JsonPropertyName("EventName")]
public string EventName { get; set; }
[JsonPropertyName("VehicleName")]
public string VehicleName { get; set; }
[JsonPropertyName("Laws")]
public List<LawsCodes> Laws { get; set; }
[JsonPropertyName("EventID")]
public string EventID { get; set; }
[JsonPropertyName("Channel")]
public string Channel { get; set; }
[JsonPropertyName("Slot")]
public string Slot { get; set; }
[JsonPropertyName("Number")]
public string Number { get; set; }
//[JsonPropertyName("PlateNumber")]
//public string PlateNumber { get; set; }
[JsonPropertyName("EventType")]
public string EventType { get; set; }
[JsonPropertyName("VehicleType")]
public string VehicleType { get; set; }
[JsonPropertyName("Distance")]
public string Distance { get; set; }
[JsonPropertyName("Speed")]
public string Speed { get; set; }
[JsonPropertyName("TotalPassTime")]
public string TotalPassTime { get; set; }
[JsonPropertyName("LimitTon")]
public string LimitTon { get; set; }
[JsonPropertyName("Ton")]
public string Ton { get; set; }
[JsonPropertyName("InTime")]
public string InTime { get; set; }
[JsonPropertyName("AlarmTime")]
public string AlarmTime { get; set; }
[JsonPropertyName("OutTime")]
public string OutTime { get; set; }
[JsonPropertyName("LPRTime")]
public string LPRTime { get; set; }
[JsonPropertyName("IMGPath1")]
public string IMGPath1 { get; set; }
//[JsonPropertyName("IMGPath2")]
//public string IMGPath2 { get; set; }
//[JsonPropertyName("IMGPath3")]
//public string IMGPath3 { get; set; }
//[JsonPropertyName("IMGPath4")]
//public string IMGPath4 { get; set; }
//[JsonPropertyName("IMGPath5")]
//public string IMGPath5 { get; set; }
//[JsonPropertyName("IMGPath6")]
//public string IMGPath6 { get; set; }
[JsonPropertyName("IMGList")]
public List<string> IMGList { get; set; }
[JsonPropertyName("VideoPath1")]
public string VideoPath1 { get; set; }
//[JsonPropertyName("VideoPath2")]
//public string VideoPath2 { get; set; }
[JsonPropertyName("Video")]
public List<string> VideoList { get; set; }
[JsonPropertyName("IsStay")]
public string IsStay { get; set; }
[JsonPropertyName("Unsure")]
public string Unsure { get; set; }
[JsonPropertyName("CheckPunish")]
public string CheckPunish { get; set; }
[JsonPropertyName("Punished")]
public string Punished { get; set; }
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
[JsonPropertyName("Rejected")]
public string Rejected { get; set; }
[JsonPropertyName("Status")]
public string Status { get; set; }
[JsonPropertyName("Ps")]
public string Ps { get; set; }
[JsonPropertyName("HandlingTime")]
public string HandlingTime { get; set; }
[JsonPropertyName("UploadTime")]
public string UploadTime { get; set; }
[JsonPropertyName("Account")]
public string Account { get; set; }
}
public class LawsCodes
{
public string LawsCode { get; set; }
}
}

View File

@ -0,0 +1,45 @@
using System.Text.Json.Serialization;
namespace Traffic.Data.ViewModels
{
public class JsonCancelEvent
{
// "area":"中壢區",
//"handlingTime":"2021-11-17 09:23:26",
//"eventID":"20211117205715785",
//"policeID":"取消開單測試",
//"vehicleName":"汽車",
//"organization":"中壢分局",
//"county":"桃園市",
//"siteName":"中壢火車站-計程車下客區",
//"eventName":"違規停車",
//"action":"取消開單",
//"plate":"APP-0215",
//"sn":"1309697"
[JsonPropertyName("area")]
public string area { get; set; }
[JsonPropertyName("handlingTime")]
public string handlingTime { get; set; }
[JsonPropertyName("eventID")]
public string eventID { get; set; }
[JsonPropertyName("policeID")]
public string policeID { get; set; }
[JsonPropertyName("vehicleName")]
public string vehicleName { get; set; }
[JsonPropertyName("organization")]
public string organization { get; set; }
[JsonPropertyName("county")]
public string county { get; set; }
[JsonPropertyName("siteName")]
public string siteName { get; set; }
[JsonPropertyName("eventName")]
public string eventName { get; set; }
[JsonPropertyName("action")]
public string action { get; set; }
[JsonPropertyName("plate")]
public string plate { get; set; }
[JsonPropertyName("sn")]
public string sn { get; set; }
}
}

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class JsonCheckPunish
{
[JsonPropertyName("area")]
public string area { get; set; }
[JsonPropertyName("handlingTime")]
public string handlingTime { get; set; }
[JsonPropertyName("eventID")]
public string eventID { get; set; }
[JsonPropertyName("policeID")]
public string policeID { get; set; }
[JsonPropertyName("vehicleName")]
public string vehicleName { get; set; }
[JsonPropertyName("images")]
public List<string> images { get; set; }
[JsonPropertyName("county")]
public string county { get; set; }
[JsonPropertyName("siteName")]
public string siteName { get; set; }
[JsonPropertyName("plate")]
public string plate { get; set; }
[JsonPropertyName("organization")]
public string organization { get; set; }
[JsonPropertyName("eventName")]
public string eventName { get; set; }
[JsonPropertyName("sn")]
public string sn { get; set; }
[JsonPropertyName("punishID")]
public string punishID { get; set; }
}
public class JsonCheckPunishEventType1 : JsonCheckPunish
{
[JsonPropertyName("alarmTime")]
public string alarmTime { get; set; }
[JsonPropertyName("inTime")]
public string inTime { get; set; }
[JsonPropertyName("outTime")]
public string outTime { get; set; }
}
public class JsonCheckPunishEventType2 : JsonCheckPunish
{
[JsonPropertyName("distance")]
public string distance { get; set; }
[JsonPropertyName("speed")]
public string speed { get; set; }
[JsonPropertyName("totalPassTime")]
public string totalPassTime { get; set; }
[JsonPropertyName("inTime")]
public string inTime { get; set; }
[JsonPropertyName("outTime")]
public string outTime { get; set; }
}
public class JsonCheckPunishEventType3 : JsonCheckPunish
{
[JsonPropertyName("alarmTime")]
public string alarmTime { get; set; }
}
public class JsonCheckPunishEventType4 : JsonCheckPunish
{
[JsonPropertyName("alarmTime")]
public string alarmTime { get; set; }
}
public class JsonCheckPunishEventType6 : JsonCheckPunish
{
[JsonPropertyName("alarmTime")]
public string alarmTime { get; set; }
[JsonPropertyName("ton")]
public string ton { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class LoginResultModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Name")]
public string Name { get; set; }
[JsonPropertyName("Role")]
public int Role { get; set; }
[JsonPropertyName("Token")]
public string Token { get; set; }
[JsonPropertyName("Message")]
public string Message { get; set; }
[JsonPropertyName("Success")]
public bool Success { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System.Text.Json.Serialization;
namespace Traffic.Data.ViewModels
{
public class LoginViewModel
{
[JsonPropertyName("Account")]
public string Account { get; set; }
[JsonPropertyName("Password")]
public string Password { get; set; }
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class MailViewModel
{
/// <summary>
/// 寄件者
/// </summary>
public string From { get; set; }
/// <summary>
/// 收件者
/// </summary>
public string[] To { get; set; }
/// <summary>
/// 主旨
/// </summary>
public string Subject { get; set; }
/// <summary>
/// 主旨 Encoding (System.Text.Encoding.UTF8)
/// </summary>
public Encoding SubjectEncoding { get; set; }
/// <summary>
/// 內文
/// </summary>
public string Body { get; set; }
/// <summary>
/// 內文是否為Html
/// </summary>
public bool IsBodyHtml { get; set; }
/// <summary>
/// 內文 Encoding (System.Text.Encoding.UTF8)
/// </summary>
public Encoding BodyEncoding { get; set; }
/// <summary>
/// 郵件的優先度
/// </summary>
public MailPriority Priority { get; set; }
}
}

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class MalfunctionViewModel
{
[JsonPropertyName("userId")]
public int UserId { get; set; }
[JsonPropertyName("Siteid")]
public string Siteid { get; set; }
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
[JsonPropertyName("DeviceType")]
public string DeviceType { get; set; }
[JsonPropertyName("DeviceID")]
public string DeviceID { get; set; }
[JsonPropertyName("Message")]
public string Message { get; set; }
[JsonPropertyName("Time")]
public string Time { get; set; }
[JsonPropertyName("Status")]
public string Status { get; set; }
}
public class SiteMalfunctionViewModel
{
[JsonPropertyName("userId")]
public int UserId { get; set; }
[JsonPropertyName("County")]
public string County { get; set; }
[JsonPropertyName("Area")]
public string Area { get; set; }
[JsonPropertyName("Siteid")]
public string Siteid { get; set; }
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
[JsonPropertyName("SiteStatus")]
public string SiteStatus { get; set; }
[JsonPropertyName("EventType")]
public string EventType { get; set; }
[JsonPropertyName("Malfunction")]
public List<MalfunctionViewModel> Malfunctions { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class NotPunishViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("EventTypeId")]
public int EventTypeId { get; set; }
[JsonPropertyName("EventType")]
public string EventType { get; set; }
[JsonPropertyName("EventName")]
public string EventName { get; set; }
[JsonPropertyName("NotPunishType")]
public int NotPunishType { get; set; }
[JsonPropertyName("NotPunishReason")]
public string NotPunishReason { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class PageData
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("PageModule")]
public string PageModule { get; set; }
[JsonPropertyName("PageName")]
public string PageName { get; set; }
[JsonPropertyName("PageUrl")]
public string PageUrl { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class PageViewModel<T>
{
[JsonPropertyName("RowCount")]
public int RowCount { get; set; }
[JsonPropertyName("PageCount")]
public int PageCount { get; set; }
[JsonPropertyName("CurrentPage")]
public int CurrentPage { get; set; }
[JsonPropertyName("Data")]
public T Data { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class PoliceStationViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Area")]
public string Area { get; set; }
[JsonPropertyName("StationName")]
public string StationName { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class RepairViewModel
{
public int QuestionType { get; set; }
public string SendTo { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class ReportMalfunctionViewModel
{
[JsonPropertyName("Time")]
public string Time { get; set; }
[JsonPropertyName("SiteId")]
public string SiteId { get; set; }
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
[JsonPropertyName("DeviceType")]
public string DeviceType { get; set; }
[JsonPropertyName("DeviceID")]
public string DeviceID { get; set; }
[JsonPropertyName("Message")]
public string Message { get; set; }
}
}

View File

@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class ReportRequestViewModel
{
[JsonPropertyName("StartDate")]
public string StartDate { get; set; }
[JsonPropertyName("EndDate")]
public string EndDate { get; set; }
[JsonPropertyName("StartTime")]
public int StartTime { get; set; }
[JsonPropertyName("EndTime")]
public int EndTime { get; set; }
[JsonPropertyName("Sites")]
public List<string> Sites { get; set; }
}
public class ReportEventType1ViewModel
{
/// <summary>
/// 違規時間
/// </summary>
[JsonPropertyName("DateTime")]
public string DateTime { get; set; }
/// <summary>
/// 汽車
/// </summary>
[JsonPropertyName("CarCount")]
public int CarCount { get; set; }
/// <summary>
/// 機車
/// </summary>
[JsonPropertyName("MotorcycleCount")]
public int MotorcycleCount { get; set; }
/// <summary>
/// 計程車
/// </summary>
[JsonPropertyName("TaxiCount")]
public int TaxiCount { get; set; }
/// <summary>
/// 公車
/// </summary>
[JsonPropertyName("BusCount")]
public int BusCount { get; set; }
/// <summary>
/// 有車牌
/// </summary>
[JsonPropertyName("HasNumber")]
public int HasNumber { get; set; }
/// <summary>
/// 無車牌
/// </summary>
[JsonPropertyName("HasNoNumber")]
public int HasNoNumber { get; set; }
}
public class ReportEventType2ViewModel
{
/// <summary>
/// 時速
/// </summary>
[JsonPropertyName("Speed")]
public string Speed { get; set; }
/// <summary>
/// 違規數量
/// </summary>
[JsonPropertyName("Count")]
public int Count { get; set; }
}
public class ReportEventType34ViewModel
{
/// <summary>
/// 汽車
/// </summary>
[JsonPropertyName("CarCount")]
public int CarCount { get; set; }
/// <summary>
/// 貨車
/// </summary>
[JsonPropertyName("TruckCount")]
public int TruckCount { get; set; }
/// <summary>
/// 大客車
/// </summary>
[JsonPropertyName("CoachCount")]
public int CoachCount { get; set; }
}
public class ReportEventType6ViewModel
{
/// <summary>
/// 噸數
/// </summary>
[JsonPropertyName("Ton")]
public string Ton { get; set; }
/// <summary>
/// 違規數量
/// </summary>
[JsonPropertyName("Count")]
public int Count { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class Response
{
[JsonPropertyName("Result")]
public object Result { get; set; }
}
}

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class RoleData
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("RoleName")]
public string RoleName { get; set; }
[JsonPropertyName("Status")]
public bool Status { get; set; }
[JsonPropertyName("CreatorId")]
public string CreatorId { get; set; }
[JsonPropertyName("CreatedOn")]
public DateTime CreatedOn { get; set; }
}
public class RoleDataQuery
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("RoleName")]
public string RoleName { get; set; }
[JsonPropertyName("Status")]
public bool Status { get; set; }
[JsonPropertyName("CreateID")]
public int CreateID { get; set; }
[JsonPropertyName("CreateTime")]
public string CreateTime { get; set; }
}
public class RoleCodeInfo
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("RoleName")]
public string RoleName { get; set; }
}
}

View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.Models
{
public class RolePermissionData
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("RoleCodeId")]
public int RoleCodeId { get; set; }
[JsonPropertyName("PageId")]
public int PageId { get; set; }
}
public class RolePermissionDataQuery
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("RoleId")]
public int RoleId { get; set; }
[JsonPropertyName("PageId")]
public int PageId { get; set; }
[JsonPropertyName("RoleName")]
public string RoleName { get; set; }
[JsonPropertyName("PageName")]
public string PageName { get; set; }
}
public class PagePermissionData
{
[JsonPropertyName("Enable")]
public bool Enable { get; set; }
[JsonPropertyName("RoleId")]
public int RoleId { get; set; }
[JsonPropertyName("PageId")]
public int PageId { get; set; }
}
public class PagePermissionDataQuery
{
[JsonPropertyName("Enable")]
public bool Enable { get; set; }
[JsonPropertyName("RoleId")]
public int RoleId { get; set; }
[JsonPropertyName("PageId")]
public int PageId { get; set; }
[JsonPropertyName("PageModule")]
public string PageModule { get; set; }
[JsonPropertyName("PageName")]
public string PageName { get; set; }
[JsonPropertyName("PageUrl")]
public string PageUrl { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class SearchModel
{
[JsonPropertyName("Term")]
public string Term { get; set; }
[JsonPropertyName("Page")]
public int Page { get; set; }
[JsonPropertyName("PageSize")]
public int PageSize { get; set; }
[JsonPropertyName("Order")]
public string Order { get; set; }
[JsonPropertyName("IsAsc")]
public bool IsAsc { get; set; }
public SearchModel()
{
Page = 1;
PageSize = 10;
Order = "id";
IsAsc = true;
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class SearchModelViewModel
{
[JsonPropertyName("Term")]
public string Term { get; set; }
[JsonPropertyName("Page")]
public string Page { get; set; }
[JsonPropertyName("PageSize")]
public string PageSize { get; set; }
[JsonPropertyName("Order")]
public string Order { get; set; }
[JsonPropertyName("IsAsc")]
public string IsAsc { get; set; }
public SearchModelViewModel()
{
Page = "1";
PageSize = "10";
Order = "id";
IsAsc = "true";
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class SiteAndEventTypeViewModel
{
[JsonPropertyName("StartTime")]
public string StartTime { get; set; }
[JsonPropertyName("EndTime")]
public string EndTime { get; set; }
[JsonPropertyName("Sites")]
public List<string> Sites { get; set; }
[JsonPropertyName("EventTypes")]
public List<string> EventTypes { get; set; }
}
}

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class SiteInformationViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Country")]
public string County { get; set; }
[JsonPropertyName("Area")]
public string Area { get; set; }
[JsonPropertyName("SiteID")]
public string SiteID { get; set; }
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
[JsonPropertyName("EventType")]
public string EventType { get; set; }
[JsonPropertyName("EventName")]
public string EventName { get; set; }
[JsonPropertyName("Ip")]
public string Ip { get; set; }
[JsonPropertyName("DbName")]
public string DbName { get; set; }
[JsonPropertyName("TableName")]
public string TableName { get; set; }
[JsonPropertyName("User")]
public string User { get; set; }
[JsonPropertyName("Password")]
public string Password { get; set; }
[JsonPropertyName("FinalRecord")]
public int FinalRecord { get; set; }
[JsonPropertyName("Target")]
public string Target { get; set; }
[JsonPropertyName("ClusterHead")]
public string ClusterHead { get; set; }
[JsonPropertyName("ARHFinalRecord")]
public int ARHFinalRecord { get; set; }
[JsonPropertyName("Laws")]
public string Laws { get; set; }
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
[JsonPropertyName("CompanyName")]
public string CompanyName { get; set; }
[JsonPropertyName("CompanyEmail")]
public string CompanyEmail { get; set; }
}
public class UserSiteInformationViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Country")]
public string County { get; set; }
[JsonPropertyName("Area")]
public string Area { get; set; }
[JsonPropertyName("SiteID")]
public string SiteID { get; set; }
[JsonPropertyName("SiteName")]
public string SiteName { get; set; }
[JsonPropertyName("EventType")]
public string EventType { get; set; }
[JsonPropertyName("EventName")]
public string EventName { get; set; }
[JsonPropertyName("CompanyCode")]
public string CompanyCode { get; set; }
[JsonPropertyName("CompanyName")]
public string CompanyName { get; set; }
[JsonPropertyName("CompanyEmail")]
public string CompanyEmail { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mail.ViewModels
{
public class SmtpClientViewModel
{
public string Account { get; set; }
public string Password { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class TradeResultModel
{
[JsonPropertyName("Success")]
public bool Success { get; set; }
[JsonPropertyName("Message")]
public string Message { get; set; }
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class TycgViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Time")]
public string Time { get; set; }
[JsonPropertyName("Timestamp")]
public Int64 Timestamp { get; set; }
[JsonPropertyName("Trendflags")]
public int Trendflags { get; set; }
[JsonPropertyName("Status")]
public int Status { get; set; }
[JsonPropertyName("Value")]
public string Value { get; set; }
[JsonPropertyName("ip")]
public string ip { get; set; }
[JsonPropertyName("api")]
public string api { get; set; }
[JsonPropertyName("Trendflags_Tag")]
public string Trendflags_Tag { get; set; }
[JsonPropertyName("Status_tag")]
public string Status_tag { get; set; }
}
public class TycgTableNameViewModel
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("LogName")]
public string LogName { get; set; }
[JsonPropertyName("APIName")]
public string APIName { get; set; }
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Traffic.Data.Models;
namespace Traffic.Data.ViewModels
{
public class UserData
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Account")]
public string Account { get; set; }
[JsonPropertyName("UserName")]
public string UserName { get; set; }
[JsonPropertyName("Password")]
public string Password { get; set; }
[JsonPropertyName("newPassword")]
public string NewPassword { get; set; }
[JsonPropertyName("Email")]
public string Email { get; set; }
[JsonPropertyName("PhoneNumber")]
public string PhoneNumber { get; set; }
[JsonPropertyName("Status")]
public int Status { get; set; }
[JsonPropertyName("RoleCode")]
public AccountRole RoleCode { get; set; }
[JsonPropertyName("RoleCode_Id")]
public int RoleCode_Id { get; set; }
[JsonPropertyName("GroupCode")]
public AccountGroup GroupCode { get; set; }
[JsonPropertyName("GroupCode_Id")]
public int GroupCode_Id { get; set; }
[JsonPropertyName("Site_Id")]
public List<int> Site_Id { get; set; }
}
public class UserNameList
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("UserName")]
public string UserName { get; set; }
[JsonPropertyName("Email")]
public string Email { get; set; }
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Traffic.Data.Models;
namespace Traffic.Data.ViewModels
{
public class UserDataQuery
{
[JsonPropertyName("Id")]
public int Id { get; set; }
[JsonPropertyName("Account")]
public string Account { get; set; }
[JsonPropertyName("UserName")]
public string UserName { get; set; }
[JsonPropertyName("Email")]
public string Email { get; set; }
[JsonPropertyName("PhoneNumber")]
public string PhoneNumber { get; set; }
[JsonPropertyName("Status")]
public int Status { get; set; }
[JsonPropertyName("RoleCode")]
public AccountRole RoleCode { get; set; }
[JsonPropertyName("RoleCode_Id")]
public int RoleCode_Id { get; set; }
[JsonPropertyName("GroupCode")]
public AccountGroup GroupCode { get; set; }
[JsonPropertyName("GroupCode_Id")]
public int GroupCode_Id { get; set; }
[JsonPropertyName("IsLogon")]
public bool? IsLogon { get; set; }
[JsonPropertyName("CreatorId")]
public string CreatorId { get; set; }
[JsonPropertyName("CreatedOn")]
public string CreatedOn { get; set; }
[JsonPropertyName("PoliceStation")]
public PoliceStationViewModel PoliceStation { get; set; }
[JsonPropertyName("Site")]
public List<UserSiteViewModel> Site { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Traffic.Data.ViewModels
{
public class VehicleTypeViewModel
{
/// <summary>
/// 流水號
/// </summary>
public int Id { get; set; }
/// <summary>
/// 違規代碼
/// </summary>
public string VehicleType { get; set; }
/// <summary>
/// 違規名稱
/// </summary>
public string VehicleName { get; set; }
}
}

View File

@ -0,0 +1,263 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class AccountRepository : IAccountRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public AccountRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<AccountUser> GetAccountUsers()
{
var sql = $@"SELECT * FROM {nameof(AccountUser)}";
return Connection.Query<AccountUser>(sql, null, Transaction);
}
public AccountUser GetAccountUserByAccount(string account)
{
var sql = $@"SELECT * FROM {nameof(AccountUser)}
WHERE {nameof(AccountUser.Account)} = @{nameof(AccountUser.Account)}";
return Connection.QueryFirstOrDefault<AccountUser>(sql, new { Account = account }, Transaction);
}
public AccountUser GetAccountUserByAccount(string account, string password)
{
var sql = $@"SELECT * FROM {nameof(AccountUser)}
WHERE {nameof(AccountUser.Account)} = @{nameof(AccountUser.Account)}
AND {nameof(AccountUser.Password)} = @{nameof(AccountUser.Password)}";
return Connection.QueryFirstOrDefault<AccountUser>(sql, new { Account = account, Password = password }, Transaction);
}
public AccountUser GetAccountUserById(int id)
{
var sql = $@"SELECT * FROM {nameof(AccountUser)}
WHERE {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
return Connection.QueryFirstOrDefault<AccountUser>(sql, new { Id = id }, Transaction);
}
public IEnumerable<AccountRole> GetAccountRoles()
{
var sql = $@"SELECT * FROM {nameof(AccountRole)}";
return Connection.Query<AccountRole>(sql, null, Transaction);
}
public IEnumerable<AccountUserSite> GetAccountUserSite(int id)
{
var sql = $@"SELECT * FROM {nameof(AccountUserSite)}
WHERE {nameof(AccountUserSite.UserId)} = @{nameof(AccountUserSite.UserId)}";
return Connection.Query<AccountUserSite>(sql, new { UserId = id }, Transaction);
}
public IEnumerable<AccountUserSite> GetAccountUserSites()
{
var sql = $@"SELECT * FROM {nameof(AccountUserSite)}";
return Connection.Query<AccountUserSite>(sql, null, Transaction);
}
public int InsertAccountUser(AccountUser accountUser)
{
var sql = $@"INSERT INTO {nameof(AccountUser)} (
{nameof(AccountUser.Account)},
{nameof(AccountUser.Password)},
{nameof(AccountUser.UserName)},
{nameof(AccountUser.PhoneNumber)},
{nameof(AccountUser.Email)},
{nameof(AccountUser.RoleCodeId)},
{nameof(AccountUser.PoliceStationId)},
{nameof(AccountUser.CreatorId)},
{nameof(AccountUser.CreatedOn)},
{nameof(AccountUser.ChangePwdOn)})
VALUES (@{nameof(AccountUser.Account)},
@{nameof(AccountUser.Password)},
@{nameof(AccountUser.UserName)},
@{nameof(AccountUser.PhoneNumber)},
@{nameof(AccountUser.Email)},
@{nameof(AccountUser.RoleCodeId)},
@{nameof(AccountUser.PoliceStationId)},
@{nameof(AccountUser.CreatorId)},
@{nameof(AccountUser.CreatedOn)},
@{nameof(AccountUser.ChangePwdOn)});
SELECT LAST_INSERT_ID() AS `User_id`;";
return Connection.QuerySingle<int>(sql, accountUser, Transaction);
}
public int InsertAccountRole(AccountRole accountUser)
{
var sql = $@"INSERT INTO {nameof(AccountRole)} (
{nameof(AccountRole.RoleName)},
{nameof(AccountRole.CreatorId)},
{nameof(AccountRole.CreatedOn)})
VALUES (@{nameof(AccountRole.RoleName)},
@{nameof(AccountRole.CreatorId)},
@{nameof(AccountRole.CreatedOn)});
SELECT LAST_INSERT_ID() AS `User_id`;";
return Connection.QuerySingle<int>(sql, accountUser, Transaction);
}
public bool InsertAccountUserSite(List<AccountUserSite> userSite)
{
var sql = $@"INSERT INTO {nameof(AccountUserSite)} (
{nameof(AccountUserSite.UserId)},
{nameof(AccountUserSite.SiteId)})
VALUES (@{nameof(AccountUserSite.UserId)},
@{nameof(AccountUserSite.SiteId)})";
var result = Connection.Execute(sql, userSite, Transaction);
return result >= 1;
}
public bool UpdateAccountUserbyAdmin(AccountUser accountUser)
{
var sql = $@"UPDATE {nameof(AccountUser)}
SET {nameof(AccountUser.Account)}=@{nameof(AccountUser.Account)},
{nameof(AccountUser.UserName)}=@{nameof(AccountUser.UserName)},
{nameof(AccountUser.PhoneNumber)}=@{nameof(AccountUser.PhoneNumber)},
{nameof(AccountUser.Email)}=@{nameof(AccountUser.Email)},
{nameof(AccountUser.RoleCodeId)}=@{nameof(AccountUser.RoleCodeId)},
{nameof(AccountUser.PoliceStationId)}=@{nameof(AccountUser.PoliceStationId)},
{nameof(AccountUser.UpdatorId)}=@{nameof(AccountUser.UpdatorId)},
{nameof(AccountUser.UpdatedOn)}=@{nameof(AccountUser.UpdatedOn)}
WHERE {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
var result = Connection.Execute(sql, accountUser, Transaction);
return result == 1;
}
public bool UpdateAccountUserPasswordByAdmin(int id, string newPassword, int byWho, DateTime updateOn)
{
var sql = $@"UPDATE {nameof(AccountUser)}
SET {nameof(AccountUser.Password)}=@newPassword,
{nameof(AccountUser.UpdatorId)}=@{nameof(AccountUser.UpdatorId)},
{nameof(AccountUser.UpdatedOn)}=@{nameof(AccountUser.UpdatedOn)},
{nameof(AccountUser.ChangePwdOn)}=@{nameof(AccountUser.UpdatedOn)},
{nameof(AccountUser.ErrorCount)}=0
WHERE {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
var result = Connection.Execute(sql, new { Id = id, newPassword, UpdatorId = byWho, UpdatedOn = updateOn }, Transaction);
return result == 1;
}
public bool UpdateAccountUserbyUser(AccountUser accountUser)
{
var sql = $@"UPDATE {nameof(AccountUser)}
SET {nameof(AccountUser.UserName)}=@{nameof(AccountUser.UserName)},
{nameof(AccountUser.PhoneNumber)}=@{nameof(AccountUser.PhoneNumber)},
{nameof(AccountUser.Email)}=@{nameof(AccountUser.Email)},
{nameof(AccountUser.UpdatorId)}=@{nameof(AccountUser.UpdatorId)},
{nameof(AccountUser.UpdatedOn)}=@{nameof(AccountUser.UpdatedOn)}
WHERE {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
var result = Connection.Execute(sql, accountUser, Transaction);
return result == 1;
}
public bool UpdateAccountUserPasswordByUser(int id, string oldPassword, string newPassword, DateTime updatedOn)
{
var sql = $@"UPDATE {nameof(AccountUser)}
SET {nameof(AccountUser.Password)}=@newPassword,
{nameof(AccountUser.UpdatorId)}=@{nameof(AccountUser.UpdatorId)},
{nameof(AccountUser.UpdatedOn)}=@{nameof(AccountUser.UpdatedOn)},
{nameof(AccountUser.ChangePwdOn)}=@{nameof(AccountUser.UpdatedOn)},
{nameof(AccountUser.ErrorCount)}=0
WHERE {nameof(AccountUser.Password)} = @oldPassword And {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
var result = Connection.Execute(sql, new { Id = id, oldPassword, newPassword, UpdatorId = id, UpdatedOn = updatedOn }, Transaction);
return result == 1;
}
public bool InsertUserLoginLog(UserLoginLog userLogin)
{
var sql = $@"INSERT INTO {nameof(UserLoginLog)} (
{nameof(UserLoginLog.UserId)},
{nameof(UserLoginLog.LoginIP)},
{nameof(UserLoginLog.LoginOn)},
{nameof(UserLoginLog.Status)})
VALUES (@{nameof(UserLoginLog.UserId)},
@{nameof(UserLoginLog.LoginIP)},
@{nameof(UserLoginLog.LoginOn)},
@{nameof(UserLoginLog.Status)})";
var result = Connection.Execute(sql, userLogin, Transaction);
return result == 1;
}
public bool UpdateUserErrorCount(int id, int errorCount)
{
var sql = $@"UPDATE {nameof(AccountUser)}
SET {nameof(AccountUser.ErrorCount)}=@{nameof(AccountUser.ErrorCount)}
WHERE {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
var result = Connection.Execute(sql, new { id, errorCount }, Transaction);
return result == 1;
}
public bool DisableUser(int byWho, int id, int status)
{
var sql = $@"UPDATE {nameof(AccountUser)}
SET {nameof(AccountUser.Status)} = @{nameof(status)},
{nameof(AccountUser.UpdatorId)} = @{nameof(byWho)},
{nameof(AccountUser.UpdatedOn)} = NOW()
WHERE {nameof(AccountUser.Id)} = @{nameof(id)}";
var result = Connection.Execute(sql, new { byWho, id, status }, Transaction);
return result == 1;
}
public bool DeleteUser(int id)
{
var sql = $@"DELETE FROM {nameof(AccountUser)} WHERE {nameof(AccountUser.Id)} = @{nameof(AccountUser.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
public bool DeleteUserSite(int userId)
{
var sql = $@"DELETE FROM {nameof(AccountUserSite)} WHERE {nameof(AccountUserSite.UserId)} = @{nameof(AccountUserSite.UserId)}";
var result = Connection.Execute(sql, new { UserId = userId }, Transaction);
return result >= 1;
}
public IEnumerable<AccountPwd> GetAccountPwdTop3(string account)
{
var sql = $@"SELECT * FROM {nameof(AccountPwd)}
WHERE {nameof(AccountPwd.Account)} = {nameof(account)}
ORDER BY {nameof(AccountPwd.CreatedOn)} DESC
LIMIT 3";
return Connection.Query<AccountPwd>(sql, new { account }, Transaction);
}
public bool InsertAccountPwd(AccountPwd accountUser)
{
var sql = $@"INSERT INTO {nameof(AccountPwd)} (
{nameof(AccountPwd.Account)},
{nameof(AccountPwd.Password)},
{nameof(AccountPwd.CreatedOn)})
VALUES (@{nameof(AccountPwd.Account)},
@{nameof(AccountPwd.Password)},
@{nameof(AccountPwd.CreatedOn)})";
var result = Connection.Execute(sql, accountUser, Transaction);
return result >= 1;
}
}
}

View File

@ -0,0 +1,76 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class AnnounceRepository : IAnnounceRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public AnnounceRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<Announce> GetAnnounces()
{
var sql = $"SELECT * FROM {nameof(Announce)}";
return Connection.Query<Announce>(sql, null, Transaction);
}
public Announce GetAnnounceById(int id)
{
var sql = $"SELECT * FROM {nameof(Announce)} Where {nameof(Announce.Id)} = @{nameof(Announce.Id)}";
return Connection.QueryFirstOrDefault<Announce>(sql, new { id }, Transaction);
}
public bool InsertAnnounce(Announce announce)
{
var sql = $@"INSERT INTO {nameof(Announce)} (
{nameof(Announce.Title)},
{nameof(Announce.Content)},
{nameof(Announce.StartOn)},
{nameof(Announce.Status)},
{nameof(Announce.CreatorId)},
{nameof(Announce.CreatedOn)})
VALUES(@{nameof(Announce.Title)},
@{nameof(Announce.Content)},
@{nameof(Announce.StartOn)},
@{nameof(Announce.Status)},
@{nameof(Announce.CreatorId)},
@{nameof(Announce.CreatedOn)})";
var result = Connection.Execute(sql, announce, Transaction);
return result == 1;
}
public bool UpdateAnnounce(Announce announce)
{
var sql = $@"UPDATE {nameof(Announce)}
SET {nameof(Announce.Title)} = @{nameof(Announce.Title)},
{nameof(Announce.Content)} = @{nameof(Announce.Content)},
{nameof(Announce.StartOn)} = @{nameof(Announce.StartOn)},
{nameof(Announce.Status)} = @{nameof(Announce.Status)},
{nameof(Announce.UpdatorId)} = @{nameof(Announce.UpdatorId)},
{nameof(Announce.UpdatedOn)} = @{nameof(Announce.UpdatedOn)}
WHERE {nameof(Announce.Id)} = @{nameof(Announce.Id)}";
var result = Connection.Execute(sql, announce, Transaction);
return result == 1;
}
public bool DeleteAnnounce(int id)
{
var sql = $@"DELETE FROM {nameof(Announce)} WHERE {nameof(Announce.Id)} = @{nameof(Announce.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,75 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class CompanyInformationRepository : ICompanyInformationRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public CompanyInformationRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
/// <summary>
/// 分頁 select * from persons limit A offset B;
/// A就是你需要顯示多少行
/// B就是查詢的起點位置。
/// </summary>
/// <param name="pageNumber">第幾頁</param>
/// <param name="pageSize">一頁幾行</param>
/// <returns></returns>
public IEnumerable<CompanyInformation> GetCompanyInformations()
{
var sql = $"SELECT * FROM {nameof(CompanyInformation)}";
return Connection.Query<CompanyInformation>(sql, null, Transaction);
}
public CompanyInformation GetCompanyInformationById(int id)
{
var sql = $"SELECT * FROM {nameof(CompanyInformation)} Where {nameof(CompanyInformation.Id)} = @{nameof(CompanyInformation.Id)}";
return Connection.QueryFirstOrDefault<CompanyInformation>(sql, new { id }, Transaction);
}
public bool InsertCompanyInformation(CompanyInformation company)
{
var sql = $@"INSERT INTO {nameof(CompanyInformation)} (
{nameof(CompanyInformation.CompanyName)},
{nameof(CompanyInformation.CompanyCode)},
{nameof(CompanyInformation.Email)})
VALUES(@{nameof(CompanyInformation.CompanyName)},
@{nameof(CompanyInformation.CompanyCode)},
@{nameof(CompanyInformation.Email)})";
var result = Connection.Execute(sql, company, Transaction);
return result == 1;
}
public bool UpdateCompanyInformation(CompanyInformation company)
{
var sql = $@"UPDATE {nameof(CompanyInformation)}
SET {nameof(CompanyInformation.CompanyName)} = @{nameof(CompanyInformation.CompanyName)},
{nameof(CompanyInformation.CompanyCode)} = @{nameof(CompanyInformation.CompanyCode)},
{nameof(CompanyInformation.Email)} = @{nameof(CompanyInformation.Email)}
WHERE {nameof(CompanyInformation.Id)} = @{nameof(CompanyInformation.Id)}";
var result = Connection.Execute(sql, company, Transaction);
return result == 1;
}
public bool DeleteCompanyInformation(int id)
{
var sql = $@"DELETE FROM {nameof(CompanyInformation)} WHERE {nameof(CompanyInformation.Id)} = @{nameof(CompanyInformation.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,370 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Data.ViewModels;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class EventRepository : IEventRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public EventRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public int GetEventCount(string term)
{
if (string.IsNullOrWhiteSpace(term))
{
var sql = $"SELECT Count(*) FROM {nameof(Event)}";
return Connection.QueryFirst<int>(sql, null, Transaction);
}
else
{
var sql = $"SELECT Count(*) FROM {nameof(Event)} WHERE number = @number";
return Connection.QueryFirst<int>(sql, new { number = term }, Transaction);
}
}
public int GetEventBySitesCount(string siteId, string term)
{
if (string.IsNullOrWhiteSpace(term))
{
var sql = $"SELECT Count(*) FROM {nameof(Event)} WHERE siteId = @siteId";
return Connection.QueryFirst<int>(sql, new { siteId, number = term }, Transaction);
}
else
{
var sql = $"SELECT Count(*) FROM {nameof(Event)} WHERE siteId = @siteId and number = @number";
return Connection.QueryFirst<int>(sql, new { siteId, number = term }, Transaction);
}
}
public int GetThisYearEventsCount(string startTime, string endTime, string account)
{
var sql = $"SELECT Count(*) FROM {nameof(Event)} WHERE punished = 1 and uploadTime >= @startTime and uploadTime >= @endTime and account = @account";
return Connection.QueryFirst<int>(sql, new { startTime, endTime, account }, Transaction);
}
public int GetThisMonthEventsCount(string startTime, string endTime, string account)
{
var sql = $"SELECT Count(*) FROM {nameof(Event)} WHERE punished = 1 and uploadTime >= @startTime and uploadTime >= @endTime and account = @account";
return Connection.QueryFirst<int>(sql, new { startTime, endTime, account }, Transaction);
}
public int GetEventByEventTypeCount(string eventType)
{
var sql = $"SELECT Count(*) FROM {nameof(Event)} WHERE eventType = @eventType";
return Connection.QueryFirst<int>(sql, new { eventType }, Transaction);
}
public IEnumerable<ExceptionNumber> GetExceptionNumbers()
{
var sql = $"SELECT * FROM {nameof(ExceptionNumber)} ";
return Connection.Query<ExceptionNumber>(sql, null, Transaction);
}
public IEnumerable<Event> GetEvents()
{
var sql = $"SELECT * FROM {nameof(Event)} ";
return Connection.Query<Event>(sql, null, Transaction);
}
public IEnumerable<Event> GetEventsByCar(string term)
{
var sql = $@"SELECT {nameof(Event.Id)},
{nameof(Event.Number)},
{nameof(Event.SiteID)},
{nameof(Event.EventType)},
{nameof(Event.InTime)},
{nameof(Event.CheckPunish)},
{nameof(Event.Punished)},
{nameof(Event.Rejected)}
FROM {nameof(Event)} WHERE number like @term";
return Connection.Query<Event>(sql, new { term }, Transaction);
}
public IEnumerable<Event> GetEventBySites(string siteId, int pageNumber, int pageSize)
{
var sql = $"SELECT * FROM {nameof(Event)} WHERE siteId = @siteId limit @pageSize offset @offsetIndex";
return Connection.Query<Event>(sql, new { siteId, pageSize, offsetIndex = pageSize * (pageNumber - 1) }, Transaction);
}
public IEnumerable<JoinEventSite> GetEventBySitesAndEventType(List<string> sitesId, List<string> eventTypes, string startTime, string endTime)
{
var sql = $@"SELECT s.*, e.checkPunish, e.punished, e.rejected, e.ps, e.speed, e.inTime, e.outTime, e.outTime, e.number, e.vehicleType, e.Ton
FROM event as e
LEFT JOIN siteinformation s on s.siteID = e.siteID
WHERE s.siteId in @sitesId and
s.eventType in @eventTypes and
e.alarmTime >= @startTime and e.alarmTime <= @endTime";
return Connection.Query<JoinEventSite>(sql, new { sitesId, eventTypes, startTime, endTime }, Transaction);
}
public IEnumerable<Event> GetEventByEventType(string eventType, int pageNumber, int pageSize)
{
var sql = $"SELECT * FROM {nameof(Event)} WHERE eventType = @eventType limit @pageSize offset @offsetIndex";
return Connection.Query<Event>(sql, new { eventType, pageSize, offsetIndex = pageSize * (pageNumber - 1) }, Transaction);
}
public IEnumerable<Event> GetEvents(string startDatetime, string endDatetime)
{
var sql = $"SELECT * FROM {nameof(Event)} WHERE alarmTime >= @startDatetime AND alarmTime <= @endDatetime";
return Connection.Query<Event>(sql, new { startDatetime, endDatetime }, Transaction);
}
public IEnumerable<JoinEventSiteAndUser> GetEventJoinSiteAndUsers(int userId, string eventType, string startTime, string endTime)
{
var sql = $@"SELECT
e.id,
a.userId,
s.county,
s.area,
s.siteid,
s.siteName,
s.eventType,
s.laws,
e.*
FROM accountusersite as a
LEFT JOIN siteinformation as s on s.Id = a.siteid
LEFT JOIN event as e on s.siteID = e.siteID
WHERE a.userid = @userid and s.eventType = @eventType";
return Connection.Query<JoinEventSiteAndUser>(sql,
new
{
userId,
eventType,
startTime,
endTime
}, Transaction);
}
public int GetEventByTimeCount(string startTime, string endTime)
{
var sql = $@"SELECT Count(*)
FROM event
WHERE alarmTime >= @startTime and alarmTime <= @endTime ";
return Connection.QueryFirst<int>(sql,
new
{
startTime,
endTime
}, Transaction);
}
public IEnumerable<Event> GetEventByTime(string startTime, string endTime)
{
var sql = $@"SELECT *
FROM event
WHERE alarmTime >= @startTime and alarmTime <= @endTime ";
return Connection.Query<Event>(sql,
new
{
startTime,
endTime
}, Transaction);
}
public IEnumerable<VehicleTypeTable> GetVehicleType()
{
var sql = $"SELECT * FROM vehicletype";
return Connection.Query<VehicleTypeTable>(sql, null, Transaction);
}
public VehicleTypeTable GetVehicleTypebyType(string vehicletype)
{
var sql = $"SELECT * FROM vehicletype WHERE vehicletype = @vehicletype";
return Connection.QueryFirstOrDefault<VehicleTypeTable>(sql, new { vehicletype }, Transaction);
}
public Event GetEventById(int id)
{
var sql = $"SELECT * FROM {nameof(Event)} Where {nameof(Event.Id)} = @{nameof(Event.Id)}";
return Connection.QueryFirstOrDefault<Event>(sql, new { id }, Transaction);
}
public bool InsertEvent(Event data)
{
var sql = $@"INSERT INTO {nameof(Event)} (
{nameof(Event.SiteID)},
{nameof(Event.EventID)},
{nameof(Event.Channel)},
{nameof(Event.Slot)},
{nameof(Event.EventType)},
{nameof(Event.VehicleType)},
{nameof(Event.Distance)},
{nameof(Event.Speed)},
{nameof(Event.TotalPassTime)},
{nameof(Event.LimitTon)},
{nameof(Event.Ton)},
{nameof(Event.InTime)},
{nameof(Event.AlarmTime)},
{nameof(Event.OutTime)},
{nameof(Event.LPRTime)},
{nameof(Event.IMGPath1)},
{nameof(Event.IMGPath2)},
{nameof(Event.IMGPath3)},
{nameof(Event.IMGPath4)},
{nameof(Event.IMGPath5)},
{nameof(Event.IMGPath6)},
{nameof(Event.VideoPath1)},
{nameof(Event.VideoPath2)},
{nameof(Event.IsStay)},
{nameof(Event.Unsure)},
{nameof(Event.CheckPunish)},
{nameof(Event.Punished)},
{nameof(Event.CompanyCode)},
{nameof(Event.Ps)},
{nameof(Event.HandlingTime)},
{nameof(Event.UploadTime)})
VALUES(@{nameof(Event.SiteID)},
@{nameof(Event.EventID)},
@{nameof(Event.Channel)},
@{nameof(Event.Slot)},
@{nameof(Event.Number)},
@{nameof(Event.PlateNumber)},
@{nameof(Event.EventType)},
@{nameof(Event.VehicleType)},
@{nameof(Event.Distance)},
@{nameof(Event.Speed)},
@{nameof(Event.TotalPassTime)},
@{nameof(Event.LimitTon)},
@{nameof(Event.Ton)},
@{nameof(Event.InTime)},
@{nameof(Event.AlarmTime)},
@{nameof(Event.OutTime)},
@{nameof(Event.LPRTime)},
@{nameof(Event.IMGPath1)},
@{nameof(Event.IMGPath2)},
@{nameof(Event.IMGPath3)},
@{nameof(Event.IMGPath4)},
@{nameof(Event.IMGPath5)},
@{nameof(Event.IMGPath6)},
@{nameof(Event.VideoPath1)},
@{nameof(Event.VideoPath2)},
@{nameof(Event.IsStay)},
@{nameof(Event.Unsure)},
@{nameof(Event.CheckPunish)},
@{nameof(Event.Punished)},
@{nameof(Event.CompanyCode)},
@{nameof(Event.Ps)},
@{nameof(Event.HandlingTime)},
@{nameof(Event.UploadTime)})";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool UpdateEvent(Event data)
{
var sql = $@"UPDATE {nameof(Event)}
SET {nameof(Event.SiteID)} = @{nameof(Event.SiteID)},
{nameof(Event.EventID)} = @{nameof(Event.EventID)},
{nameof(Event.Channel)} = @{nameof(Event.Channel)},
{nameof(Event.Slot)} = @{nameof(Event.Slot)},
{nameof(Event.Number)} = @{nameof(Event.Number)},
{nameof(Event.PlateNumber)} = @{nameof(Event.PlateNumber)},
{nameof(Event.EventType)} = @{nameof(Event.EventType)},
{nameof(Event.VehicleType)} = @{nameof(Event.VehicleType)},
{nameof(Event.Distance)} = @{nameof(Event.Distance)},
{nameof(Event.Speed)} = @{nameof(Event.Speed)},
{nameof(Event.TotalPassTime)} = @{nameof(Event.TotalPassTime)},
{nameof(Event.LimitTon)} = @{nameof(Event.LimitTon)},
{nameof(Event.Ton)} = @{nameof(Event.Ton)},
{nameof(Event.InTime)} = @{nameof(Event.InTime)},
{nameof(Event.AlarmTime)} = @{nameof(Event.AlarmTime)},
{nameof(Event.OutTime)} = @{nameof(Event.OutTime)},
{nameof(Event.LPRTime)} = @{nameof(Event.LPRTime)},
{nameof(Event.IMGPath1)} = @{nameof(Event.IMGPath1)},
{nameof(Event.IMGPath2)} = @{nameof(Event.IMGPath2)},
{nameof(Event.IMGPath3)} = @{nameof(Event.IMGPath3)},
{nameof(Event.IMGPath4)} = @{nameof(Event.IMGPath4)},
{nameof(Event.IMGPath5)} = @{nameof(Event.IMGPath5)},
{nameof(Event.IMGPath6)} = @{nameof(Event.IMGPath6)},
{nameof(Event.VideoPath1)} = @{nameof(Event.VideoPath1)},
{nameof(Event.VideoPath2)} = @{nameof(Event.VideoPath2)},
{nameof(Event.IsStay)} = @{nameof(Event.IsStay)},
{nameof(Event.Unsure)} = @{nameof(Event.Unsure)},
{nameof(Event.CheckPunish)} = @{nameof(Event.CheckPunish)},
{nameof(Event.Punished)} = @{nameof(Event.Punished)},
{nameof(Event.CompanyCode)} = @{nameof(Event.CompanyCode)},
{nameof(Event.Ps)} = @{nameof(Event.Ps)},
{nameof(Event.HandlingTime)} = @{nameof(Event.HandlingTime)},
{nameof(Event.UploadTime)} = @{nameof(Event.UploadTime)}
WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool UpdatEventCheckPunish(string account, int eventId, string checkPunish, string law)
{
var sql = $@"UPDATE {nameof(Event)}
SET {nameof(Event.CheckPunish)} = @{nameof(Event.CheckPunish)},
{nameof(Event.Ps)} = @law,
{nameof(Event.Account)} = @{nameof(Event.Account)}
WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, new { Id = eventId, account, checkPunish, law }, Transaction);
return result == 1;
}
public bool UpdatEventNoPunish(string account, int eventId, string ps)
{
var sql = $@"UPDATE {nameof(Event)}
SET {nameof(Event.Ps)} = @{nameof(Event.Ps)}, {nameof(Event.Account)} = @{nameof(Event.Account)}
WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, new { Id = eventId, Ps = ps, account }, Transaction);
return result == 1;
}
public bool UpdateEventVehicleType(int id, string vehicleType)
{
var sql = $@"UPDATE {nameof(Event)}
SET {nameof(Event.VehicleType)} = @{nameof(Event.VehicleType)}
WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, new { id, vehicleType }, Transaction);
return result == 1;
}
public bool UpdateEventVehicleNumber(int id, string vehicleNumber)
{
var sql = $@"UPDATE {nameof(Event)}
SET {nameof(Event.Number)} = @{nameof(Event.Number)}
WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, new { id, Number = vehicleNumber }, Transaction);
return result == 1;
}
public bool DeleteEvent(int id)
{
var sql = $@"DELETE FROM {nameof(Event)} WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
public bool UpdateEventVehicle(int id, string vehicleType, string vehicleNumber)
{
var sql = $@"UPDATE {nameof(Event)}
SET {nameof(Event.Number)} = @{nameof(Event.Number)},
{nameof(Event.VehicleType)} = @{nameof(Event.VehicleType)}
WHERE {nameof(Event.Id)} = @{nameof(Event.Id)}";
var result = Connection.Execute(sql, new { id, Number = vehicleNumber, vehicleType }, Transaction);
return result == 1;
}
public int GetEventJoinSiteAndUsersCount(int userId, string eventType, string startTime, string endTime)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,72 @@
using Dapper;
using System.Collections.Generic;
using System.Data;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository
{
public class EventTypeRepository : IEventTypeRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public EventTypeRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<EventTypeData> GetEventTypes()
{
var sql = $"SELECT * FROM EventType";
return Connection.Query<EventTypeData>(sql, null, Transaction);
}
public IEnumerable<EventTypeData> GetEventType1s()
{
var sql = $"SELECT * FROM EventType1";
return Connection.Query<EventTypeData>(sql, null, Transaction);
}
public EventTypeData GetEventTypeById(int id)
{
var sql = $"SELECT * FROM EventType Where {nameof(EventTypeData.Id)} = @{nameof(EventTypeData.Id)}";
return Connection.QueryFirstOrDefault<EventTypeData>(sql, new { id }, Transaction);
}
public EventTypeData GetEventTypeByEventType(string eventType)
{
var sql = $"SELECT * FROM EventType Where {nameof(EventTypeData.EventType)} = @{nameof(EventTypeData.EventType)}";
return Connection.QueryFirstOrDefault<EventTypeData>(sql, new { eventType }, Transaction);
}
public bool InsertEventType(EventTypeData company)
{
var sql = $@"INSERT INTO EventType (
{nameof(EventTypeData.EventType)},
{nameof(EventTypeData.EventName)})
VALUES(@{nameof(EventTypeData.EventType)},
@{nameof(EventTypeData.EventName)})";
var result = Connection.Execute(sql, company, Transaction);
return result == 1;
}
public bool UpdateEventType(EventTypeData company)
{
var sql = $@"UPDATE Eventtype
SET {nameof(EventTypeData.EventType)} = @{nameof(EventTypeData.EventType)},
{nameof(EventTypeData.EventName)} = @{nameof(EventTypeData.EventName)}
WHERE {nameof(EventTypeData.Id)} = @{nameof(EventTypeData.Id)}";
var result = Connection.Execute(sql, company, Transaction);
return result == 1;
}
public bool DeleteEventType(int id)
{
var sql = $@"DELETE FROM Eventtype WHERE {nameof(EventTypeData.Id)} = @{nameof(EventTypeData.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,44 @@
using Dapper;
using System.Collections.Generic;
using System.Data;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class MalfunctionRepository : IMalfunctionRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public MalfunctionRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<Malfunction> GetMalfunctions()
{
var sql = $@"SELECT m.siteID, m.companyCode, m.deviceType, m.deviceID, m.message, Max(m.timestamp) as timestamp
FROM malfunction as m group by m.companyCode, m.deviceType, m.deviceID ";
return Connection.Query<Malfunction>(sql, null, Transaction);
}
public IEnumerable<Malfunction> GetMalfunctions(int userid)
{
var sql = $@"SELECT us.userId, s.siteid, m.companyCode, m.deviceType, m.deviceID, m.message, Max(m.timestamp) as timestamp
FROM accountusersite as us
left join siteinformation as s on us.siteid = s.id
left join malfunction as m on s.siteid = m.siteID where us.userid = @userid group by us.userId,s.county,s.area, s.siteid, s.siteName, s.eventType, m.companyCode, m.deviceType, m.deviceID ";
return Connection.Query<Malfunction>(sql, new { userid }, Transaction);
}
public IEnumerable<Malfunction> GetMalfunctions(List<string> sitesId, string startTime, string endTime)
{
var sql = $@"SELECT s.siteid, s.siteName, m.*
FROM siteinformation as s
LEFT JOIN malfunction as m on s.siteid = m.siteID
WHERE s.siteid in @sitesId and m.timestamp >= @startTime and m.timestamp <= @endTime";
return Connection.Query<Malfunction>(sql, new { sitesId, startTime, endTime }, Transaction);
}
}
}

View File

@ -0,0 +1,67 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class NotPunishRepository : INotPunishRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public NotPunishRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<NotPunish> GetNotPunishs()
{
var sql = $"SELECT * FROM {nameof(NotPunish)}";
return Connection.Query<NotPunish>(sql, null, Transaction);
}
public NotPunish GetNotPunishById(int id)
{
var sql = $"SELECT * FROM {nameof(NotPunish)} Where {nameof(NotPunish.Id)} = @{nameof(NotPunish.Id)}";
return Connection.QueryFirstOrDefault<NotPunish>(sql, new { id }, Transaction);
}
public bool InsertNotPunish(NotPunish data)
{
var sql = $@"INSERT INTO {nameof(NotPunish)} (
{nameof(NotPunish.EventTypeId)},
{nameof(NotPunish.NotPunishType)},
{nameof(NotPunish.NotPunishReason)})
VALUES(@{nameof(NotPunish.EventTypeId)},
@{nameof(NotPunish.NotPunishType)},
@{nameof(NotPunish.NotPunishReason)})";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool UpdateNotPunish(NotPunish data)
{
var sql = $@"UPDATE {nameof(NotPunish)}
SET {nameof(NotPunish.EventTypeId)} = @{nameof(NotPunish.EventTypeId)},
{nameof(NotPunish.NotPunishType)} = @{nameof(NotPunish.NotPunishType)},
{nameof(NotPunish.NotPunishReason)} = @{nameof(NotPunish.NotPunishReason)}
WHERE {nameof(NotPunish.Id)} = @{nameof(NotPunish.Id)}";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool DeleteNotPunish(int id)
{
var sql = $@"DELETE FROM {nameof(NotPunish)} WHERE {nameof(NotPunish.Id)} = @{nameof(NotPunish.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,64 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class PoliceStationRepository : IPoliceStationRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public PoliceStationRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<PoliceStation> GetPoliceStations()
{
var sql = $"SELECT * FROM {nameof(PoliceStation)}";
return Connection.Query<PoliceStation>(sql, null, Transaction);
}
public PoliceStation GetPoliceStationById(int id)
{
var sql = $"SELECT * FROM {nameof(PoliceStation)} Where {nameof(PoliceStation.Id)} = @{nameof(PoliceStation.Id)}";
return Connection.QueryFirstOrDefault<PoliceStation>(sql, new { id }, Transaction);
}
public bool InsertPoliceStation(PoliceStation station)
{
var sql = $@"INSERT INTO {nameof(PoliceStation)} (
{nameof(PoliceStation.Area)},
{nameof(PoliceStation.StationName)})
VALUES(@{nameof(PoliceStation.Area)},
@{nameof(PoliceStation.StationName)})";
var result = Connection.Execute(sql, station, Transaction);
return result == 1;
}
public bool UpdatePoliceStation(PoliceStation station)
{
var sql = $@"UPDATE {nameof(PoliceStation)}
SET {nameof(PoliceStation.Area)} = @{nameof(PoliceStation.Area)},
{nameof(PoliceStation.StationName)} = @{nameof(PoliceStation.StationName)}
WHERE {nameof(PoliceStation.Id)} = @{nameof(PoliceStation.Id)}";
var result = Connection.Execute(sql, station, Transaction);
return result == 1;
}
public bool DeletePoliceStation(int id)
{
var sql = $@"DELETE FROM {nameof(PoliceStation)} WHERE {nameof(PoliceStation.Id)} = @{nameof(PoliceStation.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,70 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class RepairRepository : IRepairRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public RepairRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<Repair> GetRepairs()
{
var sql = $"SELECT * FROM {nameof(Repair)}";
return Connection.Query<Repair>(sql, null, Transaction);
}
public Repair GetRepairById(int id)
{
var sql = $"SELECT * FROM {nameof(Repair)} Where {nameof(Repair.Id)} = @{nameof(Repair.Id)}";
return Connection.QueryFirstOrDefault<Repair>(sql, new { id }, Transaction);
}
public bool InsertRepair(Repair data)
{
var sql = $@"INSERT INTO {nameof(Repair)} (
{nameof(Repair.QuestionType)},
{nameof(Repair.SendTo)},
{nameof(Repair.Title)},
{nameof(Repair.Content)})
VALUES(@{nameof(Repair.QuestionType)},
@{nameof(Repair.SendTo)},
@{nameof(Repair.Title)},
@{nameof(Repair.Content)})";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool UpdateRepair(Repair data)
{
var sql = $@"UPDATE {nameof(Repair)}
SET {nameof(Repair.QuestionType)} = @{nameof(Repair.QuestionType)},
{nameof(Repair.SendTo)} = @{nameof(Repair.SendTo)},
{nameof(Repair.Title)} = @{nameof(Repair.Title)},
{nameof(Repair.Content)} = @{nameof(Repair.Content)}
WHERE {nameof(Repair.Id)} = @{nameof(Repair.Id)}";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool DeleteRepair(int id)
{
var sql = $@"DELETE FROM {nameof(Repair)} WHERE {nameof(Repair.Id)} = @{nameof(Repair.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,144 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class RolePageRepository : IRolePageRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public RolePageRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<RolePage> GetRolePages()
{
var sql = $"SELECT * FROM {nameof(RolePage)}";
return Connection.Query<RolePage>(sql, null, Transaction);
}
public IEnumerable<RolePage> GetRolePageByRoleId(int RoleId)
{
var sql = $"SELECT * FROM {nameof(RolePage)} Where {nameof(RolePage.RoleId)} = @{nameof(RolePage.RoleId)}";
return Connection.Query<RolePage>(sql, new { RoleId }, Transaction);
}
public bool InsertRolePage(List<RolePage> RoleId)
{
var sql = $@"INSERT INTO {nameof(RolePage)} (
{nameof(RolePage.RoleId)},
{nameof(RolePage.PageId)})
VALUES(@{nameof(RolePage.RoleId)},
@{nameof(RolePage.PageId)})";
var result = Connection.Execute(sql, RoleId, Transaction);
return result == 1;
}
public bool InsertRolePage(RolePage RoleId)
{
var sql = $@"INSERT INTO {nameof(RolePage)} (
{nameof(RolePage.RoleId)},
{nameof(RolePage.PageId)})
VALUES(@{nameof(RolePage.RoleId)},
@{nameof(RolePage.PageId)})";
var result = Connection.Execute(sql, RoleId, Transaction);
return result == 1;
}
public bool UpdateRolePage(RolePage RoleId)
{
var sql = $@"UPDATE {nameof(RolePage)}
SET {nameof(RolePage.RoleId)} = @{nameof(RolePage.RoleId)},
{nameof(RolePage.PageId)} = @{nameof(RolePage.PageId)}
WHERE {nameof(RolePage.Id)} = @{nameof(RolePage.Id)}";
var result = Connection.Execute(sql, RoleId, Transaction);
return result == 1;
}
public bool DeleteRolePage(int id)
{
var sql = $@"DELETE FROM {nameof(RolePage)} WHERE {nameof(RolePage.Id)} = @{nameof(RolePage.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
public IEnumerable<JoinRolePageInfo> GetRolePermissionInfo(int? roleid)
{
var sql = $@"SELECT r.roleid as roleId, ar.RoleName , p.id as pageid, p.pagename
FROM traffic.pagelist as p
LEFT JOIN traffic.rolepage as r on r.pageid = p.id
LEFT JOIN traffic.accountrole as ar on ar.id = r.roleId ";
return Connection.Query<JoinRolePageInfo>(sql, new { roleid }, Transaction);
}
public IEnumerable<JoinRolePageList> GetRolePageLists(int roleid)
{
var sql = $@"SELECT r.roleid as roleId, p.id as pageid, p.pagemodule, p.pagename, p.pageurl
FROM traffic.pagelist as p
LEFT JOIN traffic.rolepage as r on r.pageid = p.id
WHERE roleid = @roleid";
return Connection.Query<JoinRolePageList>(sql, new { roleid }, Transaction);
}
public IEnumerable<PageList> GetPageLists()
{
var sql = $"SELECT * FROM {nameof(PageList)}";
return Connection.Query<PageList>(sql, null, Transaction);
}
public PageList GetPageListById(int id)
{
var sql = $"SELECT * FROM {nameof(PageList)} Where {nameof(PageList.Id)} = @{nameof(PageList.Id)}";
return Connection.QueryFirstOrDefault<PageList>(sql, new { id }, Transaction);
}
public bool InsertPageList(PageList company)
{
var sql = $@"INSERT INTO {nameof(PageList)} (
{nameof(PageList.PageName)},
{nameof(PageList.PageModule)},
{nameof(PageList.PageURL)})
VALUES(@{nameof(PageList.PageName)},
@{nameof(PageList.PageModule)},
@{nameof(PageList.PageURL)})";
var result = Connection.Execute(sql, company, Transaction);
return result == 1;
}
public bool UpdatePageList(PageList company)
{
var sql = $@"UPDATE {nameof(PageList)}
SET {nameof(PageList.PageName)} = @{nameof(PageList.PageName)},
{nameof(PageList.PageModule)} = @{nameof(PageList.PageModule)},
{nameof(PageList.PageURL)} = @{nameof(PageList.PageURL)}
WHERE {nameof(PageList.Id)} = @{nameof(PageList.Id)}";
var result = Connection.Execute(sql, company, Transaction);
return result == 1;
}
public bool DeletePageList(int id)
{
var sql = $@"DELETE FROM {nameof(PageList)} WHERE {nameof(PageList.Id)} = @{nameof(PageList.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,114 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class SiteInformationRepository : ISiteInformationRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public SiteInformationRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<SiteInformation> GetSiteInformations()
{
var sql = $"SELECT * FROM {nameof(SiteInformation)}";
return Connection.Query<SiteInformation>(sql, null, Transaction);
}
public IEnumerable<SiteInformation> GetSiteInformations(List<string> eventTypes)
{
var sql = $"SELECT * FROM {nameof(SiteInformation)} where eventType in @eventTypes";
return Connection.Query<SiteInformation>(sql, new { eventTypes }, Transaction);
}
public SiteInformation GetSiteInformationById(int id)
{
var sql = $"SELECT * FROM {nameof(SiteInformation)} Where {nameof(SiteInformation.Id)} = @{nameof(SiteInformation.Id)}";
return Connection.QueryFirstOrDefault<SiteInformation>(sql, new { id }, Transaction);
}
public SiteInformation GetSiteInformationBySiteId(string siteId)
{
var sql = $"SELECT * FROM {nameof(SiteInformation)} Where {nameof(SiteInformation.SiteID)} = @{nameof(SiteInformation.SiteID)}";
return Connection.QueryFirstOrDefault<SiteInformation>(sql, new { siteId }, Transaction);
}
public bool InsertSiteInformation(SiteInformation data)
{
var sql = $@"INSERT INTO {nameof(SiteInformation)} (
{nameof(SiteInformation.County)},
{nameof(SiteInformation.Area)},
{nameof(SiteInformation.SiteID)},
{nameof(SiteInformation.SiteName)},
{nameof(SiteInformation.EventType)},
{nameof(SiteInformation.Ip)},
{nameof(SiteInformation.DbName)},
{nameof(SiteInformation.TableName)},
{nameof(SiteInformation.User)},
{nameof(SiteInformation.Password)},
{nameof(SiteInformation.FinalRecord)},
{nameof(SiteInformation.ARHFinalRecord)},
{nameof(SiteInformation.CompanyCode)},
{nameof(SiteInformation.Laws)})
VALUES(@{nameof(SiteInformation.County)},
@{nameof(SiteInformation.Area)},
@{nameof(SiteInformation.SiteID)},
@{nameof(SiteInformation.SiteName)},
@{nameof(SiteInformation.EventType)},
@{nameof(SiteInformation.Ip)},
@{nameof(SiteInformation.DbName)},
@{nameof(SiteInformation.TableName)},
@{nameof(SiteInformation.User)},
@{nameof(SiteInformation.Password)},
@{nameof(SiteInformation.FinalRecord)},
@{nameof(SiteInformation.ARHFinalRecord)},
@{nameof(SiteInformation.CompanyCode)},
@{nameof(SiteInformation.Laws)})";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool UpdateSiteInformation(SiteInformation data)
{
var sql = $@"UPDATE {nameof(SiteInformation)}
SET {nameof(SiteInformation.County)} = @{nameof(SiteInformation.County)},
{nameof(SiteInformation.Area)} = @{nameof(SiteInformation.Area)},
{nameof(SiteInformation.SiteID)} = @{nameof(SiteInformation.SiteID)},
{nameof(SiteInformation.SiteName)} = @{nameof(SiteInformation.SiteName)},
{nameof(SiteInformation.EventType)} = @{nameof(SiteInformation.EventType)},
{nameof(SiteInformation.Ip)} = @{nameof(SiteInformation.Ip)},
{nameof(SiteInformation.DbName)} = @{nameof(SiteInformation.DbName)},
{nameof(SiteInformation.TableName)} = @{nameof(SiteInformation.TableName)},
{nameof(SiteInformation.User)} = @{nameof(SiteInformation.User)},
{nameof(SiteInformation.Password)} = @{nameof(SiteInformation.Password)},
{nameof(SiteInformation.FinalRecord)} = @{nameof(SiteInformation.FinalRecord)},
{nameof(SiteInformation.Target)} = @{nameof(SiteInformation.Target)},
{nameof(SiteInformation.ClusterHead)} = @{nameof(SiteInformation.ClusterHead)},
{nameof(SiteInformation.ARHFinalRecord)} = @{nameof(SiteInformation.ARHFinalRecord)},
{nameof(SiteInformation.CompanyCode)} = @{nameof(SiteInformation.CompanyCode)},
{nameof(SiteInformation.Laws)} = @{nameof(SiteInformation.Laws)}
WHERE {nameof(SiteInformation.Id)} = @{nameof(SiteInformation.Id)}";
var result = Connection.Execute(sql, data, Transaction);
return result == 1;
}
public bool DeleteSiteInformation(int id)
{
var sql = $@"DELETE FROM {nameof(SiteInformation)} WHERE {nameof(SiteInformation.Id)} = @{nameof(SiteInformation.Id)}";
var result = Connection.Execute(sql, new { id }, Transaction);
return result == 1;
}
}
}

View File

@ -0,0 +1,64 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traffic.Data.Models;
using Traffic.Repository.Interfaces;
namespace Traffic.Repository.Implements
{
public class TycgRepository : ITycgRepository
{
public IDbTransaction Transaction { get; }
public IDbConnection Connection => Transaction.Connection;
public TycgRepository(IDbTransaction transaction)
{
Transaction = transaction;
}
public IEnumerable<Tycg> GetTycgs(string tableName)
{
var sql = string.Empty;
switch (tableName.ToLower().Trim())
{
case "tycg_logases":
sql = $"SELECT * FROM tycg_logases order by timestamp desc";
break;
case "tycg_logbigcarviolation":
sql = $"SELECT * FROM tycg_logbigcarviolation order by timestamp desc";
break;
case "tycg_logchecked":
sql = $"SELECT * FROM tycg_logchecked order by timestamp desc";
break;
case "tycg_logcrossroad":
sql = $"SELECT * FROM tycg_logcrossroad order by timestamp desc";
break;
case "tycg_logmalfunctionhttp":
sql = $"SELECT * FROM tycg_logmalfunctionhttp order by timestamp desc";
break;
case "tycg_logrejected":
sql = $"SELECT * FROM tycg_logrejected order by timestamp desc";
break;
case "tycg_logtraffichttp":
sql = $"SELECT * FROM tycg_logtraffichttp order by timestamp desc";
break;
case "tycg_loguploaded":
sql = $"SELECT * FROM tycg_loguploaded order by timestamp desc";
break;
default:
break;
}
return Connection.Query<Tycg>(sql, null, Transaction);
}
public IEnumerable<Log_Mapping> GetTycgsTableName()
{
var sql = $"SELECT * FROM {nameof(Log_Mapping)}";
return Connection.Query<Log_Mapping>(sql, null, Transaction);
}
}
}

Some files were not shown because too many files have changed in this diff Show More