Commit 228c223f by Alex Nasyr

serilog using added

parent 028f8dcb
......@@ -3,7 +3,7 @@ using System.Linq;
using System;
using System.Collections.Generic;
using System.Text.Json;
using Microsoft.Extensions.Logging;
using Serilog;
namespace SocialMinistryDataExchange.Model {
public class SMRepository : ISMRepository {
......@@ -12,7 +12,7 @@ namespace SocialMinistryDataExchange.Model {
public SMRepository() {
}
public SMRepository(IContingentContext contingentContext, ILogger<SMRepository> logger) {
public SMRepository(IContingentContext contingentContext, ILogger logger) {
_contingentContext = contingentContext;
_logger = logger;
}
......@@ -75,8 +75,8 @@ namespace SocialMinistryDataExchange.Model {
responce_record = FormatResponce(_contingentContext, record);
}
catch (Exception ex) {
_logger.LogError($"{ex.Message}, {ex.TargetSite.Name}");
_logger.LogInformation($"Creating empty person for doc.seria={doc.Person.PersonDocumentSeria}; doc.number={doc.Person.PersonDocumentNumber}");
_logger.Error($"{ex.TargetSite.Name}; {ex.Message}; {{@Person}}", doc.Person);
_logger.Information($"Creating empty Person for doc.seria={doc.Person.PersonDocumentSeria}; doc.number={doc.Person.PersonDocumentNumber}");
responce_record = FormatResponce(_contingentContext, new SMResponceTemp() { rowguid_eais = doc.Person.rowguid_eais, СерияДокумента = doc.Person.PersonDocumentSeria, НомерДокумента = doc.Person.PersonDocumentNumber });
}
......@@ -86,7 +86,7 @@ namespace SocialMinistryDataExchange.Model {
return Task.FromResult(responce);
}
static Guid? GetOrganizationType(IContingentContext context, Guid? OrgTypeUid) {
private static Guid? GetOrganizationType(IContingentContext context, Guid? OrgTypeUid) {
if (OrgTypeUid == null) {
return null;
}
......@@ -94,7 +94,7 @@ namespace SocialMinistryDataExchange.Model {
return type.Иерархия == null ? type.PrimaryKey : GetOrganizationType(context, type.Иерархия);
}
static Guid? GetProgramType(IContingentContext context, Guid? ProgramTypeUid) {
private static Guid? GetProgramType(IContingentContext context, Guid? ProgramTypeUid) {
if (ProgramTypeUid == null) {
return null;
}
......@@ -108,7 +108,7 @@ namespace SocialMinistryDataExchange.Model {
}
static SMResponce FormatResponce(IContingentContext context, SMResponceTemp record) {
private static SMResponce FormatResponce(IContingentContext context, SMResponceTemp record) {
SMResponce responce = new();
if (record.Личность != Guid.Empty) { // записи найдены
responce.rowguid_eais = record.rowguid_eais;
......
......@@ -7,7 +7,7 @@ namespace SocialMinistryDataExchange.Model {
public string document_number { get; set; }
}
// двусторонний формат обмена данными о зачислении лица в учереждения образования
// формат обмена данными о зачислении лица в учереждения образования (двусторонний)
public class SMPersonDataRequest {
public string MsgID { get; set; }
public DateTime MsgDataTime { get; set; }
......@@ -18,16 +18,8 @@ namespace SocialMinistryDataExchange.Model {
public Person Person { get; set; }
public SMPersonOccupationStatus PersonOccupation { get; set; }
}
public class SMPersonOccupationStatus {
public string Status { get; set; }
public DateTime? StatusDate { get; set; }
public string FounderType { get; set; }
public string OrganizationType { get; set; }
public string EducationProgram { get; set; }
public string EducationForm { get; set; }
}
// двусторонний формат обмена данными о статусе "нуждаемости" лица
// формат обмена данными о статусе "нуждаемости" лица (двусторонний)
public class SMPersonSocialDefenceDataRequest {
public string MsgID { get; set; }
public DateTime MsgDataTime { get; set; }
......@@ -39,15 +31,8 @@ namespace SocialMinistryDataExchange.Model {
public PersonCocialDefenceStatus PersonStatus { get; set; }
public Person[]? Relatives { get; set; }
}
public class PersonCocialDefenceStatus {
public int Status { get; set; }
public DateTime PersonStatusStartDate { get; set; }
public DateTime PersonStatusEndDate { get; set; }
public int? FamilyPersonsCount { get; set; }
public double? AvgIncome { get; set; }
public double? MinIncome { get; set; }
}
// общие классы
// общий класс личности
public class Person {
public string rowguid_eais { get; set; }
......@@ -67,4 +52,25 @@ namespace SocialMinistryDataExchange.Model {
public string? Territory { get; set; }
public string? Error { get; set; }
}
// общий класс статуса зачисленности в учереждение образования
public class SMPersonOccupationStatus {
public string Status { get; set; }
public DateTime? StatusDate { get; set; }
public string FounderType { get; set; }
public string OrganizationType { get; set; }
public string EducationProgram { get; set; }
public string EducationForm { get; set; }
}
// общий класс статуса нуждаемости
public class PersonCocialDefenceStatus {
public int Status { get; set; }
public DateTime PersonStatusStartDate { get; set; }
public DateTime PersonStatusEndDate { get; set; }
public int? FamilyPersonsCount { get; set; }
public double? AvgIncome { get; set; }
public double? MinIncome { get; set; }
}
}
......@@ -6,6 +6,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Serilog;
using Serilog.Events;
using SocialMinistryDataExchange.Model;
using SocialMinistryDataExchange.Model.DB.Center;
using System;
......@@ -23,6 +25,14 @@ namespace SocialMinistryDataExchange {
public void ConfigureServices(IServiceCollection services) {
var ConnectionString = Configuration.GetConnectionString("_center");
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Default", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.File($@"{Directory.GetCurrentDirectory()}\Logs\{DateTime.Now.ToString("yyyy-MM-dd")}.log"
//, outputTemplate: "[{Timestamp:HH:mm:ss.fff}{SourceContext}] |{Level:u3}| {Message:lj}{NewLine}{Exception}")
, outputTemplate: "[{Timestamp:HH:mm:ss.fff}] |{Level:u3}| {Message:lj}{NewLine}{Exception}")
.CreateLogger();
services.AddControllers();
services.AddSwaggerGen(c => {
......@@ -31,6 +41,7 @@ namespace SocialMinistryDataExchange {
services.AddDbContext<Contingent_center_Context>(options => options.UseSqlServer(ConnectionString));
services.AddTransient<IContingentContext, Contingent_center_Context>();
services.AddTransient<ISMRepository, SMRepository>();
services.AddSingleton<Serilog.ILogger>(Log.Logger);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
......@@ -50,8 +61,6 @@ namespace SocialMinistryDataExchange {
app.UseEndpoints(endpoints => {
endpoints.MapControllers();
});
loggerFactory.AddFile($@"{Directory.GetCurrentDirectory()}\Logs\{DateTime.Now.ToString("yyyy-MM-dd")}.log");
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Default": "Information"
//"Microsoft": "Warning",
//"Microsoft.Hosting.Lifetime": "Information"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment