сервис для синхронизации приказов студентов
This commit is contained in:
parent
9df61f850d
commit
58cdb371c5
@ -13,7 +13,7 @@ namespace CoreDatabase
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
#if RELEASE
|
||||
var connectionString = ToolsModule.ServiceProvider.ServiceProviderLoader.GetConfigData("connectionString");
|
||||
var connectionString = ToolsModule.ManagmentDependency.ServiceProviderLoader.GetConfigData("connectionString");
|
||||
optionsBuilder.UseSqlServer(connectionString);
|
||||
#endif
|
||||
|
||||
|
@ -13,8 +13,27 @@ namespace ToolsModule.ManagmentDependency
|
||||
/// </summary>
|
||||
public static partial class ServiceProviderLoader
|
||||
{
|
||||
private static readonly string _pathToImplementationExt = "..\\..\\..\\..\\ImplementationExtensions\\";
|
||||
private static readonly string _configFileName = "DepartmentPortal.config";
|
||||
|
||||
/// <summary>
|
||||
/// Получение данных с файла настроек (для releaze версии сборки)
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetConfigData(string key)
|
||||
{
|
||||
var fileName = GetFile(_configFileName);
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var doc = new XPathDocument(fileName);
|
||||
var nav = doc.CreateNavigator();
|
||||
var data = nav.SelectDescendants(key, "", false);
|
||||
data.MoveNext();
|
||||
return data.Current.Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка всех классов-реализаций IImplementationExtension
|
||||
/// </summary>
|
||||
@ -22,9 +41,7 @@ namespace ToolsModule.ManagmentDependency
|
||||
public static List<IDependencyRegistration> GetImplementationExtensions()
|
||||
{
|
||||
var list = new List<IDependencyRegistration>();
|
||||
if(Directory.Exists(_pathToImplementationExt))
|
||||
{
|
||||
var files = Directory.GetFiles(_pathToImplementationExt, "*.dll", SearchOption.AllDirectories);
|
||||
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
|
||||
var loadedFiles = new List<string>();
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
@ -42,7 +59,6 @@ namespace ToolsModule.ManagmentDependency
|
||||
}
|
||||
loadedFiles.Add(file.GetFileName());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -52,5 +68,16 @@ namespace ToolsModule.ManagmentDependency
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
private static string GetFile(string fileName) => Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), fileName);
|
||||
|
||||
private static string TryGetImplementationExtensionsFolder()
|
||||
{
|
||||
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
||||
{
|
||||
directory = directory.Parent;
|
||||
}
|
||||
return $"{directory.FullName}\\ImplementationExtensions";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -268,7 +268,6 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic
|
||||
|
||||
private void InitLogics()
|
||||
{
|
||||
|
||||
_recordLogic = DependencyManager.Instance.Resolve<IOrderSyncHistoryRecordLogic>();
|
||||
_enviromentSettingLogic = DependencyManager.Instance.Resolve<IEnviromentSettingLogic>();
|
||||
_groupsLogic = DependencyManager.Instance.Resolve<IStudentGroupLogic>();
|
||||
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<connectionString>Data Source=10.3.1.13\SQLEXPRESS;Initial Catalog=DepartmentDatabasePortal;persist security info=True;user id=sa;password=isadmin;MultipleActiveResultSets=True;</connectionString>
|
||||
</configuration>
|
@ -1,17 +1,39 @@
|
||||
using CoreDatabase;
|
||||
using DepartmentContract.Logics.IGenericEntityLogic;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog;
|
||||
using NLog.Extensions.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using ToolsModule.ManagmentDependency;
|
||||
using ToolsModule.ManagmentSecurity;
|
||||
|
||||
namespace WindowServiceSyncStudentOrders
|
||||
{
|
||||
/// <summary>
|
||||
/// 1. Find Task Scheduler (Press the Windows + R keys on your keyboard to open Run, and then type taskschd.msc)
|
||||
/// 2. If Not Exsist folder DepartmentPortal:
|
||||
/// 2.1. Right-click on the "Task Scheduler Library" and click on the "New Folder" option.
|
||||
/// 2.2. Enter the name of the new folder "DepartmentPortal" and click on the "OK" button.
|
||||
/// 3. Navigate the following: Task Scheduler Library > New Folder (DepartmentPortal), then click on "Create Basic Task".
|
||||
/// 4. Provide the Task Name such as "SyncStudentOrders" and click next.
|
||||
/// 5. Choose when would you like your task to start (Weekly) and click next.
|
||||
/// 6. Set the Start date and time of the task and click Next.
|
||||
/// 7. Select "Start a program" option from a various list of actions and then click next.
|
||||
/// 8. Click on Browse Button and choose "WindowServiceSyncStudentOrders.exe" from folder.
|
||||
/// 9. Click the Finish button to complete the task.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
private static Microsoft.Extensions.Logging.ILogger _logger;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Start sync student orders");
|
||||
ConfigLogger();
|
||||
|
||||
_logger.LogInformation("Start sync student orders");
|
||||
try
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<ISecurityManager, SecurityManager>();
|
||||
@ -21,17 +43,32 @@ namespace WindowServiceSyncStudentOrders
|
||||
Task.WaitAll(new Task[] { task });
|
||||
if (task.Result)
|
||||
{
|
||||
Console.WriteLine("Student orders sync success");
|
||||
_logger.LogInformation("Student orders sync success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Student orders sync fail");
|
||||
_logger.LogInformation("Student orders sync fail");
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
_logger.LogError(ex, "Ошибка");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigLogger()
|
||||
{
|
||||
using ILoggerFactory loggerFactory =
|
||||
LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder.ClearProviders();
|
||||
var config = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile($"appsettings.json", true, true).Build();
|
||||
LogManager.Configuration = new NLogLoggingConfiguration(config.GetSection("NLog"));
|
||||
builder.AddNLog();
|
||||
});
|
||||
_logger = loggerFactory.CreateLogger<Program>();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,10 +5,25 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Common\CoreDatabase\CoreDatabase.csproj" />
|
||||
<ProjectReference Include="..\..\Common\ToolsModule\ToolsModule.csproj" />
|
||||
<ProjectReference Include="..\..\Department\DepartmentContract\DepartmentContract.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="DepartmentPortal.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug"
|
||||
}
|
||||
},
|
||||
|
||||
"NLog": {
|
||||
"throwConfigExceptions": true,
|
||||
"targets": {
|
||||
"logfile": {
|
||||
"type": "File",
|
||||
"fileName": "c:/temp/nlog.log"
|
||||
}
|
||||
},
|
||||
"rules": [
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Debug",
|
||||
"writeTo": "logfile"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
BIN
StudentSyncService/CoreDatabase.dll
Normal file
BIN
StudentSyncService/CoreDatabase.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/CoreModels.dll
Normal file
BIN
StudentSyncService/CoreModels.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/DepartmentContract.dll
Normal file
BIN
StudentSyncService/DepartmentContract.dll
Normal file
Binary file not shown.
4
StudentSyncService/DepartmentPortal.config
Normal file
4
StudentSyncService/DepartmentPortal.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<connectionString>Data Source=10.3.1.13\SQLEXPRESS;Initial Catalog=DepartmentDatabasePortal;persist security info=True;user id=sa;password=isadmin;MultipleActiveResultSets=True;</connectionString>
|
||||
</configuration>
|
BIN
StudentSyncService/Microsoft.Data.SqlClient.dll
Normal file
BIN
StudentSyncService/Microsoft.Data.SqlClient.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
StudentSyncService/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
BIN
StudentSyncService/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.EntityFrameworkCore.SqlServer.dll
Normal file
BIN
StudentSyncService/Microsoft.EntityFrameworkCore.SqlServer.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
StudentSyncService/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.DependencyInjection.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.DependencyInjection.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.Logging.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.Options.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Extensions.Primitives.dll
Normal file
BIN
StudentSyncService/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Identity.Client.dll
Normal file
BIN
StudentSyncService/Microsoft.Identity.Client.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.IdentityModel.JsonWebTokens.dll
Normal file
BIN
StudentSyncService/Microsoft.IdentityModel.JsonWebTokens.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.IdentityModel.Logging.dll
Normal file
BIN
StudentSyncService/Microsoft.IdentityModel.Logging.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
StudentSyncService/Microsoft.IdentityModel.Protocols.dll
Normal file
BIN
StudentSyncService/Microsoft.IdentityModel.Protocols.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.IdentityModel.Tokens.dll
Normal file
BIN
StudentSyncService/Microsoft.IdentityModel.Tokens.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Microsoft.Win32.SystemEvents.dll
Normal file
BIN
StudentSyncService/Microsoft.Win32.SystemEvents.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Newtonsoft.Json.dll
Normal file
BIN
StudentSyncService/Newtonsoft.Json.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/System.Configuration.ConfigurationManager.dll
Normal file
BIN
StudentSyncService/System.Configuration.ConfigurationManager.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/System.Diagnostics.DiagnosticSource.dll
Normal file
BIN
StudentSyncService/System.Diagnostics.DiagnosticSource.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/System.Drawing.Common.dll
Normal file
BIN
StudentSyncService/System.Drawing.Common.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/System.IdentityModel.Tokens.Jwt.dll
Normal file
BIN
StudentSyncService/System.IdentityModel.Tokens.Jwt.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/System.Runtime.Caching.dll
Normal file
BIN
StudentSyncService/System.Runtime.Caching.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
StudentSyncService/System.Security.Permissions.dll
Normal file
BIN
StudentSyncService/System.Security.Permissions.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/System.Windows.Extensions.dll
Normal file
BIN
StudentSyncService/System.Windows.Extensions.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/ToolsModule.dll
Normal file
BIN
StudentSyncService/ToolsModule.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Unity.Abstractions.dll
Normal file
BIN
StudentSyncService/Unity.Abstractions.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/Unity.Container.dll
Normal file
BIN
StudentSyncService/Unity.Container.dll
Normal file
Binary file not shown.
1797
StudentSyncService/WindowServiceSyncStudentOrders.deps.json
Normal file
1797
StudentSyncService/WindowServiceSyncStudentOrders.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
StudentSyncService/WindowServiceSyncStudentOrders.dll
Normal file
BIN
StudentSyncService/WindowServiceSyncStudentOrders.dll
Normal file
Binary file not shown.
BIN
StudentSyncService/WindowServiceSyncStudentOrders.exe
Normal file
BIN
StudentSyncService/WindowServiceSyncStudentOrders.exe
Normal file
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net5.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user