Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f3562fb73 | ||
|
|
bc977af15c | ||
|
|
6be6bc533c | ||
|
|
864c76f827 | ||
|
|
8208b31d08 | ||
|
|
4f149f4eef | ||
|
|
8ce7268338 | ||
|
|
d42900e8f6 | ||
|
|
25cd092a08 | ||
|
|
e5dd9aad27 | ||
|
|
d1ad7e76c3 | ||
|
|
5e94586a75 | ||
|
|
d775ae82a0 | ||
|
|
e6b53d193c | ||
|
|
400a459479 | ||
|
|
ac74ef9cfc | ||
|
|
4c7d71a404 | ||
|
|
75d8119880 | ||
|
|
ff9d6ae361 | ||
|
|
6839fc0b78 | ||
|
|
11aea1eb5d | ||
|
|
fb58bfcde0 | ||
|
|
7be3a5c58a | ||
|
|
d3e63404a2 | ||
|
|
cd0b1da85b | ||
|
|
dc12fe8709 | ||
|
|
92dcb645db | ||
|
|
0d83e30cd2 | ||
|
|
2318269f99 | ||
|
|
84f161585a | ||
|
|
05259a09ee | ||
|
|
98442dfe90 | ||
|
|
e745f313a8 | ||
|
|
254ab86d03 | ||
|
|
4c25dd2105 | ||
|
|
da92dc45b6 | ||
|
|
e8f7ee7e36 | ||
|
|
1f4fce1e42 | ||
|
|
b6ffcca996 | ||
|
|
73a4b9a445 | ||
|
|
9df2854a3c | ||
|
|
7efd090b86 | ||
|
|
0a36544dce | ||
|
|
699110af10 | ||
|
|
272bd1a3fd | ||
|
|
9ffbcd87f2 | ||
|
|
2fae17fed4 | ||
|
|
4025224821 | ||
|
|
89c330aa0d | ||
|
|
c028b78f1c | ||
|
|
a324f5f852 | ||
|
|
62419a2c28 | ||
|
|
1294a00219 | ||
|
|
0de851f7d9 | ||
|
|
f80029bd07 | ||
|
|
a8b4aa7b22 | ||
|
|
4b674d67ab | ||
|
|
f6e21418b6 | ||
|
|
bb8d866778 | ||
|
|
3c394f632d | ||
|
|
cba9181a2d | ||
|
|
dbc2f30a27 | ||
|
|
2798aeaf0d | ||
|
|
bce3c9e401 | ||
|
|
5acf9ff954 | ||
|
|
a1d683b955 | ||
|
|
335f00367d | ||
|
|
8815df06b3 | ||
|
|
ab86c845ab | ||
|
|
e151590860 | ||
|
|
4dbda1aac3 | ||
|
|
c51ee750f9 | ||
|
|
50dcf3aff6 | ||
|
|
ae7257a3ff | ||
|
|
9c179feeca | ||
|
|
380b6ac030 | ||
|
|
ca71bd2194 | ||
|
|
b0a4da67d0 | ||
|
|
8dc902d2fb | ||
|
|
0811111865 | ||
|
|
29200ae418 | ||
|
|
44e6719c3d | ||
|
|
5c5a852ead | ||
|
|
70dd745889 | ||
|
|
fad1398668 | ||
|
|
7a757e84b2 | ||
|
|
6d276e73b8 | ||
|
|
9d107e8c0b | ||
|
|
aca0a86a6a | ||
|
|
d5a7895efa | ||
|
|
623a3c49b1 | ||
|
|
5356ef7424 | ||
|
|
1ea8e4fbe7 | ||
|
|
13b9d943b9 | ||
|
|
06f5a5dd62 | ||
|
|
cd57fc46bc | ||
|
|
7109da0d95 | ||
|
|
6137baff72 | ||
|
|
621d61e08e | ||
|
|
02cef1bf23 | ||
|
|
e3ee93c74c | ||
|
|
d383ccccbd | ||
|
|
4eaffbcc4f | ||
|
|
a201e2028e | ||
|
|
7720f4944a | ||
|
|
a394c643a2 | ||
|
|
ac48e676df | ||
|
|
d21ff69cc8 | ||
|
|
b5d4a163fd | ||
|
|
cdaceb1961 | ||
|
|
2dbcbd1ed8 | ||
|
|
c8b8f6ae92 | ||
|
|
b02fb58f2e | ||
|
|
85976547f6 | ||
|
|
a3be387ee1 | ||
|
|
e306139aec | ||
|
|
2513765e51 | ||
|
|
3366884965 | ||
|
|
a64304a05f | ||
|
|
66744e0526 | ||
|
|
dc3e6e2f7b | ||
|
|
71a5850d65 | ||
|
|
33232bae75 | ||
|
|
8dc13c702c | ||
|
|
4951fc0c7a | ||
|
|
429ccd2d70 | ||
|
|
abc90dcec1 | ||
|
|
476c9ead4c | ||
|
|
5b1f7fb642 | ||
|
|
de8b95eda1 | ||
|
|
fa48365d98 | ||
|
|
d5e11bc2e4 | ||
|
|
a97c944f12 | ||
|
|
92c15072b8 | ||
|
|
001c59a669 | ||
|
|
90637b3848 | ||
|
|
12bf69aadd | ||
|
|
fe7b52efde | ||
|
|
c7a3a608ba | ||
|
|
c3fda85182 | ||
|
|
ea305ebbf4 | ||
|
|
5207f32712 | ||
|
|
61dd5bc9a1 | ||
|
|
a7e913b3ee | ||
|
|
7996f887ba | ||
|
|
56f17681be | ||
|
|
d7c198acfa | ||
|
|
8566889cf9 | ||
|
|
ce432e1ab0 | ||
|
|
146402a96a | ||
|
|
66cf378556 | ||
|
|
d3bfeadc50 | ||
|
|
77796f3247 | ||
|
|
728b6a8a9e | ||
|
|
b69f9af6f3 | ||
|
|
148ea094ce | ||
|
|
ddc898cc2e | ||
|
|
f119b196ea | ||
|
|
04cca012f4 | ||
|
|
cb38e869a1 | ||
|
|
83980667d7 | ||
|
|
ace4130f31 | ||
|
|
2341b186ef | ||
|
|
ab1de236be | ||
|
|
3d44804bad | ||
|
|
8f38408646 | ||
|
|
29d94c9256 | ||
|
|
ebe33abf69 | ||
|
|
50a7eb5521 | ||
|
|
d55dee91e9 | ||
|
|
3a4db4dd14 | ||
|
|
6d78762275 | ||
|
|
15e6aac88c | ||
|
|
2a5ad1d1c1 | ||
|
|
3b7fd07dda | ||
|
|
efecf55dd8 | ||
|
|
6dcc4989ac | ||
|
|
b48b8dbb6c | ||
|
|
ae7ba2342e | ||
|
|
bd60138a89 | ||
|
|
7a158ed10d | ||
|
|
2e335e7b8a | ||
|
|
63b9beef35 | ||
|
|
f74922d01e | ||
|
|
2fd147bb36 | ||
|
|
9297ff3970 | ||
|
|
8c1966ef4c | ||
|
|
5097757cfb | ||
|
|
f83765378c | ||
|
|
b8fcdd5c3d | ||
|
|
8c1e60889d | ||
|
|
0e06382eee | ||
|
|
9d113d0b49 | ||
|
|
8793a1c77c | ||
|
|
2d13b0909e | ||
|
|
9f1c3df5d6 | ||
|
|
a72c9b342e | ||
|
|
50b14e8122 | ||
|
|
7f01ca243a | ||
|
|
07f617df87 | ||
|
|
52ac278316 | ||
|
|
9d0a577c1f | ||
|
|
ca789cfbc3 | ||
|
|
323af1e600 | ||
|
|
e0bca55fc2 | ||
|
|
d2106514ba | ||
|
|
a301a2a168 | ||
|
|
f5a6041a1c | ||
|
|
3091faa94c | ||
|
|
7c1d89d783 | ||
|
|
439d8cafd5 | ||
|
|
c9ffad0d91 | ||
|
|
29e6efc9e0 | ||
|
|
da27f7e882 | ||
|
|
3071ac7080 | ||
|
|
8f9e5df847 | ||
|
|
e5b1649c42 | ||
|
|
48b5fb5090 | ||
|
|
ff33a59e5c | ||
|
|
399ff8f88f | ||
|
|
cb6e627fea | ||
|
|
3be8a597d0 | ||
|
|
1ee1e8fa32 | ||
|
|
762eb19af2 | ||
|
|
943e2a716d | ||
|
|
af607f6079 | ||
|
|
62dee24619 | ||
|
|
1e9fdf7ea5 | ||
|
|
2ad8ba2d51 | ||
|
|
d4bad04103 | ||
|
|
499daa0e17 | ||
|
|
dca4f3ba73 | ||
|
|
c7784e7fef | ||
|
|
883ae6b845 | ||
|
|
5512120306 | ||
|
|
1ac31d7d76 | ||
|
|
5396fc0dcb | ||
|
|
f3ef12ccc4 | ||
|
|
bf97db26e5 | ||
|
|
5aae8fd067 | ||
|
|
790f92a940 | ||
|
|
2ae985c6e0 | ||
|
|
2f0b9e1452 | ||
|
|
872e7b3a4f | ||
|
|
f400bbf3c8 | ||
|
|
f57fef804d | ||
|
|
ac80a8a9bb | ||
|
|
b233347a7d | ||
|
|
b5e5158f1e | ||
|
|
7570908177 | ||
|
|
4570c071a7 | ||
|
|
aaa5862c80 | ||
|
|
8d5bdc2c37 | ||
|
|
01f16c616a | ||
|
|
9175f1ec76 | ||
|
|
d5cbeea8f4 | ||
|
|
ad14623749 | ||
|
|
3669267898 | ||
|
|
e74df61ca0 | ||
|
|
0d44cd48fb | ||
|
|
862f0a148b | ||
|
|
177aa668a6 | ||
|
|
30d82fc9bf | ||
|
|
3b11c6adc5 | ||
|
|
6a46975cfd | ||
|
|
a2906cc113 | ||
|
|
474dce1aa7 | ||
|
|
92801fefb9 | ||
|
|
a80870b5c3 | ||
|
|
8bbcbfab09 |
@@ -339,3 +339,8 @@ ASALocalRun/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
/src/WorkFlowCheck.API/Images
|
||||
*.pdf
|
||||
/src/WorkFlowCheck.API/Pdf/c86f3a6a-c646-4627-823c-7e24134b7725.docx
|
||||
/src/WorkFlowCheck.API/Downloads/APK/com.nuvolar.wfcapp-Signed.apk
|
||||
/src/WorkFlowCheck.API/Pdf/3b9fd83a-dce8-4427-813b-9475726700be.docx
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
echo off
|
||||
echo "dotnet ef migrations add InitialCreate --project WorkFlowCheck.DL --startup-project WorkFlowCheck.API"
|
||||
echo "dotnet ef database update --project WorkFlowCheck.DL --startup-project WorkFlowCheck.API"
|
||||
echo "dotnet ef migrations remove --project WorkFlowCheck.DL --startup-project WorkFlowCheck.API"
|
||||
pause
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!--Work around so the conditions work below-->
|
||||
<TargetFrameworks>netstandard1.0;netstandard2.0;Xamarin.iOS10;MonoAndroid10.0;net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
|
||||
<!--<TargetFrameworks>netstandard1.0;netstandard2.0;Xamarin.iOS10;MonoAndroid10.0;net8.0;net8.0-android;net8.0-ios</TargetFrameworks>-->
|
||||
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
|
||||
|
||||
<AssemblyName>Plugin.NFC</AssemblyName>
|
||||
<RootNamespace>Plugin.NFC</RootNamespace>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35527.113
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.API", "WorkFlowCheck.API\WorkFlowCheck.API.csproj", "{2466E04A-CB0C-4421-9074-A928F819926C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.DL", "WorkFlowCheck.DL\WorkFlowCheck.DL.csproj", "{25A8C0E7-18C7-4672-ABE8-29596E7E9B72}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.BL", "WorkFlowCheck.BL\WorkFlowCheck.BL.csproj", "{73049F81-7A5D-4819-ADB8-A9926672365E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.Common", "WorkFlowCheck.Common\WorkFlowCheck.Common.csproj", "{7F94D6CB-3358-4687-88E1-FA46053D6B71}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlowCheck.Web", "WorkFlowCheck.Web\WorkFlowCheck.Web.csproj", "{B4D9960A-9BCF-41DA-9103-5DABA8D2623F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2466E04A-CB0C-4421-9074-A928F819926C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2466E04A-CB0C-4421-9074-A928F819926C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2466E04A-CB0C-4421-9074-A928F819926C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2466E04A-CB0C-4421-9074-A928F819926C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{25A8C0E7-18C7-4672-ABE8-29596E7E9B72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{25A8C0E7-18C7-4672-ABE8-29596E7E9B72}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{25A8C0E7-18C7-4672-ABE8-29596E7E9B72}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{25A8C0E7-18C7-4672-ABE8-29596E7E9B72}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{73049F81-7A5D-4819-ADB8-A9926672365E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{73049F81-7A5D-4819-ADB8-A9926672365E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{73049F81-7A5D-4819-ADB8-A9926672365E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{73049F81-7A5D-4819-ADB8-A9926672365E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7F94D6CB-3358-4687-88E1-FA46053D6B71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7F94D6CB-3358-4687-88E1-FA46053D6B71}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7F94D6CB-3358-4687-88E1-FA46053D6B71}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7F94D6CB-3358-4687-88E1-FA46053D6B71}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B4D9960A-9BCF-41DA-9103-5DABA8D2623F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B4D9960A-9BCF-41DA-9103-5DABA8D2623F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B4D9960A-9BCF-41DA-9103-5DABA8D2623F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B4D9960A-9BCF-41DA-9103-5DABA8D2623F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "9.0.0",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.BL.Services;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.API.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class CheckListController : ControllerBase
|
||||
{
|
||||
private ICheckListService _checkListService;
|
||||
public CheckListController(ICheckListService checkListService)
|
||||
{
|
||||
_checkListService = checkListService;
|
||||
}
|
||||
|
||||
[HttpGet("GetCheckListHeader/{id}")]
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> GetCheckListHeader(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkListHeaderDTO = await _checkListService.GetCheckListHeaderAsync(id);
|
||||
|
||||
if (checkListHeaderDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListHeaderDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("CreatePDF/{id}")]
|
||||
public async Task<ApiResponseDTO<byte[]>> CreatePDF(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkListHeader = await _checkListService.GetCheckListHeaderAsync(id);
|
||||
var response = await _checkListService.CreateCheckListHeaderPDFAsync(id);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllCheckListHeaders")]
|
||||
public async Task<ApiResponseDTO<List<CheckListHeaderDTO>>> GetAllCheckListHeadersAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckListHeaderDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkPointListDTO = await _checkListService.GetAllCheckListHeaderAsync();
|
||||
|
||||
if (checkPointListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkPointListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateCheckListHeader")]
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader([FromBody] CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _checkListService.UpdateCheckListHeaderAsync(checkListHeaderDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("StartNewCheckList")]
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> StartNew([FromBody] CheckListHeaderNewDTO checkListHeaderNewDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var response = await _checkListService.StartNewCheckListAsync(checkListHeaderNewDTO);
|
||||
if (response != null)
|
||||
{
|
||||
retVal.Data = response;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("CloseCheckListHeader")]
|
||||
public async Task<ApiResponseDTO<bool>> CloseCheckListHeader([FromBody] CheckListHeaderCloseDTO checkListHeaderCloseDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>() { IsSuccess = false };
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _checkListService.CloseCheckListHeader(checkListHeaderCloseDTO);
|
||||
retVal.Data = result;
|
||||
retVal.IsSuccess = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("AcceptCheckListHeader/{id}/{userId}")]
|
||||
public async Task<ApiResponseDTO<bool>> AcceptCheckListHeader(int id, int userId)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool> { IsSuccess = false };
|
||||
|
||||
var response = await _checkListService.AcceptCheckListHeaderAsync(id, userId);
|
||||
|
||||
if (response)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("BlockCheckListHeader/{id}/{userId}")]
|
||||
public async Task<ApiResponseDTO<bool>> BlockCheckListHeader(int id, int userId)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool> { IsSuccess = false };
|
||||
|
||||
var response = await _checkListService.BlockCheckListHeaderAsync(id, userId);
|
||||
|
||||
if (response)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("UnBlockCheckListHeader/{id}/{userId}")]
|
||||
public async Task<ApiResponseDTO<bool>> UnBlockCheckListHeader(int id, int userId)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool> { IsSuccess = false };
|
||||
|
||||
var response = await _checkListService.UnBlockCheckListHeaderAsync(id, userId);
|
||||
|
||||
if (response)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetCheckListTemplateHeader/{id}")]
|
||||
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> GetCheckListTemplateHeader(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListTemplateHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeaderAsync(id);
|
||||
|
||||
if (CheckListTemplateHeaderDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = CheckListTemplateHeaderDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllCheckListTemplateHeaders")]
|
||||
public async Task<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>> GetAllCheckListTemplateHeadersAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckListTemplateHeaderDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkPointListDTO = await _checkListService.GetAllCheckListTemplateHeaderAsync();
|
||||
|
||||
if (checkPointListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkPointListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateCheckListTemplateHeader")]
|
||||
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader([FromBody] CheckListTemplateHeaderDTO CheckListTemplateHeaderDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListTemplateHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _checkListService.UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteCheckListTemplateHeader/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteCheckListTemplateHeader(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _checkListService.DeleteCheckListTemplateHeaderAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("CloneCheckListTemplateHeader/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> CloneCheckListTemplateHeader(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _checkListService.CloneCheckListTemplateHeaderAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetCheckListTemplateRow/{id}")]
|
||||
public async Task<ApiResponseDTO<CheckListTemplateRowDTO>> GetCheckListTemplateRow(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListTemplateRowDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkListTemplateRowDTO = await _checkListService.GetCheckListTemplateRowAsync(id);
|
||||
|
||||
if (checkListTemplateRowDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListTemplateRowDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteCheckListTemplateRow/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteCheckListTemplateRow(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _checkListService.DeleteCheckListTemplateRowAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateCheckListTemplateRow")]
|
||||
public async Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow([FromBody] CheckListTemplateRowDTO CheckListTemplateRowDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListTemplateRowDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _checkListService.UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetCheckListRow/{id}")]
|
||||
public async Task<ApiResponseDTO<CheckListRowDTO>> GetCheckListRow(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListRowDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkListRowDTO = await _checkListService.GetCheckListRowAsync(id);
|
||||
|
||||
if (checkListRowDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListRowDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateCheckListRow")]
|
||||
public async Task<ApiResponseDTO<CheckListRowDTO>> UpdateCheckListRow([FromBody] CheckListRowDTO CheckListRowDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckListRowDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _checkListService.UpdateCheckListRowAsync(CheckListRowDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.API.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class FCMController : ControllerBase
|
||||
{
|
||||
private readonly IMessageService _messageService;
|
||||
public FCMController(IMessageService messageService)
|
||||
{
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
[HttpPost("SendFCMMessage")]
|
||||
public async Task<ApiResponseDTO<bool>> SendFCMMessage([FromBody] FCMMessageDTO fCMMessageDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
retVal.IsSuccess = await _messageService.SendFCMMessage(fCMMessageDTO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpPost("SendFCMMessageToLastToken")]
|
||||
public async Task<ApiResponseDTO<bool>> SendFCMMessageToLastToken([FromBody] FCMMessageDTO fCMMessageDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
retVal.IsSuccess = await _messageService.SendFCMMessageToLastToken(fCMMessageDTO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpPost("SendFCMToken")]
|
||||
public async Task<ApiResponseDTO<bool>> SendFCMToken([FromBody] FCMMessageDTO fCMMessageDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
await _messageService.SendFCMTokenAsync(fCMMessageDTO.Token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,610 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Serilog;
|
||||
using System.Text;
|
||||
using WorkFlowCheck.BL.Services;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.API.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class SyncController : ControllerBase
|
||||
{
|
||||
private ISyncService _syncService;
|
||||
private INumberGeneratorService _numberGeneratorService;
|
||||
private IMessageService _messageService;
|
||||
private IUserService _userService;
|
||||
|
||||
|
||||
public SyncController(ISyncService syncService,
|
||||
INumberGeneratorService numberGeneratorService,
|
||||
IUserService userService,
|
||||
IMessageService messageService)
|
||||
{
|
||||
_syncService = syncService;
|
||||
_numberGeneratorService = numberGeneratorService;
|
||||
_messageService = messageService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetCheckPoint/{id}")]
|
||||
public async Task<ApiResponseDTO<CheckPointDTO>> GetCheckpointAsync(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkPointDTO = await _syncService.GetCheckPointAsync(id);
|
||||
|
||||
if (checkPointDTO != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkPointDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteCheckPoint/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteCheckpointAsync(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var response = await _syncService.DeleteCheckPointAsync(id);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllCheckPoints")]
|
||||
public async Task<ApiResponseDTO<List<CheckPointDTO>>> GetAllCheckpointsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckPointDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var checkPointListDTO = await _syncService.GetAllCheckPointAsync();
|
||||
|
||||
if (checkPointListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkPointListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateCheckPoint")]
|
||||
public async Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint([FromBody] CheckPointDTO checkPointDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _syncService.UpdateCheckPointAsync(checkPointDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateAllCheckPoint")]
|
||||
public async Task<ApiResponseDTO<List<CheckPointDTO>>> UpdateAllCheckPoint([FromBody] List<CheckPointDTO> checkPointListDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckPointDTO>>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _syncService.UpdateAllCheckPointAsync(checkPointListDTO);
|
||||
retVal.Data = result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetEquipment/{id}")]
|
||||
public async Task<ApiResponseDTO<EquipmentDTO>> GetEquipmentAsync(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<EquipmentDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var equipmentDTO = await _syncService.GetEquipmentAsync(id);
|
||||
|
||||
if (equipmentDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = equipmentDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteEquipment/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteEquipmentAsync(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var response = await _syncService.DeleteEquipmentAsync(id);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllEquipments")]
|
||||
public async Task<ApiResponseDTO<List<EquipmentDTO>>> GetAllEquipmentsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<EquipmentDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var equipmentListDTO = await _syncService.GetAllEquipmentAsync();
|
||||
|
||||
if (equipmentListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = equipmentListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateEquipment")]
|
||||
public async Task<ApiResponseDTO<EquipmentDTO>> UpdateEquipment([FromBody] EquipmentDTO EquipmentDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<EquipmentDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _syncService.UpdateEquipmentAsync(EquipmentDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetLocation/{id}")]
|
||||
public async Task<ApiResponseDTO<LocationDTO>> GetLocationAsync(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<LocationDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var locationDTO = await _syncService.GetLocationAsync(id);
|
||||
|
||||
if (locationDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = locationDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteLocation/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteLocationAsync(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var response = await _syncService.DeleteLocationAsync(id);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllLocations")]
|
||||
public async Task<ApiResponseDTO<List<LocationDTO>>> GetAllLocationsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<LocationDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var locationListDTO = await _syncService.GetAllLocationAsync();
|
||||
|
||||
if (locationListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = locationListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateLocation")]
|
||||
public async Task<ApiResponseDTO<LocationDTO>> UpdateLocation([FromBody] LocationDTO LocationDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<LocationDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _syncService.UpdateLocationAsync(LocationDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetAllCheckListTemplateHeader/{userId}")]
|
||||
public async Task<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>> GetAllCheckListTemplateHeaderAsync(int userId)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckListTemplateHeaderDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var response = await _syncService.GetAllCheckListTemplateAsync(userId);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllCheckListHeader/{userId}")]
|
||||
public async Task<ApiResponseDTO<List<CheckListHeaderDTO>>> GetAllCheckListHeaderAsync(int userId)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckListHeaderDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var response = await _syncService.GetAllCheckListAsync(userId);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpPost("SendCheckListHeader")]
|
||||
public async Task<ApiResponseDTO<string>> SendCheckListHeader([FromBody] CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<string>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _syncService.SendCheckListHeaderAsync(checkListHeaderDTO);
|
||||
retVal.Data = "Sikeres beküldés!";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(ex.Message);
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetAllNumbergenerators")]
|
||||
public async Task<ApiResponseDTO<List<NumberGeneratorTemplateDTO>>> GetAllNumbergeneratorsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<NumberGeneratorTemplateDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var locationListDTO = await _numberGeneratorService.GetAllNumbergeneratorsAsync();
|
||||
|
||||
if (locationListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = locationListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("DeviceMessageSend")]
|
||||
public async Task<ApiResponseDTO<bool>> DeviceMessageSend([FromBody] DeviceMessageDTO deviceMessageDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _syncService.DeviceMessageSend(deviceMessageDTO);
|
||||
retVal.Data = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(ex.Message);
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("DeviceMessageReadUnreaded/{deviceIdBase64}")]
|
||||
public async Task<ApiResponseDTO<List<DeviceMessageDTO>>> DeviceMessageReadUnreaded(string deviceIdBase64)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<DeviceMessageDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
|
||||
byte[] byteArray = Base64UrlEncoder.DecodeBytes(deviceIdBase64);
|
||||
string deviceId = Encoding.UTF8.GetString(byteArray);
|
||||
|
||||
|
||||
var response = await _syncService.DeviceMessageReadUnreaded(deviceId);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeviceMessageReadUnreadedRole/{roleId}")]
|
||||
public async Task<ApiResponseDTO<List<DeviceMessageDTO>>> DeviceMessageReadUnreadedRole(int roleId)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<DeviceMessageDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
|
||||
var response = await _syncService.DeviceMessageReadUnreadedRole(roleId);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("Download")]
|
||||
public async Task<IActionResult> DownloadAPKFileAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = "com.nuvolar.wfcapp-Signed.apk";
|
||||
string downloadFolder = Path.Combine(Directory.GetCurrentDirectory(), "Downloads", "APK");
|
||||
string filePath = Path.Combine(downloadFolder, fileName);
|
||||
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
return NotFound("File not found.");
|
||||
}
|
||||
|
||||
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
|
||||
var fileType = "application/octet-stream";
|
||||
|
||||
Response.Headers.Add("Content-Length", fileBytes.Length.ToString());
|
||||
|
||||
return File(fileBytes, fileType, fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("SendTestMail")]
|
||||
public async Task<ApiResponseDTO<bool>> SendTestMail()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _messageService.SendMailAsync(
|
||||
new List<string>()
|
||||
{
|
||||
"ivan.szabo.sis@gmail.com",
|
||||
}, "Teszt", "Ok");
|
||||
retVal.Data = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(ex.Message);
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetAllMobileUsers")]
|
||||
public async Task<ApiResponseDTO<List<MobileUserDTO>>> GetAllMobileUsers()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<MobileUserDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new List<MobileUserDTO>()
|
||||
};
|
||||
var usersListDTO = await _userService.GetAllUserAsync();
|
||||
|
||||
retVal.Data.AddRange(usersListDTO
|
||||
.Where(user => user.RoleDTO.Any(role => role.CanUseMobilApp))
|
||||
.Select(user => new MobileUserDTO
|
||||
{
|
||||
Id = user.Id,
|
||||
Email = user.Email,
|
||||
FirstName = user.FirstName,
|
||||
LastName = user.LastName,
|
||||
NFCActive = user.NFCActive,
|
||||
NFCCode = user.NFCCode,
|
||||
UserName = user.UserName
|
||||
})
|
||||
);
|
||||
if (retVal.Data == null || retVal.Data.Count <= 0) { retVal.IsSuccess = false; retVal.Errors.Add("No data!"); }
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpPost("UpdateAllMobileUser")]
|
||||
public async Task<ApiResponseDTO<List<MobileUserDTO>>> UpdateAllMobileUser([FromBody] List<MobileUserDTO> mobileUserListDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<MobileUserDTO>>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var mobileUserDTO in mobileUserListDTO)
|
||||
{
|
||||
var userDTO = await _userService.GetUserAsync(mobileUserDTO.Id);
|
||||
if (userDTO != null && userDTO.Id == mobileUserDTO.Id)
|
||||
{
|
||||
userDTO.NFCCode = mobileUserDTO.NFCCode;
|
||||
var result = await _userService.UpdateUserAsync(userDTO);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.API.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class SystemController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ISystemService _systemService;
|
||||
|
||||
public SystemController(ISystemService systemService)
|
||||
{
|
||||
_systemService = systemService;
|
||||
}
|
||||
|
||||
[HttpGet("GetDatabaseAndVersionInfo")]
|
||||
public async Task<ApiResponseDTO<string>> GetDatabaseAndVersionInfo()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<string>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _systemService.GetDatabaseAndVersionInfoAsync();
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetAllImageFiles")]
|
||||
public async Task<ApiResponseDTO<List<ImageFileDTO>>> GetAllImageFilesAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<ImageFileDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
try
|
||||
{
|
||||
var allowedExtensions = new[] { ".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tiff" };
|
||||
var imageFolder = Path.Combine(Directory.GetCurrentDirectory(), "Images");
|
||||
var files = Directory.GetFiles(imageFolder)
|
||||
.Where(f => allowedExtensions.Contains(Path.GetExtension(f).ToLower()))
|
||||
.Select(f =>
|
||||
{
|
||||
var fileInfo = new FileInfo(f);
|
||||
return new
|
||||
{
|
||||
FileName = fileInfo.Name,
|
||||
FileSize = FormatFileSize(fileInfo.Length),
|
||||
CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"),
|
||||
};
|
||||
});
|
||||
|
||||
var checkListFileInfos = new List<ImageFileDTO>();
|
||||
foreach (var file in files.OrderBy(o => o.FileName).ToList())
|
||||
{
|
||||
var checkListFileInfoDTO = new ImageFileDTO()
|
||||
{
|
||||
FileName = file.FileName,
|
||||
FileSize = file.FileSize,
|
||||
CreateDate = file.CreatedDate,
|
||||
|
||||
};
|
||||
checkListFileInfos.Add(checkListFileInfoDTO);
|
||||
}
|
||||
|
||||
if (checkListFileInfos != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListFileInfos;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllPDFFiles")]
|
||||
public async Task<ApiResponseDTO<List<ImageFileDTO>>> GetAllPDFilesAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<ImageFileDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
try
|
||||
{
|
||||
var pdfFolder = Path.Combine(Directory.GetCurrentDirectory(), "PDF");
|
||||
var files = Directory.GetFiles(pdfFolder, "*.pdf")
|
||||
.Select(f =>
|
||||
{
|
||||
var fileInfo = new FileInfo(f);
|
||||
return new
|
||||
{
|
||||
FileName = fileInfo.Name,
|
||||
FileSize = FormatFileSize(fileInfo.Length),
|
||||
CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"),
|
||||
};
|
||||
});
|
||||
|
||||
var checkListFileInfos = new List<ImageFileDTO>();
|
||||
foreach (var file in files.OrderBy(o => o.FileName).ToList())
|
||||
{
|
||||
var checkListFileInfoDTO = new ImageFileDTO()
|
||||
{
|
||||
FileName = file.FileName,
|
||||
FileSize = file.FileSize,
|
||||
CreateDate = file.CreatedDate,
|
||||
|
||||
};
|
||||
checkListFileInfos.Add(checkListFileInfoDTO);
|
||||
}
|
||||
|
||||
if (checkListFileInfos != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListFileInfos;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllLogAuditFiles")]
|
||||
public async Task<ApiResponseDTO<List<LogFileDTO>>> GetAllLogAuditFilesAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<LogFileDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
try
|
||||
{
|
||||
var logAuditFiles = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\AuditFlow");
|
||||
var files = Directory.GetFiles(logAuditFiles, "*.log")
|
||||
.Select(f =>
|
||||
{
|
||||
var fileInfo = new FileInfo(f);
|
||||
return new
|
||||
{
|
||||
FileName = fileInfo.Name,
|
||||
FileSize = FormatFileSize(fileInfo.Length),
|
||||
CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"),
|
||||
};
|
||||
});
|
||||
|
||||
var checkListFileInfos = new List<LogFileDTO>();
|
||||
foreach (var file in files.OrderBy(o => o.FileName).ToList())
|
||||
{
|
||||
var checkListFileInfoDTO = new LogFileDTO()
|
||||
{
|
||||
FileName = file.FileName,
|
||||
FileSize = file.FileSize,
|
||||
CreateDate = file.CreatedDate,
|
||||
|
||||
};
|
||||
checkListFileInfos.Add(checkListFileInfoDTO);
|
||||
}
|
||||
|
||||
if (checkListFileInfos != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListFileInfos;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllLogBusinessFiles")]
|
||||
public async Task<ApiResponseDTO<List<LogFileDTO>>> GetAllLogBusinessFilesAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<LogFileDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
try
|
||||
{
|
||||
var logBusinessFiles = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\BusinessFlow");
|
||||
var files = Directory.GetFiles(logBusinessFiles, "*.log")
|
||||
.Select(f =>
|
||||
{
|
||||
var fileInfo = new FileInfo(f);
|
||||
return new
|
||||
{
|
||||
FileName = fileInfo.Name,
|
||||
FileSize = FormatFileSize(fileInfo.Length),
|
||||
CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"),
|
||||
};
|
||||
});
|
||||
|
||||
var checkListFileInfos = new List<LogFileDTO>();
|
||||
foreach (var file in files.OrderBy(o => o.FileName).ToList())
|
||||
{
|
||||
var checkListFileInfoDTO = new LogFileDTO()
|
||||
{
|
||||
FileName = file.FileName,
|
||||
FileSize = file.FileSize,
|
||||
CreateDate = file.CreatedDate,
|
||||
|
||||
};
|
||||
checkListFileInfos.Add(checkListFileInfoDTO);
|
||||
}
|
||||
|
||||
if (checkListFileInfos != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = checkListFileInfos;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("DownloadFile/{filename}")]
|
||||
public async Task<ApiResponseDTO<byte[]>> DownloadFile(string filename)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
var imageFile = Path.Combine(Directory.GetCurrentDirectory(), "Images", filename);
|
||||
|
||||
if (!System.IO.File.Exists(imageFile))
|
||||
{
|
||||
retVal.Errors.Add($"{filename} does not exist");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
byte[] response = System.IO.File.ReadAllBytes(imageFile);
|
||||
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DownloadPDFFile/{filename}")]
|
||||
public async Task<ApiResponseDTO<byte[]>> DownloadPDFFile(string filename)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
var imageFile = Path.Combine(Directory.GetCurrentDirectory(), "PDF", filename);
|
||||
|
||||
if (!System.IO.File.Exists(imageFile))
|
||||
{
|
||||
retVal.Errors.Add($"{filename} does not exist");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
byte[] response = System.IO.File.ReadAllBytes(imageFile);
|
||||
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("DownloadAuditLogFile/{filename}")]
|
||||
public async Task<ApiResponseDTO<byte[]>> DownloadAuditLogFile(string filename)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
var imageFile = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\AuditFlow", filename);
|
||||
|
||||
if (!System.IO.File.Exists(imageFile))
|
||||
{
|
||||
retVal.Errors.Add($"{filename} does not exist");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
byte[] response = System.IO.File.ReadAllBytes(imageFile);
|
||||
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DownloadBusinessLogFile/{filename}")]
|
||||
public async Task<ApiResponseDTO<byte[]>> DownloadBusinessLogFile(string filename)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
var imageFile = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\BusinessFlow", filename);
|
||||
|
||||
if (!System.IO.File.Exists(imageFile))
|
||||
{
|
||||
retVal.Errors.Add($"{filename} does not exist");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
byte[] response = System.IO.File.ReadAllBytes(imageFile);
|
||||
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private string FormatFileSize(long bytes)
|
||||
{
|
||||
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
|
||||
double len = bytes;
|
||||
int order = 0;
|
||||
while (len >= 1024 && order < sizes.Length - 1)
|
||||
{
|
||||
order++;
|
||||
len /= 1024;
|
||||
}
|
||||
return $"{len:0.##} {sizes[order]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,756 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.BL.Services;
|
||||
|
||||
namespace WorkFlowCheck.API.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
private IUserService _userService;
|
||||
|
||||
public UserController(IUserService userService)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[HttpGet("GetUser/{id}")]
|
||||
public async Task<ApiResponseDTO<UserDTO>> GetUser(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var userDTO = await _userService.GetUserAsync(id);
|
||||
|
||||
if (userDTO != null)
|
||||
{
|
||||
if (userDTO.Id == 0)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No match!");
|
||||
retVal.Data = userDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = userDTO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllUsers")]
|
||||
public async Task<ApiResponseDTO<List<UserDTO>>> GetAllUsers()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<UserDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var userDTO = await _userService.GetAllUserAsync();
|
||||
|
||||
if (userDTO != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = userDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteUser/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteUser(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _userService.DeleteUserAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateUser")]
|
||||
public async Task<ApiResponseDTO<UserDTO>> UpdateUser([FromBody] UserDTO userDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _userService.UpdateUserAsync(userDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpPost("Authenticate")]
|
||||
public async Task<ApiResponseDTO<UserDTO>> Authenticate([FromBody] UserSimpleDTO userSimpleDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
|
||||
return retVal;
|
||||
}
|
||||
try
|
||||
{
|
||||
var userDTO_Response = await _userService.Authenticate(userSimpleDTO.UserName, userSimpleDTO.Password);
|
||||
if (userDTO_Response != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false && userDTO_Response.UserName == userSimpleDTO.UserName)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = userDTO_Response;
|
||||
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Ez a 2 faktoros első lépése.
|
||||
/// </summary>
|
||||
/// <param name="userSimpleDTO"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Authenticate2F1")]
|
||||
public async Task<ApiResponseDTO<string>> Authenticate2F1([FromBody] UserSimpleDTO userSimpleDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<string>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
|
||||
return retVal;
|
||||
}
|
||||
try
|
||||
{
|
||||
var response = await _userService.Authenticate2F1(userSimpleDTO.UserName, userSimpleDTO.Password);
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = response;
|
||||
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("Authenticate2F2")]
|
||||
public async Task<ApiResponseDTO<UserDTO>> Authenticate2F2([FromBody] User2FADTO user2FADTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
if (string.IsNullOrEmpty(user2FADTO.UserName) ||
|
||||
string.IsNullOrEmpty(user2FADTO.Password) ||
|
||||
string.IsNullOrEmpty(user2FADTO.Code) ||
|
||||
string.IsNullOrEmpty(user2FADTO.Token2FA))
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
|
||||
return retVal;
|
||||
}
|
||||
try
|
||||
{
|
||||
var userDTO_Response = await _userService.Authenticate2F2(user2FADTO.UserName,
|
||||
user2FADTO.Password,
|
||||
user2FADTO.Code,
|
||||
user2FADTO.Token2FA);
|
||||
if (userDTO_Response != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = userDTO_Response;
|
||||
Log.Information($"Sikeres azonosítás! {user2FADTO.UserName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {user2FADTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {user2FADTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("Authenticate2F2ChangePassword")]
|
||||
public async Task<ApiResponseDTO<UserDTO>> Authenticate2F2ChangePassword([FromBody] UserChangePassword2FADTO userChangePassword2FADTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
if (string.IsNullOrEmpty(userChangePassword2FADTO.UserName) ||
|
||||
string.IsNullOrEmpty(userChangePassword2FADTO.OldPassword) ||
|
||||
string.IsNullOrEmpty(userChangePassword2FADTO.NewPassword1) ||
|
||||
string.IsNullOrEmpty(userChangePassword2FADTO.NewPassword2) ||
|
||||
string.IsNullOrEmpty(userChangePassword2FADTO.Code) ||
|
||||
string.IsNullOrEmpty(userChangePassword2FADTO.Token2FA))
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
|
||||
return retVal;
|
||||
}
|
||||
try
|
||||
{
|
||||
var userDTO_Response = await _userService.Authenticate2F2ChangePassword(userChangePassword2FADTO.UserName,
|
||||
userChangePassword2FADTO.OldPassword,
|
||||
userChangePassword2FADTO.NewPassword1,
|
||||
userChangePassword2FADTO.Code,
|
||||
userChangePassword2FADTO.Token2FA);
|
||||
if (userDTO_Response != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = userDTO_Response;
|
||||
Log.Information($"Sikeres azonosítás! {userChangePassword2FADTO.UserName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userChangePassword2FADTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userChangePassword2FADTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("AuthenticateNFC")]
|
||||
public async Task<ApiResponseDTO<UserDTO>> AuthenticateNFC([FromBody] UserSimpleDTO userSimpleDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
|
||||
return retVal;
|
||||
}
|
||||
try
|
||||
{
|
||||
var userDTO_Response = await _userService.AuthenticateNFC(userSimpleDTO.UserName);
|
||||
if (userDTO_Response != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false && userDTO_Response.NFCActive)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = userDTO_Response;
|
||||
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add(error);
|
||||
Log.Information(error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetRole/{id}")]
|
||||
public async Task<ApiResponseDTO<RoleDTO>> GetRole(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<RoleDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var RoleDTO = await _userService.GetRoleAsync(id);
|
||||
|
||||
if (RoleDTO != null)
|
||||
{
|
||||
if (RoleDTO.Id == 0)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No match!");
|
||||
retVal.Data = RoleDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = RoleDTO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllRoles")]
|
||||
public async Task<ApiResponseDTO<List<RoleDTO>>> GetAllRoles()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<RoleDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var RoleDTO = await _userService.GetAllRoleAsync();
|
||||
|
||||
if (RoleDTO != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = RoleDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteRole/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteRole(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _userService.DeleteRoleAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateRole")]
|
||||
public async Task<ApiResponseDTO<RoleDTO>> UpdateRole([FromBody] RoleDTO roleDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<RoleDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _userService.UpdateRoleAsync(roleDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetUserRole/{id}")]
|
||||
public async Task<ApiResponseDTO<UserRoleDTO>> GetUserRole(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserRoleDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var RoleDTO = await _userService.GetUserRoleAsync(id);
|
||||
|
||||
if (RoleDTO != null)
|
||||
{
|
||||
if (RoleDTO.Id == 0)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No match!");
|
||||
retVal.Data = RoleDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = RoleDTO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllUserRoles")]
|
||||
public async Task<ApiResponseDTO<List<UserRoleDTO>>> GetAllUserRoles()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<UserRoleDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var RoleDTO = await _userService.GetAllUserRoleAsync();
|
||||
|
||||
if (RoleDTO != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = RoleDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteUserRole/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteUserRole(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _userService.DeleteUserRoleAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateUserRole")]
|
||||
public async Task<ApiResponseDTO<UserRoleDTO>> UpdateUserRole([FromBody] UserRoleDTO userRoleDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<UserRoleDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _userService.UpdateUserRoleAsync(userRoleDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetRoleCheckListTemplateHeader/{id}")]
|
||||
public async Task<ApiResponseDTO<RoleCheckListTemplateHeaderDTO>> GetRoleCheckListTemplateHeader(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<RoleCheckListTemplateHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var roleCheckListTemplateHeaderDTO = await _userService.GetRoleCheckListTemplateHeaderAsync(id);
|
||||
|
||||
if (roleCheckListTemplateHeaderDTO != null)
|
||||
{
|
||||
if (roleCheckListTemplateHeaderDTO.Id == 0)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No match!");
|
||||
retVal.Data = roleCheckListTemplateHeaderDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = roleCheckListTemplateHeaderDTO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllRoleCheckListTemplateHeaders")]
|
||||
public async Task<ApiResponseDTO<List<RoleCheckListTemplateHeaderDTO>>> GetAllRoleCheckListTemplateHeaders()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<RoleCheckListTemplateHeaderDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var results = await _userService.GetAllRoleCheckListTemplateHeadersAsync();
|
||||
|
||||
if (results != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = results;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteRoleCheckListTemplateHeader/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteRoleCheckListTemplateHeader(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _userService.DeleteRoleCheckListTemplateHeaderAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateRoleCheckListTemplateHeader")]
|
||||
public async Task<ApiResponseDTO<RoleCheckListTemplateHeaderDTO>> UpdateRoleCheckListTemplateHeader([FromBody] RoleCheckListTemplateHeaderDTO roleCheckListTemplateHeaderDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<RoleCheckListTemplateHeaderDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _userService.UpdateRoleCheckListTemplateHeaderAsync(roleCheckListTemplateHeaderDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetRoleCheckPoint/{id}")]
|
||||
public async Task<ApiResponseDTO<RoleCheckPointDTO>> GetRoleCheckPoint(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<RoleCheckPointDTO>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var roleCheckPointDTO = await _userService.GetRoleCheckPointAsync(id);
|
||||
|
||||
if (roleCheckPointDTO != null)
|
||||
{
|
||||
if (roleCheckPointDTO.Id == 0)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No match!");
|
||||
retVal.Data = roleCheckPointDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = roleCheckPointDTO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllRoleCheckPoints")]
|
||||
public async Task<ApiResponseDTO<List<RoleCheckPointDTO>>> GetAllRoleCheckPoints()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<RoleCheckPointDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var results = await _userService.GetAllRoleCheckPointsAsync();
|
||||
|
||||
if (results != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = results;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("DeleteRoleCheckPoint/{id}")]
|
||||
public async Task<ApiResponseDTO<bool>> DeleteRoleCheckPoint(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var result = await _userService.DeleteRoleCheckPointAsync(id);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
[HttpPost("UpdateRoleCheckPoint")]
|
||||
public async Task<ApiResponseDTO<RoleCheckPointDTO>> UpdateRoleCheckPoint([FromBody] RoleCheckPointDTO roleCheckPointDTO)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<RoleCheckPointDTO>()
|
||||
{
|
||||
IsSuccess = true
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _userService.UpdateRoleCheckPointAsync(roleCheckPointDTO);
|
||||
retVal.Data = result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace WorkFlowCheck.API.Middleware
|
||||
{
|
||||
public class ApiKeyMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private const string ApiKeyHeaderName = "X-Api-Key";
|
||||
private readonly ILogger<ApiKeyMiddleware> _logger;
|
||||
|
||||
public ApiKeyMiddleware(RequestDelegate next, ILogger<ApiKeyMiddleware> logger)
|
||||
{
|
||||
_next = next;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (!context.Request.Headers.TryGetValue(ApiKeyHeaderName, out var extractedApiKey))
|
||||
{
|
||||
_logger.LogWarning("API Key is missing.");
|
||||
context.Response.StatusCode = 401; // Unauthorized
|
||||
context.Response.ContentType = "text/html; charset=utf-8";
|
||||
await context.Response.WriteAsync("API Key hiányzik.");
|
||||
return;
|
||||
}
|
||||
|
||||
var appSettings = context.RequestServices.GetRequiredService<IConfiguration>();
|
||||
var apiKey = appSettings.GetValue<string>("ApiKey");
|
||||
|
||||
if (!apiKey.Equals(extractedApiKey))
|
||||
{
|
||||
_logger.LogWarning("Invalid API Key.");
|
||||
context.Response.StatusCode = 403; // Forbidden
|
||||
context.Response.ContentType = "text/html; charset=utf-8";
|
||||
await context.Response.WriteAsync("Helytelen API Key.");
|
||||
return;
|
||||
}
|
||||
|
||||
await _next(context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace WorkFlowCheck.API.Middleware
|
||||
{
|
||||
public class JwtMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
public readonly IConfiguration _configuration;
|
||||
public JwtMiddleware(RequestDelegate next, IConfiguration configuration)
|
||||
{
|
||||
_next = next;
|
||||
_configuration = configuration;
|
||||
}
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
var token = context.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();
|
||||
if (!string.IsNullOrEmpty(token) && ValidateToken(token, out var claims))
|
||||
{
|
||||
context.User = new ClaimsPrincipal(new ClaimsIdentity(claims, "jwt"));
|
||||
}
|
||||
await _next(context);
|
||||
}
|
||||
private bool ValidateToken(string token, out Claim[] claims)
|
||||
{
|
||||
var jwtSettings = _configuration.GetSection("Jwt");
|
||||
var secretKey = jwtSettings["SecretKey"];
|
||||
|
||||
claims = null;
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
var key = Encoding.UTF8.GetBytes(secretKey);
|
||||
|
||||
try
|
||||
{
|
||||
var principal = tokenHandler.ValidateToken(token, new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||
ValidateIssuer = false,
|
||||
ValidateAudience = false,
|
||||
ClockSkew = TimeSpan.Zero
|
||||
}, out var validatedToken);
|
||||
|
||||
claims = principal.Claims.ToArray();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,36 +1,177 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using WorkFlowCheck.DL;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.BL.Mappings;
|
||||
using WorkFlowCheck.BL.Infra;
|
||||
using WorkFlowCheck.DL.Seed;
|
||||
using WorkFlowCheck.Common.RequestContext;
|
||||
using WorkFlowCheck.API.RequestContext;
|
||||
using WorkFlowCheck.API.Middleware;
|
||||
using Serilog.Filters;
|
||||
|
||||
var builder = WebApplication.CreateSlimBuilder(args);
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.ConfigureHttpJsonOptions(options =>
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
string baseLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Logs");
|
||||
if (!Directory.Exists(baseLogPath))
|
||||
Directory.CreateDirectory(baseLogPath);
|
||||
|
||||
string auditLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Logs", "AuditFlow");
|
||||
if (!Directory.Exists(auditLogPath))
|
||||
Directory.CreateDirectory(auditLogPath);
|
||||
|
||||
string businessLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Logs", "BusinessFlow");
|
||||
if (!Directory.Exists(businessLogPath))
|
||||
Directory.CreateDirectory(businessLogPath);
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(builder.Configuration) // Konfiguráció betöltése
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File("logs/log-.log", rollingInterval: RollingInterval.Day)
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByIncludingOnly(Matching.WithProperty("TAG", "AuditFlow"))
|
||||
.WriteTo.File("Logs/AuditFlow/au-.log", rollingInterval: RollingInterval.Day)
|
||||
)
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByIncludingOnly(Matching.WithProperty("TAG", "BusinessFlow"))
|
||||
.WriteTo.File("Logs/BusinessFlow/bs-.log", rollingInterval: RollingInterval.Day)
|
||||
)
|
||||
.CreateLogger();
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Information("API indítása...");
|
||||
|
||||
builder.Services.AddAutoMapper(typeof(MapperProfile));
|
||||
builder.Services.AddMemoryCache();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddScoped<IRequestContext, HttpRequestContext>();
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseSqlServer(connectionString, x => x.MigrationsAssembly("WorkFlowCheck.DL")));
|
||||
//DI
|
||||
|
||||
DIConfig.DIInit(builder.Services);
|
||||
|
||||
// SWAGGER !!!
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "WorkFlowCheck API", Version = "v1" });
|
||||
|
||||
// API Key Auth definíció
|
||||
c.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme
|
||||
{
|
||||
Description = "API Key szükséges. Használat: 'ApiKey: {kulcs}'",
|
||||
Name = "X-Api-Key", // A fejlécek között keresendõ
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "ApiKey"
|
||||
});
|
||||
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "ApiKey"
|
||||
},
|
||||
Scheme = "ApiKey",
|
||||
Name = "ApiKey",
|
||||
In = ParameterLocation.Header,
|
||||
},
|
||||
Array.Empty<string>()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
builder.Host.UseSerilog();
|
||||
|
||||
builder.Services.AddControllers()
|
||||
.AddNewtonsoftJson(options =>
|
||||
{
|
||||
// Itt konfigurálhatod az egyedi beállításokat
|
||||
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
|
||||
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
||||
});
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy.WithOrigins("*").AllowAnyMethod().AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
var kestrelConfig = builder.Configuration.GetSection("Kestrel");
|
||||
options.Configure(kestrelConfig);
|
||||
});
|
||||
var app = builder.Build();
|
||||
//----------------- Munkakönyvtárak létrehozása -----------------------------
|
||||
string imageDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
|
||||
if (!Directory.Exists(imageDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(imageDirectory);
|
||||
}
|
||||
string pdfDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Pdf");
|
||||
|
||||
// Ensure the Images directory exists
|
||||
if (!Directory.Exists(pdfDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(pdfDirectory);
|
||||
}
|
||||
string downloadDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Downloads");
|
||||
if (!Directory.Exists(downloadDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(downloadDirectory);
|
||||
}
|
||||
string downloadAPKDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Downloads","APK");
|
||||
if (!Directory.Exists(downloadAPKDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(downloadAPKDirectory);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
var sampleTodos = new Todo[] {
|
||||
new(1, "Walk the dog"),
|
||||
new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)),
|
||||
new(3, "Do the laundry", DateOnly.FromDateTime(DateTime.Now.AddDays(1))),
|
||||
new(4, "Clean the bathroom"),
|
||||
new(5, "Clean the car", DateOnly.FromDateTime(DateTime.Now.AddDays(2)))
|
||||
};
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var context = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
DBInitializer.Seed(context);
|
||||
}
|
||||
|
||||
var todosApi = app.MapGroup("/todos");
|
||||
todosApi.MapGet("/", () => sampleTodos);
|
||||
todosApi.MapGet("/{id}", (int id) =>
|
||||
sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo
|
||||
? Results.Ok(todo)
|
||||
: Results.NotFound());
|
||||
// Swagger middleware
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "WorkFlowCheck API v1");
|
||||
});
|
||||
}
|
||||
|
||||
// Routing és endpointok
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseMiddleware<ApiKeyMiddleware>();
|
||||
app.UseMiddleware<JwtMiddleware>();
|
||||
|
||||
app.MapControllers();
|
||||
app.UseAuthorization();
|
||||
app.UseCors();
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Information("API fut.");
|
||||
app.Run();
|
||||
|
||||
public record Todo(int Id, string? Title, DateOnly? DueBy = null, bool IsComplete = false);
|
||||
|
||||
[JsonSerializable(typeof(Todo[]))]
|
||||
internal partial class AppJsonSerializerContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "todos",
|
||||
"applicationUrl": "http://localhost:5069",
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:5069"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:59027/",
|
||||
"sslPort": 44382
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Claims;
|
||||
using WorkFlowCheck.Common.Constants;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.RequestContext;
|
||||
|
||||
namespace WorkFlowCheck.API.RequestContext
|
||||
{
|
||||
public class HttpRequestContext : IRequestContext
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
public HttpRequestContext(IHttpContextAccessor httpContextAccessor, IMemoryCache memoryCache)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_memoryCache = memoryCache;
|
||||
|
||||
TraceId = Activity.Current?.Id;
|
||||
}
|
||||
|
||||
public string TraceId { get; }
|
||||
|
||||
public int? CurrentUserId => CurrentDbUser?.Id;
|
||||
|
||||
|
||||
|
||||
public string CurrentUsername => CurrentHttpUser?.Identity.Name;
|
||||
public string CurrentUserEmail => CurrentHttpUser?.FindFirst(System.Security.Claims.ClaimTypes.Email)?.Value;
|
||||
public CancellationToken RequestAborted => _httpContextAccessor.HttpContext.RequestAborted;
|
||||
|
||||
private UserDTO CurrentDbUser => _memoryCache.Get<UserDTO>(MemoryCacheNames.UsersNamePrefix + CurrentUserEmail);
|
||||
|
||||
private ClaimsPrincipal CurrentHttpUser => _httpContextAccessor.HttpContext.User;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,56 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<PublishAot>true</PublishAot>
|
||||
<InvariantGlobalization>false</InvariantGlobalization>
|
||||
<PublishAot>false</PublishAot>
|
||||
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WorkFlowCheck.BL\WorkFlowCheck.BL.csproj" />
|
||||
<ProjectReference Include="..\WorkFlowCheck.DL\WorkFlowCheck.DL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Apis.Auth" Version="1.69.0" />
|
||||
<PackageReference Include="MailKit" Version="4.11.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
||||
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Certs\SwaggerCert.pfx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Pdf\CheckList_Template_V1.docx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Logs\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
//"DefaultConnection": "Data Source=NSINB-37\\WFC;Initial Catalog=WFC;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"
|
||||
//"DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFC;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False",
|
||||
"DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFCUAT;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
|
||||
@@ -1,9 +1,74 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFCUAT;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"
|
||||
},
|
||||
"ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=",
|
||||
"Jwt": {
|
||||
"SecretKey": "9aLxV2t7RpM8BfKqZwXy3GehYJDUNTCrHkVZ",
|
||||
"Issuer": "https://wfcapi.nuvolar.hu/",
|
||||
"Audience": "wfc-application",
|
||||
"TokenLifetimeMinutes": 1440
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"Serilog": {
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Console"
|
||||
},
|
||||
{
|
||||
"Name": "Logger",
|
||||
"Args": {
|
||||
"filter": "Equals(TAG, 'AuditFlow')",
|
||||
"writeTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/AuditFlow/log-.txt",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Logger",
|
||||
"Args": {
|
||||
"filter": "Equals(TAG, 'BusinessFlow')",
|
||||
"writeTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/BusinessFlow/log-.txt",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext" ]
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://localhost:8660"
|
||||
}
|
||||
}
|
||||
},
|
||||
"EmailSettings": {
|
||||
"SmtpServer": "smtp.gmail.com",
|
||||
"SmtpPort": 587,
|
||||
"Username": "nuvolarsetup@gmail.com",
|
||||
"Password": "reiq pgfr nxub pvrb",
|
||||
"SenderName": "Nuvolar System"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "com-nuvolar-wfcapp",
|
||||
"private_key_id": "37642626e4a61fea715f3ef02a35d53fa9227666",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCVQKzCOgEhaQFo\nxtOYCpOc6XQNOVfNm8Z1xu1uoQtSZZIH3ivJy1IBqlyP/+sQ+7FO3Af5v90ae3rf\nvzd42QC4hrbBPyLGbVJWDHNPOzwg7bbez3waaU4i/7m4YJ61hlOObo888mjAxG8t\nz0cDEQzWPPUlLBCvtzY8Zv3jWdYaBxGUUzHxfemjTVLG7YCUjyt057HJVSH7AJpV\ndhnBi+3xlogsnK227ou/rLWoNyZVDOUaSiMor+LNiQx82eXc+UUaJgjpbI5AMk9z\n7CgAM8CSMOw7BHhCImVXaxH9rLZCsw0xpZnCJuOJKRyIMhrfcWKcHjrgkEW+xErj\nWN9lSkHRAgMBAAECggEAAwH5FUcrVom13b9bfF3ysnPdKwbNvVrLN5yDFIKV7oK1\n3Bca42u3rulIqR15doe275GVLtASL+ZfABcrslGPr1hGIqvvusdRVGL2+CjXveti\nbvgoDmVyvddwzf2S9zIiOQ2i8PHK4P8YZTg/DGmVnFPhRg7utWbMFtClw0UQQKkd\nzRwRDsw0jx9wDpP4EaO+czNvVZnnj+miL8QICN4gjbTdyQiVw2D1KzabwmozfEkM\nqTP+yH9mSC4gAEkG+X3i48QxiXZXvLflfnhF58+mT4yjIBIQbRTi0w9yLWRkcs8n\nmCq/89PZMncpNdCSJqdNOsYXgVaW8OMePxPNER2g4QKBgQDHl47N9AGyukpqEJJK\nR/8u3IwcCjLBb0wk5UxtZyz2JpoyqXoaKw7teqCqhg6lVd8MdIcVITKe0nZ+P29z\nyL+RVC+hGm/OQj6mAVyFEZptMgtQZGA2ThLY4ozZgzTW7uNyChhnUcqTiMCJ0g5g\n05imd6nQFKxI1ZfCsE7qlq6yYQKBgQC/bxKYno/6OT+9TTS+OCYVx9WJ8JCzOqFh\n/S+7qV14Bmml/JmYoSo/umxNOlKu3c7QtjU6caD/r4q/r6RHvvBxMlBu4K+vTEXh\nhFeqYORwTcEkcTDpjAGDekeJsRSxv5bg6QtsW30mtreBBC1/fOAvHD03Tz8GmFsp\nHry7b1WlcQKBgQCrnb51iix3oETh5DPVWQirI4n5hi9UMb24L81CeKepU1Hc4+qQ\nW5uvSHSjizdGpIpwLDYGThA3jeHC9gp/9Qn7DPcTQCcIo984YA1MgfFVmOUvj89G\ngmUkRdA0KuQhNzEsWk/XbvWPW9Op7YrdaLNl15iUyWHGEpo2FeEVRtEZoQKBgF5Z\nM+UcYQGGLa/y2UfXDI43izsM4YQ0JU3SJzBqbLK3FmLEeD8NT3FRRAdb81xT3ZZn\n9xvy3NKnhc6rll/17zMbBSFgg7X19YsMWtiSIIRpDgQT9XNlmWlfXtqx9+0S7B21\nPfgNr0ThUNe5Y2Mt/J+7X0BfQkTR2jwN9h665I9BAoGADx/oQLMXgKGdes4adF1Z\np9miGNsmUgXHdT+CdWkRx5uRd1a5s1Di6sOEUBPyFJ9hYc5ObRuC5q1A24ApASak\n0YCbUV1lqzFI4loXyM5ABqRTRCVGH94PXDAvsRUTTLvRIOliOeOBa8bNGGPlXtFw\nXzrkDjsz71JdNxgvT2Zz7nA=\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-fbsvc@com-nuvolar-wfcapp.iam.gserviceaccount.com",
|
||||
"client_id": "109975038898567298706",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40com-nuvolar-wfcapp.iam.gserviceaccount.com",
|
||||
"universe_domain": "googleapis.com"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
dotnet publish -c Release -o e:\wfcapi\
|
||||
pause
|
||||
@@ -0,0 +1,225 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace WorkFlowCheck.BL.DocumentGenerator
|
||||
{
|
||||
public class DokumentumGenerator
|
||||
{
|
||||
public static byte[] DocxToPdfL(byte[] wordBytes, List<string> imagePaths = null)
|
||||
{
|
||||
string pdfDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Pdf");
|
||||
string fileName = Guid.NewGuid().ToString();
|
||||
|
||||
string tempWordPath = Path.Combine(pdfDirectory, fileName + ".docx");
|
||||
string tempPdfPath = Path.Combine(pdfDirectory, fileName + ".pdf");
|
||||
|
||||
try
|
||||
{
|
||||
// Word fájl mentése ideiglenes fájlba
|
||||
File.WriteAllBytes(tempWordPath, wordBytes);
|
||||
|
||||
if (imagePaths != null && imagePaths.Count > 0)
|
||||
{
|
||||
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(tempWordPath, true))
|
||||
{
|
||||
MainDocumentPart mainPart = wordDoc.MainDocumentPart;
|
||||
foreach (string imagePath in imagePaths)
|
||||
{
|
||||
if (File.Exists(imagePath))
|
||||
{
|
||||
InsertImageAsNewPage(mainPart, imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
wordDoc.MainDocumentPart.Document.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// LibreOffice parancssori konverzió
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||
{
|
||||
#if !DEBUG
|
||||
FileName = "e:\\LibreOffice\\program\\soffice", // LibreOffice parancs
|
||||
#else
|
||||
//FileName = "c:\\Program Files\\LibreOffice\\program\\soffice", // LibreOffice parancs
|
||||
FileName = "e:\\LibreOffice\\program\\soffice", // LibreOffice parancs
|
||||
#endif
|
||||
Arguments = $"--headless --convert-to pdf \"{tempWordPath}\" --outdir \"{pdfDirectory}",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
using (Process process = Process.Start(startInfo))
|
||||
{
|
||||
process.WaitForExit();
|
||||
}
|
||||
|
||||
// Ellenőrzés, hogy létrejött-e a PDF
|
||||
if (File.Exists(tempPdfPath))
|
||||
{
|
||||
byte[] pdfBytes = File.ReadAllBytes(tempPdfPath);
|
||||
|
||||
// Ideiglenes fájlok törlése
|
||||
File.Delete(tempWordPath);
|
||||
File.Delete(tempPdfPath);
|
||||
|
||||
return pdfBytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("PDF konverzió sikertelen.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Hiba a PDF konverzió során: " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private static void InsertImageAsNewPage(MainDocumentPart mainPart, string imagePath)
|
||||
{
|
||||
string fileName = Path.GetFileName(imagePath);
|
||||
|
||||
// Kép méretezés – max szélesség/magasság A4 hasznos területhez igazítva
|
||||
using var image = SixLabors.ImageSharp.Image.Load(imagePath);
|
||||
int pixelWidth = image.Width;
|
||||
int pixelHeight = image.Height;
|
||||
|
||||
long maxWidth = 5760000L; // kb. 16 cm
|
||||
long maxHeight = 7200000L; // kb. 20 cm
|
||||
|
||||
double aspectRatio = (double)pixelHeight / pixelWidth;
|
||||
long finalWidth = maxWidth;
|
||||
long finalHeight = (long)(maxWidth * aspectRatio);
|
||||
|
||||
if (finalHeight > maxHeight)
|
||||
{
|
||||
finalHeight = maxHeight;
|
||||
finalWidth = (long)(maxHeight / aspectRatio);
|
||||
}
|
||||
|
||||
// Kép hozzáadása Word dokumentumhoz
|
||||
ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg);
|
||||
using (FileStream stream = new FileStream(imagePath, FileMode.Open))
|
||||
{
|
||||
imagePart.FeedData(stream);
|
||||
}
|
||||
|
||||
string imagePartId = mainPart.GetIdOfPart(imagePart);
|
||||
Drawing drawing = CreateImageDrawing(imagePartId, finalWidth, finalHeight);
|
||||
|
||||
// Kép beillesztése középre igazítva
|
||||
Paragraph imageParagraph = new Paragraph(new Run(drawing))
|
||||
{
|
||||
ParagraphProperties = new ParagraphProperties(
|
||||
new Justification() { Val = JustificationValues.Center }
|
||||
)
|
||||
};
|
||||
|
||||
TableCell imageCell = new TableCell(imageParagraph,
|
||||
new TableCellProperties(
|
||||
new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center },
|
||||
new TableCellWidth() { Type = TableWidthUnitValues.Pct, Width = "10000" }
|
||||
));
|
||||
|
||||
// Képes sor (magas, kitölti az oldalt)
|
||||
TableRow imageRow = new TableRow(imageCell);
|
||||
imageRow.AppendChild(new TableRowProperties(
|
||||
new TableRowHeight() { Val = 9000, HeightType = HeightRuleValues.Exact }
|
||||
));
|
||||
|
||||
// Fájlnév beillesztése középre
|
||||
Paragraph fileNamePara = new Paragraph(new Run(new Text(fileName)))
|
||||
{
|
||||
ParagraphProperties = new ParagraphProperties(
|
||||
new Justification() { Val = JustificationValues.Center }
|
||||
)
|
||||
};
|
||||
|
||||
TableCell fileNameCell = new TableCell(fileNamePara,
|
||||
new TableCellProperties(
|
||||
new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center },
|
||||
new TableCellWidth() { Type = TableWidthUnitValues.Pct, Width = "10000" }
|
||||
));
|
||||
|
||||
// Fájlnév sor (normál magasság)
|
||||
TableRow fileNameRow = new TableRow(fileNameCell);
|
||||
fileNameRow.AppendChild(new TableRowProperties(
|
||||
new TableRowHeight() { Val = 400, HeightType = HeightRuleValues.Auto }
|
||||
));
|
||||
|
||||
// Táblázat – szegély nélkül, teljes oldalszélességben
|
||||
Table table = new Table(
|
||||
new TableProperties(
|
||||
new TableWidth { Width = "10000", Type = TableWidthUnitValues.Pct },
|
||||
new TableBorders(
|
||||
new TopBorder { Val = BorderValues.None },
|
||||
new BottomBorder { Val = BorderValues.None },
|
||||
new LeftBorder { Val = BorderValues.None },
|
||||
new RightBorder { Val = BorderValues.None },
|
||||
new InsideHorizontalBorder { Val = BorderValues.None },
|
||||
new InsideVerticalBorder { Val = BorderValues.None }
|
||||
)
|
||||
),
|
||||
imageRow,
|
||||
fileNameRow
|
||||
);
|
||||
|
||||
// Új oldal és a táblázat beszúrása a dokumentum végére
|
||||
Body body = mainPart.Document.Body;
|
||||
body.Append(new Paragraph(new Run(new Break() { Type = BreakValues.Page })));
|
||||
body.Append(table);
|
||||
}
|
||||
private static Drawing CreateImageDrawing(string relationshipId, long width, long height)
|
||||
{
|
||||
return new Drawing(
|
||||
new DocumentFormat.OpenXml.Drawing.Wordprocessing.Inline(
|
||||
new DocumentFormat.OpenXml.Drawing.Wordprocessing.Extent() { Cx = width, Cy = height },
|
||||
new DocumentFormat.OpenXml.Drawing.Wordprocessing.EffectExtent()
|
||||
{
|
||||
LeftEdge = 0L,
|
||||
TopEdge = 0L,
|
||||
RightEdge = 0L,
|
||||
BottomEdge = 0L
|
||||
},
|
||||
new DocumentFormat.OpenXml.Drawing.Wordprocessing.DocProperties()
|
||||
{
|
||||
Id = (UInt32Value)1U,
|
||||
Name = "Inserted Image"
|
||||
},
|
||||
new DocumentFormat.OpenXml.Drawing.Graphic(
|
||||
new DocumentFormat.OpenXml.Drawing.GraphicData(
|
||||
new DocumentFormat.OpenXml.Drawing.Pictures.Picture(
|
||||
new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualPictureProperties(
|
||||
new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualDrawingProperties()
|
||||
{
|
||||
Id = (UInt32Value)0U,
|
||||
Name = "Picture"
|
||||
},
|
||||
new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualPictureDrawingProperties()),
|
||||
new DocumentFormat.OpenXml.Drawing.Pictures.BlipFill(
|
||||
new DocumentFormat.OpenXml.Drawing.Blip()
|
||||
{
|
||||
Embed = relationshipId
|
||||
},
|
||||
new DocumentFormat.OpenXml.Drawing.Stretch(
|
||||
new DocumentFormat.OpenXml.Drawing.FillRectangle())),
|
||||
new DocumentFormat.OpenXml.Drawing.Pictures.ShapeProperties(
|
||||
new DocumentFormat.OpenXml.Drawing.Transform2D(
|
||||
new DocumentFormat.OpenXml.Drawing.Offset() { X = 0L, Y = 0L },
|
||||
new DocumentFormat.OpenXml.Drawing.Extents() { Cx = width, Cy = height }),
|
||||
new DocumentFormat.OpenXml.Drawing.PresetGeometry(
|
||||
new DocumentFormat.OpenXml.Drawing.AdjustValueList())
|
||||
{ Preset = DocumentFormat.OpenXml.Drawing.ShapeTypeValues.Rectangle }))
|
||||
)
|
||||
{ Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" })
|
||||
)
|
||||
{ DistanceFromTop = 0U, DistanceFromBottom = 0U, DistanceFromLeft = 0U, DistanceFromRight = 0U });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WorkFlowCheck.BL.DocumentGenerator
|
||||
{
|
||||
public class SablonGenerator : IDisposable
|
||||
{
|
||||
private readonly List<OpenXmlElement> _currentRoot;
|
||||
|
||||
private MemoryStream Mem { get; }
|
||||
private WordprocessingDocument Doc { get; set; }
|
||||
|
||||
private List<OpenXmlElement> CurrentRoot => Repeater?.SablonRoot ?? _currentRoot;
|
||||
|
||||
private SubSablon Repeater { get; set; }
|
||||
|
||||
protected class SubSablon : IDisposable
|
||||
{
|
||||
private List<OpenXmlElement> SablonRootBase { get; set; }
|
||||
protected internal List<OpenXmlElement> SablonRoot { get; private set; }
|
||||
public BookmarkStart BookmarkStart { get; }
|
||||
public BookmarkEnd BookmarkEnd { get; }
|
||||
|
||||
protected internal SubSablon(WordprocessingDocument doc, string key)
|
||||
{
|
||||
var bookmark = doc.MainDocumentPart.RootElement.Descendants<BookmarkStart>()
|
||||
.FirstOrDefault(x => x.Name == key);
|
||||
//var parentBookmark = false;
|
||||
if (bookmark != null)
|
||||
{
|
||||
SablonRoot = new List<OpenXmlElement>();
|
||||
var nextSibling = bookmark.NextSibling();
|
||||
if (nextSibling == null)
|
||||
nextSibling = bookmark.Parent;
|
||||
while (nextSibling != null)
|
||||
{
|
||||
var endBookmark = (nextSibling is BookmarkEnd end && end.Id == bookmark.Id.Value) ? end : null;
|
||||
if (endBookmark == null)
|
||||
{
|
||||
endBookmark = nextSibling.Descendants<BookmarkEnd>().FirstOrDefault(x => x.Id == bookmark.Id.Value);
|
||||
if (endBookmark != null)
|
||||
SablonRoot.Add(nextSibling);
|
||||
}
|
||||
if (endBookmark != null)
|
||||
{
|
||||
bookmark.Remove();
|
||||
endBookmark.Remove();
|
||||
break;
|
||||
}
|
||||
SablonRoot.Add(nextSibling);
|
||||
var tmpNextSibling = nextSibling.NextSibling();
|
||||
if (tmpNextSibling == null)
|
||||
{
|
||||
tmpNextSibling = nextSibling.Parent;
|
||||
if (tmpNextSibling != null && !(tmpNextSibling is Body) && !(tmpNextSibling is Document))
|
||||
SablonRoot.Clear();
|
||||
else
|
||||
break;
|
||||
}
|
||||
nextSibling = tmpNextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
if (SablonRoot != null && SablonRoot.Count > 0)
|
||||
{
|
||||
SablonRootBase = new List<OpenXmlElement>();
|
||||
foreach (var item in SablonRoot)
|
||||
{
|
||||
SablonRootBase.Add(item.CloneNode(true));
|
||||
}
|
||||
BookmarkStart = new BookmarkStart() { Name = "repeater", Id = "1000" };
|
||||
BookmarkEnd = new BookmarkEnd() { Id = "1000" };
|
||||
if (SablonRoot.First().Parent != null)
|
||||
{
|
||||
SablonRoot.First().InsertBeforeSelf(BookmarkStart);
|
||||
SablonRoot.First().InsertBeforeSelf(BookmarkEnd);
|
||||
foreach (var rootItem in SablonRoot)
|
||||
rootItem.Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var rootItem in SablonRoot)
|
||||
foreach (var rootItemChildElement in rootItem.ChildElements)
|
||||
rootItemChildElement.Remove();
|
||||
SablonRoot.First().AppendChild(BookmarkStart);
|
||||
SablonRoot.First().AppendChild(BookmarkEnd);
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
private void Insert()
|
||||
{
|
||||
var root = SablonRoot;
|
||||
if (root.Count == 1 && root.First() is Document)
|
||||
{
|
||||
root = root.First().ChildElements.ToList();
|
||||
}
|
||||
for (var i = 0; i < root.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
BookmarkStart.InsertBeforeSelf(root[i]);
|
||||
else
|
||||
root[i - 1].InsertAfterSelf(root[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
SablonRoot.Clear();
|
||||
foreach (var item in SablonRootBase)
|
||||
{
|
||||
SablonRoot.Add(item.CloneNode(true));
|
||||
}
|
||||
}
|
||||
|
||||
protected internal void InsertAndReset()
|
||||
{
|
||||
Insert();
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
BookmarkStart?.Remove();
|
||||
BookmarkEnd?.Remove();
|
||||
SablonRootBase = null;
|
||||
SablonRoot = null;
|
||||
}
|
||||
}
|
||||
|
||||
public IDisposable Repeat(string key)
|
||||
{
|
||||
Repeater = new SubSablon(Doc, key);
|
||||
return Repeater;
|
||||
}
|
||||
|
||||
public SablonGenerator(byte[] content)
|
||||
{
|
||||
Mem = new MemoryStream();
|
||||
Mem.Write(content, 0, content.Length);
|
||||
try
|
||||
{
|
||||
Doc = WordprocessingDocument.Open(Mem, true, new OpenSettings()
|
||||
{
|
||||
MarkupCompatibilityProcessSettings =
|
||||
new MarkupCompatibilityProcessSettings(MarkupCompatibilityProcessMode.ProcessAllParts,
|
||||
FileFormatVersions.Office2010)
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//if (!string.IsNullOrEmpty(Config.TryGetStringValue("SablonGeneratorErrorPath")))
|
||||
//{
|
||||
// File.WriteAllBytes(Path.Combine(Config.GetStringValue("SablonGeneratorErrorPath"), DateTime.Now.ToString("yyyyMMddHHHmmss.content")), content);
|
||||
//}
|
||||
throw;
|
||||
}
|
||||
|
||||
_currentRoot = new List<OpenXmlElement>();
|
||||
CurrentRoot.AddRange(Doc.MainDocumentPart.HeaderParts.Select(x => x.RootElement));
|
||||
CurrentRoot.Add(Doc.MainDocumentPart.RootElement);
|
||||
CurrentRoot.AddRange(Doc.MainDocumentPart.FooterParts.Select(x => x.RootElement));
|
||||
}
|
||||
|
||||
public static void CheckOpenXmlDocument(byte[] content)
|
||||
{
|
||||
WordprocessingDocument doc = null;
|
||||
var mem = new MemoryStream();
|
||||
mem.Write(content, 0, content.Length);
|
||||
try
|
||||
{
|
||||
doc = WordprocessingDocument.Open(mem, true, new OpenSettings()
|
||||
{
|
||||
MarkupCompatibilityProcessSettings =
|
||||
new MarkupCompatibilityProcessSettings(MarkupCompatibilityProcessMode.ProcessAllParts,
|
||||
FileFormatVersions.Office2010)
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
//LoggerHelper.DiagnosticAudit.Information(DateTime.Now,
|
||||
//Common.Enums.Area.BaseSystem,
|
||||
//0,
|
||||
//string.Format(ex.ToString()),
|
||||
//new Guid().ToString());
|
||||
//LoggerHelper.DiagnosticAudit.Log.Information(ex.ToString());
|
||||
#else
|
||||
//LoggerHelper.DiagnosticAudit.Information(DateTime.Now,
|
||||
//Common.Enums.Area.BaseSystem,
|
||||
//0,
|
||||
//string.Format(ex.Message),
|
||||
//Guid.Empty.ToString());
|
||||
#endif
|
||||
//throw new BusinessException("Hibás vagy nem megfelelő OpenXML állomány.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
mem?.Dispose();
|
||||
doc?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Generate(Dictionary<string, string> propertyDictionary)
|
||||
{
|
||||
ReplaceBookmarks(propertyDictionary);
|
||||
if (Repeater?.SablonRoot != null) Repeater.InsertAndReset();
|
||||
}
|
||||
|
||||
public void SimpleReplace(string key, string value)
|
||||
{
|
||||
value = value == null ? "" : value;
|
||||
|
||||
foreach (var headerPart in Doc.MainDocumentPart.HeaderParts)
|
||||
SimpleReplace2(headerPart.Header, key, value);
|
||||
|
||||
SimpleReplace2(Doc.MainDocumentPart.Document.Body, key, value);
|
||||
|
||||
foreach (var footerPart in Doc.MainDocumentPart.FooterParts)
|
||||
SimpleReplace2(footerPart.Footer, key, value);
|
||||
}
|
||||
|
||||
protected void SimpleReplace(OpenXmlCompositeElement target, string key, string value)
|
||||
{
|
||||
var keyValue = key.Replace("#", "");
|
||||
var texts = target.Descendants<Text>();
|
||||
Text start = null;
|
||||
Text keyValueText = null;
|
||||
foreach (var text in texts)
|
||||
if (text.Text == "#" && start == null)
|
||||
start = text;
|
||||
else if (text.Text == "#" && start != null && keyValueText != null)
|
||||
{
|
||||
var end = text;
|
||||
keyValueText.Text = value;
|
||||
start.Remove();
|
||||
end.Remove();
|
||||
start = null;
|
||||
keyValueText = null;
|
||||
}
|
||||
else if (start != null && text.Text.ToUpper().Contains(keyValue.ToUpper()))
|
||||
keyValueText = text;
|
||||
else if (text.Text.ToUpper().Contains(key.ToUpper()))
|
||||
{
|
||||
start = null;
|
||||
keyValueText = null;
|
||||
text.Text = Regex.Replace(text.Text, key, value, RegexOptions.IgnoreCase);
|
||||
}
|
||||
else
|
||||
{
|
||||
start = null;
|
||||
keyValueText = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void SimpleReplace2(OpenXmlCompositeElement target, string key, string value)
|
||||
{
|
||||
var texts = target.Descendants<Text>();
|
||||
Text start = null;
|
||||
var tokens = new List<Text>();
|
||||
string tokenText = "";
|
||||
|
||||
foreach (var text in texts)
|
||||
{
|
||||
if (text.Text == "#" && start == null)
|
||||
{
|
||||
start = text;
|
||||
tokenText += text.Text;
|
||||
}
|
||||
else if (text.Text == "#" && start != null)
|
||||
{
|
||||
var end = text;
|
||||
tokenText += text.Text;
|
||||
|
||||
if (tokenText.ToUpper() == key.ToUpper())
|
||||
{
|
||||
start.Text = value;
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
token.Remove();
|
||||
}
|
||||
tokens.Clear();
|
||||
end.Remove();
|
||||
start = null;
|
||||
tokenText = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
start = null;
|
||||
tokens.Clear();
|
||||
tokenText = "";
|
||||
end = null;
|
||||
}
|
||||
}
|
||||
else if (text.Text.Contains('#') && text.Text.ToUpper() == key.ToUpper())
|
||||
{
|
||||
text.Text = value;
|
||||
}
|
||||
else if (text.Text.Contains('#'))
|
||||
{
|
||||
|
||||
}
|
||||
else if (start != null)
|
||||
{
|
||||
tokens.Add(text);
|
||||
tokenText += text.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SimpleReplaceForCV(string key, string value)
|
||||
{
|
||||
value = value == null ? "" : value;
|
||||
|
||||
SimpleReplaceForCV(Doc.MainDocumentPart.Document.Body, key, value);
|
||||
}
|
||||
|
||||
protected void SimpleReplaceForCV(OpenXmlCompositeElement target, string key, string value)
|
||||
{
|
||||
var keyValue = key.Replace("#", "");
|
||||
var texts = target.Descendants<Text>();
|
||||
Text start = null;
|
||||
Text keyValueText = null;
|
||||
var keyindox = "";
|
||||
foreach (var text in texts)
|
||||
{
|
||||
if (text.Text.Contains(key))
|
||||
{
|
||||
text.Text = text.Text.Replace(key, value);
|
||||
break;
|
||||
}
|
||||
|
||||
if (text.Text.Contains(keyValue + "#") && start != null)
|
||||
{
|
||||
start.Text = "";
|
||||
text.Text = text.Text.Replace(keyValue + "#", value);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((text.Text == "#" || (text.Text.Contains("#") && text.Text.Count(x => x == '#') == 1)) && start == null)
|
||||
{
|
||||
start = text;
|
||||
keyindox = start.Text;
|
||||
}
|
||||
else if (start != null && (text.Text == "#" || text.Text.Contains("#")))
|
||||
{
|
||||
for (int i = texts.ToList().IndexOf(start) + 1; i < texts.ToList().IndexOf(text) + 1; i++)
|
||||
{
|
||||
if (texts.ToList()[i].Text.Contains(key))
|
||||
{
|
||||
texts.ToList()[i].Text = texts.ToList()[i].Text.Replace(key, value);
|
||||
break;
|
||||
}
|
||||
|
||||
keyindox = keyindox + texts.ToList()[i].Text;
|
||||
}
|
||||
keyindox = keyindox.Replace("#", "");
|
||||
if (keyindox == keyValue || keyindox.Replace(" ", "") == keyValue)
|
||||
{
|
||||
for (int i = texts.ToList().IndexOf(start) + 1; i < texts.ToList().IndexOf(text); i++)
|
||||
{
|
||||
texts.ToList()[i].Text = "";
|
||||
}
|
||||
start.Text = "";
|
||||
text.Text = value;
|
||||
}
|
||||
if (keyindox.Contains(keyValue))
|
||||
{
|
||||
for (int i = texts.ToList().IndexOf(start) + 1; i < texts.ToList().IndexOf(text); i++)
|
||||
{
|
||||
texts.ToList()[i].Text = "";
|
||||
}
|
||||
start.Text = "";
|
||||
text.Text = keyindox.Replace(keyValue, value);
|
||||
}
|
||||
start = null;
|
||||
keyindox = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ReplaceBookmarks(Dictionary<string, string> propertyDictionary)
|
||||
{
|
||||
var bookmarkEndList = new List<BookmarkEnd>();
|
||||
foreach (var item in CurrentRoot)
|
||||
{
|
||||
var bookmarkEnds = item.Descendants<BookmarkEnd>();
|
||||
bookmarkEndList.AddRange(bookmarkEnds.ToList());
|
||||
}
|
||||
|
||||
foreach (var docContent in CurrentRoot)
|
||||
{
|
||||
var bookmarkStarts = docContent.Descendants<BookmarkStart>();
|
||||
|
||||
var bookmarkStartList = bookmarkStarts.ToList();
|
||||
if (docContent is BookmarkStart)
|
||||
bookmarkStartList.Add(docContent as BookmarkStart);
|
||||
|
||||
for (int k = 0; k < bookmarkStartList.Count; k++)
|
||||
{
|
||||
Run bookmarkRun = bookmarkStartList[k].NextSibling<Run>();
|
||||
if (bookmarkRun != null)
|
||||
{
|
||||
var bookmarkText = bookmarkRun.GetFirstChild<Text>().InnerText;
|
||||
if (propertyDictionary.ContainsKey(bookmarkText))
|
||||
{
|
||||
var itemValue = propertyDictionary[bookmarkText];
|
||||
|
||||
bookmarkRun.GetFirstChild<Text>().Text = itemValue ?? string.Empty;
|
||||
var id = bookmarkStartList[k].Id.Value;
|
||||
bookmarkStartList[k].Remove();
|
||||
var end = bookmarkEndList.Find(x => x.Id == id);
|
||||
end.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Táblázat generálás (a keyinrow paramétert keresi a táblázat első sorában (nem fejléc), ezt a sort kitörli, és helyére szúrja be az új sorokat
|
||||
/// amit az első paraméterben kap meg
|
||||
/// </summary>
|
||||
/// <param name="rowsAndCells">sorok és benne az egyes cellák tartalma</param>
|
||||
/// <param name="keyInRow">első (nem fejléc) sorában lévő kulcs, ez alapján azonosítjuk be a táblázatot</param>
|
||||
/// <param name="deleteEmptyRow">ha igaz, a táblázat összes meglévő sorát törli</param>
|
||||
public void SetTable_Old(List<List<string>> rowsAndCells, string keyInRow, bool deleteEmptyRow = false)
|
||||
{
|
||||
Body bod = Doc.MainDocumentPart.Document.Body;
|
||||
var table = bod.Descendants<Table>().Where(tbl => tbl.InnerText.Contains(keyInRow)).FirstOrDefault();
|
||||
if (table != null)
|
||||
{
|
||||
if (deleteEmptyRow)
|
||||
{
|
||||
var firstRow = table.ChildElements.Where(x => x is TableRow).FirstOrDefault();
|
||||
var deletedRows = table.ChildElements.Where(x => x is TableRow).ToList();
|
||||
deletedRows.Remove(firstRow);
|
||||
foreach (var item in deletedRows)
|
||||
table.RemoveChild(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
var deletedRow = table.ChildElements.Where(x => x is TableRow).LastOrDefault();
|
||||
table.RemoveChild<TableRow>(deletedRow as TableRow);
|
||||
}
|
||||
|
||||
foreach (var row in rowsAndCells)
|
||||
{
|
||||
List<OpenXmlElement> cells = new List<OpenXmlElement>();
|
||||
|
||||
foreach (var cell in row)
|
||||
{
|
||||
var tableCell = new TableCell(new Paragraph(new Run(new Text(cell))));
|
||||
cells.Add(tableCell);
|
||||
}
|
||||
|
||||
table.Append(new TableRow(cells));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetTable(List<List<string>> rowsAndCells, string keyInRow, bool deleteEmptyRow = false)
|
||||
{
|
||||
Body bod = Doc.MainDocumentPart.Document.Body;
|
||||
var table = bod.Descendants<Table>().Where(tbl => tbl.InnerText.Contains(keyInRow)).FirstOrDefault();
|
||||
if (table != null)
|
||||
{
|
||||
TableRow formatRow = null;
|
||||
|
||||
// Megkeressük az első sort és elmentjük a formázást
|
||||
if (deleteEmptyRow)
|
||||
{
|
||||
var firstRow = table.ChildElements.OfType<TableRow>().FirstOrDefault();
|
||||
if (firstRow != null)
|
||||
{
|
||||
formatRow = (TableRow)firstRow.CloneNode(true); // Az első sor másolása formázással
|
||||
var deletedRows = table.ChildElements.OfType<TableRow>().ToList();
|
||||
foreach (var item in deletedRows)
|
||||
table.RemoveChild(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var deletedRow = table.ChildElements.OfType<TableRow>().LastOrDefault();
|
||||
if (deletedRow != null)
|
||||
{
|
||||
formatRow = (TableRow)deletedRow.CloneNode(true); // Az utolsó sor másolása formázással
|
||||
table.RemoveChild(deletedRow);
|
||||
}
|
||||
}
|
||||
|
||||
// Új sorok beszúrása a mentett formázással
|
||||
foreach (var row in rowsAndCells)
|
||||
{
|
||||
List<OpenXmlElement> cells = new List<OpenXmlElement>();
|
||||
|
||||
for (int i = 0; i < row.Count; i++)
|
||||
{
|
||||
var cellText = row[i].Replace("#", "");
|
||||
|
||||
// Ha van formázási minta, alkalmazzuk
|
||||
TableCell newCell;
|
||||
if (formatRow != null && i < formatRow.Elements<TableCell>().Count())
|
||||
{
|
||||
var formatCell = formatRow.Elements<TableCell>().ElementAt(i);
|
||||
var clonedCell = (TableCell)formatCell.CloneNode(true);
|
||||
var para = clonedCell.Descendants<Paragraph>().FirstOrDefault();
|
||||
|
||||
// Ha van beágyazott szöveg, frissítjük a tartalmát
|
||||
if (para != null)
|
||||
{
|
||||
var run = para.Descendants<Run>().FirstOrDefault();
|
||||
if (run != null)
|
||||
{
|
||||
run.RemoveAllChildren<Text>();
|
||||
run.AppendChild(new Text(cellText));
|
||||
}
|
||||
}
|
||||
|
||||
newCell = clonedCell;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Alapértelmezett cella, ha nincs formázási minta
|
||||
newCell = new TableCell(new Paragraph(new Run(new Text(cellText))));
|
||||
}
|
||||
|
||||
cells.Add(newCell);
|
||||
}
|
||||
|
||||
table.Append(new TableRow(cells));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] CloseAndGetDocument()
|
||||
{
|
||||
Doc.Dispose();
|
||||
Doc = null;
|
||||
return Mem.ToArray();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Doc?.Dispose();
|
||||
Mem.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hozzáfűzi a már megnyitott fájlhoz a paraméterként kapott dokumentum tartalmát.
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
/// <param name="addPageBreak"></param>
|
||||
public void AppendDocument(byte[] document, bool addPageBreak = true)
|
||||
{
|
||||
var mainPart = Doc.MainDocumentPart;
|
||||
string altChunkId = "AltChunk_" + Guid.NewGuid().ToString().Replace("-", "");
|
||||
|
||||
var chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId);
|
||||
chunk.FeedData(new MemoryStream(document));
|
||||
|
||||
// oldaltörés, ha kell
|
||||
if (addPageBreak)
|
||||
{
|
||||
mainPart.Document.Body.AppendChild(new Paragraph(new Run(new Break() { Type = BreakValues.Page })));
|
||||
}
|
||||
|
||||
mainPart.Document.Body.AppendChild(new AltChunk() { Id = altChunkId });
|
||||
|
||||
mainPart.Document.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Értesítés jóváhagyásról</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; background-color: #f9f9f9; padding: 20px;">
|
||||
|
||||
<p style="font-size: 18px;">
|
||||
A következő munkafolyamat jóvá lett hagyva:
|
||||
</p>
|
||||
|
||||
<p style="font-size: 28px; font-weight: bold; color: #333; margin-top: 10px;">
|
||||
#DocumentNumber#
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Megerősítő kód</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; background-color: #f9f9f9; padding: 20px;">
|
||||
|
||||
<p style="font-size: 18px;">
|
||||
<strong>Workflow Check Application Web</strong> megerősítő kódja:
|
||||
</p>
|
||||
|
||||
<p style="font-size: 28px; font-weight: bold; color: #333; margin-top: 10px;">
|
||||
#token2F#
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.BL.Services;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.BL.Infra
|
||||
{
|
||||
public static class DIConfig
|
||||
{
|
||||
public static void DIInit(IServiceCollection service)
|
||||
{
|
||||
service.AddScoped<IUserService, UserService>();
|
||||
service.AddScoped<ISyncService, SyncService>();
|
||||
service.AddScoped<ICheckListService, CheckListService>();
|
||||
service.AddScoped<INumberGeneratorService, NumberGeneratorService>();
|
||||
service.AddScoped<IMessageService, MessageService>();
|
||||
service.AddScoped<ISystemService, SystemService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using AutoMapper.Configuration.Conventions;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.BL.Mappings
|
||||
{
|
||||
public class MapperProfile : Profile
|
||||
{
|
||||
public MapperProfile()
|
||||
{
|
||||
CreateMap<User, UserDTO>().ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.UserRoles.Select(ur => ur.Role)));
|
||||
|
||||
CreateMap<Role, RoleDTO>()
|
||||
.ForMember(dest => dest.ParentId, opt => opt.MapFrom(src => src.ParentId))
|
||||
.ForMember(dest => dest.ParentRoleName, opt => opt.MapFrom(src => src.Parent != null ? src.Parent.RoleName : null));
|
||||
|
||||
CreateMap<UserRole, UserRoleDTO>()
|
||||
.ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.Role))
|
||||
.ForMember(dest => dest.UserDTO, opt => opt.MapFrom(src => src.User));
|
||||
|
||||
CreateMap<UserDTO, User>()
|
||||
.ForMember(dest => dest.PasswordHash, opt => opt.MapFrom<PasswordHashResolver>());
|
||||
|
||||
|
||||
CreateMap<CheckListTemplateHeader, CheckListTemplateHeaderDTO>()
|
||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
|
||||
|
||||
CreateMap<CheckListTemplateRow, CheckListTemplateRowDTO>()
|
||||
.ForMember(dest => dest.EquipmentDTO, opt => opt.MapFrom(src => src.Equipment))
|
||||
.ForMember(dest => dest.CheckPointDTO, opt => opt.MapFrom(src => src.CheckPoint));
|
||||
|
||||
CreateMap<CheckPoint, CheckPointDTO>()
|
||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
|
||||
|
||||
CreateMap<CheckPoint, CheckPointDTO>()
|
||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
|
||||
|
||||
|
||||
|
||||
|
||||
CreateMap<CheckPointDTO, CheckPoint>();
|
||||
|
||||
CreateMap<Location, LocationDTO>();
|
||||
CreateMap<LocationDTO, Location>();
|
||||
|
||||
CreateMap<Equipment, EquipmentDTO>();
|
||||
CreateMap<EquipmentDTO, Equipment>();
|
||||
|
||||
CreateMap<DeviceMessage, DeviceMessageDTO>();
|
||||
CreateMap<DeviceMessageDTO, DeviceMessage>();
|
||||
|
||||
CreateMap<CheckListHeader, CheckListHeaderDTO>()
|
||||
.ForMember(dest => dest.UserDTO, opt => opt.MapFrom(src => src.User))
|
||||
.ForMember(dest => dest.AcceptUserId, opt => opt.MapFrom(src => src.AcceptUser != null ? src.AcceptUser.Id : (int?)null))
|
||||
.ForMember(dest => dest.AcceptUserDTO, opt => opt.MapFrom(src => src.AcceptUser))
|
||||
.ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows));
|
||||
|
||||
CreateMap<CheckListRow, CheckListRowDTO>()
|
||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRow))
|
||||
.ForMember(dest => dest.Photo, opt => opt.MapFrom(src => GetImageBytes(src.PhotoFileName)));
|
||||
|
||||
|
||||
CreateMap<RoleCheckListTemplateHeader, RoleCheckListTemplateHeaderDTO>()
|
||||
.ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.Role))
|
||||
.ForMember(dest => dest.CheckListTemplateHeaderDTO, opt => opt.MapFrom(src => src.CheckListTemplateHeader));
|
||||
}
|
||||
private byte[] GetImageBytes(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "Images", fileName);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
return File.ReadAllBytes(filePath);
|
||||
}
|
||||
return Array.Empty<byte>(); // Visszaad egy üres byte[]-ot, ha a fájl nem található
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return Array.Empty<byte>(); // Hiba esetén is üres byte[]-ot ad vissza
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.Security;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.BL.Mappings
|
||||
{
|
||||
public class PasswordHashResolver : IValueResolver<UserDTO, User, string>
|
||||
{
|
||||
public string Resolve(UserDTO source, User destination, string destMember, ResolutionContext context)
|
||||
{
|
||||
return PasswordHasher.HashPassword(source.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.BL.Models
|
||||
{
|
||||
public class EmailSettings
|
||||
{
|
||||
public string SmtpServer { get; set; } = string.Empty;
|
||||
public int SmtpPort { get; set; }
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.DL;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class BaseService
|
||||
|
||||
{
|
||||
public readonly AppDbContext _dbContext;
|
||||
public readonly IMapper _mapper;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public BaseService(AppDbContext db_dbContext, IMapper mapper)
|
||||
{
|
||||
_dbContext = db_dbContext;
|
||||
_mapper = mapper;
|
||||
_logger = Log.ForContext("Tag", "PROGSEC");
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteEntityByIdAsync<T>(int id) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var entity = await _dbContext.Set<T>().FindAsync(id);
|
||||
|
||||
if (entity == null)
|
||||
return false;
|
||||
_dbContext.Set<T>().Remove(entity);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Hiba történt a törlés során: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public async Task<T?> GetEntityByIdAsync<T>(int id) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var entity = await _dbContext.Set<T>().FindAsync(id);
|
||||
return entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Hiba történt a lekérdezés során: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<List<TEntity>> GetEntityByFilterAsync<TEntity, TFilter>(TFilter filter) where TEntity : class where TFilter : class
|
||||
{
|
||||
try
|
||||
{
|
||||
IQueryable<TEntity> query = _dbContext.Set<TEntity>();
|
||||
|
||||
|
||||
foreach (var property in typeof(TFilter).GetProperties())
|
||||
{
|
||||
var value = property.GetValue(filter);
|
||||
if (value != null)
|
||||
{
|
||||
var parameter = Expression.Parameter(typeof(TEntity), "x");
|
||||
var member = Expression.Property(parameter, property.Name);
|
||||
var constant = Expression.Constant(value);
|
||||
var equal = Expression.Equal(member, constant);
|
||||
var lambda = Expression.Lambda<Func<TEntity, bool>>(equal, parameter);
|
||||
|
||||
query = query.Where(lambda);
|
||||
}
|
||||
}
|
||||
|
||||
// Adatok lekérdezése
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Hiba történt a lekérdezés során: {ex.Message}");
|
||||
return new List<TEntity>();
|
||||
}
|
||||
}
|
||||
public async Task<PagedResult<TEntity>> GetPagedEntityByFilterAsync<TEntity, TFilter>(TFilter filter, int pageNumber, int pageSize) where TEntity : class where TFilter : class
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
// Az IQueryable típusú lista létrehozása
|
||||
IQueryable<TEntity> query = _dbContext.Set<TEntity>();
|
||||
|
||||
// Dinamikus szűrés a filter tulajdonságai alapján
|
||||
foreach (var property in typeof(TFilter).GetProperties())
|
||||
{
|
||||
var value = property.GetValue(filter);
|
||||
if (value != null)
|
||||
{
|
||||
var parameter = Expression.Parameter(typeof(TEntity), "x");
|
||||
var member = Expression.Property(parameter, property.Name);
|
||||
var constant = Expression.Constant(value);
|
||||
var equal = Expression.Equal(member, constant);
|
||||
var lambda = Expression.Lambda<Func<TEntity, bool>>(equal, parameter);
|
||||
query = query.Where(lambda);
|
||||
}
|
||||
}
|
||||
|
||||
// Teljes rekordok száma a szűrő után
|
||||
int totalCount = await query.CountAsync();
|
||||
|
||||
// Lapozás alkalmazása
|
||||
var items = await query
|
||||
.Skip((pageNumber - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
// Lapozási eredmény összerakása
|
||||
return new PagedResult<TEntity>
|
||||
{
|
||||
Items = items,
|
||||
TotalCount = totalCount,
|
||||
PageNumber = pageNumber,
|
||||
PageSize = pageSize
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Hiba történt a lekérdezés során: {ex.Message}");
|
||||
return new PagedResult<TEntity>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public class PagedResult<TEntity>
|
||||
{
|
||||
public List<TEntity> Items { get; set; } = new List<TEntity>();
|
||||
public int TotalCount { get; set; }
|
||||
public int PageNumber { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,733 @@
|
||||
using AutoMapper;
|
||||
using DocumentFormat.OpenXml.Office.CustomUI;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.BL.DocumentGenerator;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.DL;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class CheckListService : BaseService, ICheckListService
|
||||
{
|
||||
|
||||
private readonly INumberGeneratorService _numberGeneratorService;
|
||||
private readonly IMessageService _messageService;
|
||||
|
||||
public CheckListService(AppDbContext dbContext,
|
||||
IMapper mapper,
|
||||
INumberGeneratorService numberGeneratorService,
|
||||
IMessageService messageService,
|
||||
IUserService userService) : base(dbContext, mapper)
|
||||
{
|
||||
_numberGeneratorService = numberGeneratorService;
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
public async Task<CheckListHeaderDTO> GetCheckListHeaderAsync(int Id)
|
||||
{
|
||||
var retVal = new CheckListHeaderDTO()
|
||||
{
|
||||
CheckListRowDTO = new List<CheckListRowDTO>()
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.Id == Id)
|
||||
.Include(i => i.User)
|
||||
.Include(i => i.AcceptUser)
|
||||
.Include(i => i.CheckListRows)
|
||||
.ThenInclude(r => r.CheckListTemplateRow)
|
||||
.ThenInclude(r => r.CheckPoint)
|
||||
.Include(i => i.CheckListRows)
|
||||
.ThenInclude(r => r.CheckListTemplateRow)
|
||||
.ThenInclude(r => r.Equipment)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
res.CheckListRows = res.CheckListRows
|
||||
.OrderBy(r => r.CheckListTemplateRow.CheckPoint?.ShortName ?? string.Empty)
|
||||
.ThenBy(r => r.CheckListTemplateRow.RowIndex)
|
||||
.ToList();
|
||||
|
||||
|
||||
}
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<CheckListHeaderDTO>(res);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<CheckListHeaderDTO>> GetAllCheckListHeaderAsync()
|
||||
{
|
||||
var retVal = new List<CheckListHeaderDTO>();
|
||||
try
|
||||
{
|
||||
var checkListHeaders = await _dbContext.CheckListHeaders
|
||||
.Include(i => i.CheckListRows)
|
||||
.Include(i => i.User)
|
||||
.Include(i => i.AcceptUser)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (checkListHeaders != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckListHeaderDTO>>(checkListHeaders);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckListHeaderDTO> UpdateCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var retVal = new CheckListHeaderDTO() { CheckListRowDTO = new List<CheckListRowDTO>() };
|
||||
try
|
||||
{
|
||||
if (checkListHeaderDTO.Id == 0)
|
||||
{
|
||||
var checkListHeader = new CheckListHeader()
|
||||
{
|
||||
CheckListTemplateHeaderId = checkListHeaderDTO.CheckListTemplateHeaderDTO.Id,
|
||||
Description = checkListHeaderDTO.Description,
|
||||
ShortName = checkListHeaderDTO.ShortName,
|
||||
GuidNumber = Guid.NewGuid(),
|
||||
};
|
||||
_dbContext.CheckListHeaders.Add(checkListHeader);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListHeaderDTO>(checkListHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
var checkListHeader = await _dbContext.CheckListHeaders
|
||||
.Include(i => i.CheckListRows)
|
||||
.Where(w => w.Id == checkListHeaderDTO.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkListHeader != null)
|
||||
{
|
||||
checkListHeader.Description = checkListHeaderDTO.Description;
|
||||
checkListHeader.ShortName = checkListHeaderDTO.ShortName;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListHeaderDTO>(checkListHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckListHeaderDTO> StartNewCheckListAsync(CheckListHeaderNewDTO checkListHeaderNewDTO)
|
||||
{
|
||||
var retVal = new CheckListHeaderDTO()
|
||||
{
|
||||
CheckListRowDTO = new List<CheckListRowDTO>()
|
||||
};
|
||||
using var transaction = await _dbContext.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
var checkListTemplateHeader = await _dbContext.CheckListTemplateHeaders
|
||||
.Where(w => w.Id == checkListHeaderNewDTO.CheckListTemplateHeaderId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkListTemplateHeader == null)
|
||||
{
|
||||
return retVal;
|
||||
}
|
||||
var currentDate = DateTime.UtcNow;
|
||||
var documentNumber = await _numberGeneratorService.GenerateNextNumberAsync(checkListTemplateHeader.NumberGenerator1Id ?? 1, transaction, currentDate);
|
||||
CheckListHeader checkListHeader = new CheckListHeader()
|
||||
{
|
||||
CheckListTemplateHeaderId = checkListHeaderNewDTO.CheckListTemplateHeaderId,
|
||||
CheckStatus = CheckStatus.Open,
|
||||
DateExecution = currentDate,
|
||||
IsEditable = true,
|
||||
UserId = checkListHeaderNewDTO.UserId,
|
||||
ShortName = "",
|
||||
Description = checkListTemplateHeader.Description ?? "",
|
||||
DocumentNumber = documentNumber,
|
||||
GuidNumber = Guid.NewGuid(),
|
||||
IsDeleted = false,
|
||||
IsStorno = false,
|
||||
CheckListRows = new List<CheckListRow>()
|
||||
};
|
||||
|
||||
|
||||
_dbContext.CheckListHeaders.Add(checkListHeader);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
var checkListTemplateRows = await _dbContext.CheckListTemplateRows
|
||||
.Where(w => w.CheckListTemplateHeaderId == checkListHeaderNewDTO.CheckListTemplateHeaderId)
|
||||
.OrderBy(o => o.RowIndex)
|
||||
.ToListAsync();
|
||||
foreach (var item in checkListTemplateRows)
|
||||
{
|
||||
CheckListRow checkListRow = new CheckListRow()
|
||||
{
|
||||
Answer = "",
|
||||
CheckListHeaderId = checkListHeader.Id,
|
||||
CheckListTemplateRowId = item.Id,
|
||||
GuidNumber = Guid.NewGuid(),
|
||||
IsDeleted = false,
|
||||
PhotoFileName = "",
|
||||
};
|
||||
_dbContext.CheckListRows.Add(checkListRow);
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
|
||||
retVal = _mapper.Map<CheckListHeaderDTO>(checkListHeader);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> AcceptCheckListHeaderAsync(int id, int userid)
|
||||
{
|
||||
var retVal = false;
|
||||
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users
|
||||
.Where(w => w.Id == userid)
|
||||
.FirstOrDefaultAsync();
|
||||
if (user == null) return false;
|
||||
|
||||
var checkListHeader = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.Id == id && w.CheckStatus == CheckStatus.Sent)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (checkListHeader != null)
|
||||
{
|
||||
checkListHeader.CheckStatus = CheckStatus.Signed;
|
||||
checkListHeader.IsEditable = false;
|
||||
checkListHeader.AcceptUserId = userid;
|
||||
|
||||
checkListHeader.DateExecution = DateTime.Now;
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap státuszváltozása, jóváhagyás: Ellenőrzés:{checkListHeader.DocumentNumber}, Felhasználó: {user.LastName} {user.FirstName}");
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
var pdf = await CreateCheckListHeaderPDFAsync(id);
|
||||
if (pdf != null && pdf.Length > 0)
|
||||
{
|
||||
string pdfDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Pdf");
|
||||
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var fileName = $"CD_{timestamp}_{checkListHeader.GuidNumber.ToString().ToUpper()}.pdf";
|
||||
|
||||
var filePath = Path.Combine(pdfDirectory, fileName);
|
||||
await File.WriteAllBytesAsync(filePath, pdf);
|
||||
|
||||
await SendMailToAcceptedUser(filePath, checkListHeader, userid);
|
||||
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private async Task SendMailToAcceptedUser(string filePath, CheckListHeader checkListHeader, int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = _dbContext.Users.Where(W => W.Id == userId).FirstOrDefault();
|
||||
if (user != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(user.Email))
|
||||
{
|
||||
var recepients = new List<string>()
|
||||
{
|
||||
user.Email,
|
||||
};
|
||||
|
||||
await _messageService.SendMailAsync(recepients,
|
||||
$"Értesítés folyamat jóváhagyásáról {checkListHeader.DocumentNumber}",
|
||||
GetAcceptCheckListHeaderMessageBody(checkListHeader),
|
||||
filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private string GetAcceptCheckListHeaderMessageBody(CheckListHeader checkListHeader)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName = "WorkFlowCheck.BL.HtmlTemplates.AcceptCheckListHeaderBody.html";
|
||||
|
||||
using var stream = assembly.GetManifestResourceStream(resourceName);
|
||||
if (stream == null)
|
||||
throw new FileNotFoundException($"Nem található a beágyazott erőforrás: {resourceName}");
|
||||
|
||||
using var reader = new StreamReader(stream);
|
||||
var html = reader.ReadToEnd();
|
||||
return html.Replace("#DocumentNumber#", checkListHeader.DocumentNumber);
|
||||
}
|
||||
public async Task<byte[]> CreateCheckListHeaderPDFAsync(int checkListHeaderId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var checkListHeader = await this.GetCheckListHeaderAsync(checkListHeaderId);
|
||||
|
||||
string pdfDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Pdf");
|
||||
|
||||
byte[] byteArray = File.ReadAllBytes(Path.Combine(pdfDirectory, "CheckList_Template_V1.docx"));
|
||||
SablonGenerator gen = new SablonGenerator(byteArray);
|
||||
|
||||
gen.SimpleReplace("#description#", checkListHeader.Description);
|
||||
gen.SimpleReplace("#DocumentNumber#", checkListHeader.DocumentNumber);
|
||||
gen.SimpleReplace("#DateExecution#", checkListHeader.DateExecution.ToString("yyyy.MM.dd HH:mm"));
|
||||
|
||||
gen.SimpleReplace("#WorkUser#", $"{checkListHeader.UserDTO?.LastName} {checkListHeader.UserDTO?.FirstName}");
|
||||
gen.SimpleReplace("#AcceptUser#", $"{checkListHeader.AcceptUserDTO?.LastName} {checkListHeader.AcceptUserDTO?.FirstName}");
|
||||
gen.SimpleReplace("#Guid#", checkListHeader.GuidNumber.ToString());
|
||||
|
||||
if (checkListHeader.CheckListRowDTO != null && checkListHeader.CheckListRowDTO.Count > 0)
|
||||
{
|
||||
var elements = new List<List<string>>();
|
||||
foreach (var item in checkListHeader.CheckListRowDTO)
|
||||
{
|
||||
if (item.CheckListTemplateRowDTO != null)
|
||||
{
|
||||
var cells = new List<string>
|
||||
{
|
||||
$"{item.CheckListTemplateRowDTO.RowIndex.ToString()}.",
|
||||
item.CheckListTemplateRowDTO.OperationDescription,
|
||||
item.Answer
|
||||
};
|
||||
elements.Add(cells);
|
||||
}
|
||||
}
|
||||
gen.SetTable(elements, "#rowindex");
|
||||
}
|
||||
|
||||
|
||||
byte[] content = gen.CloseAndGetDocument();
|
||||
|
||||
string imageDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
|
||||
|
||||
var images = checkListHeader.CheckListRowDTO.Where(w => (w.CheckListTemplateRowDTO.AnswerType == "P" || w.CheckListTemplateRowDTO.AnswerType == "PN") &&
|
||||
string.IsNullOrEmpty(w.Answer) != true)
|
||||
.Select(s => Path.Combine(imageDirectory, s.Answer))
|
||||
.ToList();
|
||||
return DokumentumGenerator.DocxToPdfL(content, images);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
public async Task<bool> BlockCheckListHeaderAsync(int id, int userid)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var checkListHeader = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.Id == id && w.CheckStatus == CheckStatus.InProgress)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (checkListHeader != null && checkListHeader.CheckStatus == CheckStatus.InProgress)
|
||||
{
|
||||
checkListHeader.CheckStatus = CheckStatus.Blocked;
|
||||
checkListHeader.IsEditable = false;
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap blokkolva: Ellenőrzés:{id}, Felhasználó:{userid}");
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
|
||||
|
||||
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> UnBlockCheckListHeaderAsync(int id, int userid)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var checkListHeader = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.Id == id && w.CheckStatus == CheckStatus.Blocked)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (checkListHeader != null && checkListHeader.CheckStatus == CheckStatus.Blocked)
|
||||
{
|
||||
checkListHeader.CheckStatus = CheckStatus.InProgress;
|
||||
checkListHeader.IsEditable = true;
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap feloldva: Ellenőrzés:{id}, Felhasználó:{userid}");
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> CloseCheckListHeader(CheckListHeaderCloseDTO closeCheckListHeaderCloseDTO)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var checkListHeader = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.Id == closeCheckListHeaderCloseDTO.Id &&
|
||||
(w.CheckStatus == CheckStatus.Blocked ||
|
||||
w.CheckStatus == CheckStatus.InProgress ||
|
||||
w.CheckStatus == CheckStatus.Open
|
||||
))
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (checkListHeader != null)
|
||||
{
|
||||
checkListHeader.CheckStatus = CheckStatus.Closed;
|
||||
checkListHeader.IsEditable = false;
|
||||
checkListHeader.AcceptUserId = closeCheckListHeaderCloseDTO.UserId;
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap lezárva: Ellenőrzés:{closeCheckListHeaderCloseDTO.Id}, " +
|
||||
$"Felhasználó:{closeCheckListHeaderCloseDTO.UserId}, " +
|
||||
$"Lezárás oka: {closeCheckListHeaderCloseDTO.CloseReason}");
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeaderAsync(int Id)
|
||||
{
|
||||
var retVal = new CheckListTemplateHeaderDTO()
|
||||
{
|
||||
CheckListTemplateRowDTO = new List<CheckListTemplateRowDTO>()
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListTemplateHeaders
|
||||
.Where(w => w.Id == Id)
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.ThenInclude(i => i.CheckPoint)
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.ThenInclude(i => i.Equipment)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<CheckListTemplateHeaderDTO>(res);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync()
|
||||
{
|
||||
var retVal = new List<CheckListTemplateHeaderDTO>();
|
||||
try
|
||||
{
|
||||
var roles = await _dbContext.CheckListTemplateHeaders
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (roles != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckListTemplateHeaderDTO>>(roles);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
|
||||
{
|
||||
var retVal = new CheckListTemplateHeaderDTO() { CheckListTemplateRowDTO = new List<CheckListTemplateRowDTO>() };
|
||||
try
|
||||
{
|
||||
if (checkListTemplateHeaderDTO.Id == 0)
|
||||
{
|
||||
var checkListTemplateHeader = new CheckListTemplateHeader()
|
||||
{
|
||||
Description = checkListTemplateHeaderDTO.Description,
|
||||
ShortName = checkListTemplateHeaderDTO.ShortName,
|
||||
IsDeleted = false,
|
||||
NumberGenerator1Id = checkListTemplateHeaderDTO.NumberGenerator1Id,
|
||||
NumberGenerator2Id = checkListTemplateHeaderDTO.NumberGenerator2Id,
|
||||
|
||||
};
|
||||
_dbContext.CheckListTemplateHeaders.Add(checkListTemplateHeader);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListTemplateHeaderDTO>(checkListTemplateHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
var checkListTemplateHeader = await _dbContext.CheckListTemplateHeaders
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.Where(w => w.Id == checkListTemplateHeaderDTO.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkListTemplateHeader != null)
|
||||
{
|
||||
checkListTemplateHeader.Description = checkListTemplateHeaderDTO.Description;
|
||||
checkListTemplateHeader.ShortName = checkListTemplateHeaderDTO.ShortName;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListTemplateHeaderDTO>(checkListTemplateHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteCheckListTemplateHeaderAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<CheckListTemplateHeader>(id);
|
||||
}
|
||||
public async Task<bool> CloneCheckListTemplateHeaderAsync(int id)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var checkListTemplateHeader = await _dbContext.CheckListTemplateHeaders
|
||||
.AsNoTracking()
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.Where(w => w.Id == id).FirstOrDefaultAsync();
|
||||
if (checkListTemplateHeader != null)
|
||||
{
|
||||
|
||||
var newCheckListTemplateHeader = new CheckListTemplateHeader()
|
||||
{
|
||||
CheckListTemplateRows = new List<CheckListTemplateRow>(),
|
||||
Description = checkListTemplateHeader.Description,
|
||||
IsDeleted = false,
|
||||
NumberGenerator1Id = checkListTemplateHeader.NumberGenerator1Id,
|
||||
NumberGenerator2Id = checkListTemplateHeader.NumberGenerator2Id,
|
||||
ShortName = $"{checkListTemplateHeader.ShortName} (másolat)",
|
||||
};
|
||||
foreach (var checkListTemplateRow in checkListTemplateHeader.CheckListTemplateRows)
|
||||
{
|
||||
var newCheckListTemplateRow = new CheckListTemplateRow()
|
||||
{
|
||||
AnswerType = checkListTemplateRow.AnswerType,
|
||||
CheckListTemplateHeader = newCheckListTemplateHeader,
|
||||
CheckPointId = checkListTemplateRow.CheckPointId,
|
||||
EquipmentId = checkListTemplateRow.EquipmentId,
|
||||
IsDeleted = false,
|
||||
OperationDescription = checkListTemplateRow.OperationDescription,
|
||||
RowIndex = checkListTemplateRow.RowIndex,
|
||||
};
|
||||
newCheckListTemplateHeader.CheckListTemplateRows.Add(newCheckListTemplateRow);
|
||||
}
|
||||
_dbContext.CheckListTemplateHeaders.Add(newCheckListTemplateHeader);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.ForContext("TAG", "BusinessFlow").Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id)
|
||||
{
|
||||
var retVal = new CheckListTemplateRowDTO();
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListTemplateRows
|
||||
.Include(i => i.Equipment)
|
||||
.Include(i => i.CheckPoint)
|
||||
.Where(w => w.Id == id)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<CheckListTemplateRowDTO>(res);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteCheckListTemplateRowAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<CheckListTemplateRow>(id);
|
||||
}
|
||||
public async Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO)
|
||||
{
|
||||
var retVal = new CheckListTemplateRowDTO() { };
|
||||
try
|
||||
{
|
||||
if (checkListTemplateRowDTO.Id == 0)
|
||||
{
|
||||
var checkListTemplateRow = new CheckListTemplateRow()
|
||||
{
|
||||
CheckListTemplateHeaderId = checkListTemplateRowDTO.CheckListTemplateHeaderId,
|
||||
CheckPointId = checkListTemplateRowDTO.CheckPointId,
|
||||
EquipmentId = checkListTemplateRowDTO.EquipmentId,
|
||||
OperationDescription = checkListTemplateRowDTO.OperationDescription,
|
||||
AnswerType = checkListTemplateRowDTO.AnswerType,
|
||||
RowIndex = checkListTemplateRowDTO.RowIndex,
|
||||
|
||||
};
|
||||
_dbContext.CheckListTemplateRows.Add(checkListTemplateRow);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListTemplateRowDTO>(checkListTemplateRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
var checkListTemplateRow = await _dbContext.CheckListTemplateRows
|
||||
.Where(w => w.Id == checkListTemplateRowDTO.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkListTemplateRow != null)
|
||||
{
|
||||
checkListTemplateRow.CheckListTemplateHeaderId = checkListTemplateRowDTO.CheckListTemplateHeaderId;
|
||||
checkListTemplateRow.CheckPointId = checkListTemplateRowDTO.CheckPointId;
|
||||
checkListTemplateRow.EquipmentId = checkListTemplateRowDTO.EquipmentId;
|
||||
checkListTemplateRow.OperationDescription = checkListTemplateRowDTO.OperationDescription;
|
||||
checkListTemplateRow.AnswerType = checkListTemplateRowDTO.AnswerType;
|
||||
checkListTemplateRow.RowIndex = checkListTemplateRowDTO.RowIndex;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListTemplateRowDTO>(checkListTemplateRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<CheckListRowDTO> GetCheckListRowAsync(int id)
|
||||
{
|
||||
var retVal = new CheckListRowDTO();
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListRows
|
||||
.Include(i => i.CheckListTemplateRow)
|
||||
.Where(w => w.Id == id)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<CheckListRowDTO>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckListRowDTO> UpdateCheckListRowAsync(CheckListRowDTO checkListRowDTO)
|
||||
{
|
||||
var retVal = new CheckListRowDTO() { };
|
||||
try
|
||||
{
|
||||
if (checkListRowDTO.Id == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var checkListRow = await _dbContext.CheckListRows
|
||||
.Where(w => w.Id == checkListRowDTO.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkListRow != null)
|
||||
{
|
||||
checkListRow.Answer = checkListRowDTO.Answer;
|
||||
//checkListRow.Photo = checkListRowDTO.Photo;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListRowDTO>(checkListRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface ICheckListService
|
||||
{
|
||||
Task<CheckListHeaderDTO> GetCheckListHeaderAsync(int Id);
|
||||
Task<List<CheckListHeaderDTO>> GetAllCheckListHeaderAsync();
|
||||
Task<CheckListHeaderDTO> UpdateCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO);
|
||||
Task<bool> AcceptCheckListHeaderAsync(int id, int userid);
|
||||
Task<bool> BlockCheckListHeaderAsync(int id, int userid);
|
||||
Task<bool> UnBlockCheckListHeaderAsync(int id, int userid);
|
||||
Task<bool> CloseCheckListHeader(CheckListHeaderCloseDTO closeCheckListHeaderCloseDTO);
|
||||
Task<byte[]> CreateCheckListHeaderPDFAsync(int checkListHeaderId);
|
||||
Task<CheckListHeaderDTO> StartNewCheckListAsync(CheckListHeaderNewDTO checkListHeaderNewDTO);
|
||||
|
||||
|
||||
Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeaderAsync(int Id);
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
|
||||
Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
|
||||
Task<bool> DeleteCheckListTemplateHeaderAsync(int id);
|
||||
Task<bool> CloneCheckListTemplateHeaderAsync(int id);
|
||||
Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id);
|
||||
Task<bool> DeleteCheckListTemplateRowAsync(int id);
|
||||
Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO);
|
||||
|
||||
Task<CheckListRowDTO> GetCheckListRowAsync(int id);
|
||||
Task<CheckListRowDTO> UpdateCheckListRowAsync(CheckListRowDTO checkListRowDTO);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface IMessageService
|
||||
{
|
||||
Task<bool> SendMailAsync(List<string> recipients, string subject, string htmlBody, string? attachmentFilePath = null);
|
||||
|
||||
Task<bool> SendFCMTokenAsync(string token);
|
||||
Task<string> GetLastFCMTokensAsync();
|
||||
Task<bool> SendFCMMessage(FCMMessageDTO fCMMessageDTO);
|
||||
Task<bool> SendFCMMessageToLastToken(FCMMessageDTO fCMMessageDTO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface INumberGeneratorService
|
||||
{
|
||||
Task<string> GenerateNextNumberAsync(int templateId, IDbContextTransaction transaction, DateTime? baseDate = null);
|
||||
Task<string> GetSampleAsync(int templateId, DateTime? baseDate = null);
|
||||
Task<List<NumberGeneratorTemplateDTO>> GetAllNumbergeneratorsAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface ISyncService
|
||||
{
|
||||
Task<List<CheckPointDTO>> GetAllCheckPointAsync();
|
||||
Task<CheckPointDTO> GetCheckPointAsync(int id);
|
||||
Task<bool> DeleteCheckPointAsync(int id);
|
||||
Task<CheckPointDTO> UpdateCheckPointAsync(CheckPointDTO checkPointDTO);
|
||||
Task<List<CheckPointDTO>> UpdateAllCheckPointAsync(List<CheckPointDTO> checkPointListDTO);
|
||||
|
||||
|
||||
Task<List<LocationDTO>> GetAllLocationAsync();
|
||||
Task<LocationDTO> GetLocationAsync(int id);
|
||||
Task<bool> DeleteLocationAsync(int id);
|
||||
Task<LocationDTO> UpdateLocationAsync(LocationDTO LocationDTO);
|
||||
|
||||
|
||||
Task<List<EquipmentDTO>> GetAllEquipmentAsync();
|
||||
Task<EquipmentDTO> GetEquipmentAsync(int id);
|
||||
Task<bool> DeleteEquipmentAsync(int id);
|
||||
Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO);
|
||||
|
||||
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync(int userId);
|
||||
Task<List<CheckListHeaderDTO>> GetAllCheckListAsync(int userId);
|
||||
|
||||
Task<CheckListHeaderDTO> SendCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO);
|
||||
|
||||
Task<bool> DeviceMessageSend(DeviceMessageDTO deviceMessageDTO);
|
||||
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceId);
|
||||
Task<List<DeviceMessageDTO>> DeviceMessageReadUnreadedRole(int roleId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface ISystemService
|
||||
{
|
||||
Task<string> GetDatabaseAndVersionInfoAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
Task<UserDTO> GetUserAsync(int Id);
|
||||
Task<List<UserDTO>> GetAllUserAsync();
|
||||
Task<bool> DeleteUserAsync(int Id);
|
||||
Task<UserDTO> UpdateUserAsync(UserDTO userDTO);
|
||||
Task<UserDTO> Authenticate(string UserName, string Password);
|
||||
Task<string> Authenticate2F1(string UserName, string Password);
|
||||
Task<UserDTO> Authenticate2F2(string UserName, string Password, string Code, string token2FA);
|
||||
Task<UserDTO> Authenticate2F2ChangePassword(string UserName, string OldPassword, string NewPassword, string Code, string token2FA);
|
||||
Task<UserDTO> AuthenticateNFC(string NFCCode);
|
||||
|
||||
|
||||
Task<RoleDTO> GetRoleAsync(int Id);
|
||||
Task<List<RoleDTO>> GetAllRoleAsync();
|
||||
Task<bool> DeleteRoleAsync(int Id);
|
||||
Task<RoleDTO> UpdateRoleAsync(RoleDTO roleDTO);
|
||||
|
||||
Task<UserRoleDTO> GetUserRoleAsync(int Id);
|
||||
Task<List<UserRoleDTO>> GetAllUserRoleAsync();
|
||||
Task<bool> DeleteUserRoleAsync(int Id);
|
||||
Task<UserRoleDTO> UpdateUserRoleAsync(UserRoleDTO userRoleDTO);
|
||||
|
||||
Task<RoleCheckListTemplateHeaderDTO> GetRoleCheckListTemplateHeaderAsync(int Id);
|
||||
Task<List<RoleCheckListTemplateHeaderDTO>> GetAllRoleCheckListTemplateHeadersAsync();
|
||||
Task<bool> DeleteRoleCheckListTemplateHeaderAsync(int Id);
|
||||
Task<RoleCheckListTemplateHeaderDTO> UpdateRoleCheckListTemplateHeaderAsync(RoleCheckListTemplateHeaderDTO roleCheckListTemplateHeaderDTO);
|
||||
|
||||
Task<RoleCheckPointDTO> GetRoleCheckPointAsync(int Id);
|
||||
Task<List<RoleCheckPointDTO>> GetAllRoleCheckPointsAsync();
|
||||
Task<bool> DeleteRoleCheckPointAsync(int Id);
|
||||
Task<RoleCheckPointDTO> UpdateRoleCheckPointAsync(RoleCheckPointDTO roleCheckPointDTO);
|
||||
|
||||
string GenerateJwtToken(UserDTO userDTO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
using MailKit.Net.Smtp;
|
||||
using MailKit.Security;
|
||||
using MimeKit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using WorkFlowCheck.BL.Models;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WorkFlowCheck.DL;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class MessageService : BaseService, IMessageService
|
||||
{
|
||||
private readonly EmailSettings _settings;
|
||||
|
||||
public MessageService(AppDbContext dbContext,
|
||||
IMapper mapper,
|
||||
IConfiguration configuration) : base(dbContext, mapper)
|
||||
{
|
||||
_settings = configuration.GetSection("EmailSettings").Get<EmailSettings>()!;
|
||||
}
|
||||
|
||||
public async Task<bool> SendMailAsync(List<string> recipients, string subject, string htmlBody, string? attachmentFilePath = null)
|
||||
{
|
||||
var message = new MimeMessage();
|
||||
message.From.Add(new MailboxAddress(_settings.SenderName, _settings.Username));
|
||||
|
||||
foreach (var recipient in recipients)
|
||||
{
|
||||
message.To.Add(MailboxAddress.Parse(recipient));
|
||||
}
|
||||
|
||||
message.Subject = subject;
|
||||
|
||||
var builder = new BodyBuilder
|
||||
{
|
||||
HtmlBody = htmlBody
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(attachmentFilePath) && File.Exists(attachmentFilePath))
|
||||
{
|
||||
builder.Attachments.Add(attachmentFilePath);
|
||||
}
|
||||
|
||||
message.Body = builder.ToMessageBody();
|
||||
using var smtp = new SmtpClient();
|
||||
await smtp.ConnectAsync(_settings.SmtpServer, _settings.SmtpPort, SecureSocketOptions.StartTls);
|
||||
await smtp.AuthenticateAsync(_settings.Username, _settings.Password);
|
||||
await smtp.SendAsync(message);
|
||||
await smtp.DisconnectAsync(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
public async Task<bool> SendFCMTokenAsync(string token)
|
||||
{
|
||||
var retVal = true;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
|
||||
var FCMToken = await _dbContext.FCMTokens.Where(w => w.Token == token).FirstOrDefaultAsync();
|
||||
if (FCMToken == null)
|
||||
{
|
||||
FCMToken = new FCMToken();
|
||||
FCMToken.Token = token;
|
||||
await _dbContext.FCMTokens.AddAsync(FCMToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
FCMToken.LastModAt = DateTime.UtcNow;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.ForContext("TAG", "BusinessFlow").Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<string> GetLastFCMTokensAsync()
|
||||
{
|
||||
var retVal = "";
|
||||
try
|
||||
{
|
||||
var FCMToken = await _dbContext.FCMTokens
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.LastModAt)
|
||||
.Take(1)
|
||||
.FirstOrDefaultAsync();
|
||||
if (FCMToken != null && !string.IsNullOrEmpty(FCMToken.Token))
|
||||
{
|
||||
retVal += FCMToken.Token;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = "";
|
||||
Log.ForContext("TAG", "BusinessFlow").Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> SendFCMMessage(FCMMessageDTO fCMMessageDTO)
|
||||
{
|
||||
var retVal = true;
|
||||
try
|
||||
{
|
||||
var pathToJsonKey = "com-nuvolar-wfcapp-firebase-adminsdk-fbsvc-37642626e4.json";
|
||||
var projectId = "com-nuvolar-wfcapp";
|
||||
var credential = GoogleCredential
|
||||
.FromFile(pathToJsonKey)
|
||||
.CreateScoped("https://www.googleapis.com/auth/firebase.messaging");
|
||||
var accessToken = await credential.UnderlyingCredential.GetAccessTokenForRequestAsync();
|
||||
|
||||
var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
|
||||
|
||||
var message = new
|
||||
{
|
||||
message = new
|
||||
{
|
||||
token = fCMMessageDTO.Token,
|
||||
notification = new
|
||||
{
|
||||
title = fCMMessageDTO.Title,
|
||||
body = fCMMessageDTO.Body,
|
||||
},
|
||||
android = new
|
||||
{
|
||||
notification = new
|
||||
{
|
||||
channel_id = "com.nuvolar.wfcapp.general"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var json = JsonConvert.SerializeObject(message);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
|
||||
var response = await client.PostAsync($"https://fcm.googleapis.com/v1/projects/{projectId}/messages:send", content);
|
||||
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> SendFCMMessageToLastToken(FCMMessageDTO fCMMessageDTO)
|
||||
{
|
||||
var retVal = true;
|
||||
try
|
||||
{
|
||||
fCMMessageDTO.Token = await GetLastFCMTokensAsync();
|
||||
|
||||
retVal = await SendFCMMessage(fCMMessageDTO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.DL;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class NumberGeneratorService : INumberGeneratorService
|
||||
{
|
||||
private readonly AppDbContext _dbContext;
|
||||
private static readonly Dictionary<int, SemaphoreSlim> _templateLocks = new();
|
||||
|
||||
public NumberGeneratorService(AppDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<string> GenerateNextNumberAsync(int templateId, IDbContextTransaction transaction, DateTime? baseDate = null)
|
||||
{
|
||||
var semaphore = GetOrCreateSemaphore(templateId);
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var template = await _dbContext.Set<NumberGeneratorTemplate>()
|
||||
.FirstOrDefaultAsync(t => t.Id == templateId);
|
||||
|
||||
if (template == null)
|
||||
throw new InvalidOperationException($"Template with ID {templateId} not found.");
|
||||
|
||||
var now = baseDate ?? DateTime.Now;
|
||||
var (year, month) = GetKeyDateParts(template, now);
|
||||
|
||||
var templateDate = await _dbContext.Set<NumberGeneratorTemplateDate>()
|
||||
.FirstOrDefaultAsync(td => td.NumberGeneratorTemplateId == templateId && td.Year == year && td.Month == month);
|
||||
|
||||
if (templateDate == null)
|
||||
{
|
||||
templateDate = new NumberGeneratorTemplateDate
|
||||
{
|
||||
NumberGeneratorTemplateId = template.Id,
|
||||
Year = year,
|
||||
Month = month,
|
||||
CurrentNumber = 0
|
||||
};
|
||||
_dbContext.Add(templateDate);
|
||||
}
|
||||
|
||||
templateDate.CurrentNumber++;
|
||||
var formatted = templateDate.CurrentNumber.ToString(template.DigitFormat);
|
||||
var dynamicSuffix = BuildDynamicSuffix(template, now);
|
||||
var result = BuildFormattedNumber(template, formatted, dynamicSuffix);
|
||||
|
||||
templateDate.LastGeneratedNumber = result;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
}
|
||||
public async Task<string> GetSampleAsync(int templateId, DateTime? baseDate = null)
|
||||
{
|
||||
var template = await _dbContext.Set<NumberGeneratorTemplate>()
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(t => t.Id == templateId);
|
||||
|
||||
if (template == null)
|
||||
throw new InvalidOperationException($"Template with ID {templateId} not found.");
|
||||
|
||||
var now = baseDate ?? DateTime.Now;
|
||||
var formatted = 1.ToString(template.DigitFormat);
|
||||
var dynamicSuffix = BuildDynamicSuffix(template, now);
|
||||
|
||||
return BuildFormattedNumber(template, formatted, dynamicSuffix);
|
||||
}
|
||||
public async Task<List<NumberGeneratorTemplateDTO>> GetAllNumbergeneratorsAsync()
|
||||
{
|
||||
var retVal = new List<NumberGeneratorTemplateDTO>();
|
||||
try
|
||||
{
|
||||
var numbergenerators = await _dbContext.NumberGeneratorTemplates.ToListAsync();
|
||||
foreach (var numbergenerator in numbergenerators)
|
||||
{
|
||||
var numbergeneratortemplateDTO = new NumberGeneratorTemplateDTO();
|
||||
numbergeneratortemplateDTO.Id = numbergenerator.Id;
|
||||
numbergeneratortemplateDTO.ShortName = numbergenerator.ShortName;
|
||||
numbergeneratortemplateDTO.Sample = await this.GetSampleAsync(numbergenerator.Id, DateTime.Now);
|
||||
retVal.Add(numbergeneratortemplateDTO);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
private SemaphoreSlim GetOrCreateSemaphore(int templateId)
|
||||
{
|
||||
lock (_templateLocks)
|
||||
{
|
||||
if (!_templateLocks.ContainsKey(templateId))
|
||||
_templateLocks[templateId] = new SemaphoreSlim(1, 1);
|
||||
|
||||
return _templateLocks[templateId];
|
||||
}
|
||||
}
|
||||
private static (int year, int? month) GetKeyDateParts(NumberGeneratorTemplate template, DateTime date)
|
||||
{
|
||||
int year = date.Year;
|
||||
int? month = template.GenerateType == GenerateType.YearAndMonth ? date.Month : null;
|
||||
return (year, month);
|
||||
}
|
||||
private static string BuildDynamicSuffix(NumberGeneratorTemplate template, DateTime date)
|
||||
{
|
||||
return template.GenerateType switch
|
||||
{
|
||||
GenerateType.OnlyYear => date.Year.ToString(),
|
||||
GenerateType.YearAndMonth => $"{date.Year}/{date.Month:D2}",
|
||||
_ => template.Suffix
|
||||
};
|
||||
}
|
||||
private static string BuildFormattedNumber(NumberGeneratorTemplate template, string formattedNumber, string dynamicSuffix)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if (!string.IsNullOrEmpty(template.Prefix))
|
||||
sb.Append(template.Prefix);
|
||||
|
||||
if (!string.IsNullOrEmpty(template.PrefixSeparator) && !string.IsNullOrEmpty(template.Prefix))
|
||||
sb.Append(template.PrefixSeparator);
|
||||
|
||||
sb.Append(formattedNumber);
|
||||
|
||||
if (!string.IsNullOrEmpty(dynamicSuffix))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(template.SuffixSeparator))
|
||||
sb.Append(template.SuffixSeparator);
|
||||
|
||||
sb.Append(dynamicSuffix);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,599 @@
|
||||
|
||||
using AutoMapper;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using System.Collections.Generic;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.Common.RequestContext;
|
||||
using WorkFlowCheck.DL;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class SyncService : BaseService, ISyncService
|
||||
{
|
||||
private readonly IRequestContext _requestContext;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IMessageService _messageService;
|
||||
|
||||
public SyncService(AppDbContext dbContext,
|
||||
IMapper mapper,
|
||||
IRequestContext requestContext,
|
||||
IMessageService messageService,
|
||||
IUserService userService) : base(dbContext, mapper)
|
||||
{
|
||||
_requestContext = requestContext;
|
||||
_userService = userService;
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
public async Task<List<CheckPointDTO>> GetAllCheckPointAsync()
|
||||
{
|
||||
var retVal = new List<CheckPointDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckPoints
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckPointDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckPointDTO> GetCheckPointAsync(int id)
|
||||
{
|
||||
var retVal = new CheckPointDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var checkpoint = await _dbContext.CheckPoints
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.Where(w => w.Id == id)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkpoint != null)
|
||||
{
|
||||
retVal = _mapper.Map<CheckPointDTO>(checkpoint);
|
||||
|
||||
var role = await _dbContext.Roles.Where(w => w.Id == retVal.RoleId).FirstOrDefaultAsync();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteCheckPointAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<CheckPoint>(id);
|
||||
}
|
||||
public async Task<CheckPointDTO> UpdateCheckPointAsync(CheckPointDTO checkPointDTO)
|
||||
{
|
||||
var retVal = new CheckPointDTO();
|
||||
|
||||
try
|
||||
{
|
||||
if (checkPointDTO.Id == 0) //Hozzáadás, ha Id == 0
|
||||
{
|
||||
var checkPoint = _mapper.Map<CheckPoint>(checkPointDTO);
|
||||
_dbContext.CheckPoints.Add(checkPoint);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<CheckPointDTO>(checkPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
var res = await _dbContext.CheckPoints.Where(w => w.Id == checkPointDTO.Id).FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
res.ShortName = checkPointDTO.ShortName;
|
||||
res.Code = checkPointDTO.Code;
|
||||
res.IsEnabled = checkPointDTO.IsEnabled;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<CheckPointDTO>(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<CheckPointDTO>> UpdateAllCheckPointAsync(List<CheckPointDTO> checkPointListDTO)
|
||||
{
|
||||
var retVal = new List<CheckPointDTO>();
|
||||
try
|
||||
{
|
||||
var ids = checkPointListDTO.Select(dto => dto.Id).ToList();
|
||||
var checkPoints = await _dbContext.CheckPoints
|
||||
.Where(cp => ids.Contains(cp.Id))
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var checkPoint in checkPoints)
|
||||
{
|
||||
var dto = checkPointListDTO.FirstOrDefault(d => d.Id == checkPoint.Id);
|
||||
if (dto != null)
|
||||
{
|
||||
checkPoint.Code = dto.Code;
|
||||
}
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<List<CheckPointDTO>>(checkPoints);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<List<LocationDTO>> GetAllLocationAsync()
|
||||
{
|
||||
var retVal = new List<LocationDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.Locations.ToListAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<LocationDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<LocationDTO> GetLocationAsync(int id)
|
||||
{
|
||||
var retVal = new LocationDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.Locations
|
||||
.Where(w => w.Id == id)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<LocationDTO>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteLocationAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<DL.Entities.Location>(id);
|
||||
}
|
||||
public async Task<LocationDTO> UpdateLocationAsync(LocationDTO LocationDTO)
|
||||
{
|
||||
var retVal = new LocationDTO();
|
||||
|
||||
try
|
||||
{
|
||||
if (LocationDTO.Id == 0) //Hozzáadás, ha Id == 0
|
||||
{
|
||||
var Location = _mapper.Map<DL.Entities.Location>(LocationDTO);
|
||||
_dbContext.Locations.Add(Location);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<LocationDTO>(Location);
|
||||
}
|
||||
else
|
||||
{
|
||||
var res = await _dbContext.Locations.Where(w => w.Id == LocationDTO.Id).FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
res.FullName = LocationDTO.FullName;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<LocationDTO>(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<List<EquipmentDTO>> GetAllEquipmentAsync()
|
||||
{
|
||||
var retVal = new List<EquipmentDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.Equipments.ToListAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<EquipmentDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<EquipmentDTO> GetEquipmentAsync(int id)
|
||||
{
|
||||
var retVal = new EquipmentDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.Equipments
|
||||
.Where(w => w.Id == id)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<EquipmentDTO>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteEquipmentAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<Equipment>(id);
|
||||
}
|
||||
public async Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO)
|
||||
{
|
||||
var retVal = new EquipmentDTO();
|
||||
|
||||
try
|
||||
{
|
||||
if (EquipmentDTO.Id == 0) //Hozzáadás, ha Id == 0
|
||||
{
|
||||
var Equipment = _mapper.Map<Equipment>(EquipmentDTO);
|
||||
_dbContext.Equipments.Add(Equipment);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<EquipmentDTO>(Equipment);
|
||||
}
|
||||
else
|
||||
{
|
||||
var res = await _dbContext.Equipments.Where(w => w.Id == EquipmentDTO.Id).FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
res.ShortName = EquipmentDTO.ShortName;
|
||||
res.EquipmentNumber = EquipmentDTO.EquipmentNumber;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<EquipmentDTO>(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync(int userId)
|
||||
{
|
||||
var retVal = new List<CheckListTemplateHeaderDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var user = _dbContext.Users.Where(w => w.Id == userId).FirstOrDefault();
|
||||
if (user != null)
|
||||
{
|
||||
var res = await (from ur in _dbContext.UserRoles
|
||||
join rth in _dbContext.RoleCheckListTemplateHeaders on ur.RoleId equals rth.RoleId
|
||||
join header in _dbContext.CheckListTemplateHeaders on rth.CheckListTemplateHeaderId equals header.Id
|
||||
where ur.UserId == userId
|
||||
select header)
|
||||
.Include(h => h.CheckListTemplateRows)
|
||||
.Distinct()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckListTemplateHeaderDTO>>(res);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<CheckListHeaderDTO>> GetAllCheckListAsync(int userId)
|
||||
{
|
||||
var retVal = new List<CheckListHeaderDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.CheckStatus == CheckStatus.Open ||
|
||||
w.CheckStatus == CheckStatus.InProgress ||
|
||||
w.CheckStatus == CheckStatus.Blocked ||
|
||||
w.CheckStatus == CheckStatus.Sent)
|
||||
.Include(i => i.CheckListRows)
|
||||
//.ThenInclude(i => i.CheckListTemplateRow)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckListHeaderDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<CheckListHeaderDTO> SendCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var retVal = new CheckListHeaderDTO();
|
||||
|
||||
try
|
||||
{
|
||||
if (checkListHeaderDTO.Id > 0)
|
||||
{
|
||||
var res = await _dbContext.CheckListHeaders
|
||||
.Include(i => i.CheckListRows)
|
||||
.Where(w => w.Id == checkListHeaderDTO.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (res != null && (res.CheckStatus == CheckStatus.Open ||
|
||||
res.CheckStatus == CheckStatus.InProgress))
|
||||
{
|
||||
var ids = checkListHeaderDTO.CheckListRowDTO?.Select(r => r.Id).ToList();
|
||||
if (ids != null && ids.Count > 0)
|
||||
{
|
||||
var rowsToUpdate = await _dbContext.CheckListRows
|
||||
.Where(r => ids.Contains(r.Id))
|
||||
.ToListAsync();
|
||||
foreach (var row in rowsToUpdate)
|
||||
{
|
||||
var dtoRow = checkListHeaderDTO.CheckListRowDTO?.FirstOrDefault(r => r.Id == row.Id);
|
||||
if (dtoRow != null)
|
||||
{
|
||||
row.Answer = dtoRow.Answer;
|
||||
if (dtoRow.Photo != null && dtoRow.Photo.Length > 0)
|
||||
{
|
||||
|
||||
string imageDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
|
||||
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var fileName = $"PH_{timestamp}_{row.CheckListHeaderId}_{row.Id}.jpeg";
|
||||
row.PhotoFileName = fileName;
|
||||
var filePath = Path.Combine(imageDirectory, fileName);
|
||||
await File.WriteAllBytesAsync(filePath, dtoRow.Photo);
|
||||
row.Answer = fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = _mapper.Map<CheckListHeaderDTO>(res);
|
||||
string Answer = "";
|
||||
if (NeedBlocking(checkListHeaderDTO, out Answer))
|
||||
{
|
||||
/// TODO: blokkolás miatt
|
||||
res.CheckStatus = CheckStatus.Blocked;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap blokkolva: Ellenőrzés:{checkListHeaderDTO.Id}, Felhasználó:{_requestContext.CurrentUsername}");
|
||||
|
||||
var user = await _userService.GetUserAsync(_requestContext.CurrentUserId ?? 1);
|
||||
|
||||
foreach (var item in user.RoleDTO)
|
||||
{
|
||||
var deviceMessageDTO = new DeviceMessageDTO()
|
||||
{
|
||||
IsReaded = false,
|
||||
Message = $"Ellenőrző lap blokkolva! [{checkListHeaderDTO.DocumentNumber}]\n({Answer})",
|
||||
SendDate = DateTime.UtcNow,
|
||||
ExtraDataJSON = "",
|
||||
RoleId = item.ParentId,
|
||||
DeviceIdFrom = "",
|
||||
DeviceIdTo = "",
|
||||
};
|
||||
|
||||
await this.DeviceMessageSend(deviceMessageDTO);
|
||||
|
||||
var fCMMessageDTO = new FCMMessageDTO
|
||||
{
|
||||
Body = deviceMessageDTO.Message,
|
||||
Title = "Blokkolási értesítés",
|
||||
UserId = user.Id,
|
||||
};
|
||||
await _messageService.SendFCMMessageToLastToken(fCMMessageDTO);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
res.CheckStatus = CheckStatus.InProgress;
|
||||
|
||||
if (CheckIfLastReached(checkListHeaderDTO))
|
||||
{
|
||||
/// TODO: most kell a CheckStatust állítani és menjen üzenet !
|
||||
res.CheckStatus = CheckStatus.Sent;
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap státuszváltozása: Ellenőrzés:{checkListHeaderDTO.Id}, Felhasználó:{_requestContext.CurrentUsername}");
|
||||
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
|
||||
retVal = _mapper.Map<CheckListHeaderDTO>(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
private bool NeedBlocking(CheckListHeaderDTO checkListHeaderDTO, out string Answer)
|
||||
{
|
||||
var retVal = false;
|
||||
Answer = "";
|
||||
if (checkListHeaderDTO.CheckListRowDTO != null && checkListHeaderDTO.CheckListRowDTO.Count > 0)
|
||||
{
|
||||
var checkListRows = checkListHeaderDTO.CheckListRowDTO;
|
||||
foreach (var row in checkListRows)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(row.Answer))
|
||||
{
|
||||
if (row.CheckListTemplateRowDTO != null)
|
||||
{
|
||||
Answer = row.CheckListTemplateRowDTO.OperationDescription;
|
||||
if (row.CheckListTemplateRowDTO.AnswerType == "PI-N" && row.Answer == "Igen")
|
||||
{
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
if (row.CheckListTemplateRowDTO.AnswerType == "I-PN" && row.Answer == "Nem")
|
||||
{
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
private bool CheckIfLastReached(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var retVal = false;
|
||||
|
||||
if (checkListHeaderDTO != null && checkListHeaderDTO.CheckListRowDTO != null && checkListHeaderDTO.CheckListRowDTO.Count > 0)
|
||||
{
|
||||
var totalRowCount = checkListHeaderDTO.CheckListRowDTO.Where(w => w.CheckListTemplateRowDTO.AnswerType != "PN" &&
|
||||
w.CheckListTemplateRowDTO.CheckPointDTO.IsEnabled == true).Count();
|
||||
|
||||
var answeredCount = checkListHeaderDTO.CheckListRowDTO.Where(w => w.CheckListTemplateRowDTO.AnswerType != "PN" &&
|
||||
w.CheckListTemplateRowDTO.CheckPointDTO.IsEnabled == true &&
|
||||
string.IsNullOrEmpty(w.Answer) != true).Count();
|
||||
|
||||
if (totalRowCount == answeredCount) { retVal = true; }
|
||||
}
|
||||
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeviceMessageSend(DeviceMessageDTO deviceMessageDTO)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var deviceMessage = _mapper.Map<DeviceMessage>(deviceMessageDTO);
|
||||
deviceMessage.SendDate = DateTime.UtcNow;
|
||||
deviceMessage.IsReaded = false;
|
||||
_dbContext.DeviceMessages.Add(deviceMessage);
|
||||
await _dbContext.SaveChangesAsync(true);
|
||||
retVal = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<DeviceMessageDTO>> DeviceMessageReadUnreaded(string deviceId)
|
||||
{
|
||||
var retVal = new List<DeviceMessageDTO>();
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.DeviceMessages
|
||||
.Where(w => w.DeviceIdTo == deviceId && w.IsReaded != true)
|
||||
.ToListAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<DeviceMessageDTO>>(res);
|
||||
foreach (var deviceMessage in res)
|
||||
{
|
||||
deviceMessage.IsReaded = true;
|
||||
deviceMessage.ReceiveDate = DateTime.UtcNow;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<DeviceMessageDTO>> DeviceMessageReadUnreadedRole(int roleId)
|
||||
{
|
||||
var retVal = new List<DeviceMessageDTO>();
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.DeviceMessages
|
||||
.Where(w => w.RoleId == roleId && w.IsReaded != true)
|
||||
.ToListAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<DeviceMessageDTO>>(res);
|
||||
foreach (var deviceMessage in res)
|
||||
{
|
||||
deviceMessage.IsReaded = true;
|
||||
deviceMessage.ReceiveDate = DateTime.UtcNow;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using AutoMapper;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.DL;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class SystemService : ISystemService
|
||||
{
|
||||
public readonly AppDbContext _dbContext;
|
||||
public readonly IMapper _mapper;
|
||||
public readonly IConfiguration _config;
|
||||
public SystemService(AppDbContext dbContext,
|
||||
IMapper mapper,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_config = configuration;
|
||||
_dbContext = dbContext;
|
||||
_mapper = mapper;
|
||||
}
|
||||
public async Task<string> GetDatabaseAndVersionInfoAsync()
|
||||
{
|
||||
var retVal = "";
|
||||
var connection = _dbContext.Database.GetDbConnection();
|
||||
var typeName = connection.GetType().Name;
|
||||
|
||||
//if (typeName.Contains("Npgsql"))
|
||||
//{
|
||||
// var builder = new NpgsqlConnectionStringBuilder(connection.ConnectionString);
|
||||
// retVal= builder.Database;
|
||||
//}
|
||||
|
||||
if (typeName.Contains("SqlConnection"))
|
||||
{
|
||||
var builder = new SqlConnectionStringBuilder(connection.ConnectionString);
|
||||
retVal= builder.InitialCatalog;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,793 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.DL;
|
||||
using WorkFlowCheck.Common.Security;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using WorkFlowCheck.BL.Static;
|
||||
using System.Reflection;
|
||||
|
||||
namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class UserService : BaseService, IUserService
|
||||
{
|
||||
private IConfiguration _configuration;
|
||||
private IMessageService _messageService;
|
||||
|
||||
public UserService(AppDbContext dbContext,
|
||||
IMapper mapper,
|
||||
IConfiguration configuration,
|
||||
IMessageService messageService) : base(dbContext, mapper)
|
||||
{
|
||||
|
||||
_configuration = configuration;
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
public async Task<UserDTO> GetUserAsync(int Id)
|
||||
{
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
if (user != null)
|
||||
{
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<UserDTO>> GetAllUserAsync()
|
||||
{
|
||||
var retVal = new List<UserDTO>
|
||||
{
|
||||
new UserDTO
|
||||
{
|
||||
RoleDTO = new List<RoleDTO>()
|
||||
}
|
||||
};
|
||||
try
|
||||
{
|
||||
var users = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.ToListAsync();
|
||||
if (users != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<UserDTO>>(users);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteUserAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<User>(id);
|
||||
}
|
||||
public async Task<UserDTO> Authenticate(string userName, string password)
|
||||
{
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
|
||||
try
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Bejelentkezési kísérlet: {userName}");
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.UserName == userName && w.Active != false)
|
||||
.FirstOrDefaultAsync();
|
||||
if (user != null && PasswordHasher.VerifyPassword(user.PasswordHash, password))
|
||||
{
|
||||
var userDTO = new UserDTO()
|
||||
{
|
||||
Id = user.Id,
|
||||
UserName = user.UserName,
|
||||
RoleDTO = new List<RoleDTO>(),
|
||||
};
|
||||
foreach (var item in user.UserRoles)
|
||||
{
|
||||
userDTO.RoleDTO.Add(new RoleDTO()
|
||||
{
|
||||
Id = item.Role.Id,
|
||||
RoleName = item.Role.RoleName,
|
||||
});
|
||||
}
|
||||
user.JwtToken = GenerateJwtToken(userDTO);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Sikeres bejelentkezés: {userName}");
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Error($"Sikertelen bejelenkezési kísérlet: {userName}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<string> Authenticate2F1(string userName, string password)
|
||||
{
|
||||
var retVal = "";
|
||||
try
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Bejelentkezési kísérlet: {userName}");
|
||||
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.UserName == userName)
|
||||
.FirstOrDefaultAsync();
|
||||
if (user != null && PasswordHasher.VerifyPassword(user.PasswordHash, password))
|
||||
{
|
||||
var canUseWebAdmin = false;
|
||||
foreach (var userRole in user.UserRoles)
|
||||
{
|
||||
if (userRole.Role.CanUseWebAdmin)
|
||||
{
|
||||
canUseWebAdmin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(user.Email) && canUseWebAdmin)
|
||||
{
|
||||
var code = CodeGenerator2F.GenerateSixDigitCode();
|
||||
|
||||
await _messageService.SendMailAsync(new List<string>()
|
||||
{
|
||||
user.Email,
|
||||
}, "Bejelentkezés megerősítése",
|
||||
Get2FConfirmationMessageBody(code));
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Bejelentkezési kísérlet, email küldés: {user.Email}");
|
||||
retVal = CodeGenerator2F.GenerateToken2F(userName, password, code);
|
||||
return retVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"A WEB felület NEM használható!: {userName}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Error($"Sikertelen bejelentkezési kísérlet: {userName}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<UserDTO> Authenticate2F2(string userName, string password, string code, string token2FA)
|
||||
{
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.UserName == userName && w.Active != false)
|
||||
.FirstOrDefaultAsync();
|
||||
if (user != null && PasswordHasher.VerifyPassword(user.PasswordHash, password))
|
||||
{
|
||||
if (CodeGenerator2F.ValidateToken2F(token2FA, userName, password, code))
|
||||
{
|
||||
var userDTO = new UserDTO()
|
||||
{
|
||||
Id = user.Id,
|
||||
UserName = user.UserName,
|
||||
RoleDTO = new List<RoleDTO>(),
|
||||
};
|
||||
foreach (var item in user.UserRoles)
|
||||
{
|
||||
userDTO.RoleDTO.Add(new RoleDTO()
|
||||
{
|
||||
Id = item.Role.Id,
|
||||
RoleName = item.Role.RoleName,
|
||||
});
|
||||
}
|
||||
user.JwtToken = GenerateJwtToken(userDTO);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Sikeres 2FA azonosítás!: {userName}");
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Error($"Sikertelen 2FA bejelentkezési kísérlet: {userName}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
public async Task<UserDTO> Authenticate2F2ChangePassword(string userName, string oldPassword, string newPassword, string code, string token2FA)
|
||||
{
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.UserName == userName && w.Active != false)
|
||||
.FirstOrDefaultAsync();
|
||||
if (user != null && PasswordHasher.VerifyPassword(user.PasswordHash, oldPassword))
|
||||
{
|
||||
if (CodeGenerator2F.ValidateToken2F(token2FA, userName, oldPassword, code))
|
||||
{
|
||||
user.PasswordHash = PasswordHasher.HashPassword(newPassword);
|
||||
|
||||
|
||||
var userDTO = new UserDTO()
|
||||
{
|
||||
Id = user.Id,
|
||||
UserName = user.UserName,
|
||||
RoleDTO = new List<RoleDTO>(),
|
||||
};
|
||||
foreach (var item in user.UserRoles)
|
||||
{
|
||||
userDTO.RoleDTO.Add(new RoleDTO()
|
||||
{
|
||||
Id = item.Role.Id,
|
||||
RoleName = item.Role.RoleName,
|
||||
});
|
||||
}
|
||||
|
||||
user.PasswordHash = PasswordHasher.HashPassword(newPassword);
|
||||
user.JwtToken = GenerateJwtToken(userDTO);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Sikeres jelszó módosítás: {userName}");
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Error($"Sikertelen jelszó módosítási kísérlet: {userName}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<UserDTO> AuthenticateNFC(string NFCCode)
|
||||
{
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.NFCCode == NFCCode && w.NFCActive == true)
|
||||
.FirstOrDefaultAsync();
|
||||
if (user != null)
|
||||
{
|
||||
|
||||
var userDTO = new UserDTO()
|
||||
{
|
||||
Id = user.Id,
|
||||
UserName = user.UserName,
|
||||
RoleDTO = new List<RoleDTO>(),
|
||||
};
|
||||
foreach (var item in user.UserRoles)
|
||||
{
|
||||
userDTO.RoleDTO.Add(new RoleDTO()
|
||||
{
|
||||
Id = item.Role.Id,
|
||||
RoleName = item.Role.RoleName,
|
||||
});
|
||||
}
|
||||
user.JwtToken = GenerateJwtToken(userDTO);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
Log.ForContext("TAG", "AuditFlow").Information($"Sikeres NFC kártya azonosítás kísérlet: {user.UserName}");
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext("TAG", "AuditFlow").Error($"Sikertelen NFC kártya azonosítás: {NFCCode}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public string GenerateJwtToken(UserDTO userDTO)
|
||||
{
|
||||
var jwtSettings = _configuration.GetSection("Jwt");
|
||||
var secretKey = jwtSettings["SecretKey"];
|
||||
var issuer = jwtSettings["Issuer"];
|
||||
var audience = jwtSettings["Audience"];
|
||||
var tokenLifetime = int.Parse(jwtSettings["TokenLifetimeMinutes"]);
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new Claim(ClaimTypes.Name, userDTO.UserName),
|
||||
new Claim(ClaimTypes.NameIdentifier, userDTO.Id.ToString())
|
||||
};
|
||||
|
||||
foreach (var role in userDTO.RoleDTO)
|
||||
{
|
||||
claims.Add(new Claim(ClaimTypes.Role, role.RoleName));
|
||||
}
|
||||
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
|
||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||
var token = new JwtSecurityToken(
|
||||
issuer: issuer,
|
||||
audience: audience,
|
||||
claims: claims,
|
||||
expires: DateTime.UtcNow.AddMinutes(tokenLifetime),
|
||||
signingCredentials: creds);
|
||||
|
||||
return new JwtSecurityTokenHandler().WriteToken(token);
|
||||
}
|
||||
public async Task<UserDTO> UpdateUserAsync(UserDTO userDTO)
|
||||
{
|
||||
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
|
||||
try
|
||||
{
|
||||
if (userDTO.Id == 0)
|
||||
{
|
||||
var user = new User();
|
||||
user.UserName = userDTO.UserName;
|
||||
user.FirstName = userDTO.FirstName;
|
||||
user.LastName = userDTO.LastName;
|
||||
user.Email = userDTO.Email;
|
||||
user.NFCActive = userDTO.NFCActive;
|
||||
user.NFCCode = userDTO.NFCCode;
|
||||
user.JwtToken = "";
|
||||
user.Token2FA = "";
|
||||
user.IsDeleted = false;
|
||||
user.Active = userDTO.Active;
|
||||
|
||||
|
||||
user.PasswordHash = PasswordHasher.HashPassword(userDTO.Password);
|
||||
|
||||
|
||||
_dbContext.Users.Add(user);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
var user = await _dbContext.Users.Where(w => w.Id == userDTO.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
user.UserName = userDTO.UserName;
|
||||
user.FirstName = userDTO.FirstName;
|
||||
user.LastName = userDTO.LastName;
|
||||
user.Email = userDTO.Email;
|
||||
user.Active = userDTO.Active;
|
||||
user.NFCActive = userDTO.NFCActive;
|
||||
user.NFCCode = userDTO.NFCCode;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private string Get2FConfirmationMessageBody(string token2F)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName = "WorkFlowCheck.BL.HtmlTemplates.Token2FBody.html";
|
||||
|
||||
using var stream = assembly.GetManifestResourceStream(resourceName);
|
||||
if (stream == null)
|
||||
throw new FileNotFoundException($"Nem található a beágyazott erőforrás: {resourceName}");
|
||||
|
||||
using var reader = new StreamReader(stream);
|
||||
var html = reader.ReadToEnd();
|
||||
return html.Replace("#token2F#", token2F);
|
||||
}
|
||||
|
||||
public async Task<RoleDTO> GetRoleAsync(int Id)
|
||||
{
|
||||
var retVal = new RoleDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Roles.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
if (user != null)
|
||||
{
|
||||
retVal = _mapper.Map<RoleDTO>(user);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<RoleDTO>> GetAllRoleAsync()
|
||||
{
|
||||
var retVal = new List<RoleDTO>();
|
||||
try
|
||||
{
|
||||
var roles = await _dbContext.Roles.ToListAsync();
|
||||
if (roles != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<RoleDTO>>(roles);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteRoleAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<Role>(id);
|
||||
}
|
||||
public async Task<RoleDTO> UpdateRoleAsync(RoleDTO roleDTO)
|
||||
{
|
||||
var retVal = new RoleDTO();
|
||||
try
|
||||
{
|
||||
if (roleDTO.Id == 0)
|
||||
{
|
||||
var role = new Role();
|
||||
role.RoleName = roleDTO.RoleName;
|
||||
if (roleDTO.ParentId > 0)
|
||||
{
|
||||
role.ParentId = roleDTO.ParentId;
|
||||
}
|
||||
role.IsAdmin = roleDTO.IsAdmin;
|
||||
role.CanDownloadAPK = roleDTO.CanDownloadAPK;
|
||||
role.CanEnableBlocked = roleDTO.CanEnableBlocked;
|
||||
role.CanUseWebAdmin = roleDTO.CanUseWebAdmin;
|
||||
role.CanUseMobilApp = roleDTO.CanUseMobilApp;
|
||||
_dbContext.Roles.Add(role);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<RoleDTO>(role);
|
||||
}
|
||||
else
|
||||
{
|
||||
var role = await _dbContext.Roles.Where(w => w.Id == roleDTO.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (role != null)
|
||||
{
|
||||
role.RoleName = roleDTO.RoleName;
|
||||
if (roleDTO.ParentId > 0)
|
||||
{
|
||||
role.ParentId = roleDTO.ParentId;
|
||||
}
|
||||
role.IsAdmin = roleDTO.IsAdmin;
|
||||
role.CanDownloadAPK = roleDTO.CanDownloadAPK;
|
||||
role.CanEnableBlocked = roleDTO.CanEnableBlocked;
|
||||
role.CanUseWebAdmin = roleDTO.CanUseWebAdmin;
|
||||
role.CanUseMobilApp = roleDTO.CanUseMobilApp;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<RoleDTO>(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<UserRoleDTO> GetUserRoleAsync(int Id)
|
||||
{
|
||||
var retVal = new UserRoleDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var userRole = await _dbContext.UserRoles.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
if (userRole != null)
|
||||
{
|
||||
retVal = _mapper.Map<UserRoleDTO>(userRole);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<UserRoleDTO>> GetAllUserRoleAsync()
|
||||
{
|
||||
var retVal = new List<UserRoleDTO>();
|
||||
try
|
||||
{
|
||||
var userRoles = await _dbContext.UserRoles
|
||||
.Include(i => i.User)
|
||||
.Include(i => i.Role)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (userRoles != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<UserRoleDTO>>(userRoles);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteUserRoleAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<UserRole>(id);
|
||||
}
|
||||
public async Task<UserRoleDTO> UpdateUserRoleAsync(UserRoleDTO userRoleDTO)
|
||||
{
|
||||
var retVal = new UserRoleDTO();
|
||||
try
|
||||
{
|
||||
if (userRoleDTO.Id == 0)
|
||||
{
|
||||
var userRole = new UserRole();
|
||||
userRole.UserId = userRoleDTO.UserId;
|
||||
userRole.RoleId = userRoleDTO.RoleId;
|
||||
|
||||
_dbContext.UserRoles.Add(userRole);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<UserRoleDTO>(userRole);
|
||||
}
|
||||
else
|
||||
{
|
||||
var userRole = await _dbContext.UserRoles.Where(w => w.Id == userRoleDTO.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (userRole != null)
|
||||
{
|
||||
userRole.UserId = userRoleDTO.UserId;
|
||||
userRole.RoleId = userRoleDTO.RoleId;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<UserRoleDTO>(userRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<RoleCheckListTemplateHeaderDTO> GetRoleCheckListTemplateHeaderAsync(int Id)
|
||||
{
|
||||
var retVal = new RoleCheckListTemplateHeaderDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var userRole = await _dbContext.RoleCheckListTemplateHeaders.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
if (userRole != null)
|
||||
{
|
||||
retVal = _mapper.Map<RoleCheckListTemplateHeaderDTO>(userRole);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<RoleCheckListTemplateHeaderDTO>> GetAllRoleCheckListTemplateHeadersAsync()
|
||||
{
|
||||
var retVal = new List<RoleCheckListTemplateHeaderDTO>();
|
||||
try
|
||||
{
|
||||
var results = await _dbContext.RoleCheckListTemplateHeaders
|
||||
.Include(i => i.CheckListTemplateHeader)
|
||||
.Include(i => i.Role)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (results != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<RoleCheckListTemplateHeaderDTO>>(results);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteRoleCheckListTemplateHeaderAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<RoleCheckListTemplateHeader>(id);
|
||||
}
|
||||
public async Task<RoleCheckListTemplateHeaderDTO> UpdateRoleCheckListTemplateHeaderAsync(RoleCheckListTemplateHeaderDTO roleCheckListTemplateHeaderDTO)
|
||||
{
|
||||
var retVal = new RoleCheckListTemplateHeaderDTO();
|
||||
try
|
||||
{
|
||||
if (roleCheckListTemplateHeaderDTO.Id == 0)
|
||||
{
|
||||
var roleCheckListTemplateHeader_Exists = await _dbContext.RoleCheckListTemplateHeaders
|
||||
.Where(w => w.RoleId == roleCheckListTemplateHeaderDTO.RoleId &&
|
||||
w.CheckListTemplateHeaderId == roleCheckListTemplateHeaderDTO.CheckListTemplateHeaderId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (roleCheckListTemplateHeader_Exists == null)
|
||||
{
|
||||
var roleCheckListTemplateHeader = new RoleCheckListTemplateHeader();
|
||||
roleCheckListTemplateHeader.CheckListTemplateHeaderId = roleCheckListTemplateHeaderDTO.CheckListTemplateHeaderId;
|
||||
roleCheckListTemplateHeader.RoleId = roleCheckListTemplateHeaderDTO.RoleId;
|
||||
roleCheckListTemplateHeader.Enabled = roleCheckListTemplateHeaderDTO.Enabled;
|
||||
|
||||
_dbContext.RoleCheckListTemplateHeaders.Add(roleCheckListTemplateHeader);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<RoleCheckListTemplateHeaderDTO>(roleCheckListTemplateHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = _mapper.Map<RoleCheckListTemplateHeaderDTO>(roleCheckListTemplateHeader_Exists);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var roleCheckListTemplateHeader = await _dbContext.RoleCheckListTemplateHeaders.Where(w => w.Id == roleCheckListTemplateHeaderDTO.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (roleCheckListTemplateHeader != null)
|
||||
{
|
||||
roleCheckListTemplateHeader.CheckListTemplateHeaderId = roleCheckListTemplateHeaderDTO.CheckListTemplateHeaderId;
|
||||
roleCheckListTemplateHeader.RoleId = roleCheckListTemplateHeaderDTO.RoleId;
|
||||
roleCheckListTemplateHeader.Enabled = roleCheckListTemplateHeaderDTO.Enabled;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<RoleCheckListTemplateHeaderDTO>(roleCheckListTemplateHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<RoleCheckPointDTO> GetRoleCheckPointAsync(int Id)
|
||||
{
|
||||
var retVal = new RoleCheckPointDTO();
|
||||
|
||||
try
|
||||
{
|
||||
var userRole = await _dbContext.RoleCheckPoints.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
if (userRole != null)
|
||||
{
|
||||
retVal = _mapper.Map<RoleCheckPointDTO>(userRole);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<RoleCheckPointDTO>> GetAllRoleCheckPointsAsync()
|
||||
{
|
||||
var retVal = new List<RoleCheckPointDTO>();
|
||||
try
|
||||
{
|
||||
var results = await _dbContext.RoleCheckPoints
|
||||
.Include(i => i.CheckPoint)
|
||||
.Include(i => i.Role)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
if (results != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<RoleCheckPointDTO>>(results);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> DeleteRoleCheckPointAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<RoleCheckPoint>(id);
|
||||
}
|
||||
public async Task<RoleCheckPointDTO> UpdateRoleCheckPointAsync(RoleCheckPointDTO roleCheckPointDTO)
|
||||
{
|
||||
var retVal = new RoleCheckPointDTO();
|
||||
try
|
||||
{
|
||||
if (roleCheckPointDTO.Id == 0)
|
||||
{
|
||||
var roleCheckPoint_Exists = await _dbContext.RoleCheckPoints
|
||||
.Where(w => w.RoleId == roleCheckPointDTO.RoleId &&
|
||||
w.CheckPointId == roleCheckPointDTO.CheckPointId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (roleCheckPoint_Exists == null)
|
||||
{
|
||||
var roleCheckPoint = new RoleCheckPoint();
|
||||
roleCheckPoint.CheckPointId = roleCheckPointDTO.CheckPointId;
|
||||
roleCheckPoint.RoleId = roleCheckPointDTO.RoleId;
|
||||
roleCheckPoint.Enabled = roleCheckPointDTO.Enabled;
|
||||
|
||||
_dbContext.RoleCheckPoints.Add(roleCheckPoint);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<RoleCheckPointDTO>(roleCheckPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = _mapper.Map<RoleCheckPointDTO>(roleCheckPoint_Exists);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var roleCheckPoint = await _dbContext.RoleCheckPoints.Where(w => w.Id == roleCheckPointDTO.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (roleCheckPoint != null)
|
||||
{
|
||||
roleCheckPoint.CheckPointId = roleCheckPointDTO.CheckPointId;
|
||||
roleCheckPoint.RoleId = roleCheckPointDTO.RoleId;
|
||||
roleCheckPoint.Enabled = roleCheckPointDTO.Enabled;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<RoleCheckPointDTO>(roleCheckPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.BL.Static
|
||||
{
|
||||
public static class CodeGenerator2F
|
||||
{
|
||||
private static readonly Random _random = new Random();
|
||||
private const string SecretKey = "874512WcfApplicationNuvolar.hu!%mBX210jUUKL";
|
||||
private static readonly byte[] KeyBytes = Encoding.UTF8.GetBytes(SecretKey);
|
||||
|
||||
public static string GenerateSixDigitCode()
|
||||
{
|
||||
return _random.Next(100000, 1000000).ToString(); // 100000 - 999999
|
||||
}
|
||||
public static string GenerateToken2F(string value1, string value2, string value3)
|
||||
{
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim("val1", value1),
|
||||
new Claim("val2", value2),
|
||||
new Claim("val3", value3)
|
||||
};
|
||||
|
||||
var descriptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Subject = new ClaimsIdentity(claims),
|
||||
Expires = DateTime.UtcNow.AddSeconds(60 * 60 * 2),
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(KeyBytes), SecurityAlgorithms.HmacSha256Signature)
|
||||
};
|
||||
|
||||
var token = tokenHandler.CreateToken(descriptor);
|
||||
return tokenHandler.WriteToken(token);
|
||||
}
|
||||
public static bool ValidateToken2F(string token, string expected1, string expected2, string expected3)
|
||||
{
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
|
||||
try
|
||||
{
|
||||
var parameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = false,
|
||||
ValidateAudience = false,
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(KeyBytes),
|
||||
ClockSkew = TimeSpan.Zero // nincs türelmi idő
|
||||
};
|
||||
|
||||
var principal = tokenHandler.ValidateToken(token, parameters, out var validatedToken);
|
||||
|
||||
var val1 = principal.FindFirst("val1")?.Value;
|
||||
var val2 = principal.FindFirst("val2")?.Value;
|
||||
var val3 = principal.FindFirst("val3")?.Value;
|
||||
|
||||
return val1 == expected1 && val2 == expected2 && val3 == expected3;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="HtmlTemplates\Token2FBody.html" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="HtmlTemplates\AcceptCheckListHeaderBody.html" />
|
||||
<EmbeddedResource Include="HtmlTemplates\Token2FBody.html" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
|
||||
<PackageReference Include="Google.Apis.Auth" Version="1.69.0" />
|
||||
<PackageReference Include="MailKit" Version="4.11.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
||||
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WorkFlowCheck.Common\WorkFlowCheck.Common.csproj" />
|
||||
<ProjectReference Include="..\WorkFlowCheck.DL\WorkFlowCheck.DL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.Constants
|
||||
{
|
||||
public static class MemoryCacheNames
|
||||
{
|
||||
public const string UsersNamePrefix = "Users_";
|
||||
public const string TranslationsNamePrefix = "Translations_";
|
||||
public const string Languages = "Languages";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class ApiRequestDTO<T>
|
||||
{
|
||||
public UserDTO UserDTO { get; set; }
|
||||
public T Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class ApiResponseBaseDTO
|
||||
{
|
||||
public ApiResponseBaseDTO()
|
||||
{
|
||||
Errors = new List<string>();
|
||||
}
|
||||
public bool IsSuccess { get; set; }
|
||||
public List<string> Errors { get; set; }
|
||||
public bool HandleError { get; set; }
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Errors == null || Errors.Count() == 0) return string.Empty;
|
||||
return string.Join(';', Errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ApiResponseDTO : ApiResponseBaseDTO
|
||||
{
|
||||
public object Data { get; set; }
|
||||
}
|
||||
|
||||
public interface IApiResponseDTO<out T>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class ApiResponseDTO<T> : ApiResponseBaseDTO, IApiResponseDTO<T>
|
||||
{
|
||||
public T Data { get; set; }
|
||||
}
|
||||
public class ApiResponseListDTO<T> : ApiResponseBaseDTO
|
||||
{
|
||||
public T[] Data { get; set; }
|
||||
public int Total { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListHeaderCloseDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string CloseReason { get; set; } = null!;
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.Common.Helper;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListHeaderDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CheckListTemplateHeaderId { get; set; }
|
||||
public CheckListTemplateHeaderDTO? CheckListTemplateHeaderDTO { get; set; }
|
||||
|
||||
[DisplayName("Státusz")]
|
||||
public CheckStatus CheckStatus { get; set; }
|
||||
|
||||
public string StatusName => DisplayNameHelper.GetEnumDisplayName(CheckStatus);
|
||||
|
||||
[DisplayName("Dátum")]
|
||||
public DateTime DateExecution { get; set; }
|
||||
|
||||
[DisplayName("Ellenőrző")]
|
||||
public int UserId { get; set; }
|
||||
public UserDTO? UserDTO { get; set; }
|
||||
|
||||
[DisplayName("Jóváhagyó")]
|
||||
public int? AcceptUserId { get; set; }
|
||||
public UserDTO? AcceptUserDTO { get; set; }
|
||||
|
||||
[DisplayName("Megnevezés")]
|
||||
public string ShortName { get; set; } = null!;
|
||||
|
||||
[DisplayName("Leírás")]
|
||||
public string Description { get; set; } = null!;
|
||||
|
||||
[DisplayName("Sorszám")]
|
||||
public string DocumentNumber { get; set; } = null!;
|
||||
|
||||
[DisplayName("Azonosító")]
|
||||
public Guid GuidNumber { get; set; }
|
||||
|
||||
[DisplayName("Stornózva")]
|
||||
public bool IsStorno { get; set; }
|
||||
|
||||
[DisplayName("Szerkeszthető")]
|
||||
public bool IsEditable { get; set; }
|
||||
|
||||
public ICollection<CheckListRowDTO>? CheckListRowDTO { get; set; } = new List<CheckListRowDTO>();
|
||||
|
||||
public CheckListHeaderDTO()
|
||||
{
|
||||
CheckListRowDTO = new List<CheckListRowDTO>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListHeaderInfoDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Összes ellenőrzési szám")]
|
||||
public int TotalRowCount { get; set; }
|
||||
|
||||
[DisplayName("Még ellenőrizendő száma")]
|
||||
public int EmptyAnswerCount { get; set; }
|
||||
|
||||
[DisplayName("Készültség %")]
|
||||
public string ReadyPercent { get; set; }
|
||||
|
||||
[DisplayName("Ellenőrzési pontok száma")]
|
||||
public int CheckPointCount { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListHeaderNewDTO
|
||||
{
|
||||
public int CheckListTemplateHeaderId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListRowDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CheckListHeaderId { get; set; }
|
||||
public int CheckListTemplateRowId { get; set; }
|
||||
public CheckListTemplateRowDTO? CheckListTemplateRowDTO { get; set; }
|
||||
public string GroupName => $"AnswerGroup_{CheckListTemplateRowDTO?.Id ?? 0}";
|
||||
|
||||
[DisplayName("Eredmény")]
|
||||
public string Answer { get; set; } = null!;
|
||||
|
||||
public bool? AnswerYes { get; set; } = null!;
|
||||
public bool? AnswerNo { get; set; } = null!;
|
||||
|
||||
[DisplayName("Kép")]
|
||||
public byte[]? Photo { get; set; } = null!;
|
||||
public Guid GuidNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListTemplateHeaderDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Megnevezés")]
|
||||
public string ShortName { get; set; } = null!;
|
||||
[DisplayName("Leírás")]
|
||||
public string Description { get; set; } = null!;
|
||||
[DisplayName("Sorszám (munkalap)")]
|
||||
public int? NumberGenerator1Id { get; set; }
|
||||
[DisplayName("Sorszám (dokumentum)")]
|
||||
public int? NumberGenerator2Id { get; set; }
|
||||
|
||||
public NumberGeneratorTemplateDTO? NumberGenerator1 { get; set; }
|
||||
public NumberGeneratorTemplateDTO? NumberGenerator2 { get; set; }
|
||||
public ICollection<CheckListTemplateRowDTO>? CheckListTemplateRowDTO { get; set; } = new List<CheckListTemplateRowDTO>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckListTemplateRowDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A sorrend megadása kötelező.")]
|
||||
[DisplayName("Sorrend")]
|
||||
public int RowIndex { get; set; }
|
||||
public int CheckListTemplateHeaderId { get; set; }
|
||||
|
||||
[DisplayName("Berendezés")]
|
||||
public int EquipmentId { get; set; }
|
||||
public EquipmentDTO? EquipmentDTO { get; set; } = null!;
|
||||
|
||||
public int CheckPointId { get; set; }
|
||||
public CheckPointDTO? CheckPointDTO { get; set; } = null!;
|
||||
|
||||
[DisplayName("Tevékenység leírása")]
|
||||
public string OperationDescription { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// I-N (Igen, nem)
|
||||
/// P (Fénykép készítése)
|
||||
/// PN (Fénykép nem kötelező készítése)
|
||||
/// SI-N (Sárga igen,fehér nem)
|
||||
/// I-SN (Fehér igen, sárga nem)
|
||||
/// PI-N (Piros igen,fehér nem)
|
||||
/// I-PN (Fehér igen, piros nem)
|
||||
/// V (Érték megadása)
|
||||
///
|
||||
/// </summary>
|
||||
[DisplayName("Válasz tipus")]
|
||||
public string AnswerType { get; set; } = null!;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckPointDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A megnevezés megadása kötelező.")]
|
||||
[DisplayName("Megnevezés")]
|
||||
public string ShortName { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A kód megadása kötelező.")]
|
||||
[DisplayName("Kód")]
|
||||
public string Code { get; set; }
|
||||
|
||||
[DisplayName("Használatban")]
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
|
||||
[DisplayName("Szabály")]
|
||||
public int? RoleId { get; set; }
|
||||
|
||||
|
||||
[DisplayName("Szabály neve")]
|
||||
public string? RoleName { get; set; }
|
||||
public List<CheckListTemplateRowDTO>? CheckListTemplateRowDTO { get; set; } = new List<CheckListTemplateRowDTO>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class DeviceMessageDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime? SendDate { get; set; }
|
||||
public DateTime? ReceiveDate { get; set; }
|
||||
public string DeviceIdFrom { get; set; } = null!;
|
||||
public string DeviceIdTo { get; set; } = null!;
|
||||
public string Message { get; set; } = null!;
|
||||
public string ExtraDataJSON { get; set; } = null!;
|
||||
public bool IsReaded { get; set; }
|
||||
public int? RoleId { get; set; }
|
||||
public RoleDTO? RoleDTO { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class EquipmentDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A megnevezést megadása kötelező.")]
|
||||
[DisplayName("Megnevezés")]
|
||||
public string ShortName { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az azonosító megadása kötelező.")]
|
||||
[DisplayName("Azonosító")]
|
||||
public string EquipmentNumber { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class FCMMessageDTO
|
||||
|
||||
{
|
||||
public string? Token { get; set; }
|
||||
public string? Body { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class ImageFileDTO
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string FileSize { get; set; }
|
||||
public string CreateDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class LocationDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A megnevezést megadása kötelező.")]
|
||||
[DisplayName("Megnevezés")]
|
||||
public string FullName { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class LogFileDTO
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string FileSize { get; set; }
|
||||
public string CreateDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class MobileUserDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? FullName => $"{LastName} {FirstName}";
|
||||
public string? Email { get; set; }
|
||||
public bool NFCActive { get; set; }
|
||||
public string NFCCode { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class NumberGeneratorTemplateDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
public string Sample { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class PDFFileDTO
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string FileSize { get; set; }
|
||||
public string CreateDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class RoleCheckListTemplateHeaderDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A szabály megnevezésének megadása kötelező.")]
|
||||
[DisplayName("Szabály")]
|
||||
public int RoleId { get; set; }
|
||||
public RoleDTO? RoleDTO { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az ellenőrzési sablon megadása kötelező.")]
|
||||
[DisplayName("Ellenőrzési sablon")]
|
||||
public int CheckListTemplateHeaderId { get; set; }
|
||||
public CheckListTemplateHeaderDTO? CheckListTemplateHeaderDTO { get; set; } = null!;
|
||||
|
||||
|
||||
[DisplayName("Engedélyezve?")]
|
||||
public bool Enabled { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class RoleCheckPointDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A szabály megadása kötelező.")]
|
||||
[DisplayName("Szabály")]
|
||||
public int RoleId { get; set; }
|
||||
public RoleDTO? RoleDTO { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az ellenőrzési pont megadása kötelező.")]
|
||||
[DisplayName("Ellenőrzési pont")]
|
||||
public int CheckPointId { get; set; }
|
||||
public CheckPointDTO? CheckPointDTO { get; set; } = null!;
|
||||
|
||||
[DisplayName("Engedélyezve?")]
|
||||
public bool Enabled { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class RoleDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A szabály megnevezésének megadása kötelező.")]
|
||||
[DisplayName("Megnevezés")]
|
||||
public string RoleName { get; set; } = null!;
|
||||
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
[DisplayName("Szülő szerepkör neve")]
|
||||
public string? ParentRoleName { get; set; }
|
||||
|
||||
[DisplayName("Adminisztrátor?")]
|
||||
public bool IsAdmin { get; set; }
|
||||
|
||||
[DisplayName("Új program letöltés?")]
|
||||
public bool CanDownloadAPK { get; set; }
|
||||
|
||||
[DisplayName("Folyamat blokk/engedélyez?")]
|
||||
public bool CanEnableBlocked { get; set; }
|
||||
|
||||
[DisplayName("WEB felület?")]
|
||||
public bool CanUseWebAdmin { get; set; }
|
||||
|
||||
[DisplayName("Mobil App?")]
|
||||
public bool CanUseMobilApp { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class User2FADTO
|
||||
{
|
||||
|
||||
public string UserName { get; set; } = null!;
|
||||
public string Password { get; set; } = null!;
|
||||
public string Code { get; set; } = null!;
|
||||
public string Token2FA { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class UserChangePassword2FADTO
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Felhasználó")]
|
||||
public string UserName { get; set; } = null!;
|
||||
|
||||
[DisplayName("Régi jelszó")]
|
||||
public string OldPassword { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "A jelszó kötelező.")]
|
||||
[RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{6,}$", ErrorMessage = "Az új jelszónak legalább 6 karakter hosszúnak kell lennie, és tartalmaznia kell kis- és nagybetűt, számot és speciális karaktert.")]
|
||||
[DisplayName("Új jelszó")]
|
||||
public string NewPassword1 { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "A jelszó kötelező.")]
|
||||
[RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{6,}$", ErrorMessage = "Az új jelszónak legalább 6 karakter hosszúnak kell lennie, és tartalmaznia kell kis- és nagybetűt, számot és speciális karaktert.")]
|
||||
[DisplayName("Jelszó megerősítése")]
|
||||
public string NewPassword2 { get; set; } = null!;
|
||||
|
||||
[DisplayName("Ellenőrző kód")]
|
||||
public string Code { get; set; } = null!;
|
||||
public string Token2FA { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class UserDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Az utónév kötelező.")]
|
||||
[EmailAddress(ErrorMessage = "Érvénytelen email cím.")]
|
||||
[RegularExpression(@"^[^@\s]+@[^@\s]+\.[^@\s]+$", ErrorMessage = "Az email formátum nem megfelelő.")]
|
||||
[DisplayName("E-mail")]
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az utónév kötelező.")]
|
||||
[DisplayName("Utónév")]
|
||||
public string FirstName { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az vezetéknév kötelező.")]
|
||||
[DisplayName("Vezetéknév")]
|
||||
public string LastName { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "A felhasználónév kötelező.")]
|
||||
[DisplayName("Felhasználó neve")]
|
||||
public string UserName { get;set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "A jelszó kötelező.")]
|
||||
[RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{6,}$", ErrorMessage = "A jelszónak legalább 6 karakter hosszúnak kell lennie, és tartalmaznia kell kis- és nagybetűt, számot és speciális karaktert.")]
|
||||
[DisplayName("Jelszó")]
|
||||
public string Password { get; set; } = null!;
|
||||
|
||||
|
||||
public string JwtToken { get; set; } = null!;
|
||||
|
||||
[DisplayName("Aktív")]
|
||||
public bool Active { get; set; }
|
||||
|
||||
[DisplayName("NFC belépés")]
|
||||
public bool NFCActive { get; set; }
|
||||
|
||||
[DisplayName("NFC kód")]
|
||||
public string NFCCode { get; set; } = null!;
|
||||
|
||||
public ICollection<RoleDTO>? RoleDTO { get; set; } = new List<RoleDTO>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class UserRoleDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int? RoleId { get; set; } = 0;
|
||||
public RoleDTO? RoleDTO { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public UserDTO? UserDTO { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class UserSimpleDTO
|
||||
{
|
||||
[Required(ErrorMessage = "A felhasználónév kötelező.")]
|
||||
public string UserName { get; set; } = null!;
|
||||
[Required(ErrorMessage = "A jelszó megadása kötelező.")]
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace WorkFlowCheck.Common.Enums
|
||||
{
|
||||
public enum CheckStatus
|
||||
{
|
||||
|
||||
[Display(Name = "Nyitott")]
|
||||
Open = 0,
|
||||
|
||||
[Display(Name = "Folyamatban")]
|
||||
InProgress = 1,
|
||||
|
||||
[Display(Name = "Blokkolt")]
|
||||
Blocked = 2,
|
||||
|
||||
[Display(Name = "Sztornózva")]
|
||||
Storno = 3,
|
||||
|
||||
[Display(Name = "Beküldött")]
|
||||
Sent = 4,
|
||||
|
||||
[Display(Name = "Jóváhagyva")]
|
||||
Signed = 5,
|
||||
|
||||
[Display(Name = "Lezárva")]
|
||||
Closed = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.Helper
|
||||
{
|
||||
public static class DisplayNameHelper
|
||||
{
|
||||
public static string GetDisplayName(string propertyName, Type modelType)
|
||||
{
|
||||
var property = modelType.GetProperty(propertyName);
|
||||
var displayNameAttribute = property?.GetCustomAttributes(typeof(DisplayNameAttribute), false)
|
||||
.FirstOrDefault() as DisplayNameAttribute;
|
||||
|
||||
return displayNameAttribute?.DisplayName ?? propertyName;
|
||||
}
|
||||
public static string GetEnumDisplayName(this Enum enumValue)
|
||||
{
|
||||
return enumValue
|
||||
.GetType()
|
||||
.GetMember(enumValue.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<DisplayAttribute>()?
|
||||
.Name ?? enumValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.RequestContext
|
||||
{
|
||||
public interface IRequestContext
|
||||
{
|
||||
string TraceId { get; }
|
||||
|
||||
string CurrentUsername { get; }
|
||||
string CurrentUserEmail { get; }
|
||||
int? CurrentUserId { get; }
|
||||
CancellationToken RequestAborted { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.Security
|
||||
{
|
||||
public static class PasswordHasher
|
||||
{
|
||||
// Jelszó hashelése
|
||||
private const string _saltstring = "xc45DDfrt!!ED210:";
|
||||
public static string HashPassword(string password)
|
||||
{
|
||||
// Generate a random salt
|
||||
byte[] salt = Encoding.UTF8.GetBytes(_saltstring);
|
||||
|
||||
|
||||
// Hash the password with the salt
|
||||
using (var rfc2898 = new Rfc2898DeriveBytes(password, salt, 10000, HashAlgorithmName.SHA256))
|
||||
{
|
||||
byte[] hash = rfc2898.GetBytes(32); // 256-bit hash
|
||||
byte[] hashBytes = new byte[48]; // Salt (16 bytes) + Hash (32 bytes)
|
||||
Array.Copy(salt, 0, hashBytes, 0, 16);
|
||||
Array.Copy(hash, 0, hashBytes, 16, 32);
|
||||
|
||||
return Convert.ToBase64String(hashBytes);
|
||||
}
|
||||
}
|
||||
|
||||
// Jelszó ellenőrzése
|
||||
public static bool VerifyPassword(string storedPasswordHash, string inputPassword)
|
||||
{
|
||||
byte[] hashBytes = Convert.FromBase64String(storedPasswordHash);
|
||||
|
||||
// Extract salt (first 16 bytes) and stored hash (next 32 bytes)
|
||||
byte[] salt = Encoding.UTF8.GetBytes(_saltstring);
|
||||
byte[] storedHash = new byte[32];
|
||||
Array.Copy(hashBytes, 0, salt, 0, 16);
|
||||
Array.Copy(hashBytes, 16, storedHash, 0, 32);
|
||||
|
||||
// Hash the input password with the same salt
|
||||
using (var rfc2898 = new Rfc2898DeriveBytes(inputPassword, salt, 10000, HashAlgorithmName.SHA256))
|
||||
{
|
||||
byte[] inputHash = rfc2898.GetBytes(32);
|
||||
|
||||
// Compare the stored hash and the calculated hash
|
||||
return CryptographicOperations.FixedTimeEquals(storedHash, inputHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,191 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using System;
|
||||
using WorkFlowCheck.Common.RequestContext;
|
||||
using WorkFlowCheck.Common.Security;
|
||||
using WorkFlowCheck.DL.Configurations;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
using WorkFlowCheck.DL.Extensions;
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.DL
|
||||
{
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
private readonly IRequestContext _requestContext;
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options, IRequestContext requestContext)
|
||||
: base(options)
|
||||
{
|
||||
_requestContext = requestContext;
|
||||
}
|
||||
|
||||
#region Entities DbSet
|
||||
public DbSet<Entities.CheckListHeader> CheckListHeaders { get; set; } = null!;
|
||||
public DbSet<Entities.CheckListRow> CheckListRows { get; set; } = null!;
|
||||
public DbSet<Entities.CheckListTemplateHeader> CheckListTemplateHeaders { get; set; } = null!;
|
||||
public DbSet<Entities.CheckListTemplateRow> CheckListTemplateRows { get; set; } = null!;
|
||||
public DbSet<Entities.CheckPoint> CheckPoints { get; set; } = null!;
|
||||
public DbSet<DeviceMessage> DeviceMessages { get; set; } = null!;
|
||||
public DbSet<Entities.Equipment> Equipments { get; set; } = null!;
|
||||
public DbSet<Entities.FCMToken> FCMTokens { get; set; } = null!;
|
||||
public DbSet<Entities.Location> Locations { get; set; } = null!;
|
||||
public DbSet<Entities.NumberGeneratorTemplate> NumberGeneratorTemplates { get; set; } = null!;
|
||||
public DbSet<Entities.NumberGeneratorTemplateDate> NumberGeneratorTemplateDates { get; set; } = null!;
|
||||
public DbSet<Entities.Role> Roles { get; set; } = null!;
|
||||
public DbSet<Entities.User> Users { get; set; } = null!;
|
||||
public DbSet<Entities.UserRole> UserRoles { get; set; } = null!;
|
||||
public DbSet<Entities.RoleCheckListTemplateHeader> RoleCheckListTemplateHeaders { get; set; } = null!;
|
||||
public DbSet<Entities.RoleCheckPoint> RoleCheckPoints { get; set; } = null!;
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfiguration(new CheckListHeaderTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new CheckListRowTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new CheckListTemplateHeaderTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new CheckListTemplateRowTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new CheckPointTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new DeviceMessageTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new EquipmentTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new FCMTokenTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new LocationTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new NumberGeneratorTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new NumberGeneratorDateTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new RoleTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new RoleCheckListTemplateHeaderTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new RoleCheckPointTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new UserTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new UserRoleTypeConfiguration());
|
||||
|
||||
|
||||
modelBuilder.RegisterSoftDeleteQueryFilters();
|
||||
|
||||
SeedInit(modelBuilder);
|
||||
}
|
||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
SaveChangesCore();
|
||||
return await base.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
protected virtual void SaveChangesCore()
|
||||
{
|
||||
var utcNow = DateTime.UtcNow;
|
||||
|
||||
var deletedEntries = ChangeTracker
|
||||
.Entries()
|
||||
.Where(e => e.Entity is ISoftDeletableEntity && e.State == EntityState.Deleted);
|
||||
|
||||
UpdateDeletedEntries(deletedEntries);
|
||||
|
||||
var modifiedEntries = ChangeTracker
|
||||
.Entries()
|
||||
.Where(e => e.Entity is IAuditableEntity && e.State == EntityState.Modified);
|
||||
|
||||
UpdateModifiedEntires(modifiedEntries, utcNow);
|
||||
|
||||
var addedEntries = ChangeTracker
|
||||
.Entries()
|
||||
.Where(e => e.Entity is IAuditableEntity && e.State == EntityState.Added);
|
||||
|
||||
UpdateAddedEntries(addedEntries, utcNow);
|
||||
}
|
||||
private void UpdateAddedEntries(IEnumerable<EntityEntry> addedEntries, DateTime utcNow)
|
||||
{
|
||||
foreach (var entry in addedEntries)
|
||||
{
|
||||
((IAuditableEntity)entry.Entity).CreatedAt = utcNow;
|
||||
((IAuditableEntity)entry.Entity).LastModAt = utcNow;
|
||||
((IAuditableEntity)entry.Entity).CreatedBy = _requestContext.CurrentUsername ?? "Admin";
|
||||
((IAuditableEntity)entry.Entity).LastModBy = _requestContext.CurrentUsername ?? "Admin";
|
||||
}
|
||||
}
|
||||
private void UpdateModifiedEntires(IEnumerable<EntityEntry> modifiedEntries, DateTime utcNow)
|
||||
{
|
||||
foreach (var entry in modifiedEntries)
|
||||
{
|
||||
((IAuditableEntity)entry.Entity).LastModAt = utcNow;
|
||||
((IAuditableEntity)entry.Entity).LastModBy = _requestContext.CurrentUsername ?? "Admin";
|
||||
}
|
||||
}
|
||||
private void UpdateDeletedEntries(IEnumerable<EntityEntry> deletedEntries)
|
||||
{
|
||||
foreach (var entry in deletedEntries)
|
||||
{
|
||||
((ISoftDeletableEntity)entry.Entity).IsDeleted = true;
|
||||
entry.State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
|
||||
private void SeedInit(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>().HasData(
|
||||
new User
|
||||
{
|
||||
Id = 1,
|
||||
Email = "admin@nuvolar.hu",
|
||||
FirstName = "Administrator",
|
||||
LastName = "System",
|
||||
IsDeleted = false,
|
||||
UserName = "admin",
|
||||
PasswordHash = PasswordHasher.HashPassword("111111"),
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CreatedBy = "System",
|
||||
LastModAt = DateTime.UtcNow,
|
||||
LastModBy = "System",
|
||||
JwtToken = "",
|
||||
Active = true,
|
||||
Token2FA = "",
|
||||
NFCActive = true,
|
||||
NFCCode = "00000000"
|
||||
},
|
||||
new User
|
||||
{
|
||||
Id = 2,
|
||||
Email = "user@nuvolar.hu",
|
||||
FirstName = "User",
|
||||
LastName = "System",
|
||||
IsDeleted = false,
|
||||
UserName = "user",
|
||||
PasswordHash = PasswordHasher.HashPassword("222222"),
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CreatedBy = "System",
|
||||
LastModAt = DateTime.UtcNow,
|
||||
LastModBy = "System",
|
||||
JwtToken = "",
|
||||
Active = true,
|
||||
Token2FA = "",
|
||||
NFCActive = true,
|
||||
NFCCode = "00000000"
|
||||
}
|
||||
);
|
||||
modelBuilder.Entity<NumberGeneratorTemplate>().HasData(
|
||||
new NumberGeneratorTemplate
|
||||
{
|
||||
Id = 1,
|
||||
CurrentNumber = 0,
|
||||
DigitFormat = "D4",
|
||||
GenerateType = GenerateType.OnlyYear,
|
||||
LastGeneratedNumber = "",
|
||||
Prefix = "CHK",
|
||||
PrefixSeparator = "-",
|
||||
ShortName = "Ellenőrzési dokumentum sorszámozása",
|
||||
Suffix = "",
|
||||
SuffixSeparator = "-",
|
||||
}
|
||||
);
|
||||
modelBuilder.Entity<NumberGeneratorTemplateDate>().HasData(
|
||||
new NumberGeneratorTemplateDate
|
||||
{
|
||||
Id = 1,
|
||||
CurrentNumber = 0,
|
||||
LastGeneratedNumber = "",
|
||||
Month = 0,
|
||||
Year = 1,
|
||||
NumberGeneratorTemplateId = 1,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class CheckListHeaderTypeConfiguration : IEntityTypeConfiguration<Entities.CheckListHeader>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.CheckListHeader> builder)
|
||||
{
|
||||
builder.ToTable("CheckListHeader");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
builder
|
||||
.HasOne(ch => ch.AcceptUser)
|
||||
.WithMany()
|
||||
.HasForeignKey(ch => ch.AcceptUserId)
|
||||
.OnDelete(DeleteBehavior.Restrict); // Elkerüljük a cascade delete-et
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class CheckListRowTypeConfiguration : IEntityTypeConfiguration<Entities.CheckListRow>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.CheckListRow> builder)
|
||||
{
|
||||
builder.ToTable("CheckListRow");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class CheckListTemplateHeaderTypeConfiguration : IEntityTypeConfiguration<Entities.CheckListTemplateHeader>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.CheckListTemplateHeader> builder)
|
||||
{
|
||||
builder.ToTable("CheckListTemplateHeader");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class CheckListTemplateRowTypeConfiguration : IEntityTypeConfiguration<Entities.CheckListTemplateRow>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.CheckListTemplateRow> builder)
|
||||
{
|
||||
builder.ToTable("CheckListTemplateRow");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class CheckPointTypeConfiguration : IEntityTypeConfiguration<Entities.CheckPoint>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.CheckPoint> builder)
|
||||
{
|
||||
builder.ToTable("CheckPoint");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class DeviceMessageTypeConfiguration : IEntityTypeConfiguration<Entities.DeviceMessage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.DeviceMessage> builder)
|
||||
{
|
||||
builder.ToTable("DeviceMessage");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
|
||||
builder.HasIndex(e => e.DeviceIdTo)
|
||||
.HasDatabaseName("IX_DeviceMessage_DeviceIdTo");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class EquipmentTypeConfiguration : IEntityTypeConfiguration<Entities.Equipment>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Equipment> builder)
|
||||
{
|
||||
builder.ToTable("Equipment");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class FCMTokenTypeConfiguration : IEntityTypeConfiguration<Entities.FCMToken>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.FCMToken> builder)
|
||||
{
|
||||
builder.ToTable("FCMToken");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class LocationTypeConfiguration : IEntityTypeConfiguration<Entities.Location>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Location> builder)
|
||||
{
|
||||
builder.ToTable("Location");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class NumberGeneratorTypeConfiguration : IEntityTypeConfiguration<Entities.NumberGeneratorTemplate>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.NumberGeneratorTemplate> builder)
|
||||
{
|
||||
builder.ToTable("NumberGeneratorTemplate");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
}
|
||||
public class NumberGeneratorDateTypeConfiguration : IEntityTypeConfiguration<Entities.NumberGeneratorTemplateDate>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.NumberGeneratorTemplateDate> builder)
|
||||
{
|
||||
builder.ToTable("NumberGeneratorTemplateDate");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class RoleCheckListTemplateHeaderTypeConfiguration : IEntityTypeConfiguration<Entities.RoleCheckListTemplateHeader>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.RoleCheckListTemplateHeader> builder)
|
||||
{
|
||||
builder.ToTable("RoleCheckListTemplateHeader");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class RoleCheckPointTypeConfiguration : IEntityTypeConfiguration<Entities.RoleCheckPoint>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.RoleCheckPoint> builder)
|
||||
{
|
||||
builder.ToTable("RoleCheckPoint");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class RoleTypeConfiguration : IEntityTypeConfiguration<Entities.Role>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Role> builder)
|
||||
{
|
||||
builder.ToTable("Roles");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
builder.HasOne(r => r.Parent)
|
||||
.WithMany(r => r.Children)
|
||||
.HasForeignKey(r => r.ParentId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class UserRoleTypeConfiguration : IEntityTypeConfiguration<Entities.UserRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.UserRole> builder)
|
||||
{
|
||||
builder.ToTable("UserRoles");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Configurations
|
||||
{
|
||||
public class UserTypeConfiguration : IEntityTypeConfiguration<Entities.User>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.User> builder)
|
||||
{
|
||||
builder.ToTable("Users");
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.DL.Entities
|
||||
{
|
||||
public class CheckListHeader : IAuditableEntity, ISoftDeletableEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CheckListTemplateHeaderId { get; set; }
|
||||
public virtual CheckListTemplateHeader CheckListTemplateHeader { get; set; }
|
||||
public CheckStatus CheckStatus { get; set; }
|
||||
public DateTime DateExecution { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public int? AcceptUserId { get; set; }
|
||||
public virtual User? AcceptUser { get; set; }
|
||||
public string ShortName { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public string DocumentNumber { get; set; } = null!;
|
||||
public Guid GuidNumber { get; set; }
|
||||
public bool IsStorno { get; set; }
|
||||
public bool IsEditable { get; set; }
|
||||
public DateTime LastModAt { get; set; }
|
||||
public string LastModBy { get; set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public string CreatedBy { get; set; } = null!;
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
public virtual ICollection<CheckListRow> CheckListRows { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.DL.Entities
|
||||
{
|
||||
public class CheckListRow : ISoftDeletableEntity, IAuditableEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CheckListHeaderId { get; set; }
|
||||
public virtual CheckListHeader CheckListHeader { get; set; } = null!;
|
||||
public int CheckListTemplateRowId { get; set; }
|
||||
public virtual CheckListTemplateRow CheckListTemplateRow { get; set; } = null!;
|
||||
public string Answer { get; set; } = null!;
|
||||
public string PhotoFileName { get; set; }=null!;
|
||||
public Guid GuidNumber { get; set; }
|
||||
public DateTime LastModAt { get; set; }
|
||||
public string LastModBy { get; set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public string CreatedBy { get; set; } = null!;
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.DL.Entities
|
||||
{
|
||||
public class CheckListTemplateHeader : ISoftDeletableEntity, IAuditableEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShortName { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime LastModAt { get; set; }
|
||||
public string LastModBy { get; set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public string CreatedBy { get; set; } = null!;
|
||||
|
||||
public int? NumberGenerator1Id { get; set; }
|
||||
public int? NumberGenerator2Id { get; set; }
|
||||
public NumberGeneratorTemplate NumberGenerator1 { get; set; }
|
||||
public NumberGeneratorTemplate NumberGenerator2 { get; set; }
|
||||
|
||||
public virtual ICollection<CheckListTemplateRow> CheckListTemplateRows { get; set; } = new List<CheckListTemplateRow>();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.DL.Entities
|
||||
{
|
||||
public class CheckListTemplateRow : ISoftDeletableEntity, IAuditableEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int RowIndex { get; set; }
|
||||
public int CheckListTemplateHeaderId { get; set; }
|
||||
public virtual CheckListTemplateHeader CheckListTemplateHeader { get; set; }
|
||||
public int EquipmentId { get; set; }
|
||||
public virtual Equipment Equipment { get; set; }
|
||||
public int CheckPointId { get; set; }
|
||||
public virtual CheckPoint CheckPoint { get; set; }
|
||||
public string OperationDescription { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// I-N (Igen, nem)
|
||||
/// P (Fénykép készítése)
|
||||
/// SI-N (Sárga igen,fehér nem)
|
||||
/// I-SN (Fehér igen, sárga nem)
|
||||
/// PI-N (Piros igen,fehér nem)
|
||||
/// I-PN (Fehér igen, piros nem)
|
||||
///
|
||||
/// </summary>
|
||||
public string AnswerType { get; set; } = null!;
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime LastModAt { get; set; }
|
||||
public string LastModBy { get; set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public string CreatedBy { get; set; } = null!;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.DL.Entities
|
||||
{
|
||||
public class CheckPoint : ISoftDeletableEntity, IAuditableEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
public string Code { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime LastModAt { get; set; }
|
||||
public string LastModBy { get; set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public string CreatedBy { get; set; } = null!;
|
||||
public int RoleId { get; set; }
|
||||
|
||||
|
||||
public virtual ICollection<CheckListTemplateRow> CheckListTemplateRows { get; set; } = new List<CheckListTemplateRow>();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.DL.Entities
|
||||
{
|
||||
public class DeviceMessage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime SendDate { get; set; }
|
||||
public DateTime? ReceiveDate { get; set; }
|
||||
public string DeviceIdFrom { get; set; } = null!;
|
||||
public string DeviceIdTo { get; set; } = null!;
|
||||
public string Message { get; set; } = null!;
|
||||
public string ExtraDataJSON { get; set; } = null!;
|
||||
public bool IsReaded { get; set; }
|
||||
public int? RoleId { get; set; }
|
||||
public virtual Role? Role { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user