Skip to content

Commit

Permalink
FEAT : Se agrega archivo de configuracion por entorno de desarrollo e…
Browse files Browse the repository at this point in the history
…n el servicio de windows
  • Loading branch information
angelortiz0398 committed May 7, 2024
1 parent e0744d7 commit 3840238
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 15 deletions.
40 changes: 37 additions & 3 deletions FHL_SGD_Notificaciones_Service/App.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FHL_SGD_Notificaciones_Service.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
Expand All @@ -15,4 +20,33 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="Development.UrlServer" value="https://localhost:7289" />
<add key="Development.ExecutionTime" value="30" />
<add key="Production.UrlServer" value="https://example.com/api" />
<add key="Production.ExecutionTime" value="300" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<applicationSettings>
<FHL_SGD_Notificaciones_Service.Properties.Settings>
<setting name="ConnectionStrings" serializeAs="String">
<value>Default</value>
</setting>
<setting name="ASPNETCORE_ENVIRONMENT" serializeAs="String">
<value>Development</value>
</setting>
</FHL_SGD_Notificaciones_Service.Properties.Settings>
</applicationSettings>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -52,6 +53,18 @@
<PropertyGroup>
<StartupObject>FHL_SGD_Notificaciones_Service.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>E3753BADA396997E997A63072D3C19F86AA6D344</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>FHL_SGD_Notificaciones_Service_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
Expand Down Expand Up @@ -82,6 +95,7 @@
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
Expand All @@ -103,6 +117,7 @@
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -132,18 +147,24 @@
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<Compile Include="Shared\RespuestaNotificacion.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ClassDiagram1.cd" />
<None Include="FHL_SGD_Notificaciones_Service_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\launchSettings.json" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings1.Designer.cs</LastGenOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="user.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NotificacionService.resx">
Expand Down
21 changes: 15 additions & 6 deletions FHL_SGD_Notificaciones_Service/NotificacionService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using FHL_SGD_Notificaciones_Service.Shared;
using FHL_SGD_Notificaciones_Service.Properties;
using FHL_SGD_Notificaciones_Service.Shared;
using Newtonsoft.Json;
using System;
using System.Configuration;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.ServiceProcess;
using System.Threading.Tasks;
Expand All @@ -14,6 +15,10 @@ public partial class NotificacionService : ServiceBase
private EventLog EventLog1 { get; set; }
private readonly string logSourceName = "NotificacionSource";
private readonly string logName = "Log";
private string UrlServer { get; set; } = string.Empty;
private string ExecutionTime { get; set; } = string.Empty;
private readonly string Environment = string.Empty;


public NotificacionService()
{
Expand All @@ -28,12 +33,16 @@ public NotificacionService()

EventLog1.Source = logSourceName;
EventLog1.Log = logName;
Environment = Properties.Settings.Default.ASPNETCORE_ENVIRONMENT;
UrlServer = ConfigurationManager.AppSettings[$"{Environment}.UrlServer"];
ExecutionTime = ConfigurationManager.AppSettings[$"{Environment}.ExecutionTime"];

}

protected override void OnStart(string[] args)
{
EventLog1.WriteEntry("Se inicio correctamente el proceso.");
EnviaSolicitud();
_ = EnviaSolicitud();
}

protected override void OnStop()
Expand All @@ -43,7 +52,7 @@ protected override void OnStop()

public async Task EnviaSolicitud()
{
string url = "https://localhost:7289/ValidadorNotificaciones/Validar";
string url = $"{UrlServer}/ValidadorNotificaciones/Validar";
// Ignorar la validación del certificado
HttpClientHandler handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
Expand All @@ -67,8 +76,8 @@ public async Task EnviaSolicitud()
EventLog1.WriteEntry($"Consulta a {urlBase} fallida. Respuesta: {responseBody}");
}

// Esperar 30 segundos antes de la próxima solicitud
await Task.Delay(TimeSpan.FromSeconds(30));
// Espera algunos segundos antes de la próxima solicitud
await Task.Delay(TimeSpan.FromSeconds(Convert.ToInt32(ExecutionTime)));
}
}
catch (Exception ex)
Expand Down
4 changes: 2 additions & 2 deletions FHL_SGD_Notificaciones_Service/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
// utilizando el carácter "*", como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="NotificacionesService.Properties" GeneratedClassName="Settings">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="FHL_SGD_Notificaciones_Service.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ConnectionStrings" Type="System.String" Scope="Application">
Expand Down

0 comments on commit 3840238

Please sign in to comment.