Files
.vscode
FabApprovalWorkerService
.config
.vscode
Clients
Models
Properties
Services
ApprovalService.cs
CorrectiveActionService.cs
DalService.cs
DbConnectionService.cs
ECNService.cs
MRBService.cs
MonInClient.cs
PCRBService.cs
SmtpService.cs
TrainingService.cs
UserService.cs
WindowsService.cs
SetupScripts
Utilities
Workers
.editorconfig
FabApprovalWorkerService.csproj
FabApprovalWorkerService.csproj.user
Program.cs
nLog.Development.config
nLog.Staging.config
nLog.config
FabApprovalWorkerServiceTests
.editorconfig
.gitignore
FabApprovalWorkerService.sln
README.md
azure-pipelines.yml
Mike Phares 7be540964a Pull Request 33523 suggestions
Pull Request 33520 suggestions

Injected AppSettings instead of using GetEnvironmentVariable at Services level

When debugging only
app.Services.GetRequiredService<IPCRBService>();

Get ready to use VSCode IDE

Align .editorconfig files
2024-12-03 10:48:07 -07:00

58 lines
2.3 KiB
C#

using FabApprovalWorkerService.Models;
using Infineon.Monitoring.MonA;
namespace FabApprovalWorkerService.Services;
public interface IMonInClient {
void PostMetric(string metricName, double metricValue);
void PostStatus(string statusName, State state);
}
public class MonInClient : IMonInClient {
private readonly ILogger<MonInClient> _logger;
private readonly string _site;
private readonly string _resource;
public MonInClient(ILogger<MonInClient> logger, AppSettings appSettings) {
_logger = logger ??
throw new ArgumentNullException("ILogger not injected");
_site = appSettings.MonInSite;
_resource = appSettings.WorkerServiceMonInResource;
}
public void PostMetric(string metricName, double metricValue) {
try {
_logger.LogInformation("Attempting to send MonIn metric request for resource {0} with name {1} and value {2}",
_resource,
metricName,
metricValue);
MonIn.GetInstance().SendPerformanceMessage(_site, _resource, metricName, metricValue);
} catch (Exception ex) {
_logger.LogError("An exception occurred when attempting to send MonIn metric request for resource {0} with name {1} and value {2}. Exception: {3}",
_resource,
metricName,
metricValue,
ex.Message);
}
}
public void PostStatus(string statusName, State state) {
try {
_logger.LogInformation("Attempting to send MonIn status request for resource {0} with name {1} and value {2}",
_resource,
statusName,
state.ToString());
MonIn.GetInstance().SendStatus(_site, _resource, statusName, state);
} catch (Exception ex) {
_logger.LogError("An exception occurred when attempting to send MonIn status request for resource {0} with name {1} and value {2}. Exception: {3}",
_resource,
statusName,
state.ToString(),
ex.Message);
}
}
}