ISEbd-22_Alimova_M.S._Confe.../Confectionery/ConfectioneryView/Program.cs

102 lines
4.7 KiB
C#
Raw Permalink Normal View History

using ConfectioneryBusinessLogic;
2024-04-12 01:04:02 +04:00
using ConfectioneryBusinessLogic.OfficePackage.Implements;
using ConfectioneryBusinessLogic.OfficePackage;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.StoragesContracts;
2024-03-29 00:00:37 +04:00
using ConfectioneryDatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2024-06-03 23:32:39 +04:00
using ConfectioneryBusinessLogic.BusinessLogics;
using Microsoft.EntityFrameworkCore.Design;
2024-06-04 00:56:24 +04:00
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.DI;
2024-02-16 01:11:22 +04:00
namespace ConfectioneryView
{
2024-06-03 23:32:39 +04:00
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2024-06-03 23:32:39 +04:00
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
InitDependency();
2024-06-04 00:56:24 +04:00
try
{
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-06-04 00:56:24 +04:00
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
});
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var logger = DependencyManager.Instance.Resolve<ILogger>();
2024-06-04 00:56:24 +04:00
logger?.LogError(ex, "Mails Problem");
}
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-06-03 23:32:39 +04:00
}
private static void InitDependency()
2024-06-03 23:32:39 +04:00
{
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
2024-06-03 23:32:39 +04:00
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IPastryStorage, PastryStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
2024-06-04 00:56:24 +04:00
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IPastryLogic, PastryLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
2024-06-04 00:56:24 +04:00
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
2024-06-04 00:56:24 +04:00
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormPastry>();
DependencyManager.Instance.RegisterType<FormPastryComponent>();
DependencyManager.Instance.RegisterType<FormPastrys>();
DependencyManager.Instance.RegisterType<FormReportPastryComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
2024-06-04 00:56:24 +04:00
DependencyManager.Instance.RegisterType<EntityFrameworkDesignServicesBuilder>();
}
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-06-03 23:32:39 +04:00
}
2024-02-16 01:11:22 +04:00
}