Separação de classes e responsabilidades.
This commit is contained in:
parent
243d1551d1
commit
771de2de33
10
App/App.csproj
Normal file
10
App/App.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
10
App/Program.cs
Normal file
10
App/Program.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace App
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Data/AccessRepository.cs
Normal file
12
Data/AccessRepository.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
internal class AccessRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Data/Data.csproj
Normal file
9
Data/Data.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
12
Data/PostgresRepository.cs
Normal file
12
Data/PostgresRepository.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
internal class PostgresRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Domain/Domain.csproj
Normal file
9
Domain/Domain.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
12
Domain/Medicao.cs
Normal file
12
Domain/Medicao.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Domain
|
||||
{
|
||||
internal class Medicao
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Domain/Perfil.cs
Normal file
12
Domain/Perfil.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Domain
|
||||
{
|
||||
internal class Perfil
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Infrastructure/Infra.csproj
Normal file
9
Infrastructure/Infra.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
51
Infrastructure/RateLimiter.cs
Normal file
51
Infrastructure/RateLimiter.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Infra
|
||||
{
|
||||
public class RateLimiter
|
||||
{
|
||||
private readonly int _maxRequests;
|
||||
private readonly TimeSpan _interval;
|
||||
private int _requestCount;
|
||||
private DateTime _windowStart;
|
||||
private readonly object _lock = new();
|
||||
|
||||
public RateLimiter(int maxRequests, TimeSpan interval)
|
||||
{
|
||||
_maxRequests = maxRequests;
|
||||
_interval = interval;
|
||||
var now = DateTime.Now;
|
||||
_windowStart = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute - (now.Minute % interval.Minutes), 0);
|
||||
_requestCount = 0;
|
||||
}
|
||||
|
||||
public async Task WaitAsync(CancellationToken ct)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if ((DateTime.Now - _windowStart) > _interval)
|
||||
{
|
||||
// reset janela
|
||||
_windowStart = DateTime.Now;
|
||||
_requestCount = 0;
|
||||
}
|
||||
|
||||
if (_requestCount < _maxRequests)
|
||||
{
|
||||
_requestCount++;
|
||||
return; // pode prosseguir
|
||||
}
|
||||
}
|
||||
|
||||
// já bateu o limite → espera até reset
|
||||
await Task.Delay(200, ct); // aguarda 200ms e tenta de novo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Infrastructure/SoapFaultException.cs
Normal file
12
Infrastructure/SoapFaultException.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Infra
|
||||
{
|
||||
internal class SoapFaultException
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Infrastructure/SoapHelper.cs
Normal file
12
Infrastructure/SoapHelper.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Infra
|
||||
{
|
||||
internal class SoapHelper
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.1.32319.34
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PI_Assync_SCDE", "PI_Assync_SCDE.csproj", "{48DFCC70-0352-4394-9821-2B243EB389AB}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App_old", "App_old.csproj", "{48DFCC70-0352-4394-9821-2B243EB389AB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infra", "Infrastructure\Infra.csproj", "{0910ED06-C154-41FF-B556-ADBA53A10427}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Data", "Data\Data.csproj", "{4B7EE8CE-E452-4B31-9B21-64113B6C48C8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{38CE64C7-8F03-4622-8DD5-5BA19F66E7AF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{2B2323E4-C409-4432-AA45-54C1642FDA88}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App", "App\App.csproj", "{2B43C133-911B-4F3D-9DAB-1DA342D3822B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -15,6 +25,26 @@ Global
|
||||
{48DFCC70-0352-4394-9821-2B243EB389AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48DFCC70-0352-4394-9821-2B243EB389AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48DFCC70-0352-4394-9821-2B243EB389AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0910ED06-C154-41FF-B556-ADBA53A10427}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0910ED06-C154-41FF-B556-ADBA53A10427}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0910ED06-C154-41FF-B556-ADBA53A10427}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0910ED06-C154-41FF-B556-ADBA53A10427}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4B7EE8CE-E452-4B31-9B21-64113B6C48C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B7EE8CE-E452-4B31-9B21-64113B6C48C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B7EE8CE-E452-4B31-9B21-64113B6C48C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B7EE8CE-E452-4B31-9B21-64113B6C48C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{38CE64C7-8F03-4622-8DD5-5BA19F66E7AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{38CE64C7-8F03-4622-8DD5-5BA19F66E7AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{38CE64C7-8F03-4622-8DD5-5BA19F66E7AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{38CE64C7-8F03-4622-8DD5-5BA19F66E7AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2B2323E4-C409-4432-AA45-54C1642FDA88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2B2323E4-C409-4432-AA45-54C1642FDA88}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2B2323E4-C409-4432-AA45-54C1642FDA88}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2B2323E4-C409-4432-AA45-54C1642FDA88}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2B43C133-911B-4F3D-9DAB-1DA342D3822B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2B43C133-911B-4F3D-9DAB-1DA342D3822B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2B43C133-911B-4F3D-9DAB-1DA342D3822B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2B43C133-911B-4F3D-9DAB-1DA342D3822B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
43
Program.cs
43
Program.cs
@ -419,49 +419,6 @@ internal class Plat_integ
|
||||
throw new SoapFaultException(faultCode, faultString, errorCode, message);
|
||||
}
|
||||
}
|
||||
|
||||
public class RateLimiter
|
||||
{
|
||||
private readonly int _maxRequests;
|
||||
private readonly TimeSpan _interval;
|
||||
private int _requestCount;
|
||||
private DateTime _windowStart;
|
||||
private readonly object _lock = new();
|
||||
|
||||
public RateLimiter(int maxRequests, TimeSpan interval)
|
||||
{
|
||||
_maxRequests = maxRequests;
|
||||
_interval = interval;
|
||||
var now = DateTime.Now;
|
||||
_windowStart = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute - (now.Minute % interval.Minutes), 0);
|
||||
_requestCount = 0;
|
||||
}
|
||||
|
||||
public async Task WaitAsync(CancellationToken ct)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if ((DateTime.Now - _windowStart) > _interval)
|
||||
{
|
||||
// reset janela
|
||||
_windowStart = DateTime.Now;
|
||||
_requestCount = 0;
|
||||
}
|
||||
|
||||
if (_requestCount < _maxRequests)
|
||||
{
|
||||
_requestCount++;
|
||||
return; // pode prosseguir
|
||||
}
|
||||
}
|
||||
|
||||
// já bateu o limite → espera até reset
|
||||
await Task.Delay(200, ct); // aguarda 200ms e tenta de novo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class perfil
|
||||
|
||||
28
Properties/Resources.Designer.cs
generated
28
Properties/Resources.Designer.cs
generated
@ -1,24 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
// O código foi gerado por uma ferramenta.
|
||||
// Versão de Tempo de Execução:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se
|
||||
// o código for gerado novamente.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PI_Assync_SCDE.Properties {
|
||||
namespace App_old.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
// Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder
|
||||
// através de uma ferramenta como ResGen ou Visual Studio.
|
||||
// Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente
|
||||
// com a opção /str, ou recrie o projeto do VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
@ -33,13 +33,13 @@ namespace PI_Assync_SCDE.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// Retorna a instância de ResourceManager armazenada em cache usada por essa classe.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PI_Assync_SCDE.Properties.Resources", typeof(Resources).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("App_old.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@ -47,8 +47,8 @@ namespace PI_Assync_SCDE.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// Substitui a propriedade CurrentUICulture do thread atual para todas as
|
||||
/// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
|
||||
12
Services/MedicaoService.cs
Normal file
12
Services/MedicaoService.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Services
|
||||
{
|
||||
internal class MedicaoService
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Services/Services.csproj
Normal file
9
Services/Services.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
12
Services/SoapService.cs
Normal file
12
Services/SoapService.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Services
|
||||
{
|
||||
internal class SoapService
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user