2024-02-16 10:22:34 +04:00
|
|
|
using ConfectioneryBusinessLogic;
|
2024-04-12 01:04:02 +04:00
|
|
|
using ConfectioneryBusinessLogic.OfficePackage.Implements;
|
|
|
|
using ConfectioneryBusinessLogic.OfficePackage;
|
2024-02-16 10:22:34 +04:00
|
|
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
|
|
using ConfectioneryContracts.StoragesContracts;
|
2024-03-29 00:00:37 +04:00
|
|
|
using ConfectioneryDatabaseImplement.Implements;
|
2024-02-16 10:22:34 +04:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using NLog.Extensions.Logging;
|
2024-05-05 10:14:47 +04:00
|
|
|
using ConfectioneryBusinessLogic.BusinessLogics;
|
|
|
|
using Microsoft.EntityFrameworkCore.Design;
|
2024-05-23 08:34:49 +04:00
|
|
|
using ConfectioneryContracts.BindingModels;
|
2024-06-02 21:18:31 +04:00
|
|
|
using ConfectioneryContracts.DI;
|
2024-02-16 10:22:34 +04:00
|
|
|
|
2024-02-16 01:11:22 +04:00
|
|
|
namespace ConfectioneryView
|
|
|
|
{
|
|
|
|
internal static class Program
|
|
|
|
{
|
2024-02-16 10:22:34 +04:00
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
|
|
|
2024-02-16 01:11:22 +04:00
|
|
|
/// <summary>
|
|
|
|
/// The main entry point for the application.
|
|
|
|
/// </summary>
|
|
|
|
[STAThread]
|
|
|
|
static void Main()
|
|
|
|
{
|
|
|
|
ApplicationConfiguration.Initialize();
|
2024-06-02 21:18:31 +04:00
|
|
|
InitDependency();
|
2024-05-23 08:34:49 +04:00
|
|
|
try
|
|
|
|
{
|
2024-06-02 21:18:31 +04:00
|
|
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
2024-05-23 08:34:49 +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)
|
|
|
|
{
|
2024-06-02 21:18:31 +04:00
|
|
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
2024-05-23 08:34:49 +04:00
|
|
|
logger?.LogError(ex, "Mails Problem");
|
|
|
|
}
|
2024-06-02 21:18:31 +04:00
|
|
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
|
|
|
}
|
|
|
|
private static void InitDependency()
|
|
|
|
{
|
|
|
|
DependencyManager.InitDependency();
|
|
|
|
|
|
|
|
DependencyManager.Instance.AddLogging(option =>
|
|
|
|
{
|
|
|
|
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-02 14:24:38 +04:00
|
|
|
|
2024-06-02 21:18:31 +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-02 14:24:38 +04:00
|
|
|
|
2024-06-02 21:18:31 +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-02 14:24:38 +04:00
|
|
|
|
2024-06-02 21:18:31 +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-02 14:24:38 +04:00
|
|
|
|
2024-06-02 21:18:31 +04:00
|
|
|
DependencyManager.Instance.RegisterType<EntityFrameworkDesignServicesBuilder>();
|
2024-05-04 00:52:53 +04:00
|
|
|
}
|
2024-06-02 21:18:31 +04:00
|
|
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
2024-05-23 08:34:49 +04:00
|
|
|
}
|
2024-02-16 01:11:22 +04:00
|
|
|
}
|