commit 06d83ecbf49f064c21807b1051e209c4aa531c1b Author: Luis Rendon Date: Wed Sep 18 16:56:43 2024 -0500 Se Agrego el backend del proyecto de aminusa. diff --git a/.vs/AdminusaBackend/DesignTimeBuild/.dtbcache.v2 b/.vs/AdminusaBackend/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..7c91df1 Binary files /dev/null and b/.vs/AdminusaBackend/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/AdminusaBackend/FileContentIndex/1292e3a6-cce8-4945-9ed6-8b74ab24e6e8.vsidx b/.vs/AdminusaBackend/FileContentIndex/1292e3a6-cce8-4945-9ed6-8b74ab24e6e8.vsidx new file mode 100644 index 0000000..7e4fca5 Binary files /dev/null and b/.vs/AdminusaBackend/FileContentIndex/1292e3a6-cce8-4945-9ed6-8b74ab24e6e8.vsidx differ diff --git a/.vs/AdminusaBackend/FileContentIndex/1d537255-f345-4248-83f2-e13f4f4be5e6.vsidx b/.vs/AdminusaBackend/FileContentIndex/1d537255-f345-4248-83f2-e13f4f4be5e6.vsidx new file mode 100644 index 0000000..2612d33 Binary files /dev/null and b/.vs/AdminusaBackend/FileContentIndex/1d537255-f345-4248-83f2-e13f4f4be5e6.vsidx differ diff --git a/.vs/AdminusaBackend/FileContentIndex/f0735fb4-11ba-47d6-b737-561c9143aeec.vsidx b/.vs/AdminusaBackend/FileContentIndex/f0735fb4-11ba-47d6-b737-561c9143aeec.vsidx new file mode 100644 index 0000000..9b74e07 Binary files /dev/null and b/.vs/AdminusaBackend/FileContentIndex/f0735fb4-11ba-47d6-b737-561c9143aeec.vsidx differ diff --git a/.vs/AdminusaBackend/config/applicationhost.config b/.vs/AdminusaBackend/config/applicationhost.config new file mode 100644 index 0000000..269dc55 --- /dev/null +++ b/.vs/AdminusaBackend/config/applicationhost.config @@ -0,0 +1,1021 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.vs/AdminusaBackend/v17/.futdcache.v2 b/.vs/AdminusaBackend/v17/.futdcache.v2 new file mode 100644 index 0000000..f70b4c7 Binary files /dev/null and b/.vs/AdminusaBackend/v17/.futdcache.v2 differ diff --git a/.vs/AdminusaBackend/v17/.suo b/.vs/AdminusaBackend/v17/.suo new file mode 100644 index 0000000..a5549f7 Binary files /dev/null and b/.vs/AdminusaBackend/v17/.suo differ diff --git a/.vs/AdminusaBackend/v17/DocumentLayout.json b/.vs/AdminusaBackend/v17/DocumentLayout.json new file mode 100644 index 0000000..f92e325 --- /dev/null +++ b/.vs/AdminusaBackend/v17/DocumentLayout.json @@ -0,0 +1,150 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Projects\\staging\\AdminusaBackend\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\appsettings.staging.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\appsettings.staging.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\repository\\reportes\\reportesrepository.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\repository\\reportes\\reportesrepository.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\repository\\catalogos\\catrelacionprecuentacheques.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\repository\\catalogos\\catrelacionprecuentacheques.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\controllers\\catalogos\\catalogorelacionescontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\controllers\\catalogos\\catalogorelacionescontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\repository\\exelservices\\exelrepositoryprecta.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\repository\\exelservices\\exelrepositoryprecta.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\repository\\exelservices\\exelhourworking\\exelhours.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\repository\\exelservices\\exelhourworking\\exelhours.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\repository\\exelservices\\exelrepository.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\repository\\exelservices\\exelrepository.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|c:\\projects\\staging\\adminusabackend\\adminusabackend\\controllers\\authcontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}|AdminusaBackend\\AdminusaBackend.csproj|solutionrelative:adminusabackend\\controllers\\authcontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 0, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "appsettings.Staging.json", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\appsettings.Staging.json", + "RelativeDocumentMoniker": "AdminusaBackend\\appsettings.Staging.json", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\appsettings.Staging.json", + "RelativeToolTip": "AdminusaBackend\\appsettings.Staging.json", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAYAAAAlAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|", + "WhenOpened": "2024-09-18T21:19:14.988Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 3, + "Title": "CatalogoRelacionesController.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Controllers\\Catalogos\\CatalogoRelacionesController.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Controllers\\Catalogos\\CatalogoRelacionesController.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Controllers\\Catalogos\\CatalogoRelacionesController.cs", + "RelativeToolTip": "AdminusaBackend\\Controllers\\Catalogos\\CatalogoRelacionesController.cs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAB0AAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-18T20:45:12.815Z" + }, + { + "$type": "Document", + "DocumentIndex": 7, + "Title": "AuthController.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Controllers\\AuthController.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Controllers\\AuthController.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Controllers\\AuthController.cs", + "RelativeToolTip": "AdminusaBackend\\Controllers\\AuthController.cs", + "ViewState": "AQIAAKQAAAAAAAAAAAAgwMQAAABqAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-18T20:33:41.6Z" + }, + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "CatRelacionPrecuentaCheques.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\Catalogos\\CatRelacionPrecuentaCheques.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Repository\\Catalogos\\CatRelacionPrecuentaCheques.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\Catalogos\\CatRelacionPrecuentaCheques.cs", + "RelativeToolTip": "AdminusaBackend\\Repository\\Catalogos\\CatRelacionPrecuentaCheques.cs", + "ViewState": "AQIAAEwAAAAAAAAAAAAiwBwAAAAJAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-18T20:27:49.884Z" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "ReportesRepository.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\Reportes\\ReportesRepository.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Repository\\Reportes\\ReportesRepository.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\Reportes\\ReportesRepository.cs", + "RelativeToolTip": "AdminusaBackend\\Repository\\Reportes\\ReportesRepository.cs", + "ViewState": "AQIAADUAAAAAAAAAAIAwwEgAAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-18T20:27:25.522Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 6, + "Title": "ExelRepository.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\ExelServices\\ExelRepository.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Repository\\ExelServices\\ExelRepository.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\ExelServices\\ExelRepository.cs", + "RelativeToolTip": "AdminusaBackend\\Repository\\ExelServices\\ExelRepository.cs", + "ViewState": "AQIAADYAAAAAAAAAAAApwE8AAAAIAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-18T20:26:57.606Z" + }, + { + "$type": "Document", + "DocumentIndex": 4, + "Title": "ExelRepositoryPrecta.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\ExelServices\\ExelRepositoryPrecta.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Repository\\ExelServices\\ExelRepositoryPrecta.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\ExelServices\\ExelRepositoryPrecta.cs", + "RelativeToolTip": "AdminusaBackend\\Repository\\ExelServices\\ExelRepositoryPrecta.cs", + "ViewState": "AQIAACoAAAAAAAAAAAAYwEUAAAAqAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-18T20:26:58.26Z" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "ExelHours.cs", + "DocumentMoniker": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\ExelServices\\ExelHourWorking\\ExelHours.cs", + "RelativeDocumentMoniker": "AdminusaBackend\\Repository\\ExelServices\\ExelHourWorking\\ExelHours.cs", + "ToolTip": "C:\\Projects\\staging\\AdminusaBackend\\AdminusaBackend\\Repository\\ExelServices\\ExelHourWorking\\ExelHours.cs", + "RelativeToolTip": "AdminusaBackend\\Repository\\ExelServices\\ExelHourWorking\\ExelHours.cs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAkAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-09-13T23:37:12.966Z" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/.vs/ProjectEvaluation/adminusabackend.metadata.v7.bin b/.vs/ProjectEvaluation/adminusabackend.metadata.v7.bin new file mode 100644 index 0000000..e6b31a7 Binary files /dev/null and b/.vs/ProjectEvaluation/adminusabackend.metadata.v7.bin differ diff --git a/.vs/ProjectEvaluation/adminusabackend.projects.v7.bin b/.vs/ProjectEvaluation/adminusabackend.projects.v7.bin new file mode 100644 index 0000000..add1e5e Binary files /dev/null and b/.vs/ProjectEvaluation/adminusabackend.projects.v7.bin differ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d37ec09 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,32 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net7.0/AdminusaBackend.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+https?://\\S+", + "uriFormat": "https://localhost:5020/swagger/index.html" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e32cc98 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,103 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder} /AdminusaBackend/AdminusaBackend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/AdminusaBackend/AdminusaBackend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/AdminusaBackend/AdminusaBackend.csproj" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish for PRODUCTION", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "/property:Configuration=Release", + "/property:EnvironmentName=Production", + "${workspaceFolder}/AdminusaBackend/AdminusaBackend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false, + "close": true + }, + "problemMatcher": "$msCompile" + }, + { + "label": "publish for QA", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "/property:Configuration=Release", + "/property:EnvironmentName=Staging", + "${workspaceFolder}/AdminusaBackend/AdminusaBackend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false, + "close": true + }, + "problemMatcher": "$msCompile" + }, + { + "label": "Clean & Build", + "command": "dotnet clean; dotnet build", + "type": "shell", + "args": [ ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false, + "close": true + }, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/AdminusaBackend.sln b/AdminusaBackend.sln new file mode 100644 index 0000000..8a6daf5 --- /dev/null +++ b/AdminusaBackend.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34714.143 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdminusaBackend", "AdminusaBackend\AdminusaBackend.csproj", "{8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E58CCFA-D856-4B9B-AA47-BC985F0BA3A7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DC38F6D0-0858-4D61-AD80-C7901816A9BE} + EndGlobalSection +EndGlobal diff --git a/AdminusaBackend/.gitignore b/AdminusaBackend/.gitignore new file mode 100644 index 0000000..6bcc92b --- /dev/null +++ b/AdminusaBackend/.gitignore @@ -0,0 +1,402 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +*.dll + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +bin/* +Bin/* +obj/* +Obj/* +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/AdminusaBackend/AdminusaBackend.csproj b/AdminusaBackend/AdminusaBackend.csproj new file mode 100644 index 0000000..4da7a79 --- /dev/null +++ b/AdminusaBackend/AdminusaBackend.csproj @@ -0,0 +1,19 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + diff --git a/AdminusaBackend/Clientes/Contracts/ICatResponsablesRepository.cs b/AdminusaBackend/Clientes/Contracts/ICatResponsablesRepository.cs new file mode 100644 index 0000000..dcbe39e --- /dev/null +++ b/AdminusaBackend/Clientes/Contracts/ICatResponsablesRepository.cs @@ -0,0 +1,24 @@ +using AdminusaBackend.Clientes.Email; +/*using ZINCBackend.Clientes.ZincInternacional.Model;*/ +using AdminusaBackend.DTO; +using AdminusaBackend.DTO.Usuario; + +namespace AdminusaBackend.Clientes.Contracts +{ + public interface ICatResponsablesRepository + { + /* public Task> Get(); + public Task> ResponsablesEmailsGetAll();*/ + /*public Task GetByUser(DTOLogin data);*/ + /* public Task searchResponsable(string Usuario);*/ + public Task> CreatePIN(int Id); + public Task ValidatePIN(DTOPINUsuario data); + public Task resetPassword(DTOResetPassword user); + /* public Task> GetEmailsByResponsable(int id);*/ + /*public Task EmailAppend(I1868CatResponsableCorreos data);*/ + /* public Task UserAppend(int id, String Usuario);*/ + /* public Task GetEmailsByIdDetalle(int id); + public Task GetEmailsByInvoice(int id);*/ + /*public Task DeleteEmail(int id);*/ + } +} \ No newline at end of file diff --git a/AdminusaBackend/Clientes/Email/DTOSendEmail.cs b/AdminusaBackend/Clientes/Email/DTOSendEmail.cs new file mode 100644 index 0000000..71b4b30 --- /dev/null +++ b/AdminusaBackend/Clientes/Email/DTOSendEmail.cs @@ -0,0 +1,10 @@ + +namespace AdminusaBackend.Clientes.Email; + +public class DTOSendEmail +{ + public string To { get; set; } = null!; + public string Subject { get; set; } = null!; + public string Text { get; set; } = null!; + public string Html { get; set; } = null!; +} \ No newline at end of file diff --git a/AdminusaBackend/Clientes/Email/DTOSendEmailBcc.cs b/AdminusaBackend/Clientes/Email/DTOSendEmailBcc.cs new file mode 100644 index 0000000..9041ba9 --- /dev/null +++ b/AdminusaBackend/Clientes/Email/DTOSendEmailBcc.cs @@ -0,0 +1,13 @@ + +namespace AdminusaBackend.Clientes.Email +{ + public class DTOSendEmailBcc + { + public string To { get; set; } = null!; + public string Cc { get; set; } = null!; + public string Bcc { get; set; } = null!; + public string Subject { get; set; } = null!; + public string Text { get; set; } = null!; + public string Html { get; set; } = null!; + } +} \ No newline at end of file diff --git a/AdminusaBackend/Clientes/Repository/CatResponsablesRepository.cs b/AdminusaBackend/Clientes/Repository/CatResponsablesRepository.cs new file mode 100644 index 0000000..1d153ca --- /dev/null +++ b/AdminusaBackend/Clientes/Repository/CatResponsablesRepository.cs @@ -0,0 +1,163 @@ +using System.Data.Common; +using System.ComponentModel.DataAnnotations.Schema; +using Dapper; +using Microsoft.AspNetCore.Server.IIS.Core; +using System.Data; +using AdminusaBackend.Clientes.Email; +using AdminusaBackend.Clientes.Contracts; +using AdminusaBackend.Context; +using AdminusaBackend.Crypto; +using AdminusaBackend.DTO; + +using AdminusaBackend.DTO.Usuario; + +namespace AdminusaBackend.Clientes.Repository +{ + public class CatResponsablesRepository : ICatResponsablesRepository + { + + private readonly DapperContext _context; + public CatResponsablesRepository(DapperContext context) { _context = context; } + + /*public async Task> Get() + { + var query = "[CatResponsables.Get]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); + return entrada; + } +*//* + public async Task GetByUser(DTOLogin data) + { + var query = "[CatResponsables.GetByUser]"; + using var connection = _context.CreateConnection(); + var hashedPassword = CryptDecrypt.Encrypt(data.Contrasena); + var entrada = await connection.QueryAsync(query, new + { + @data.Usuario, + @Contrasena = hashedPassword + }, commandType: CommandType.StoredProcedure); + return entrada.First(); + } +*//* + public async Task searchResponsable(string Usuario) + { + var query = "SELECT * FROM CatResponsables WHERE Usuario=@Usuario"; + using (var connection = _context.CreateConnection()) + { + var usuario = await connection.QueryAsync(query, new { @Usuario }); + return usuario.Count() > 0 ? usuario.First().id : 0; + } + } +*/ + + public async Task> CreatePIN(int Id) + { + var query = "[CatResponsables.PIN.Create]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { @Id }, commandType: CommandType.StoredProcedure); + return entrada; + } + + public async Task ValidatePIN(DTOPINUsuario data) + { + var query = "[CatResponsables.PIN.Validate]"; + using (var connection = _context.CreateConnection()) + { + var result = await connection.QueryAsync(query, new { @data.PIN, @data.Usuario }, commandType: CommandType.StoredProcedure); + if (result.Count() == 0) return false; + return true; + } + } + + public async Task resetPassword(DTOResetPassword user) + { + var query = "[CatResponsables.Password.Reset]"; + DTOLogin userFound = new DTOLogin(); + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query, new + { + @user.PIN, + @Contrasena = user.Contrasena, + @HashContrasena = CryptDecrypt.Encrypt(user.Contrasena), + }, commandType: CommandType.StoredProcedure); + if (usuarios.Count() > 0) userFound = usuarios.First(); + } + return userFound; + } + + /*public async Task EmailAppend(I1868CatResponsableCorreos data) + { + var query = "[CatResponsables.Correo.Append]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new + { + @id = data.id, + @IdResponsable = data.IdResponsable, + @Correo = data.Correo + }, commandType: CommandType.StoredProcedure); + return entrada.First(); + } +*/ + /* public async Task UserAppend(int id, String Usuario) + { + var query = "[CatResponsables.Usuario.Append]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new + { + @id, + @Usuario + }, commandType: CommandType.StoredProcedure); + return true; + } +*//* + public async Task> GetEmailsByResponsable(int id) + { + var query = "[CatResponsables.Correo.Get]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { @id }, commandType: CommandType.StoredProcedure); + return entrada; + }*/ +/* + public async Task> ResponsablesEmailsGetAll() + { + var query = "[CatResponsables.Correo.GetAll]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); + return entrada; + } +*/ + /* public async Task GetEmailsByIdDetalle(int id) + { + var query = "[CatResponsables.Correo.GetByIdDetalle]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new + { + @id + }, + commandType: CommandType.StoredProcedure); + return entrada.FirstOrDefault(new DTONotificacionTransportista { Correos = "", Pedido = "", Factura = "", Direccion = "", ResponsableCruce = "" }); + }*/ +/* + public async Task GetEmailsByInvoice(int id) + { + var query = "[CatResponsables.Correo.GetByInvoice]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new + { + @id + }, + commandType: CommandType.StoredProcedure); + return entrada.FirstOrDefault(new DTONotificacionTransportista { Correos = "", Pedido = "", Factura = "", Direccion = "", ResponsableCruce = "" }); + }*/ + + /* public async Task DeleteEmail(int id) + { + var query = "[CatResponsables.Correo.Delete]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { @id }, commandType: CommandType.StoredProcedure); + return true; + }*/ + } +} \ No newline at end of file diff --git a/AdminusaBackend/Context/DapperContext.cs b/AdminusaBackend/Context/DapperContext.cs new file mode 100644 index 0000000..fa3999b --- /dev/null +++ b/AdminusaBackend/Context/DapperContext.cs @@ -0,0 +1,19 @@ +using Microsoft.Data.SqlClient; +using System.Data; + + +namespace AdminusaBackend.Context +{ + public class DapperContext + { + private readonly IConfiguration _configuration; + private readonly string _connectionString; + public DapperContext(IConfiguration configuration) + { + _configuration = configuration; + _connectionString = _configuration.GetConnectionString("SqlConnection"); + } + public IDbConnection CreateConnection() + => new SqlConnection(_connectionString); + } +} diff --git a/AdminusaBackend/Contracts/Catalogos/ExelController.cs b/AdminusaBackend/Contracts/Catalogos/ExelController.cs new file mode 100644 index 0000000..cdbfc8a --- /dev/null +++ b/AdminusaBackend/Contracts/Catalogos/ExelController.cs @@ -0,0 +1,129 @@ +using Microsoft.AspNetCore.Mvc; +using System.IO; +using System.Threading.Tasks; +using AdminusaBackend.Repository.ExelServices; +using AdminusaBackend.Repository.ExcelServices; +using AdminusaBackend.Repository.EcxelServices.ExelHourWorking; + +namespace AdminusaBackend.Contracts.Catalogos +{ + + + [Route("api/[controller]")] + [ApiController] + public class ExcelController : ControllerBase + { + private readonly ExcelRepository _repository; + private readonly ExcelRepositoryPrecta _repositoryp; + private readonly ExelHours _repositoryWH; + + + public ExcelController(ExcelRepository repository, ExcelRepositoryPrecta repositoryp, ExelHours repositoryWH) + { + _repository = repository; + _repositoryp = repositoryp; + _repositoryWH = repositoryWH; + + } + + + + [HttpPost("uploadBook")] + public async Task UploadFile([FromForm] IFormFile file) + { + if (file == null || file.Length == 0) + { + return BadRequest("No file uploaded."); + } + + using (var stream = new MemoryStream()) + { + await file.CopyToAsync(stream); + await _repository.ProcessExcelFileAsync(stream); + } + + return Ok(new { message = "File processed successfully." }); + } + + + + + [HttpPost("uploadPrecta")] + public async Task UploadFileP([FromForm] IFormFile file) + { + if (file == null || file.Length == 0) + { + return BadRequest("No file uploaded."); + } + + using (var stream = new MemoryStream()) + { + await file.CopyToAsync(stream); + await _repositoryp.ProcessPrectaExcelFileAsync(stream); + } + + return Ok(new { message = "File processed successfully." }); + } + + + + + [HttpPost("UploadWorkingHours")] + public async Task UploadFileWHours([FromForm] IFormFile file) + { + if (file == null || file.Length == 0) { return BadRequest("No File Uploades"); } + using var stream = new MemoryStream(); + { + await file.CopyToAsync(stream); + await _repositoryWH.ProccesHoursExelFileAysn(stream); + + } + + return Ok(new { message = "File processed successfully" }); + + } + + + + + + // Si La ultima Fecha de los registros de la tabla es 14-08-2024 Las Nuevas inseciones Deben Ser > ala Fecha actal del registro en las Tablas ejemplos: 15-08-2024. + + /* + [HttpPost("UploadWorkingHours")] + public async Task UploadFileWHours([FromForm] IFormFile file) + { + if (file == null || file.Length == 0) + { + return BadRequest("No file uploaded"); + } + + var fileExtension = Path.GetExtension(file.FileName); + + if (fileExtension != ".xls" && fileExtension != ".xlsx") + { + return BadRequest("Unsupported file format. Please upload a .xls or .xlsx file."); + } + + using var stream = new MemoryStream(); + await file.CopyToAsync(stream); + + // Reinicia la posición del stream a 0 + stream.Position = 0; + + try + { + await _repositoryWH.ProcessHoursExcelFileAsync(stream, fileExtension); + return Ok(new { message = "File processed successfully" }); + } + catch (Exception ex) + { + return StatusCode(500, $"An error occurred while processing the file: {ex.Message}"); + } + } + */ + + + } + +} diff --git a/AdminusaBackend/Contracts/Catalogos/ICatChequesPrecuenta.cs b/AdminusaBackend/Contracts/Catalogos/ICatChequesPrecuenta.cs new file mode 100644 index 0000000..f2dc0ca --- /dev/null +++ b/AdminusaBackend/Contracts/Catalogos/ICatChequesPrecuenta.cs @@ -0,0 +1,20 @@ +using AdminusaBackend.DTO.ExelServices; +using AdminusaBackend.Models.Catalogos; +using AdminusaBackend.Models.Reportes; + + +namespace AdminusaBackend.Contracts.Catalogos +{ + public interface ICatChequesPrecuenta + { + + public Task> GetRelacionBooKPrectaPrecuenta(); + public Task> GetRelacionBookPrecta(string Inicio, string Fin); + public Task> PostRelacionPrecuentaCheques(string Precuenta,string Cheques); + public Task> GetRelacionPrecuentaCheque(); + public Task> DeleteRelacionPrecuentaCheque(string Precuenta); + + + public Task>GetRelacionPrecuentaCheque(string Inicio, string Fin); + } +} diff --git a/AdminusaBackend/Contracts/IMenuRepository.cs b/AdminusaBackend/Contracts/IMenuRepository.cs new file mode 100644 index 0000000..d2cc890 --- /dev/null +++ b/AdminusaBackend/Contracts/IMenuRepository.cs @@ -0,0 +1,10 @@ +using AdminusaBackend.Models; + +namespace AdminusaBackend.Contracts +{ + public interface IMenuRepository + { + public Task> GetItemsMenu(Usuarios user); + public Task> GetItemsMenuTransportista(); + } +} \ No newline at end of file diff --git a/AdminusaBackend/Contracts/IPerfilesRepository.cs b/AdminusaBackend/Contracts/IPerfilesRepository.cs new file mode 100644 index 0000000..224a040 --- /dev/null +++ b/AdminusaBackend/Contracts/IPerfilesRepository.cs @@ -0,0 +1,19 @@ +using AdminusaBackend.DTO; +using AdminusaBackend.DTO.Usuario; +using AdminusaBackend.Models; + +namespace AdminusaBackend.Contracts +{ + public interface IPerfilesRepository + { + public Task> getPerfiles(); + public Task PerfilGetById(int id); + public Task> getMenu(); + public Task> getPerfilMenuById(int id); + public Task> getAllPerfilesMenu(); + public Task> createPerfil(DTOPerfilCreate data); + public Task> createItemMenu(Menu data); + public Task> asignaItemMenuPerfil(DTOItemMenuPerfil data); + + } +} \ No newline at end of file diff --git a/AdminusaBackend/Contracts/IUsuariosRepository.cs b/AdminusaBackend/Contracts/IUsuariosRepository.cs new file mode 100644 index 0000000..8c158e8 --- /dev/null +++ b/AdminusaBackend/Contracts/IUsuariosRepository.cs @@ -0,0 +1,25 @@ + +using AdminusaBackend.DTO; +using AdminusaBackend.DTO.Usuario; +using AdminusaBackend.Models; + +namespace AdminusaBackend.Contracts +{ + public interface IUsuariosRepository + { + public Task> getAllUsuariosShort(); + public Task> getAllUsuarios(); + public Task GetUsuario(DTOLogin user); + public Task searchUsuario(string Usuario); + public Task GetUsuarioById(int id); + public Task createUsuario(DTOUsuario user); + public Task CreatePIN(int Id); + public Task ValidatePIN(DTOPINUsuario data); + public Task resetPassword(DTOResetPassword user); + public Task> clonarUsuario(DTOClonarUsuario user); + public Task> CatalogoRolesGET(); + public Task> RolesAsignadosGET(int id); + public Task> GETPerfilesParecidos(string Perfil); + public Task DisableUser(int id); + } +} diff --git a/AdminusaBackend/Contracts/Reportes/IRpRepository.cs b/AdminusaBackend/Contracts/Reportes/IRpRepository.cs new file mode 100644 index 0000000..a06e9bc --- /dev/null +++ b/AdminusaBackend/Contracts/Reportes/IRpRepository.cs @@ -0,0 +1,19 @@ +using AdminusaBackend.DTO.Reportes; +using AdminusaBackend.Models.Reportes; + +namespace AdminusaBackend.Contracts.Reportes +{ + public interface IRptRepository + { + + + public Task> GetWorkingHours(string Inicio, string Fin); + + public Task> GetRelacionesTrafico(); + /*public Task>GetNoRelaciones();*/ + + public Task> GetNoRelaciones(); + + public Task> GetTotalHoursWorkings(string Inicio, string Fin ); + } +} diff --git a/AdminusaBackend/Contracts/Reportes/IRptBookPrectacs.cs b/AdminusaBackend/Contracts/Reportes/IRptBookPrectacs.cs new file mode 100644 index 0000000..5f2f178 --- /dev/null +++ b/AdminusaBackend/Contracts/Reportes/IRptBookPrectacs.cs @@ -0,0 +1,16 @@ +using AdminusaBackend.Models.Reportes; + +namespace AdminusaBackend.Contracts.Reportes +{ + public interface IRptBookPrectacs + { + + /* public Task> GetRelacionesTrafico( ); + *//*public Task>GetNoRelaciones();*//* + + public Task> GetNoRelaciones(); +*/ + + + } +} diff --git a/AdminusaBackend/Controllers/AuthController.cs b/AdminusaBackend/Controllers/AuthController.cs new file mode 100644 index 0000000..eb961cb --- /dev/null +++ b/AdminusaBackend/Controllers/AuthController.cs @@ -0,0 +1,294 @@ +using AdminusaBackend.Models; +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; +using Microsoft.AspNetCore.Mvc; +using AdminusaBackend.Contracts; +using AdminusaBackend.DTO; +using Microsoft.AspNetCore.Authorization; +using AdminusaBackend.Clientes.Contracts; +using AdminusaBackend.Services.Utilerias; +using AdminusaBackend.Clientes.Email; +using AdminusaBackend.DTO.Usuario; + + + +namespace AdminusaBackend.Controllers +{ + [Route("api/[Controller]")] + [ApiController] + public class AuthController : ControllerBase + { + public IConfiguration _config; + private readonly IUsuariosRepository _usuariosRepo; + private readonly IPerfilesRepository _perfilesRepo; + private readonly IMenuRepository _menuRepo; + private readonly ICatResponsablesRepository _transportRepo; + + public AuthController(IConfiguration config, IUsuariosRepository usuariosRepo, IMenuRepository menuRepo, IPerfilesRepository perfilesRepo, ICatResponsablesRepository transportRepo ) + { + _config = config; + _usuariosRepo = usuariosRepo; + _perfilesRepo = perfilesRepo; + _menuRepo = menuRepo; + _transportRepo = transportRepo; + } + + [HttpPost] + public async Task Post(DTOLogin _userData) + { + if (_userData.Contrasena == _config.GetValue("DefaultUser:Password")) + { + return StatusCode(401, "La primera vez que accese debera cambiar su contraseña!"); + } + if (_userData != null && _userData.Usuario != null && _userData.Contrasena != null) + { + var user = await _usuariosRepo.GetUsuario(_userData); + if (user == null) return BadRequest("Invalid credentials"); + if (user != null) + { + var menu = await _menuRepo.GetItemsMenu(user); + var claims = new List(); + var ProfileData = await _perfilesRepo.PerfilGetById(user.Id); + claims.Add(new Claim(JwtRegisteredClaimNames.Sub, _config["Jwt:Subject"])); + claims.Add(new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())); + claims.Add(new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString())); + claims.Add(new Claim("UserId", user.Id.ToString())); + claims.Add(new Claim("Usuario", user.Usuario)); + claims.Add(new Claim("Departamento", (user.sDept ?? user.sDept ?? "No asignado"))); + claims.Add(new Claim("UserType", (user != null) ? user.TipoUsuario.ToString() : "0")); + claims.Add(new Claim("Perfil", ProfileData.Perfil)); + foreach (Menu item in menu) { claims.Add(new Claim(ClaimTypes.Role, item.Url)); } + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); + var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + var token = new JwtSecurityToken( + _config["Jwt:Issuer"], + _config["Jwt:Audience"], + claims, + expires: DateTime.UtcNow.AddHours(Int32.Parse(_config["Jwt:ExpirationHours"])), + // expires: DateTime.UtcNow.AddMinutes(2), + signingCredentials: signIn); + + var _token = new JwtSecurityTokenHandler().WriteToken(token); + return new OkObjectResult(new { menu = menu, token = _token }); + } + else + { + return BadRequest("Invalid credentials"); + } + } + else + { + return BadRequest(); + } + } + + /*[HttpPost] + [Route("AreYouTransport")] + public async Task IsItTransportUser(DTOLogin _userData) + { + if (_userData != null && _userData.Usuario != null && _userData.Contrasena != null) + { + var user = await _transportRepo.GetByUser(_userData); + if (user == null) return BadRequest("Invalid credentials"); + if (user != null) + { + var menu = await _menuRepo.GetItemsMenuTransportista(); + var claims = new List(); + var ProfileData = await _perfilesRepo.PerfilGetById(0); + claims.Add(new Claim(JwtRegisteredClaimNames.Sub, _config["Jwt:Subject"])); + claims.Add(new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())); + claims.Add(new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString())); + claims.Add(new Claim("UserId", user.id.ToString())); + claims.Add(new Claim("Usuario", user.Usuario)); + claims.Add(new Claim("Departamento", "No asignado")); + claims.Add(new Claim("UserType", "0")); + claims.Add(new Claim("Perfil", "Transportista")); + foreach (Menu item in menu) { claims.Add(new Claim(ClaimTypes.Role, item.Url)); } + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); + var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + var token = new JwtSecurityToken( + _config["Jwt:Issuer"], + _config["Jwt:Audience"], + claims, + expires: DateTime.UtcNow.AddHours(Int32.Parse(_config["Jwt:ExpirationHours"])), + signingCredentials: signIn); + + var _token = new JwtSecurityTokenHandler().WriteToken(token); + return new OkObjectResult(new { menu = menu, token = _token }); + } + else + { + return BadRequest("Invalid credentials"); + } + } + else + { + return BadRequest(); + } + } +*/ + [HttpGet] + [Route("GetPermissions")] + public async Task GetPermissions(string Usuario, string Contrasena) + { + DTOLogin _userData = new DTOLogin(); + _userData.Usuario = Usuario; + _userData.Contrasena = Contrasena; + if (_userData.Contrasena == _config.GetValue("DefaultUser:Password")) + { + return StatusCode(401, "La primera vez que accese debera cambiar su contraseña!"); + } + if (_userData != null && _userData.Usuario != null && _userData.Contrasena != null) + { + var user = await _usuariosRepo.GetUsuario(_userData); + if (user == null) return BadRequest("Invalid credentials"); + if (user != null) + { + var menu = await _menuRepo.GetItemsMenu(user); + var claims = new List(); + foreach (Menu item in menu) { claims.Add(new Claim(ClaimTypes.Role, item.Url)); } + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); + var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + var token = new JwtSecurityToken( + _config["Jwt:Issuer"], + _config["Jwt:Audience"], + claims, + expires: DateTime.UtcNow.AddHours(Int32.Parse(_config["Jwt:ExpirationHours"])), + //expires: DateTime.UtcNow.AddMinutes(5), + signingCredentials: signIn); + + var _token = new JwtSecurityTokenHandler().WriteToken(token); + return new OkObjectResult(new { menu = menu, token = _token }); + } + else + { + return BadRequest("Invalid credentials"); + } + } + else + { + return BadRequest(); + } + } + + [HttpPost] + [Route("forgotPassword")] + public async Task forgotPassword(DTOLogin userData) + { + if (userData == null) return BadRequest(new { respuesta = "Usuario invalido" }); + int IdUser = await _usuariosRepo.searchUsuario(userData.Usuario); + if (IdUser > 0) // Es un usuario del ZINC + { + DTOPINData PINData = await _usuariosRepo.CreatePIN(IdUser); + string htmlContent = $@" + + + + +
Estimado usuario, mediante este correo se le notifica que esta en proceso de cambiar su contraseña
Se ha generado un PIN para poder cambiar su contraseña. PIN : {PINData.PIN}
El PIN tiene un tiempo de vida de 10 minutos, a partir de su generacion, despues de ese tiempo caduca
Si usted no es quien ha activando este mecanismo, favor de ponerse en contacto con personal de GEMCO
"; + if (PINData.PIN > 0) + { + Utilerias email = new Utilerias(_config); + var dataEmail = new DTOSendEmail() + { + To = PINData.Correo, + Subject = "adminusa informa: Se le generado un PIN para el cambio de su contraseña, expira en 10 minutos", + Text = "adminusa informa: Se le generado un PIN para el cambio de su contraseña, expira en 10 minutos", + Html = htmlContent + }; + await email.SendEmail(dataEmail); + return new OkObjectResult(new { respuesta = "Continua con el proceso" }); + } + } + /*else // Es un usuario : Transportista / Responsable + { + int IdResponsable = await _transportRepo.searchResponsable(userData.Usuario); + if (IdResponsable > 0) + { + var PINData = await _transportRepo.CreatePIN(IdResponsable); + int PIN = 0; + string EmailGroup = ""; + foreach (DTOPINData data in PINData) + { + PIN = data.PIN; + EmailGroup += data.Correo + ","; + } + EmailGroup = EmailGroup.Remove(EmailGroup.Length - 1, 1); + string htmlContent = $@" + + + + +
Estimado usuario, mediante este correo se le notifica que esta en proceso de cambiar su contraseña
Se ha generado un PIN para poder cambiar su contraseña. PIN : {PIN}
El PIN tiene un tiempo de vida de 10 minutos, a partir de su generacion, despues de ese tiempo caduca
Si usted no es quien ha activando este mecanismo, favor de ponerse en contacto con personal de ZINC
"; + if (PIN > 0) + { + Utilerias email = new Utilerias(_config); + var dataEmail = new DTOSendEmail() + { + To = EmailGroup, + Subject = "ZINC informa: Se le generado un PIN para el cambio de su contraseña, expira en 10 minutos", + Text = "ZINC informa: Se le generado un PIN para el cambio de su contraseña, expira en 10 minutos", + Html = htmlContent + }; + await email.SendEmail(dataEmail); + return new OkObjectResult(new { respuesta = "Continua con el proceso" }); + } + } + else return StatusCode(403, "Acceso denegado"); + }*/ + return BadRequest(new { respuesta = "Invalid Request" }); + } + + [HttpPost] + [Route("validatePIN")] + public async Task validatePIN(DTOPINUsuario userData) + { + var PINUsuario = await _usuariosRepo.ValidatePIN(userData); + if (!PINUsuario) + { + var PINTransportista = await _transportRepo.ValidatePIN(userData); + if (!PINTransportista) return StatusCode(403, "Acceso denegado"); + } + return new OkObjectResult(new { respuesta = "Continua con el proceso" }); + } + + [Route("resetPassword")] + [HttpPost] + public async Task resetPassword(DTOResetPassword data) + { + try + { + var result = await _usuariosRepo.resetPassword(data); + if (result.Usuario == null) + { + var resetPassword = await _transportRepo.resetPassword(data); + if (resetPassword == null) return StatusCode(400, "Cuenta de usuario no existe"); + } + return Ok(result); + } + catch (Exception ex) + { + return StatusCode(500, ex); + } + } + + [HttpGet] + [Route("GetEnvironment")] + public IActionResult GetEnvironment() + { + return StatusCode(200, Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") + ' ' + _config.GetValue("AmazonPyAPI")); + } + + + [Authorize] + [Route("Validate")] + [HttpGet] + public IActionResult GetValidation() + { + return StatusCode(200, "Its Ok"); + } + + } +} diff --git a/AdminusaBackend/Controllers/Catalogos/CatalogoRelacionesController.cs b/AdminusaBackend/Controllers/Catalogos/CatalogoRelacionesController.cs new file mode 100644 index 0000000..4c02294 --- /dev/null +++ b/AdminusaBackend/Controllers/Catalogos/CatalogoRelacionesController.cs @@ -0,0 +1,103 @@ +using AdminusaBackend.Models.Catalogos; +using AdminusaBackend.Models.Reportes; +using AdminusaBackend.Contracts.Catalogos; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace AdminusaBackend.Controllers.Catalogos +{ + + /*[Authorize]*/ + [Route("api/Catalogos/[Controller]")] + public class CatRelacionesBookPrectaController : Controller + { + + + public IConfiguration _Configuration; + + private readonly ICatChequesPrecuenta _Repo; + + private readonly string URLNodeAPI; + + public CatRelacionesBookPrectaController(IConfiguration config, ICatChequesPrecuenta Repo) + { + + _Configuration = config; + URLNodeAPI = _Configuration.GetValue("AmazonNodeApi"); + _Repo = Repo; + } + + + + + [Route("GetAll")] + [HttpGet] + public async Task> GetRelacionBookPrecta(string Inicio, string Fin) + { + var result = await _Repo.GetRelacionBookPrecta(Inicio, Fin); + return result; + + + } + + + [Route("GetAllPreChe")] + [HttpGet] + public async Task> GetRelacionBookPrectaPrecuenta() + { + var result = await _Repo.GetRelacionBooKPrectaPrecuenta(); + return result; + } + + + + [Route("PrecuentaChequesAppend")] + [HttpPost] + public async Task> PostRelacionPrecuentaCheques(string Precuenta, string Cheques) + { + var result = await _Repo.PostRelacionPrecuentaCheques(Precuenta, Cheques); + return result; + } + + + [Route("GetAllPrecuentaCheques")] + [HttpGet] + public async Task> GetRelacionPrecuentaCheques() + { + var result = await _Repo.GetRelacionPrecuentaCheque(); + return result; + } + + + [Route("DeleteAllPrecuentaCheques")] + [HttpDelete] + public async Task> DeleteRelacionChequesPrecuenta(string Precuenta) + { + var result = await _Repo.DeleteRelacionPrecuentaCheque(Precuenta); + return result; + } + + + + + + /*Este edn point relaiza la busqueda de datos por un filtro de un rango de fechas selecionado pero con las relaciones ya de la tabla y no con codigo */ + [Route("GetAllPrecuentaChequesF")] + [HttpGet] + public async Task> GetRelacionPrecuentaCheque(string Inicio, string Fin) + + { + var result = await _Repo.GetRelacionPrecuentaCheque(Inicio, Fin); + return result; + } + + + + + + + + + + } +} diff --git a/AdminusaBackend/Controllers/PerfilesController.cs b/AdminusaBackend/Controllers/PerfilesController.cs new file mode 100644 index 0000000..65170eb --- /dev/null +++ b/AdminusaBackend/Controllers/PerfilesController.cs @@ -0,0 +1,167 @@ +using AdminusaBackend.Contracts; +using AdminusaBackend.DTO; +using AdminusaBackend.DTO.Usuario; +using AdminusaBackend.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; + +namespace AdminusaBackend.Controllers +{ + [Authorize] + [Route("api/[controller]")] + [ApiController] + public class PerfilesController : ControllerBase + { + public IConfiguration _configuration; + private readonly IUsuariosRepository _usuariosRepo; + private readonly IMenuRepository _menuRepo; + private readonly IPerfilesRepository _perfilesRepo; + public PerfilesController(IConfiguration config, IUsuariosRepository usuariosRepo, IMenuRepository menuRepo, IPerfilesRepository perfilesRepo) + { + _configuration = config; + _usuariosRepo = usuariosRepo; + _menuRepo = menuRepo; + _perfilesRepo = perfilesRepo; + } + + [Route("getPerfiles")] + [HttpGet] + public async Task GetPerfiles() + { + try + { + var perfiles = await _perfilesRepo.getPerfiles(); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + [Route("getMenu")] + [HttpGet] + public async Task GetMenu() + { + try + { + var perfiles = await _perfilesRepo.getMenu(); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + + [Route("asignaItemMenu")] + [HttpPost] + public async Task asignaItemMenu(DTOItemMenuPerfil data) + { + try + { + var perfiles = await _perfilesRepo.asignaItemMenuPerfil(data); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + [Route("getAllPerfilesMenu")] + [HttpGet] + public async Task GetAllPerfilesMenu() + { + try + { + var perfiles = await _perfilesRepo.getAllPerfilesMenu(); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + + [Route("getPerfilMenuById")] + [HttpGet] + public async Task GetPerfilMenuBuId(int id) + { + try + { + var perfiles = await _perfilesRepo.getPerfilMenuById(id); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + [Route("createPerfil")] + [HttpPost] + public async Task createPerfil(DTOPerfilCreate data) + { + try + { + var perfiles = await _perfilesRepo.createPerfil(data); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + + [Route("createItemMenu")] + [HttpPost] + public async Task createItemMenu(Menu data) + { + try + { + var result = await _perfilesRepo.createItemMenu(data); + return Ok(result); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + +/* + [Route("getAllTransportistas")] + [HttpGet] + public async Task GetAllTransportistas(int id) + { + try + { + var transportistas = await _perfilesRepo.getAllTransportistas(id); + return Ok(transportistas); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + [Route("getAllProveedores")] + [HttpGet] + public async Task GetAllProveedores(int id) + { + try + { + var proveedores = await _perfilesRepo.getAllProveedores(id); + return Ok(proveedores); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + }*/ + + } +} \ No newline at end of file diff --git a/AdminusaBackend/Controllers/Reportes/ReportesController.cs b/AdminusaBackend/Controllers/Reportes/ReportesController.cs new file mode 100644 index 0000000..29862dd --- /dev/null +++ b/AdminusaBackend/Controllers/Reportes/ReportesController.cs @@ -0,0 +1,72 @@ +using AdminusaBackend.Contracts.Catalogos; +using AdminusaBackend.Contracts.Reportes; +using AdminusaBackend.DTO.Reportes; +using AdminusaBackend.Models.Reportes; +using Microsoft.AspNetCore.Mvc; + + +namespace AdminusaBackend.Controllers.Reportes +{ + + [Route("api/[controller]")] + + public class ReportesController : Controller + { + + public IConfiguration _Configuration; + + private readonly IRptRepository _Repo; + + + public ReportesController(IConfiguration config, IRptRepository Repo) + { + _Configuration = config; + _Repo = Repo; + } + + + + [Route("GetAllSoloTrafico")] + [HttpGet] + public async Task> GetRelacionTrafico() + { + var result = await _Repo.GetRelacionesTrafico(); + return result; + } + + + [Route("GetAllNoRelaciones")] + [HttpGet] + public async Task> GetNoRelaciones() + { + var result = await _Repo.GetNoRelaciones(); + return result; + } + + [Route("GetAllWorkingHours")] + [HttpGet] + + public async Task> GetWorkingHours(string Inicio, string Fin) + { + var result = await _Repo.GetWorkingHours(Inicio, Fin); + return result; + } + + + + [Route("TotalHours")] + [HttpGet] + public async Task> GetTotalHoursWorkings(string Inicio, string Fin) + { + var result = await _Repo.GetTotalHoursWorkings(Inicio, Fin); + return result; + } + + + + + + + + } +} diff --git a/AdminusaBackend/Controllers/UsuariosController.cs b/AdminusaBackend/Controllers/UsuariosController.cs new file mode 100644 index 0000000..893bae7 --- /dev/null +++ b/AdminusaBackend/Controllers/UsuariosController.cs @@ -0,0 +1,173 @@ +using AdminusaBackend.Contracts; +using AdminusaBackend.DTO; +using AdminusaBackend.Models; +using Microsoft.AspNetCore.Mvc; +// La siguiente libreria sirve para enviar un email de notificacion al usuario de que se le ha creado un acceso a este sitio +// using ZINCBackend.Services.Utilerias; +using AdminusaBackend.DTO.Usuario; +using Microsoft.AspNetCore.Authorization; + +namespace AdminusaBackend.Controllers +{ + /*[Authorize]*/ + [Route("api/[controller]")] + [ApiController] + public class UsuariosController : ControllerBase + { + private readonly IUsuariosRepository _usuariosRepo; + private readonly IConfiguration _config; + + public UsuariosController(IUsuariosRepository usuariosRepo, IConfiguration config) { _usuariosRepo = usuariosRepo; _config = config; } + + [Route("getUsuarioById")] + [HttpGet] + public async Task getAllUsuarios(int id) + { + try + { + var usuario = await _usuariosRepo.GetUsuarioById(id); + if (usuario == null) return NotFound(); + return Ok(usuario); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("getAllUsuarios")] + [HttpGet] + public async Task getAllUsuarios() + { + try + { + var usuarios = await _usuariosRepo.getAllUsuarios(); + return Ok(usuarios); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("getAllUsuariosShort")] + [HttpGet] + public async Task getAllUsuariosShort() + { + try + { + var usuarios = await _usuariosRepo.getAllUsuariosShort(); + return Ok(usuarios); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("Auth")] + [HttpPost] + public async Task Auth(DTOLogin user) + { + try + { + var usuarios = await _usuariosRepo.GetUsuario(user); + return Ok(usuarios); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("searchUsuario")] + [HttpPost] + public async Task searchUsuario(DTOLogin user) + { + try + { + var result = await _usuariosRepo.searchUsuario(user.Usuario); + if (result != null) return StatusCode(409, new { message = "Usuario registrado previamente" }); + return Ok(new { message = "Usuario libre, no registrado previamente" }); + } + catch (Exception ex) + { + return StatusCode(500, ex); + } + } + + [Route("createUsuario")] + [HttpPost] + public async Task POST(DTOUsuario user) + { + try + { + var usuario = await _usuariosRepo.createUsuario(user); + if (user.Id == 0) + { + // El siguiente bloque de codigo enviar email al usuario para notificarle que ya se le he creado un acceso + // Utilerias email = new Utilerias(_config); + // Boolean sendOk = email.SendEmail("", usuario); + //Boolean sendOk = true; + } + return Ok(usuario); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("clonarUsuario")] + [HttpPost] + public async Task POST(DTOClonarUsuario user) + { + try + { + var usuarios = await _usuariosRepo.clonarUsuario(user); + return Ok(usuarios); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("Catalogo/Roles/GET")] + [HttpGet] + public async Task CatalogoRolesGET() + { + try + { + var Roles = await _usuariosRepo.CatalogoRolesGET(); + return Ok(Roles); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + [Route("Catalogo/Roles/AsignadosGET")] + [HttpGet] + public async Task RolesAsignadosGET(int id) + { + try + { + var Roles = await _usuariosRepo.RolesAsignadosGET(id); + return Ok(Roles); + } + catch (Exception ex) { return StatusCode(500, ex.Message); } + } + + + [Route("Catalogo/Usuarios/PerfilesParecidos")] + [HttpGet] + public async Task GETPerfilesParecidos(string Perfil) + { + try + { + var perfiles = await _usuariosRepo.GETPerfilesParecidos(Perfil); + return Ok(perfiles); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + + [Route("DisableUser")] + [HttpPut] + public async Task DisableUser(int id) + { + try + { + var result = await _usuariosRepo.DisableUser(id); + return Ok(result); + } + catch (Exception ex) + { + return StatusCode(500, ex.Message); + } + } + } +} diff --git a/AdminusaBackend/Controllers/WeatherForecastController.cs b/AdminusaBackend/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..5905931 --- /dev/null +++ b/AdminusaBackend/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace AdminusaBackend.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/AdminusaBackend/Crypto/Crypto.cs b/AdminusaBackend/Crypto/Crypto.cs new file mode 100644 index 0000000..55c2849 --- /dev/null +++ b/AdminusaBackend/Crypto/Crypto.cs @@ -0,0 +1,48 @@ +using System.Security.Cryptography; +using System.Text; + +namespace AdminusaBackend.Crypto +{ + public class CryptDecrypt + { + private readonly static string key = "G3mc0H42hk3y2!0$2*2#n4813dc2h47p"; + public static string Encrypt(string text) + { + byte[] iv = new byte[16]; + byte[] array; + using (Aes aes = Aes.Create()) { + aes.Key = Encoding.UTF8.GetBytes(key); + aes.IV = iv; + ICryptoTransform encrypt = aes.CreateEncryptor(aes.Key, aes.IV); + using (MemoryStream ms = new MemoryStream()) + { + using (CryptoStream cryptoStream = new CryptoStream((Stream)ms, encrypt, CryptoStreamMode.Write)) { + using (StreamWriter streamWriter = new StreamWriter(cryptoStream)) { + streamWriter.Write(text); + } + array = ms.ToArray(); + } + } + } + return Convert.ToBase64String(array); + } + + public static string Decrypt(string text) + { + byte[] iv = new byte[16]; + byte[] buffer = Convert.FromBase64String(text); + using (Aes aes = Aes.Create()) { + aes.Key = Encoding.UTF8.GetBytes(key); + aes.IV = iv; + ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key,aes.IV); + using (MemoryStream ms = new MemoryStream(buffer)) { + using(CryptoStream cryptoStream = new CryptoStream((Stream)ms, decryptor, CryptoStreamMode.Read)) { + using (StreamReader sr = new StreamReader(cryptoStream)) { + return sr.ReadToEnd(); + } + } + } + } + } + } +} diff --git a/AdminusaBackend/DTO/DTOItemMenuPerfil.cs b/AdminusaBackend/DTO/DTOItemMenuPerfil.cs new file mode 100644 index 0000000..925d898 --- /dev/null +++ b/AdminusaBackend/DTO/DTOItemMenuPerfil.cs @@ -0,0 +1,10 @@ +namespace AdminusaBackend.DTO +{ + public class DTOItemMenuPerfil + { + public int IdPerfil { get; set; } = 0; + public int itemMenu { get; set; } = 0; + public bool asignado { get; set; } = false; + + } +} diff --git a/AdminusaBackend/DTO/DTOLogin.cs b/AdminusaBackend/DTO/DTOLogin.cs new file mode 100644 index 0000000..88be44b --- /dev/null +++ b/AdminusaBackend/DTO/DTOLogin.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.DTO +{ + public class DTOLogin + { + public string Usuario { get; set; } = null!; + public string Contrasena { get; set; } = null!; + } +} diff --git a/AdminusaBackend/DTO/DTORolesAsignados.cs b/AdminusaBackend/DTO/DTORolesAsignados.cs new file mode 100644 index 0000000..4dbb629 --- /dev/null +++ b/AdminusaBackend/DTO/DTORolesAsignados.cs @@ -0,0 +1,11 @@ + +namespace AdminusaBackend.DTO +{ + public class DTORolesAsignados + { + public int Id { get; set; } = 0; + public int Usuario { get; set; } = 0; + public int Rol { get; set; } = 0; + public Boolean Activo { get; set; } = false; + } +} \ No newline at end of file diff --git a/AdminusaBackend/DTO/ExelServices/Book.cs b/AdminusaBackend/DTO/ExelServices/Book.cs new file mode 100644 index 0000000..6098b59 --- /dev/null +++ b/AdminusaBackend/DTO/ExelServices/Book.cs @@ -0,0 +1,24 @@ +namespace AdminusaBackend.DTO.ExelServices +{ + public class Book + { + + + + + public string? Type { get; set; } + public string? Cheques { get; set; } + public string? Date { get; set; } + public string? Num { get; set; } + public string? Name { get; set; } + public string? Memo { get; set; } + /* public float Amount { get; set; }*/ + + public decimal? Amount { get; set; } + + public string? Trafico { get; set; } + + + } + +} diff --git a/AdminusaBackend/DTO/ExelServices/Precta.cs b/AdminusaBackend/DTO/ExelServices/Precta.cs new file mode 100644 index 0000000..a4d3b66 --- /dev/null +++ b/AdminusaBackend/DTO/ExelServices/Precta.cs @@ -0,0 +1,18 @@ + +namespace AdminusaBackend.DTO.ExelServices +{ + public class Precta + { + public string? Trafico { get; set; } + public string? Precuenta { get; set; } + public string? Concepto { get; set; } + public string? Importe { get; set; } + public string? Cantidad { get; set; } + public string? Tipo { get; set; } + public string? IdProvedor { get; set; } + public string? NomProvedor { get; set; } + public string? TagTabulador { get; set; } + public string? NombreTabulador { get; set; } + public string? Rctadeb { get; set; } + } +} diff --git a/AdminusaBackend/DTO/Reportes/TotalHoursWorking.cs b/AdminusaBackend/DTO/Reportes/TotalHoursWorking.cs new file mode 100644 index 0000000..1b622e7 --- /dev/null +++ b/AdminusaBackend/DTO/Reportes/TotalHoursWorking.cs @@ -0,0 +1,17 @@ +namespace AdminusaBackend.DTO.Reportes +{ + public class TotalHoursWorking + { + + public string? EmpNo { get; set; } + public string? AcNo { get; set;} + + public string? Name { get; set;} + public string? TotalHoursAccumulated { get; set;} + + public string? TotalHoursWithMilitaryMinutes { get; set;} + + + + } +} diff --git a/AdminusaBackend/DTO/Usuario/DTOClonarUsuario.cs b/AdminusaBackend/DTO/Usuario/DTOClonarUsuario.cs new file mode 100644 index 0000000..be012f5 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOClonarUsuario.cs @@ -0,0 +1,10 @@ + +namespace AdminusaBackend.DTO.Usuario + +{ + public class DTOClonarUsuario + { + public int IDUsuarioOrigen { get; set; } = 0!; + public int IdUsuarioDestino { get; set; } = 0!; + } +} diff --git a/AdminusaBackend/DTO/Usuario/DTOPINData.cs b/AdminusaBackend/DTO/Usuario/DTOPINData.cs new file mode 100644 index 0000000..3047406 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOPINData.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOPINData + { + public int PIN { get; set; } = 0!; + public string Correo { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/AdminusaBackend/DTO/Usuario/DTOPINUsuario.cs b/AdminusaBackend/DTO/Usuario/DTOPINUsuario.cs new file mode 100644 index 0000000..fc98111 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOPINUsuario.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOPINUsuario + { + public int PIN { get; set; } = 0!; + public string Usuario { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/AdminusaBackend/DTO/Usuario/DTOPerfilCreate.cs b/AdminusaBackend/DTO/Usuario/DTOPerfilCreate.cs new file mode 100644 index 0000000..38d7cc5 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOPerfilCreate.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOPerfilCreate + { + public string Perfil { get; set; } = null!; + public int IdPerfilClonado { get; set; } = 0!; + } +} diff --git a/AdminusaBackend/DTO/Usuario/DTOResetPassword.cs b/AdminusaBackend/DTO/Usuario/DTOResetPassword.cs new file mode 100644 index 0000000..1d8bf49 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOResetPassword.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOResetPassword + { + public int PIN { get; set; } = 0; + public string Contrasena { get; set; } = null!; + } +} \ No newline at end of file diff --git a/AdminusaBackend/DTO/Usuario/DTOUsuario.cs b/AdminusaBackend/DTO/Usuario/DTOUsuario.cs new file mode 100644 index 0000000..b85c120 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOUsuario.cs @@ -0,0 +1,14 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOUsuario + { + public int Id { get; set; } = 0; + public string Usuario { get; set; } = null!; + public string Nombre { get; set; } = null!; + public string? Contrasena { get; set; } = null!; + public string Correo { get; set; } = null!; + public int TipoUsuario { get; set; } = 0; + public int IdPerfil { get; set; } = 0; + public string? FechaAlta { get; set; } = null!; + } +} \ No newline at end of file diff --git a/AdminusaBackend/DTO/Usuario/DTOUsuarioTransportista.cs b/AdminusaBackend/DTO/Usuario/DTOUsuarioTransportista.cs new file mode 100644 index 0000000..9c94b09 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOUsuarioTransportista.cs @@ -0,0 +1,9 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOUsuarioTransportista + { + public int IdUsuario { get; set; } + public int sClave { get; set; } + public bool Asignado { get; set; } + } +} diff --git a/AdminusaBackend/DTO/Usuario/DTOUsuariosPerfilParecido.cs b/AdminusaBackend/DTO/Usuario/DTOUsuariosPerfilParecido.cs new file mode 100644 index 0000000..8630a67 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOUsuariosPerfilParecido.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.DTO.Usuario; + +public class DTOUsuariosPerfilParecido +{ + public int IdUsuario { get; set; } = 0; + public string Nombre { get; set; } = null!; + public string Perfil { get; set; } = null!; +} diff --git a/AdminusaBackend/DTO/Usuario/DTOUsuariosShort.cs b/AdminusaBackend/DTO/Usuario/DTOUsuariosShort.cs new file mode 100644 index 0000000..47234c0 --- /dev/null +++ b/AdminusaBackend/DTO/Usuario/DTOUsuariosShort.cs @@ -0,0 +1,9 @@ +namespace AdminusaBackend.DTO.Usuario +{ + public class DTOUsuariosShort + { + public int id { get; set; } = 0!; + public string Usuario { get; set; } = null!; + public Boolean Activo { get; set; } = false; + } +} diff --git a/AdminusaBackend/Models/CatRoles.cs b/AdminusaBackend/Models/CatRoles.cs new file mode 100644 index 0000000..6c7dd63 --- /dev/null +++ b/AdminusaBackend/Models/CatRoles.cs @@ -0,0 +1,9 @@ +namespace AdminusaBackend.Models +{ + public class CatRoles + { + public int Id { set; get; } + public string Rol { set; get; } = null!; + public byte Activo { set; get; } + } +} \ No newline at end of file diff --git a/AdminusaBackend/Models/Catalogos/CatRelacionPrecuentaCheque.cs b/AdminusaBackend/Models/Catalogos/CatRelacionPrecuentaCheque.cs new file mode 100644 index 0000000..e7d9615 --- /dev/null +++ b/AdminusaBackend/Models/Catalogos/CatRelacionPrecuentaCheque.cs @@ -0,0 +1,11 @@ +namespace AdminusaBackend.Models.Catalogos +{ + public class CatRelacionPrecuentaCheque + { + public int id { get; set; } + public string? Precuenta { get; set; } + public string? Cheques { get; set; } + + + } +} diff --git a/AdminusaBackend/Models/Menu.cs b/AdminusaBackend/Models/Menu.cs new file mode 100644 index 0000000..8b58d24 --- /dev/null +++ b/AdminusaBackend/Models/Menu.cs @@ -0,0 +1,11 @@ +namespace AdminusaBackend.Models +{ + public class Menu + { + public int Id { get; set; } + public string Descripcion { get; set; } = null!; + public int PadreId { get; set; } + public int Posicion { get; set; } + public string Url { get; set; } = null!; + } +} \ No newline at end of file diff --git a/AdminusaBackend/Models/Perfiles.cs b/AdminusaBackend/Models/Perfiles.cs new file mode 100644 index 0000000..5e8b8b4 --- /dev/null +++ b/AdminusaBackend/Models/Perfiles.cs @@ -0,0 +1,8 @@ +namespace AdminusaBackend.Models +{ + public class Perfiles + { + public int id { get; set; } + public string Perfil { get; set; } = string.Empty; + } +} diff --git a/AdminusaBackend/Models/PerfilesMenu.cs b/AdminusaBackend/Models/PerfilesMenu.cs new file mode 100644 index 0000000..3094984 --- /dev/null +++ b/AdminusaBackend/Models/PerfilesMenu.cs @@ -0,0 +1,16 @@ +namespace AdminusaBackend.Models +{ + public class PerfilesMenu + { + public int id { set; get; } + public int IdPerfil { set; get; } + public int itemMenu { set; get; } + public string Perfil { set; get; } = null!; + public string Descripcion { set; get; } = null!; + public int PadreId { set; get; } + public int Posicion { set; get; } + public string Url { set; get; } = null!; + public int Habilitado { set; get; } + public int Agrupado { set; get; } + } +} \ No newline at end of file diff --git a/AdminusaBackend/Models/Reportes/RelacionBookPrecta.cs b/AdminusaBackend/Models/Reportes/RelacionBookPrecta.cs new file mode 100644 index 0000000..7712071 --- /dev/null +++ b/AdminusaBackend/Models/Reportes/RelacionBookPrecta.cs @@ -0,0 +1,41 @@ +namespace AdminusaBackend.Models.Reportes +{ + public class RelacionBookPrecta + { + + public string? Type { get; set; } + public string? Cheques { get; set; } + public string? Date { get; set; } + public string? Num { get; set; } + public string? Name { get; set; } + public string? Memo { get; set; } + public double Amount { get; set; } + public string? Trafico { get; set; } + public string? Trafico1 { get; set; } + public string? Precuenta { get; set; } + public string? Concepto { get; set; } + public double Importe { get; set; } + public string? Cantidad { get; set; } + public char? Tipo { get; set; } + public string? IdProvedor { get; set; } + public string? NomProvedor { get; set; } + public string? TagTabulador { get; set; } + public string? NombreTabulador { get; set; } + public string? Rctadeb { get; set; } + public string? Diferencia { get; set; } + + + + + + + + + + // precuenta 5404016 cheques 5215013 + // precuenta 5213001 cheques 5215011 + + + + } +} diff --git a/AdminusaBackend/Models/Reportes/WorkingHours.cs b/AdminusaBackend/Models/Reportes/WorkingHours.cs new file mode 100644 index 0000000..362d40f --- /dev/null +++ b/AdminusaBackend/Models/Reportes/WorkingHours.cs @@ -0,0 +1,46 @@ +/*using Org.BouncyCastle.Asn1.X509;*/ + +namespace AdminusaBackend.Models.Reportes +{ + public class WorkingHours + { + public string EmpNo { get; set; } + public string AcNo { get; set; } + public string No { get; set; } + public string Name { get; set; } + public string Date { get; set; } // Almacenando la fecha como string + /* public TimeSpan? ClockIn1 { get; set; } + public TimeSpan? ClockOut1 { get; set; } + public TimeSpan? ClockIn2 { get; set; } + public TimeSpan? ClockOut2 { get; set; } + public TimeSpan? ClockIn3 { get; set; } + public TimeSpan? ClockOut3 { get; set; } + public TimeSpan? ClockIn4 { get; set; } + public TimeSpan? ClockOut4 { get; set; } + public TimeSpan? ClockIn5 { get; set; } + public TimeSpan? ClockOut5 { get; set; } + public TimeSpan? TotalInTime { get; set; }*/ + + public string? ClockIn1 { get; set; } + public string? ClockOut1 { get; set; } + public string? ClockIn2 { get; set; } + public string? ClockOut2 { get; set; } + + public string? ClockIn3 { get; set; } + public string? ClockOut3 { get; set; } + + public string? ClockIn4 { get; set; } + public string? ClockOut4 { get; set; } + + public string? ClockIn5 { get; set; } + public string? ClockOut5 { get; set; } + public string? TotalInTime { get; set; } + + public string? TotalHoursWorked { get; set; } + + + + + } + +} diff --git a/AdminusaBackend/Models/Usuarios.cs b/AdminusaBackend/Models/Usuarios.cs new file mode 100644 index 0000000..6f37221 --- /dev/null +++ b/AdminusaBackend/Models/Usuarios.cs @@ -0,0 +1,37 @@ +namespace AdminusaBackend.Models +{ + public class Usuarios + { + public int Id { get; set; } = 0; + public string Usuario { get; set; } = null!; + public string Nombre { get; set; } = null!; + public string Contrasena { get; set; } = null!; + public string Correo { get; set; } = null!; + public byte TipoUsuario { get; set; } = 2; + public byte Activo { get; set; } = 1; + public string FechaAlta { get; set; } = null!; + public int UsuarioAlta { get; set; } = 0!; + public string FechaModifico { get; set; } = null!; + public int UsuarioModifico { get; set; } = 0!; + public string FechaElimino { get; set; } = null!; + public int UsuarioElimino { get; set; } = 0!; + public string MotivoElimino { get; set; } = null!; + public int IdModulo { get; set; } = 0!; + public int Dept { get; set; } = 0!; + public string? sDept { get; set; } = null!; + public int Tmercancia { get; set; } = 0!; + public string FechaUltimaVisita { get; set; } = null!; + public int Visitas { get; set; } = 0!; + public int Internos { get; set; } = 0!; + public int PermisoEspecial { get; set; } = 0!; + public int EstadoConfiguracion { get; set; } = 0!; + public string FechaValidacionConf { get; set; } = null!; + public string RealizoEncuesta { get; set; } = null!; + public int EncuestaActiva { get; set; } = 0!; + public string FechaLimiteEncuesta { get; set; } = null!; + public string CodigoAccesoM { get; set; } = null!; + public string TokenAccesoM { set; get; } = null!; + public string DeviceToken { get; set; } = null!; + public int IdPerfil { get; set; } = 0!; + } +} diff --git a/AdminusaBackend/Program.cs b/AdminusaBackend/Program.cs new file mode 100644 index 0000000..4a0112a --- /dev/null +++ b/AdminusaBackend/Program.cs @@ -0,0 +1,164 @@ + +using AdminusaBackend.Context; +using AdminusaBackend.Catalogos; +using AdminusaBackend.Contracts; +using AdminusaBackend.Contracts.Catalogos; + + +using AdminusaBackend.Repository; +using Microsoft.OpenApi.Models; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.IdentityModel.Tokens; + +using System.Text; +using AdminusaBackend.Clientes.Contracts; +using AdminusaBackend.Clientes.Repository; +using AdminusaBackend.Repository.ExelServices; +using AdminusaBackend.Repository.ExcelServices; +using AdminusaBackend.Contracts.Reportes; +using AdminusaBackend.Repository.Reportes; +using AdminusaBackend.Repository.EcxelServices.ExelHourWorking; + + +internal class Program +{ + private static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + builder.Services.AddSingleton(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + + + + + // Reportes + builder.Services.AddScoped(); + + // Servivios Exel + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + //Catalogos + builder.Services.AddScoped(); + + + + + builder.Services.AddControllers(); + + /* builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => + { + options.RequireHttpsMetadata = false; + options.SaveToken = true; + options.TokenValidationParameters = new TokenValidationParameters() + { + ValidateIssuer = true, + ValidateAudience = true, + ValidAudience = builder.Configuration["Jwt:Audience"], + ValidIssuer = builder.Configuration["Jwt:Issuer"], + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"])) + }; + });*/ + + + builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.TokenValidationParameters = new TokenValidationParameters + { + ValidateIssuer = true, + ValidateAudience = true, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + ValidIssuer = builder.Configuration["Jwt:Issuer"], + ValidAudience = builder.Configuration["Jwt:Audience"], + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"])) + }; + }); + + + + var key = builder.Configuration["Jwt:Key"]; + Console.WriteLine(key); + + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + + builder.Services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "Adminusa Backend", + Version = "v1" + }); + c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme() + { + Name = "Authorization", + Type = SecuritySchemeType.ApiKey, + Scheme = "Bearer", + BearerFormat = "JWT", + In = ParameterLocation.Header, + Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 1safsfsdfdfd\"", + }); + c.AddSecurityRequirement(new OpenApiSecurityRequirement { + { + new OpenApiSecurityScheme { + Reference = new OpenApiReference { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + } + }, + new string[] {} + } + }); + }); + + //services cors + builder.Services.AddCors(p => p.AddPolicy("corsapp", builder => + { + if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") + { + builder.WithOrigins("http://localhost:3000", + "http://localhost:5263", + "https://localhost:5020").AllowAnyMethod().AllowAnyHeader(); + } + else if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Staging") + { + builder.WithOrigins( + + ).AllowAnyMethod().AllowAnyHeader(); + } + else if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Production") + { + builder.WithOrigins( + + ).AllowAnyMethod().AllowAnyHeader(); + } + })); + + + + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + app.UseCors("corsapp"); + app.UseAuthorization(); + + app.MapControllers(); + + app.Run(); + } +} \ No newline at end of file diff --git a/AdminusaBackend/Properties/launchSettings.json b/AdminusaBackend/Properties/launchSettings.json new file mode 100644 index 0000000..9687e5f --- /dev/null +++ b/AdminusaBackend/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:44989", + "sslPort": 44376 + } + }, + "profiles": { + "Adminusa": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:5020;http://localhost:5021", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/AdminusaBackend/Repository/Catalogos/CatRelacionPrecuentaCheques.cs b/AdminusaBackend/Repository/Catalogos/CatRelacionPrecuentaCheques.cs new file mode 100644 index 0000000..9a0e55a --- /dev/null +++ b/AdminusaBackend/Repository/Catalogos/CatRelacionPrecuentaCheques.cs @@ -0,0 +1,102 @@ +using AdminusaBackend.Models.Catalogos; +using AdminusaBackend.Models.Reportes; +using Dapper; +using AdminusaBackend. Context; +using AdminusaBackend.Contracts.Catalogos; +using System.Data; + +namespace AdminusaBackend.Catalogos +{ + public class CatRelacionPrecuentaCheques : ICatChequesPrecuenta + { + private readonly DapperContext _context; + + public CatRelacionPrecuentaCheques(DapperContext context) { _context = context; } + + + + public async Task> GetRelacionBookPrecta(string Inicio, string Fin) + { + var query = "[RelacionBookPrecta]"; + using (var conn = _context.CreateConnection()) + { + var result = await conn.QueryAsync(query, + new { @Inicio = Inicio, @Fin = Fin }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + + + } + public async Task> GetRelacionBooKPrectaPrecuenta() + { + var query = "[RelacionBookPrectaPrecuentaCheques]"; + using (var con = _context.CreateConnection()) + { + var result = await con.QueryAsync(query); + return result.ToList(); + } + } + + + + + public async Task> PostRelacionPrecuentaCheques(string Precuenta, string Cheques) + { + var query = "UpsertRelacionChequesPrecuenta"; + using (var con = _context.CreateConnection()) + { + var result = await con.QueryAsync(query, new { @Precuenta = Precuenta, @Cheques = Cheques }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + } + + + + public async Task> GetRelacionPrecuentaCheque() + { + var query = "Select * from RelacionPrecuentaCheque "; + using (var con = _context.CreateConnection()) + { + var result = await con.QueryAsync (query); + return result.ToList (); + } + } + + + + + + + public async Task> DeleteRelacionPrecuentaCheque(string Precuenta) + { + var query = "Delete from RelacionPrecuentaCheque where Precuenta= @Precuenta"; + + using (var con = _context.CreateConnection()) + { + + var result = await con.QueryAsync(query, + new { Precuenta }); + + return result.ToList(); + } + } + + + public async Task> GetRelacionPrecuentaCheque(string Inicio, string Fin) + { + var query = "[RelacionBookPrecta]"; + using (var con = _context.CreateConnection()) + { + var result = await con.QueryAsync(query, new {@Inicio = Inicio, @Fin = Fin }, commandType: CommandType.StoredProcedure); + return result.ToList(); + + } + } + + + + + + + } +} diff --git a/AdminusaBackend/Repository/ExelServices/ExelHourWorking/ExelHours.cs b/AdminusaBackend/Repository/ExelServices/ExelHourWorking/ExelHours.cs new file mode 100644 index 0000000..e448b57 --- /dev/null +++ b/AdminusaBackend/Repository/ExelServices/ExelHourWorking/ExelHours.cs @@ -0,0 +1,174 @@ + + + + +using Dapper; +using AdminusaBackend.Context; +using OfficeOpenXml; +using AdminusaBackend.Models.Reportes; +using Microsoft.AspNetCore.Mvc; +/*using Org.BouncyCastle.Asn1.Cms;*/ + +namespace AdminusaBackend.Repository.EcxelServices.ExelHourWorking +{ + public class ExelHours + { + private readonly DapperContext _dapperContext; + + public ExelHours(DapperContext dapperContext) + { + _dapperContext = dapperContext; + ExcelPackage.LicenseContext = LicenseContext.Commercial; + } + + public async Task ProccesHoursExelFileAysn(Stream fileStream) + { + List records = new List(); + + using (var package = new ExcelPackage(fileStream)) + { + var worksheet = package.Workbook.Worksheets[0]; + var rowCount = worksheet.Dimension.Rows; + + // Obtener la fecha máxima existente en la tabla + DateTime? maxDate = await GetMaxDateAsync(); + Console.WriteLine($"Fecha máxima existente en la tabla: {maxDate}"); + + for (int row = 2; row <= rowCount; row++) + { + try + { + // Especificar el formato de la fecha en Excel + DateTime date = DateTime.ParseExact(worksheet.Cells[row, 5].Text, "M/d/yyyy", null); + Console.WriteLine($"Fecha en la fila {row}: {date}"); + + // Validar que la fecha sea mayor a la fecha máxima + if (maxDate == null || date > maxDate) + { + var record = new WorkingHours + { + EmpNo = worksheet.Cells[row, 1].Text, + AcNo = worksheet.Cells[row, 2].Text, + No = worksheet.Cells[row, 3].Text, + Name = worksheet.Cells[row, 4].Text, + Date = date.ToString("yyyy-MM-dd"), // Convertir la fecha a un formato estándar antes de guardarla + ClockIn1 = worksheet.Cells[row, 6].Text, + ClockOut1 = worksheet.Cells[row, 7].Text, + ClockIn2 = worksheet.Cells[row, 8].Text, + ClockOut2 = worksheet.Cells[row, 9].Text, + ClockIn3 = worksheet.Cells[row, 10].Text, + ClockOut3 = worksheet.Cells[row, 11].Text, + ClockIn4 = worksheet.Cells[row, 12].Text, + ClockOut4 = worksheet.Cells[row, 13].Text, + ClockIn5 = worksheet.Cells[row, 14].Text, + ClockOut5 = worksheet.Cells[row, 15].Text, + /* ClockIn1 = TimeSpan.FromHours(), + ClockOut1 = TimeSpan.FromHours(1), + ClockIn2 = TimeSpan.FromHours(1), + ClockOut2 = TimeSpan.FromHours(1), + ClockIn3 = TimeSpan.FromHours(1), + ClockOut3 = TimeSpan.FromHours(1), + ClockIn4 = TimeSpan.FromHours(1), + ClockOut4 = TimeSpan.FromHours(1), + ClockIn5 = TimeSpan.FromHours(1), + ClockOut5 = TimeSpan.FromHours(1), + TotalInTime = TimeSpan.FromHours(1)*/ + + TotalInTime = worksheet.Cells[row, 16].Text + }; + + records.Add(record); + } + else + { + Console.WriteLine($"Fecha en la fila {row} es menor o igual a la fecha máxima existente y no será insertada."); + } + } + catch (FormatException ex) + { + Console.WriteLine($"Error al parsear la fecha en la fila {row}: {worksheet.Cells[row, 5].Text}. Excepción: {ex.Message}"); + } + } + + } + + if (records.Any()) + { + await InsertWorkingHoursAsync(records); + return new OkObjectResult("Datos insertados correctamente."); + } + else + { + return new BadRequestObjectResult("No se encontraron registros con fechas mayores a la fecha máxima existente."); + } + } + + + private async Task GetMaxDateAsync() +{ + using (var connection = _dapperContext.CreateConnection()) + { + var query = "SELECT MAX(CAST(Date AS DATE)) FROM WorkingHours"; + + try + { + var maxDate = await connection.ExecuteScalarAsync(query); + return maxDate ?? DateTime.MinValue; // Retorna una fecha mínima si la tabla está vacía + } + catch (Exception ex) + { + Console.WriteLine($"Error al obtener la fecha máxima: {ex.Message}"); + return null; + } + } +} + + + + private async Task InsertWorkingHoursAsync(IEnumerable records) + { + using (var connection = _dapperContext.CreateConnection()) + { + var createTableQuery = @" +IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'WorkingHours') +CREATE TABLE WorkingHours ( +EmpNo VARCHAR(50), +AcNo VARCHAR(50), +No VARCHAR(50), +Name VARCHAR(100), +Date VARCHAR(20), +ClockIn1 VARCHAR(20), +ClockOut1 VARCHAR(20), +ClockIn2 VARCHAR(20), +ClockOut2 VARCHAR(20), +ClockIn3 VARCHAR(20), +ClockOut3 VARCHAR(20), +ClockIn4 VARCHAR(20), +ClockOut4 VARCHAR(20), +ClockIn5 VARCHAR(20), +ClockOut5 VARCHAR(20), +TotalInTime VARCHAR(20))"; + + await connection.ExecuteAsync(createTableQuery); + + var insertQuery = @" +INSERT INTO WorkingHours ( +EmpNo, AcNo, No, Name, Date, ClockIn1, ClockOut1, ClockIn2, ClockOut2, +ClockIn3, ClockOut3, ClockIn4, ClockOut4, ClockIn5, ClockOut5, TotalInTime) +VALUES ( +@EmpNo, @AcNo, @No, @Name, @Date, @ClockIn1, @ClockOut1, @ClockIn2, @ClockOut2, +@ClockIn3, @ClockOut3, @ClockIn4, @ClockOut4, @ClockIn5, @ClockOut5, @TotalInTime)"; + + try + { + await connection.ExecuteAsync(insertQuery, records); + } + catch (Exception ex) + { + Console.WriteLine($"Error al insertar datos: {ex.Message}"); + throw; + } + } + } + } +} diff --git a/AdminusaBackend/Repository/ExelServices/ExelRepository.cs b/AdminusaBackend/Repository/ExelServices/ExelRepository.cs new file mode 100644 index 0000000..2bc3026 --- /dev/null +++ b/AdminusaBackend/Repository/ExelServices/ExelRepository.cs @@ -0,0 +1,124 @@ + +using Dapper; +using OfficeOpenXml; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using AdminusaBackend.DTO.ExelServices; +using Microsoft.Extensions.Configuration; +using AdminusaBackend.Context; +using AdminusaBackend.Context; +using AdminusaBackend.DTO.ExelServices; + +namespace AdminusaBackend.Repository.ExelServices +{ + public class ExcelRepository + { + private readonly DapperContext _dapperContext; + + public ExcelRepository(DapperContext dapperContext) + { + _dapperContext = dapperContext; + ExcelPackage.LicenseContext = LicenseContext.Commercial; + } + + public async Task ProcessExcelFileAsync(Stream fileStream) + { + List records = new List(); + + using (var package = new ExcelPackage(fileStream)) + { + var worksheet = package.Workbook.Worksheets[0]; + var rowCount = worksheet.Dimension.Rows; + var colCount = worksheet.Dimension.Columns; + string valorActual = null; + + for (int row = 2; row <= rowCount; row++) // Asumiendo que la primera fila tiene encabezados + { + var typeValue = worksheet.Cells[row, 1].Text; + + if (typeValue.Contains("·")) + { + valorActual = typeValue.Split('·')[0].Trim(); + } + else + { + var match = Regex.Match(typeValue, @"\b\d+[-]?\d*\b"); + if (match.Success) + { + valorActual = match.Value; + } + } + string cheques = valorActual; + if (typeValue.StartsWith("Total")) + { + valorActual = null; + } + + var record = new Book + { + Type = typeValue, + Cheques = cheques ?? string.Empty, + Date = worksheet.Cells[row, 2].Text, + Num = worksheet.Cells[row, 3].Text, + Name = worksheet.Cells[row, 4].Text, + Memo = worksheet.Cells[row, 5].Text, + /*Amount = float.TryParse(worksheet.Cells[row, 6].Text, out float amount) ? amount : 0f,*/ + Amount = decimal.TryParse(worksheet.Cells[row, 6].Text, out decimal amount) ? amount : 0m, + + Trafico = worksheet.Cells[row, 5].Text.Split().FirstOrDefault() + }; + + records.Add(record); + } + } + + await InsertRecordsAsync(records); + } + + private async Task InsertRecordsAsync(IEnumerable records) + { + using (var connection = _dapperContext.CreateConnection()) + { + var createTableQuery = @" + IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'Cheques') + CREATE TABLE Cheques ( + Type VARCHAR(100), + Cheques VARCHAR(100), + Date VARCHAR(20), + Num VARCHAR(100), + Name VARCHAR(100), + Memo VARCHAR(100), + Amount DECIMAL(18, 2), + Trafico VARCHAR(100) + )"; + + await connection.ExecuteAsync(createTableQuery); + + var insertQuery = @" + INSERT INTO Cheques (Type, Cheques, Date, Num, Name, Memo, Amount, Trafico) + VALUES (@Type, @Cheques, @Date, @Num, @Name, @Memo, @Amount, @Trafico)"; + + try + { + await connection.ExecuteAsync(insertQuery, records); + Console.WriteLine($"Se insertaron {records.Count()} registros correctamente en la tabla Cheques."); + } + catch (Exception ex) + { + Console.WriteLine($"Error al insertar datos: {ex.Message}"); + throw; // Opcional, vuelve a lanzar la excepción para que el llamador también pueda manejarla + } + } + } + + + + + + + } +} diff --git a/AdminusaBackend/Repository/ExelServices/ExelRepositoryPrecta.cs b/AdminusaBackend/Repository/ExelServices/ExelRepositoryPrecta.cs new file mode 100644 index 0000000..640d36b --- /dev/null +++ b/AdminusaBackend/Repository/ExelServices/ExelRepositoryPrecta.cs @@ -0,0 +1,98 @@ +using Dapper; +using OfficeOpenXml; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using AdminusaBackend.DTO.ExelServices; +using AdminusaBackend.Context; +using AdminusaBackend.Context; +using AdminusaBackend.DTO.ExelServices; + +namespace AdminusaBackend.Repository.ExcelServices +{ + public class ExcelRepositoryPrecta + { + private readonly DapperContext _dapperContext; + + public ExcelRepositoryPrecta(DapperContext dapperContext) + { + _dapperContext = dapperContext; + ExcelPackage.LicenseContext = LicenseContext.Commercial; + } + + // Método para procesar archivos Excel tipo Precta + public async Task ProcessPrectaExcelFileAsync(Stream fileStream) + { + List records = new List(); + + using (var package = new ExcelPackage(fileStream)) + { + var worksheet = package.Workbook.Worksheets[0]; + var rowCount = worksheet.Dimension.Rows; + + for (int row = 2; row <= rowCount; row++) // Asumiendo que la primera fila tiene encabezados + { + var record = new Precta + { + Trafico = worksheet.Cells[row, 1].Text, + Precuenta = worksheet.Cells[row, 2].Text, + Concepto = worksheet.Cells[row, 3].Text, + Importe = worksheet.Cells[row, 4].Text, + Cantidad = worksheet.Cells[row, 5].Text, + Tipo = worksheet.Cells[row, 6].Text, + IdProvedor = worksheet.Cells[row, 7].Text, + NomProvedor = worksheet.Cells[row, 8].Text, + TagTabulador = worksheet.Cells[row, 9].Text, + NombreTabulador = worksheet.Cells[row, 10].Text, + Rctadeb = worksheet.Cells[row, 11].Text + }; + + records.Add(record); + } + } + + await InsertPrectaRecordsAsync(records); + } + + private async Task InsertPrectaRecordsAsync(IEnumerable records) + { + using (var connection = _dapperContext.CreateConnection()) + { + var createTableQuery = @" + IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'Precuenta') + CREATE TABLE Precuenta ( + Trafico VARCHAR(255), + Precuenta VARCHAR(255), + Concepto VARCHAR(255), + Importe VARCHAR(255), + Cantidad VARCHAR(255), + Tipo VARCHAR(255), + IdProvedor VARCHAR(255), + NomProvedor VARCHAR(255), + TagTabulador VARCHAR(255), + NombreTabulador VARCHAR(255), + Rctadeb VARCHAR(255) + )"; + + await connection.ExecuteAsync(createTableQuery); + + var insertQuery = @" + INSERT INTO Precuenta (Trafico, Precuenta, Concepto, Importe, Cantidad, Tipo, IdProvedor, NomProvedor, TagTabulador, NombreTabulador, Rctadeb) + VALUES (@Trafico, @Precuenta, @Concepto, @Importe, @Cantidad, @Tipo, @IdProvedor, @NomProvedor, @TagTabulador, @NombreTabulador, @Rctadeb)"; + + try + { + await connection.ExecuteAsync(insertQuery, records); + Console.WriteLine($"Se insertaron {records.Count()} registros correctamente en la tabla UnifiedTable2."); + } + catch (Exception ex) + { + Console.WriteLine($"Error al insertar datos: {ex.Message}"); + throw; // Opcional, vuelve a lanzar la excepción para que el llamador también pueda manejarla + } + } + } + } + +} diff --git a/AdminusaBackend/Repository/MenuRepository.cs b/AdminusaBackend/Repository/MenuRepository.cs new file mode 100644 index 0000000..4a8671b --- /dev/null +++ b/AdminusaBackend/Repository/MenuRepository.cs @@ -0,0 +1,35 @@ +using Dapper; +using AdminusaBackend.Context; +using AdminusaBackend.Contracts; +using AdminusaBackend.Models; +using System.Data; + +namespace AdminusaBackend.Repository +{ + public class MenuRepository : IMenuRepository + { + + private readonly DapperContext _context; + public MenuRepository(DapperContext context) { _context = context; } + public async Task> GetItemsMenu(Usuarios user) + { + var query = "[Menu.Get]"; + using (var connection = _context.CreateConnection()) + { + var menu = await connection.QueryAsync(query, new { @id = user.Id }, commandType: CommandType.StoredProcedure); + return menu.ToList(); + } + } + + public async Task> GetItemsMenuTransportista() + { + var query = "[Menu.Transportista.Get]"; + using (var connection = _context.CreateConnection()) + { + var menu = await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); + return menu.ToList(); + } + } + + } +} diff --git a/AdminusaBackend/Repository/PerfilesRepository.cs b/AdminusaBackend/Repository/PerfilesRepository.cs new file mode 100644 index 0000000..396698b --- /dev/null +++ b/AdminusaBackend/Repository/PerfilesRepository.cs @@ -0,0 +1,107 @@ +using Dapper; +using AdminusaBackend.Context; +using AdminusaBackend.Contracts; +using AdminusaBackend.DTO; +using AdminusaBackend.DTO.Usuario; +using AdminusaBackend.Models; +using System.Data; + +namespace AdminusaBackend.Repository +{ + public class PerfilesRepository : IPerfilesRepository + { + private readonly DapperContext _context; + public PerfilesRepository(DapperContext context) { _context = context; } + public async Task> getPerfiles() + { + var query = "[Perfiles.Get]"; + using (var connection = _context.CreateConnection()) + { + var perfiles = await connection.QueryAsync(query, new { @id = 0 }, commandType: CommandType.StoredProcedure); + return perfiles.ToList(); + } + } + public async Task PerfilGetById(int id) + { + var query = "[Perfil.GetById]"; + using (var connection = _context.CreateConnection()) + { + var perfiles = await connection.QueryAsync(query, new { @id }, commandType: CommandType.StoredProcedure); + return perfiles.FirstOrDefault(new Perfiles()); + } + } + public async Task> getMenu() + { + var query = "SELECT * FROM Menu"; + using (var connection = _context.CreateConnection()) + { + var result = await connection.QueryAsync(query); + return result.ToList(); + } + } + public async Task> getPerfilMenuById(int id) + { + var query = "[Perfil.MenuById]"; + using (var connection = _context.CreateConnection()) + { + var perfiles = await connection.QueryAsync(query, new { @id = id }, commandType: CommandType.StoredProcedure); + return perfiles.ToList(); + } + } + public async Task> getAllPerfilesMenu() + { + var query = "getAllPerfilesMenu"; + using (var connection = _context.CreateConnection()) + { + var perfiles = await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); + return perfiles.ToList(); + } + } + public async Task> createPerfil(DTOPerfilCreate data) + { + var query = "[Perfil.Append]"; + using (var connection = _context.CreateConnection()) + { + var perfiles = await connection.QueryAsync(query, new { @Perfil = data.Perfil, @IdPerfilClonado = data.IdPerfilClonado }, commandType: CommandType.StoredProcedure); + return perfiles.ToList(); + } + } + public async Task> createItemMenu(Menu data) + { + var query = "[Menu.Item.Append]"; + using (var connection = _context.CreateConnection()) + { + var result = await connection.QueryAsync(query, new { @Descripcion = data.Descripcion, @PadreId = data.PadreId, @Posicion = data.Posicion, @URL = data.Url }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + } + public async Task> asignaItemMenuPerfil(DTOItemMenuPerfil data) + { + var query = "[Menu.Item.Perfil.Assign]"; + using (var connection = _context.CreateConnection()) + { + var perfiles = await connection.QueryAsync(query, new { @IdPerfil = data.IdPerfil, @itemMenu = data.itemMenu, @asignado = data.asignado }, commandType: CommandType.StoredProcedure); + return perfiles.ToList(); + } + } + /*public async Task> getAllTransportistas(int id) + { + //var query = "SELECT sClave, CONCAT(sClave,' | ',sRazonSocial) as sRazonSocial FROM SIR.Admin.ADMINC_42_PROVEEDORES ORDER BY 2"; + var query = "getAllTransportistas"; + using (var connection = _context.CreateConnection()) + { + var transportistas = await connection.QueryAsync(query, new { @IdUsuario = id }, commandType: CommandType.StoredProcedure); + return transportistas.ToList(); + } + } + public async Task> getAllProveedores(int id) + { + var query = "getAllProveedores"; + using (var connection = _context.CreateConnection()) + { + var proveedores = await connection.QueryAsync(query, new { @IdUsuario = id }, commandType: CommandType.StoredProcedure); + return proveedores.ToList(); + } + }*/ + } +} diff --git a/AdminusaBackend/Repository/Reportes/ReportesRepository.cs b/AdminusaBackend/Repository/Reportes/ReportesRepository.cs new file mode 100644 index 0000000..68af600 --- /dev/null +++ b/AdminusaBackend/Repository/Reportes/ReportesRepository.cs @@ -0,0 +1,84 @@ +using AdminusaBackend.Context; +using AdminusaBackend.Contracts.Reportes; +using AdminusaBackend.DTO.Reportes; +using AdminusaBackend.Models.Reportes; +using Dapper; +/*using NPOI.Util;*/ +using System.Data; + + +namespace AdminusaBackend.Repository.Reportes +{ + public class ReportesRepository : IRptRepository + { + + private readonly DapperContext _context; + + public ReportesRepository(DapperContext context) { _context = context; } + + + public async Task>GetRelacionesTrafico() + { + + + var query = "[RelacionesSoloTrafico]"; + using (var con = _context.CreateConnection()) + { + var result = await con.QueryAsync(query ); + return result.ToList(); + } + + } + + + + public async Task > GetNoRelaciones() + { + var query = "[DatosNoRelacionan]"; + using (var con =_context.CreateConnection()) + { + var result = await con.QueryAsync(query); + return result.ToList(); + } + + } + + + + public async Task> GetWorkingHours(string Inicio, string Fin) + { + + var query = "[TotalTiempos]"; + using (var con = _context.CreateConnection()) + { + var result = await con.QueryAsync (query, new {@Inicio = Inicio, @Fin = Fin}, commandType: CommandType.StoredProcedure ); + return result.ToList(); + } + + } + + + + public async Task> GetTotalHoursWorkings(string Inicio, string Fin) + { + var query = "[TotalHorasWithMilitaryMinutes]"; + using var con = _context.CreateConnection(); + { + var result = await con.QueryAsync(query, new + { @Inicio = Inicio, @Fin = Fin }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + } + + + + + + + + + + + + } +} diff --git a/AdminusaBackend/Repository/UsuariosRepository.cs b/AdminusaBackend/Repository/UsuariosRepository.cs new file mode 100644 index 0000000..55e3241 --- /dev/null +++ b/AdminusaBackend/Repository/UsuariosRepository.cs @@ -0,0 +1,203 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.Data.Common; +using Dapper; +using AdminusaBackend.Context; +using AdminusaBackend.Contracts; +using AdminusaBackend.DTO; +using AdminusaBackend.Models; +using System.Data; +using AdminusaBackend.Crypto; +using AdminusaBackend.DTO.Usuario; + +namespace AdminusaBackend.Repository +{ + public class UsuariosRepository : IUsuariosRepository + { + private readonly DapperContext _context; + private readonly IConfiguration _config; + public UsuariosRepository(DapperContext context, IConfiguration config) + { + _context = context; + _config = config; + } + + public async Task> getAllUsuariosShort() + { + var query = "SELECT id, Usuario, Activo FROM Usuario WHERE Usuario<>'Admin' ORDER BY Usuario"; + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query); + return usuarios.ToList(); + } + } + + public async Task> getAllUsuarios() + { + var query = "SELECT * FROM Usuario"; + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query); + return usuarios.ToList(); + } + } + + public async Task GetUsuarioById(int id) + { + var query = "SELECT * FROM Usuario WHERE id=@id"; + using (var connection = _context.CreateConnection()) + { + var usuario = await connection.QueryAsync(query, new { id = id }); + var usr = usuario.First(); + return usr; + } + } + + public async Task GetUsuario(DTOLogin user) + { + var query = "[Usuario.Get]"; + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query, + new + { + Usuario = user.Usuario, + Contrasena = user.Contrasena, + @HashContrasena = CryptDecrypt.Encrypt(user.Contrasena), + }, commandType: CommandType.StoredProcedure); + Usuarios userFound = usuarios.First(); + if (userFound == null) return null!; + var hashed = CryptDecrypt.Decrypt(userFound.Contrasena); + if (hashed != user.Contrasena) return null!; + return userFound; + } + } + + public async Task searchUsuario(string Usuario) + { + var query = "SELECT * FROM Usuario WHERE Usuario=@Usuario"; + using (var connection = _context.CreateConnection()) + { + var usuario = await connection.QueryAsync(query, new { @Usuario }); + return usuario.Count() > 0 ? usuario.First().Id : 0; + } + } + + public async Task CreatePIN(int Id) + { + var query = "[Usuario.PIN.Create]"; + using (var connection = _context.CreateConnection()) + { + var data = await connection.QueryAsync(query, new { @Id }, commandType: CommandType.StoredProcedure); + return data.First(); + } + } + public async Task ValidatePIN(DTOPINUsuario data) + { + var query = "[Usuario.PIN.Validate]"; + using (var connection = _context.CreateConnection()) + { + var result = await connection.QueryAsync(query, new { @data.PIN, @data.Usuario }, commandType: CommandType.StoredProcedure); + if (result.Count() == 0) return false; + return true; + } + } + + public async Task resetPassword(DTOResetPassword user) + { + var query = "[Usuario.Password.Reset]"; + DTOLogin userFound = new DTOLogin(); + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query, new + { + @user.PIN, + @Contrasena = user.Contrasena, + @HashContrasena = CryptDecrypt.Encrypt(user.Contrasena), + }, commandType: CommandType.StoredProcedure); + if (usuarios.Count() > 0) userFound = usuarios.First(); + } + return userFound; + } + + public async Task createUsuario(DTOUsuario user) + { + var query = "[Usuario.Append]"; + using (var connection = _context.CreateConnection()) + { + if (user.Id == 0) user.Contrasena = _config.GetValue("DefaultUser:Password"); + var usuario = await connection.QueryAsync(query, new + { + @id = user.Id, + @Usuario = user.Usuario, + @Nombre = user.Nombre, + @Contrasena = CryptDecrypt.Encrypt(user.Contrasena), + @user.TipoUsuario, + @Correo = user.Correo, + @user.IdPerfil + }, commandType: CommandType.StoredProcedure); + return usuario.First(); + } + } + + public async Task> clonarUsuario(DTOClonarUsuario user) + { + var query = "[Usuario.Clonar]"; + using (var connection = _context.CreateConnection()) + { + var usuario = await connection.QueryAsync(query, new + { + @IdUsuarioOrigen = user.IDUsuarioOrigen, + @IdUsuarioDestino = user.IdUsuarioDestino + }, commandType: CommandType.StoredProcedure); + return usuario.ToList(); + } + } + + // Catalogo de Roles + public async Task> CatalogoRolesGET() + { + var query = "[CatRoles.GET]"; + using (var connection = _context.CreateConnection()) + { + var result = await connection.QueryAsync(query, new + { + }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + } + + public async Task> RolesAsignadosGET(int id) + { + var query = "[RolesAsignados.GET]"; + using (var connection = _context.CreateConnection()) + { + var result = await connection.QueryAsync(query, new + { + @id + }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + } + + + public async Task> GETPerfilesParecidos(string Perfil) + { + var query = "[Usuarios.Perfiles.Parecidos.Get]"; + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query, new { @Perfil }, commandType: CommandType.StoredProcedure); + return usuarios.ToList(); + } + } + + public async Task DisableUser(int id) + { + var query = "[Usuario.Disable]"; + using (var connection = _context.CreateConnection()) + { + var usuarios = await connection.QueryAsync(query, new { @id }, commandType: CommandType.StoredProcedure); + return true; + } + } + } +} diff --git a/AdminusaBackend/Services/Utilerias.cs b/AdminusaBackend/Services/Utilerias.cs new file mode 100644 index 0000000..23cad07 --- /dev/null +++ b/AdminusaBackend/Services/Utilerias.cs @@ -0,0 +1,52 @@ +using System.Net.Mail; +using System.Text; +using Newtonsoft.Json; +using AdminusaBackend.Clientes.Email; + +namespace AdminusaBackend.Services.Utilerias +{ + public class Utilerias + { + private IConfiguration _config; + + public Utilerias(IConfiguration config) + { + _config = config; + } + + public static string Base64Encode(string plainText) + { + var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); + return System.Convert.ToBase64String(plainTextBytes); + } + + public async Task SendEmail(DTOSendEmail data) + { + using var client = new HttpClient(); + string EmailAPI = _config.GetValue("EmailAPI"); + client.BaseAddress = new Uri(EmailAPI); + HttpContent body = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); + var response = client.PostAsync("SendEmail", body).Result; + if (response.IsSuccessStatusCode) + { + var content = await response.Content.ReadAsStringAsync(); + } + return true; + } + + public async Task SendEmailBcc(DTOSendEmailBcc data) + { + using var client = new HttpClient(); + string EmailAPI = _config.GetValue("EmailAPI"); + client.BaseAddress = new Uri(EmailAPI); + HttpContent body = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); + var response = client.PostAsync("SendEmailBcc", body).Result; + if (response.IsSuccessStatusCode) + { + var content = await response.Content.ReadAsStringAsync(); + } + return true; + } + + } +} \ No newline at end of file diff --git a/AdminusaBackend/WeatherForecast.cs b/AdminusaBackend/WeatherForecast.cs new file mode 100644 index 0000000..e419980 --- /dev/null +++ b/AdminusaBackend/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace AdminusaBackend +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/AdminusaBackend/appsettings.Development.json b/AdminusaBackend/appsettings.Development.json new file mode 100644 index 0000000..6d63bec --- /dev/null +++ b/AdminusaBackend/appsettings.Development.json @@ -0,0 +1,26 @@ +{ + "ConnectionStrings": { + "SqlConnection": "server=.; database=Adminusa; Integrated Security=true;TrustServerCertificate=True;Command Timeout=360" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "DefaultUser": { + "Password": "Bienvenido123!" + }, + "EmailServer": "gemcousa-com.mail.protection.outlook.com", + "EmailPort": 25, + "EmailPassword": "N#16rm87", + "EmailAccount": "noreply@gemcousa.com", + "pathArchivoElectronico": "C:\\downs\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\", + "pathTemp": "C:\\downs\\temp\\", + "Allfiles": "C:\\data\\", + "Twilio_SID": "AC59baecf4872fa93e3c315180c96b4cc2", + "Twilio_Token":"5416fe0460e9afaf5400697def878c04", + "NodeAPI" : "https://nodeapi.gemcousa.mx/", + + "EmailAPI" : "https://pyapi.gemcousa.mx/" +} \ No newline at end of file diff --git a/AdminusaBackend/appsettings.Staging.json b/AdminusaBackend/appsettings.Staging.json new file mode 100644 index 0000000..106974f --- /dev/null +++ b/AdminusaBackend/appsettings.Staging.json @@ -0,0 +1,25 @@ +{ + "ConnectionStrings": { + "SqlConnection": "server=.,14033;database=Adminusa;User Id=sa;Password=T3st1n93nv4Qa;TrustServerCertificate=True;" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "DefaultUser": { + "Password": "Bienvenido123!" + }, + "EmailServer": "gemcousa-com.mail.protection.outlook.com", + "EmailPort": 25, + "EmailPassword": "N#16rm87", + "EmailAccount": "noreply@gemcousa.com", + "pathArchivoElectronico": "D:\\data\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\", + "pathTemp": "D:\\data\\temp\\", + "AllFiles": "D:\\data\\", + "Twilio_SID": "AC59baecf4872fa93e3c315180c96b4cc2", + "Twilio_Token":"5416fe0460e9afaf5400697def878c04", + "NodeAPI" : "https://nodeapi.gemcousa.mx/", + "EmailAPI" : "https://pyapi.gemcousa.mx/" +} diff --git a/AdminusaBackend/appsettings.json b/AdminusaBackend/appsettings.json new file mode 100644 index 0000000..e017f64 --- /dev/null +++ b/AdminusaBackend/appsettings.json @@ -0,0 +1,36 @@ +{ + "ConnectionStrings": { + "SqlConnection": "server=.; database=Adminusa;User Id=sa;Password=Chispa10192;TrustServerCertificate=True;" + }, + "DefaultUser": { + "Password": "Bienvenido123!" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "Jwt": { + "Key": "GFE1j5KLolZHDK9iKw5xK17Rz4ty7BlbXgnjPL6dNwVCCNQWU8uRGVyZmAZPWZMs4XX0phFMS849p25Lrwsn31Bi4J7GT2HQ9xeWlJLarJPDyoRZZvChpovwgrquQ9Pd", + "Issuer": "JWTAuthenticationServer", + "Audience": "JWTServicePostmanClient", + "Subject": "JWTServiceAccessToken", + "ExpirationHours": 4 + }, + "EmailServer": "gemcousa-com.mail.protection.outlook.com", + "EmailPort": 25, + "EmailPassword": "N#16rm87", + "EmailAccount": "noreply@gemcousa.com", + "pathArchivoElectronico": "D:\\data\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\", + "pathTemp": "D:\\data\\temp\\", + "pathFotosBodega": "D:\\data\\Bodega\\Fotos\\", + "pathZipCorresponsales": "D:\\data\\Corresponsales\\Zips\\", + "CorresponsalesFilePath": "D:\\data\\Corresponsales\\", + "AllFiles": "D:\\data\\", + "Twilio_SID": "AC59baecf4872fa93e3c315180c96b4cc2", + "Twilio_Token":"5416fe0460e9afaf5400697def878c04", + "NodeAPI" : "https://nodeapi.gemcousa.mx/", + "EmailAPI" : "https://pyapi.gemcousa.mx/" +}