Обновление Сервиса

parent 3f583117
......@@ -2,12 +2,12 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;
using NLog.Extensions.Logging;
using ProfitGroup.SampleNotifyService.Core.Auth;
using ProfitGroup.SampleNotifyService.Core.Handlers;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.SampleNotifyService.Services;
using ProfitGroup.NotifyService.Core.Auth;
using ProfitGroup.NotifyService.Core.Handlers;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Services;
namespace ProfitGroup.SampleNotifyService.Core.Application
namespace ProfitGroup.NotifyService.Core.Application
{
public static class Extensions
{
......@@ -39,7 +39,7 @@ namespace ProfitGroup.SampleNotifyService.Core.Application
(options => options.UseSqlServer(builder.Configuration.GetConnectionString("RnDConnection")));
builder.Services.AddTransient<Handlers.RouteHandler>();
builder.Services.AddTransient<INotifyService, NotifyService>();
builder.Services.AddTransient<INotifyService, Services.NotifyService>();
builder.Services.AddAuthorization();
......
......@@ -13,7 +13,7 @@ namespace ProfitGroup.SampleNotifyService.Core.Auth
public BasicAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock)
{
this._logger = logger.CreateLogger<BasicAuthenticationHandler>();
_logger = logger.CreateLogger<BasicAuthenticationHandler>();
}
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
......@@ -32,10 +32,10 @@ namespace ProfitGroup.SampleNotifyService.Core.Auth
var username = credentials[0];
var password = credentials[1];
_logger.LogInformation($"Login: {username}, Password: {password}");
if (IsValidUser(username, password))
{
_logger.LogInformation("Успешная авторизация");
var claims = new[] { new Claim(ClaimTypes.Name, username) };
var identity = new ClaimsIdentity(claims, Scheme.Name);
var principal = new ClaimsPrincipal(identity);
......@@ -43,10 +43,9 @@ namespace ProfitGroup.SampleNotifyService.Core.Auth
return Task.FromResult(AuthenticateResult.Success(ticket));
}
else
{
return Task.FromResult(AuthenticateResult.Fail("Incorrect login or password"));
}
_logger.LogInformation($"Произошла ошибка при авторизации. Указан неверный логин или пароль");
return Task.FromResult(AuthenticateResult.Fail("Incorrect login or password"));
}
catch (Exception ex)
{
......@@ -56,11 +55,13 @@ namespace ProfitGroup.SampleNotifyService.Core.Auth
private bool IsValidUser(string username, string password)
{
#if DEBUG
return username == "S4test" && password == "ST6aAFw10";
#endif
return username == "S4test" && password == "ST6aAFw10";
// ToDo: Сменить пароль при переносе решения
// APP02
return username == "S4test" && password == "lMxeTqMIH04R8mCE";
// Productive
// return username == "S4test" && password == "lMxeTqMIH04R8mCE";
}
}
}
using ProfitGroup.SampleNotifyService.Models;
using ProfitGroup.NotifyService.Models;
namespace ProfitGroup.SampleNotifyService.Core.Configs
namespace ProfitGroup.NotifyService.Core.Configs
{
public class Config
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class ProfITS4MtLogConfiguration : IEntityTypeConfiguration<ProfITS4MtLog>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class ProfITS4PrLogConfiguration : IEntityTypeConfiguration<ProfITS4PrLog>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtAuConfiguration : IEntityTypeConfiguration<RndtAu>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtBomHeaderConfiguration : IEntityTypeConfiguration<RndtBomHeader>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtScConfiguration : IEntityTypeConfiguration<RndtSc>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtScIcConfiguration : IEntityTypeConfiguration<RndtScIc>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtScIiConfiguration : IEntityTypeConfiguration<RndtScIi>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtSpAuConfiguration : IEntityTypeConfiguration<RndtSpAu>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtSpConfiguration : IEntityTypeConfiguration<RndtSp>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtSpIcConfiguration : IEntityTypeConfiguration<RndtSpIc>
{
......
......@@ -2,11 +2,11 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
using System.Collections.Generic;
using System;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations
{
public partial class RndtSpIiConfiguration : IEntityTypeConfiguration<RndtSpIi>
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class ProfITS4MtLog
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class ProfITS4PrLog
{
......
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities.Configurations;
using ProfitGroup.NotifyService.Data.Core.Data.Entities.Configurations;
using System.Collections.Generic;
using System;
#nullable disable
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RDnLDatabaseContext : DbContext
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtAu
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtBomHeader
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtSc
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtScIc
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtScIi
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtSp
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtSpAu
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtSpIc
{
......
......@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
namespace ProfitGroup.SampleNotifyService.Data.Core.Data.Entities
namespace ProfitGroup.NotifyService.Data.Core.Data.Entities
{
public partial class RndtSpIi
{
......
using System.Text;
namespace ProfitGroup.SampleNotifyService.Core.Handlers
namespace ProfitGroup.NotifyService.Core.Handlers
{
public static class BodyParser
{
......
using System.Xml.Serialization;
namespace ProfitGroup.SampleNotifyService.Core.Handlers
namespace ProfitGroup.NotifyService.Core.Handlers
{
public static class ContentDeserializer
{
......
namespace ProfitGroup.SampleNotifyService.Core.Handlers;
namespace ProfitGroup.NotifyService.Core.Handlers;
public class RequestScopedLoggerMiddleware
{
......
using ProfitGroup.SampleNotifyService.Core.Configs;
using ProfitGroup.SampleNotifyService.Models;
using ProfitGroup.SampleNotifyService.Services;
using System.Text;
using System.Text;
using System.Xml.Serialization;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Core.Configs;
using ProfitGroup.NotifyService.Models;
using ProfitGroup.NotifyService.Services;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
namespace ProfitGroup.SampleNotifyService.Core.Handlers
namespace ProfitGroup.NotifyService.Core.Handlers
{
public class RouteHandler
{
......@@ -73,7 +73,7 @@ namespace ProfitGroup.SampleNotifyService.Core.Handlers
{
var confirmation = model.Body.MTConfirmation.Confirmation;
var isSuccess = await _notifyService.SaveParameterLog(confirmation.ID, confirmation.Version, confirmation.StatusCode, confirmation.StatusText);
var isSuccess = await _notifyService.SaveParameterLog(confirmation.ID, Convert.ToInt32(confirmation.Version), confirmation.StatusCode, confirmation.StatusText);
if (!isSuccess)
{
......@@ -92,7 +92,7 @@ namespace ProfitGroup.SampleNotifyService.Core.Handlers
{
var confirmation = model.Body.MTConfirmation.Confirmation;
var isSuccess = await _notifyService.SaveMethodLog(confirmation.ID, confirmation.Version, confirmation.StatusCode, confirmation.StatusText);
var isSuccess = await _notifyService.SaveMethodLog(confirmation.ID, Convert.ToInt32(confirmation.Version), confirmation.StatusCode, confirmation.StatusText);
if (!isSuccess)
{
......@@ -121,7 +121,7 @@ namespace ProfitGroup.SampleNotifyService.Core.Handlers
return Results.NotFound(errorText);
}
var infoCard = await _notifyService.GetSampleInfoCardAsync(confirmation.ID);
var infoCard = await _notifyService.GetSampleInfoCardAsync((int)sample.SC);
if (infoCard == null)
{
......@@ -160,10 +160,10 @@ namespace ProfitGroup.SampleNotifyService.Core.Handlers
{
var errorText = $"Полученое неверное значение локации. Полученное значение: \"{locate}\"";
_logger.LogError(errorText);
return Results.BadRequest($"");
return Results.BadRequest(errorText);
}
var specification = await _notifyService.GetSpecificationAsync(confirmation.ID, confirmation.Version);
var specification = await _notifyService.GetSpecificationAsync(confirmation.ID, Convert.ToInt32(confirmation.Version));
if (specification == null)
{
......@@ -174,7 +174,7 @@ namespace ProfitGroup.SampleNotifyService.Core.Handlers
}
var infoCard =
await _notifyService.GetSpecificationInfoCardAsync(confirmation.ID, confirmation.Version, locate);
await _notifyService.GetSpecificationInfoCardAsync((int)specification.SP, Convert.ToInt32(confirmation.Version), locate);
if (infoCard == null)
{
......
namespace ProfitGroup.SampleNotifyService.Models
namespace ProfitGroup.NotifyService.Models
{
public enum AttributeSaveAction
{
......
using System.Xml.Serialization;
namespace ProfitGroup.SampleNotifyService.Models
namespace ProfitGroup.NotifyService.Models
{
[XmlRoot(ElementName = "Confirmation", Namespace = "")]
public class Confirmation
......@@ -16,7 +16,7 @@ namespace ProfitGroup.SampleNotifyService.Models
public int ID { get; set; }
[XmlAttribute(AttributeName = "Version", Namespace = "")]
public int Version { get; set; }
public string Version { get; set; }
[XmlAttribute(AttributeName = "StatusCode", Namespace = "")]
public string StatusCode { get; set; }
......
namespace ProfitGroup.SampleNotifyService.Models
namespace ProfitGroup.NotifyService.Models
{
public enum ObjectTypes
{
......
......@@ -16,7 +16,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.4" />
<PackageReference Include="NLog.Web" Version="5.3.5" />
<PackageReference Include="NLog.Web" Version="5.3.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
......
using ProfitGroup.SampleNotifyService.Core.Application;
using ProfitGroup.NotifyService.Core.Application;
WebApplication
.CreateBuilder(args)
......
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
namespace ProfitGroup.SampleNotifyService.Services;
namespace ProfitGroup.NotifyService.Services;
public interface INotifyService
{
......
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using ProfitGroup.SampleNotifyService.Core.Configs;
using ProfitGroup.SampleNotifyService.Data.Core.Data.Entities;
using ProfitGroup.NotifyService.Core.Configs;
using ProfitGroup.NotifyService.Data.Core.Data.Entities;
namespace ProfitGroup.SampleNotifyService.Services;
namespace ProfitGroup.NotifyService.Services;
public class NotifyService : INotifyService
{
......@@ -234,9 +234,9 @@ public class NotifyService : INotifyService
};
await _context.Database.ExecuteSqlRawAsync(
"UPDATE ProfITS4MtLog " +
"SET S4Status = @StatusCode, S4StatusText = @StatusText, S4StatusDate = @StatusDate " +
"WHERE MT = @MethodId AND MT_VERSION = @MethodVersion", parameters);
"UPDATE [RndSuite].[ProfITS4MtLog] " +
"SET [S4Status] = @StatusCode, [S4StatusText] = @StatusText, [S4StatusDate] = @StatusDate " +
"WHERE [MT] = @MethodId AND [MT_VERSION] = @MethodVersion", parameters);
// await _context.SaveChangesAsync();
return true;
}
......@@ -275,9 +275,9 @@ public class NotifyService : INotifyService
};
var affectedRows = await _context.Database.ExecuteSqlRawAsync(
"UPDATE ProfITS4PrLog " +
"SET S4Status = @StatusCode, S4StatusText = @StatusText, S4StatusDate = @StatusDate " +
"WHERE PR = @ParameterId AND PR_VERSION = @ParameterVersion", parameters);
"UPDATE [RndSuite].[ProfITS4PrLog] " +
"SET [S4Status] = @StatusCode, [S4StatusText] = @StatusText, [S4StatusDate] = @StatusDate " +
"WHERE [PR] = @ParameterId AND [PR_VERSION] = @ParameterVersion", parameters);
// await _context.SaveChangesAsync();
return true;
......
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace ProfitGroup.SampleService.Models.Entities
{
public partial class Rndtpack
{
public Nullable<int> lo { get; set; }
public string control { get; set; }
public string pack { get; set; }
public string pack_KSSS { get; set; }
public string pack_en { get; set; }
public string pack_cn { get; set; }
public string pack_au { get; set; }
public string pack_id { get; set; }
public int id { get; set; }
}
public class RndtpackMapObject
{
public decimal Id { get; set; }
public string Pack { get; set; }
public string PackKSSS { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
namespace ProfitGroup.SampleService.Models
{
public class StringWriterUTF8 : StringWriter
{
public override Encoding Encoding => Encoding.UTF8;
}
}
\ No newline at end of file
This diff is collapsed.
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 to comment