8 лаба

This commit is contained in:
Володя 2023-05-15 21:17:32 +03:00
parent f2a6d47960
commit da7f9c64e9
57 changed files with 1065 additions and 250 deletions

2
.gitignore vendored
View File

@ -3,7 +3,7 @@
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
ImplementationExtensions/
# User-specific files
*.rsuser
*.suo

View File

@ -0,0 +1,103 @@
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using AutomobilePlantContracts.StoragesContracts;
using AutomobilePlantDataModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantBusinessLogic.BusinessLogics
{
public class BackUpLogic : IBackUpLogic
{
private readonly ILogger _logger;
private readonly IBackUpInfo _backUpInfo;
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
{
_logger = logger;
_backUpInfo = backUpInfo;
}
public void CreateBackUp(BackUpSaveBinidngModel model)
{
if (_backUpInfo == null)
{
return;
}
try
{
_logger.LogDebug("Clear folder");
// зачистка папки и удаление старого архива
var dirInfo = new DirectoryInfo(model.FolderName);
if (dirInfo.Exists)
{
foreach (var file in dirInfo.GetFiles())
{
file.Delete();
}
}
_logger.LogDebug("Delete archive");
string fileName = $"{model.FolderName}.zip";
if (File.Exists(fileName))
{
File.Delete(fileName);
}
// берем метод для сохранения
_logger.LogDebug("Get assembly");
var typeIId = typeof(IId);
var assembly = typeIId.Assembly;
if (assembly == null)
{
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
}
var types = assembly.GetTypes();
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
_logger.LogDebug("Find {count} types", types.Length);
foreach (var type in types)
{
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
{
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
if (modelType == null)
{
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
}
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
// вызываем метод на выполнение
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
}
}
_logger.LogDebug("Create zip and remove folder");
// архивируем
ZipFile.CreateFromDirectory(model.FolderName, fileName);
// удаляем папку
dirInfo.Delete(true);
}
catch (Exception)
{
throw;
}
}
private void SaveToFile<T>(string folderName) where T : class, new()
{
var records = _backUpInfo.GetList<T>();
if (records == null)
{
_logger.LogWarning("{type} type get null list", typeof(T).Name);
return;
}
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
jsonFormatter.WriteObject(fs, records);
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
public string Title { get; private set; }
public bool Visible { get; private set; }
public int Width { get; private set; }
public GridViewAutoSize GridViewAutoSize { get; private set; }
public bool IsUseAutoSize { get; private set; }
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
{
Title = title;
Visible = visible;
Width = width;
GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize;
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.Attributes
{
public enum GridViewAutoSize
{
NotSet = 0,
None = 1,
ColumnHeader = 2,
AllCellsExceptHeader = 4,
AllCells = 6,
DisplayedCellsExceptHeader = 8,
DisplayedCells = 10,
Fill = 16
}
}

View File

@ -6,6 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
</ItemGroup>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.BindingModels
{
public class BackUpSaveBinidngModel
{
public string FolderName { get; set; } = string.Empty;
}
}

View File

@ -15,5 +15,7 @@ namespace AutomobilePlantContracts.BindingModels
public string Body { get; set; } = string.Empty;
public DateTime DateDelivery { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using AutomobilePlantContracts.BindingModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.BusinessLogicsContracts
{
public interface IBackUpLogic
{
void CreateBackUp(BackUpSaveBinidngModel model);
}
}

View File

@ -0,0 +1,67 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace AutomobilePlantContracts.DI
{
public class DependencyManager
{
private readonly IDependencyContainer _dependencyManager;
private static DependencyManager? _manager;
private static readonly object _locjObject = new();
private DependencyManager()
{
_dependencyManager = new UnityServiceContainer();
}
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
/// <summary>
/// Иницализация библиотек, в которых идут установки зависомстей
/// </summary>
public static void InitDependency()
{
var ext = ServiceProviderLoader.GetImplementationExtensions();
if (ext == null)
{
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
}
// регистрируем зависимости
ext.RegisterServices();
}
/// <summary>
/// Регистрация логгера
/// </summary>
/// <param name="configure"></param>
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
/// <summary>
/// Получение класса со всеми зависмостями
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public T Resolve<T>() => _dependencyManager.Resolve<T>();
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.DI
{
public interface IDependencyContainer
{
/// <summary>
/// Регистрация логгера
/// </summary>
/// <param name="configure"></param>
void AddLogging(Action<ILoggingBuilder> configure);
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
/// <param name="isSingle"></param>
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="isSingle"></param>
void RegisterType<T>(bool isSingle) where T : class;
/// <summary>
/// Получение класса со всеми зависмостями
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
T Resolve<T>();
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.DI
{
public interface IImplementationExtension
{
public int Priority { get; }
/// <summary>
/// Регистрация сервисов
/// </summary>
public void RegisterServices();
}
}

View File

@ -0,0 +1,62 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.DI
{
public class ServiceDependencyContainer : IDependencyContainer
{
private ServiceProvider? _serviceProvider;
private readonly ServiceCollection _serviceCollection;
public ServiceDependencyContainer()
{
_serviceCollection = new ServiceCollection();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
_serviceCollection.AddLogging(configure);
}
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T, U>();
}
else
{
_serviceCollection.AddTransient<T, U>();
}
_serviceProvider = null;
}
public void RegisterType<T>(bool isSingle) where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T>();
}
else
{
_serviceCollection.AddTransient<T>();
}
_serviceProvider = null;
}
public T Resolve<T>()
{
if (_serviceProvider == null)
{
_serviceProvider = _serviceCollection.BuildServiceProvider();
}
return _serviceProvider.GetService<T>()!;
}
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.DI
{
public class ServiceProviderLoader
{
/// <summary>
/// Загрузка всех классов-реализаций IImplementationExtension
/// </summary>
/// <returns></returns>
public static IImplementationExtension? GetImplementationExtensions()
{
IImplementationExtension? source = null;
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
foreach (var file in files.Distinct())
{
Assembly asm = Assembly.LoadFrom(file);
foreach (var t in asm.GetExportedTypes())
{
if (t.IsClass && typeof(IImplementationExtension).IsAssignableFrom(t))
{
if (source == null)
{
source = (IImplementationExtension)Activator.CreateInstance(t)!;
}
else
{
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
if (newSource.Priority > source.Priority)
{
source = newSource;
}
}
}
}
}
return source;
}
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";
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using Unity.Microsoft.Logging;
namespace AutomobilePlantContracts.DI
{
public class UnityServiceContainer : IDependencyContainer
{
private UnityContainer? _unityContainer;
public UnityServiceContainer()
{
_unityContainer = new UnityContainer();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
_unityContainer.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
}
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
{
if (isSingle)
{
_unityContainer.RegisterSingleton<T, U>();
}
else
{
_unityContainer.RegisterType<T, U>();
}
}
public void RegisterType<T>(bool isSingle) where T : class
{
if (isSingle)
{
_unityContainer.RegisterSingleton<T>();
}
else
{
_unityContainer.RegisterType<T>();
}
}
public T Resolve<T>()
{
return _unityContainer.Resolve<T>()!;
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantContracts.StoragesContracts
{
public interface IBackUpInfo
{
List<T>? GetList<T>() where T : class, new();
Type? GetTypeByModelInterface(string modelInterfaceName);
}
}

View File

@ -5,15 +5,19 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using AutomobilePlantContracts.Attributes;
namespace AutomobilePlantContracts.ViewModel
{
public class CarViewModel : ICarModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("Название изделия")]
[Column(title: "Название", width: 150)]
public string CarName { get; set; } = string.Empty;
[DisplayName("Цена")]
[Column(title: "Цена", width: 50)]
public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IComponentModel, int)> CarComponents
{
get;

View File

@ -1,4 +1,5 @@
using AutomobilePlantDataModels.Models;
using AutomobilePlantContracts.Attributes;
using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,12 +11,13 @@ namespace AutomobilePlantContracts.ViewModel
{
public class ClientViewModel : IClientModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("ФИО клиента")]
[Column(title: "Имя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFIO { get; set; } = string.Empty;
[DisplayName("Логин (эл. почта)")]
[Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Email { get; set; } = string.Empty;
[DisplayName("Пароль")]
[Column(title: "Пароль", width: 150)]
public string Password { get; set; } = string.Empty;
}
}

View File

@ -5,14 +5,17 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using AutomobilePlantContracts.Attributes;
namespace AutomobilePlantContracts.ViewModel
{
public class ComponentViewModel : IComponentModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("Название компонента")]
[Column(title: "Название", width: 150)]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")]
[Column(title: "Цена", width: 150)]
public double Cost { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using AutomobilePlantDataModels.Models;
using AutomobilePlantContracts.Attributes;
using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,18 +11,19 @@ namespace AutomobilePlantContracts.ViewModel
{
public class ImplementerViewModel : IImplementerModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("ФИО исполнителя")]
[Column(title: "Имя", width: 150)]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Пароль")]
[Column(title: "Пароль", width: 150)]
public string Password { get; set; } = string.Empty;
[DisplayName("Стаж работы")]
[Column(title: "Стаж", width: 100)]
public int WorkExperience { get; set; }
[DisplayName("Квалификация")]
[Column(title: "Квалификация", width: 100)]
public int Qualification { get; set; }
}
}

View File

@ -1,24 +1,28 @@
using AutomobilePlantDataModels.Models;
using AutomobilePlantContracts.Attributes;
using AutomobilePlantDataModels.Models;
using System.ComponentModel;
namespace AutomobilePlantContracts.ViewModel
{
public class MessageInfoViewModel : IMessageInfoModel
{
[Column(visible: false)]
public string MessageId { get; set; } = string.Empty;
[Column(visible: false)]
public int? ClientId { get; set; }
[DisplayName("Отправитель")]
[Column(title: "Отправитель", width: 150)]
public string SenderName { get; set; } = string.Empty;
[DisplayName("Дата письма")]
[Column(title: "Дата", width: 100)]
public DateTime DateDelivery { get; set; }
[DisplayName("Заголовок")]
[Column(title: "Заголовок", width: 150)]
public string Subject { get; set; } = string.Empty;
[DisplayName("Текст")]
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Body { get; set; } = string.Empty;
[Column(visible: false)]
public int Id { get; set; }
}
}

View File

@ -6,31 +6,35 @@ using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using AutomobilePlantDataModels.Enums;
using AutomobilePlantContracts.Attributes;
namespace AutomobilePlantContracts.ViewModel
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер")]
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("Клиент")]
[Column(title: "Клиент", width: 150)]
public string ClientName { get; set; } = string.Empty;
[Column(visible: false)]
public int ClientId { get; set; }
[Column(visible: false)]
public int? ImplementerId { get; set; }
[DisplayName("Исполнитель")]
[Column(title: "Исполнитель", width: 150)]
public string? ImplementerName { get; set; } = string.Empty;
[Column(visible: false)]
public int CarId { get; set; }
[DisplayName("Изделие")]
[Column(title: "Машина", width: 150)]
public string CarName { get; set; } = string.Empty;
[DisplayName("Количество")]
[Column(title: "Кол-во", width: 150)]
public int Count { get; set; }
[DisplayName("Сумма")]
[Column(title: "Сумма", width: 150)]
public double Sum { get; set; }
[DisplayName("Статус")]
[Column(title: "Статус", width: 150)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")]
[Column(title: "Дата создания", width: 150)]
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
[DisplayName("Дата выполнения")]
[Column(title: "Дата выполнения", width: 150)]
public DateTime? DateImplement { get; set; }
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AutomobilePlantDataModels.Models
{
public interface IMessageInfoModel
public interface IMessageInfoModel : IId
{
string MessageId { get; }

View File

@ -11,4 +11,8 @@
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -0,0 +1,17 @@
using AutomobilePlantContracts.StoragesContracts;
namespace AutomobilePlantListImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
throw new NotImplementedException();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,28 @@
using AbstractShopContracts.StoragesContracts;
using AutomobilePlantContracts.DI;
using AutomobilePlantContracts.StoragesContracts;
using AutomobilePlantListImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantListImplement
{
public class ListImplementationExtension : IImplementationExtension
{
public int Priority => 0;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -32,6 +32,7 @@ namespace AutomobilePlantListImplement.Models
}
return new MessageInfoModel()
{
Id = model.Id,
MessageId = model.MessageId,
ClientId = model.ClientId,
SenderName = model.SenderName,
@ -42,6 +43,7 @@ namespace AutomobilePlantListImplement.Models
}
public MessageInfoViewModel GetViewModel => new()
{
Id = Id,
MessageId = MessageId,
ClientId = ClientId,
SenderName = SenderName,
@ -49,6 +51,7 @@ namespace AutomobilePlantListImplement.Models
Subject = Subject,
Body = Body,
};
public int Id { get; set; }
}
}

View File

@ -0,0 +1,51 @@
using AutomobilePlantContracts.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlant
{
internal static class DataGridViewExtension
{
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
{
if (data == null)
{
return;
}
grid.DataSource = data;
var type = typeof(T);
var properties = type.GetProperties();
foreach (DataGridViewColumn column in grid.Columns)
{
var property = properties.FirstOrDefault(x => x.Name == column.Name);
if (property == null)
{
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}");
}
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
if (attribute == null)
{
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
}
// ищем нужный нам атрибут
if (attribute is ColumnAttribute columnAttr)
{
column.HeaderText = columnAttr.Title;
column.Visible = columnAttr.Visible;
if (columnAttr.IsUseAutoSize)
{
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
}
else
{
column.Width = columnAttr.Width;
}
}
}
}
}
}

View File

@ -53,33 +53,35 @@
// CarNameLabel
//
this.CarNameLabel.AutoSize = true;
this.CarNameLabel.Location = new System.Drawing.Point(12, 9);
this.CarNameLabel.Name = "PackageNameLabel";
this.CarNameLabel.Size = new System.Drawing.Size(65, 15);
this.CarNameLabel.Location = new System.Drawing.Point(14, 12);
this.CarNameLabel.Name = "CarNameLabel";
this.CarNameLabel.Size = new System.Drawing.Size(84, 20);
this.CarNameLabel.TabIndex = 0;
this.CarNameLabel.Text = "Название: ";
//
// PriceLabel
//
this.PriceLabel.AutoSize = true;
this.PriceLabel.Location = new System.Drawing.Point(12, 43);
this.PriceLabel.Location = new System.Drawing.Point(14, 57);
this.PriceLabel.Name = "PriceLabel";
this.PriceLabel.Size = new System.Drawing.Size(73, 15);
this.PriceLabel.Size = new System.Drawing.Size(90, 20);
this.PriceLabel.TabIndex = 1;
this.PriceLabel.Text = "Стоимость: ";
//
// CarNameTextBox
//
this.CarNameTextBox.Location = new System.Drawing.Point(83, 6);
this.CarNameTextBox.Name = "PackageNameTextBox";
this.CarNameTextBox.Size = new System.Drawing.Size(283, 23);
this.CarNameTextBox.Location = new System.Drawing.Point(95, 8);
this.CarNameTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.CarNameTextBox.Name = "CarNameTextBox";
this.CarNameTextBox.Size = new System.Drawing.Size(323, 27);
this.CarNameTextBox.TabIndex = 2;
//
// PriceTextBox
//
this.PriceTextBox.Location = new System.Drawing.Point(83, 40);
this.PriceTextBox.Location = new System.Drawing.Point(95, 53);
this.PriceTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.PriceTextBox.Name = "PriceTextBox";
this.PriceTextBox.Size = new System.Drawing.Size(283, 23);
this.PriceTextBox.Size = new System.Drawing.Size(323, 27);
this.PriceTextBox.TabIndex = 3;
//
// ComponentsGroupBox
@ -89,18 +91,21 @@
this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
this.ComponentsGroupBox.Controls.Add(this.AddButton);
this.ComponentsGroupBox.Controls.Add(this.DataGridView);
this.ComponentsGroupBox.Location = new System.Drawing.Point(12, 80);
this.ComponentsGroupBox.Location = new System.Drawing.Point(14, 107);
this.ComponentsGroupBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ComponentsGroupBox.Name = "ComponentsGroupBox";
this.ComponentsGroupBox.Size = new System.Drawing.Size(722, 350);
this.ComponentsGroupBox.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ComponentsGroupBox.Size = new System.Drawing.Size(825, 467);
this.ComponentsGroupBox.TabIndex = 5;
this.ComponentsGroupBox.TabStop = false;
this.ComponentsGroupBox.Text = "Компоненты";
//
// UpdateButton
//
this.UpdateButton.Location = new System.Drawing.Point(590, 203);
this.UpdateButton.Location = new System.Drawing.Point(674, 271);
this.UpdateButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.UpdateButton.Name = "UpdateButton";
this.UpdateButton.Size = new System.Drawing.Size(110, 38);
this.UpdateButton.Size = new System.Drawing.Size(126, 51);
this.UpdateButton.TabIndex = 4;
this.UpdateButton.Text = "Обновить";
this.UpdateButton.UseVisualStyleBackColor = true;
@ -108,9 +113,10 @@
//
// DeleteButton
//
this.DeleteButton.Location = new System.Drawing.Point(590, 143);
this.DeleteButton.Location = new System.Drawing.Point(674, 191);
this.DeleteButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.DeleteButton.Name = "DeleteButton";
this.DeleteButton.Size = new System.Drawing.Size(110, 38);
this.DeleteButton.Size = new System.Drawing.Size(126, 51);
this.DeleteButton.TabIndex = 3;
this.DeleteButton.Text = "Удалить";
this.DeleteButton.UseVisualStyleBackColor = true;
@ -118,9 +124,10 @@
//
// ChangeButton
//
this.ChangeButton.Location = new System.Drawing.Point(590, 82);
this.ChangeButton.Location = new System.Drawing.Point(674, 109);
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ChangeButton.Name = "ChangeButton";
this.ChangeButton.Size = new System.Drawing.Size(110, 38);
this.ChangeButton.Size = new System.Drawing.Size(126, 51);
this.ChangeButton.TabIndex = 2;
this.ChangeButton.Text = "Изменить";
this.ChangeButton.UseVisualStyleBackColor = true;
@ -128,9 +135,10 @@
//
// AddButton
//
this.AddButton.Location = new System.Drawing.Point(590, 22);
this.AddButton.Location = new System.Drawing.Point(674, 29);
this.AddButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.AddButton.Name = "AddButton";
this.AddButton.Size = new System.Drawing.Size(110, 38);
this.AddButton.Size = new System.Drawing.Size(126, 51);
this.AddButton.TabIndex = 1;
this.AddButton.Text = "Добавить";
this.AddButton.UseVisualStyleBackColor = true;
@ -159,7 +167,8 @@
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
this.DataGridView.Location = new System.Drawing.Point(6, 22);
this.DataGridView.Location = new System.Drawing.Point(7, 29);
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.DataGridView.Name = "DataGridView";
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
@ -169,32 +178,39 @@
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.DataGridView.RowHeadersWidth = 51;
this.DataGridView.RowTemplate.Height = 25;
this.DataGridView.Size = new System.Drawing.Size(561, 322);
this.DataGridView.Size = new System.Drawing.Size(641, 429);
this.DataGridView.TabIndex = 0;
//
// ID
//
this.ID.HeaderText = "ID";
this.ID.MinimumWidth = 6;
this.ID.Name = "ID";
this.ID.Visible = false;
this.ID.Width = 125;
//
// ComponentNameField
//
this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ComponentNameField.HeaderText = "Компонент";
this.ComponentNameField.MinimumWidth = 6;
this.ComponentNameField.Name = "ComponentNameField";
//
// CountField
//
this.CountField.HeaderText = "Количество";
this.CountField.MinimumWidth = 6;
this.CountField.Name = "CountField";
this.CountField.Width = 125;
//
// ButtonCancel
//
this.ButtonCancel.Location = new System.Drawing.Point(602, 446);
this.ButtonCancel.Location = new System.Drawing.Point(688, 595);
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(110, 34);
this.ButtonCancel.Size = new System.Drawing.Size(126, 45);
this.ButtonCancel.TabIndex = 7;
this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true;
@ -202,9 +218,10 @@
//
// SaveButton
//
this.SaveButton.Location = new System.Drawing.Point(486, 446);
this.SaveButton.Location = new System.Drawing.Point(555, 595);
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.SaveButton.Name = "SaveButton";
this.SaveButton.Size = new System.Drawing.Size(110, 34);
this.SaveButton.Size = new System.Drawing.Size(126, 45);
this.SaveButton.TabIndex = 8;
this.SaveButton.Text = "Сохранить";
this.SaveButton.UseVisualStyleBackColor = true;
@ -212,9 +229,9 @@
//
// FormCar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(746, 498);
this.ClientSize = new System.Drawing.Size(853, 664);
this.Controls.Add(this.SaveButton);
this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.ComponentsGroupBox);
@ -222,8 +239,10 @@
this.Controls.Add(this.CarNameTextBox);
this.Controls.Add(this.PriceLabel);
this.Controls.Add(this.CarNameLabel);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormCar";
this.Text = "Изделие";
this.Load += new System.EventHandler(this.FormCar_Load);
this.ComponentsGroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
this.ResumeLayout(false);

View File

@ -1,5 +1,6 @@
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using AutomobilePlantContracts.DI;
using AutomobilePlantContracts.SearchModel;
using AutomobilePlantDataModels.Models;
using Microsoft.Extensions.Logging;
@ -83,7 +84,7 @@ namespace AutomobilePlant
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormCarComponent));
DependencyManager.Instance.Resolve<FormCarComponent>();
if (service is FormCarComponent form)
{
if (form.ShowDialog() == DialogResult.OK)
@ -112,7 +113,7 @@ namespace AutomobilePlant
if (DataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormCarComponent));
DependencyManager.Instance.Resolve<FormCarComponent>();
if (service is FormCarComponent form)
{
int id =

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@ -10,6 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AutomobilePlantContracts.DI;
namespace AutomobilePlant
{
@ -34,15 +35,7 @@ namespace AutomobilePlant
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["CarName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DataGridView.Columns["CarComponents"].Visible = false;
}
DataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка изделий");
@ -56,7 +49,7 @@ namespace AutomobilePlant
private void AddButton_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
var service = DependencyManager.Instance.Resolve<FormCar>();
if (service is FormCar form)
{
@ -70,7 +63,7 @@ namespace AutomobilePlant
{
if (DataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
var service = DependencyManager.Instance.Resolve<FormCar>();
if (service is FormCar form)
{

View File

@ -1,4 +1,5 @@
using AutomobilePlantContracts.BindingModels;
using AutomobilePlant;
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
@ -26,13 +27,7 @@ namespace AbstractShopView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)

View File

@ -1,5 +1,6 @@
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using AutomobilePlantContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -32,14 +33,7 @@ namespace AutomobilePlant
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["ComponentName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
DataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка компонентов");
}
catch (Exception ex)
@ -52,7 +46,7 @@ namespace AutomobilePlant
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormComponent));
DependencyManager.Instance.Resolve<FormComponent>();
if (service is FormComponent form)
{
if (form.ShowDialog() == DialogResult.OK)
@ -66,7 +60,7 @@ namespace AutomobilePlant
if (DataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormComponent));
DependencyManager.Instance.Resolve<FormComponent>();
if (service is FormComponent form)
{
form.Id =

View File

@ -1,5 +1,6 @@
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using AutomobilePlantContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -33,14 +34,7 @@ namespace AutomobilePlant
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["ImplementerFIO"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
DataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка исполнителей");
}
catch (Exception ex)
@ -53,7 +47,7 @@ namespace AutomobilePlant
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormImplementer));
DependencyManager.Instance.Resolve<FormImplementer>();
if (service is FormImplementer form)
{
if (form.ShowDialog() == DialogResult.OK)
@ -67,7 +61,7 @@ namespace AutomobilePlant
if (DataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormImplementer));
DependencyManager.Instance.Resolve<FormImplementer>();
if (service is FormImplementer form)
{
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);

View File

@ -39,11 +39,12 @@
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.начатьРаботуToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DataGridView = new System.Windows.Forms.DataGridView();
this.CreateOrderButton = new System.Windows.Forms.Button();
this.IssuedOrderButton = new System.Windows.Forms.Button();
this.UpdateListButton = new System.Windows.Forms.Button();
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.бекапToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
this.SuspendLayout();
@ -57,7 +58,8 @@
this.клиентыToolStripMenuItem,
this.исполнителиToolStripMenuItem,
this.начатьРаботуToolStripMenuItem,
this.письмаToolStripMenuItem});
this.письмаToolStripMenuItem,
this.бекапToolStripMenuItem});
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
@ -140,6 +142,13 @@
this.начатьРаботуToolStripMenuItem.Text = "Начать работу";
this.начатьРаботуToolStripMenuItem.Click += new System.EventHandler(this.начатьРаботуToolStripMenuItem_Click);
//
// письмаToolStripMenuItem
//
this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.письмаToolStripMenuItem.Text = "Письма";
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
//
// DataGridView
//
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@ -184,12 +193,12 @@
this.UpdateListButton.UseVisualStyleBackColor = true;
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
//
// письмаToolStripMenuItem
// бекапToolStripMenuItem
//
this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.письмаToolStripMenuItem.Text = "Письма";
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
this.бекапToolStripMenuItem.Name = "бекапToolStripMenuItem";
this.бекапToolStripMenuItem.Size = new System.Drawing.Size(64, 24);
this.бекапToolStripMenuItem.Text = "Бекап";
this.бекапToolStripMenuItem.Click += new System.EventHandler(this.бекапToolStripMenuItem_Click);
//
// FormMain
//
@ -232,5 +241,6 @@
private ToolStripMenuItem исполнителиToolStripMenuItem;
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
private ToolStripMenuItem письмаToolStripMenuItem;
private ToolStripMenuItem бекапToolStripMenuItem;
}
}

View File

@ -1,7 +1,9 @@
using AbstractShopView;
using AutomobilePlantBusinessLogic.BusinessLogics;
using AutomobilePlantBusinessLogic.MailWorker;
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using AutomobilePlantContracts.DI;
using AutomobilePlantDataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
@ -22,14 +24,16 @@ namespace AutomobilePlant
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
private readonly IWorkProcess _workProcess;
private readonly IBackUpLogic _backUpLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
_workProcess = workProcess;
_backUpLogic = backUpLogic;
}
private void FormMain_Load(object sender, EventArgs e)
@ -43,15 +47,7 @@ namespace AutomobilePlant
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["CarId"].Visible = false;
DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["ImplementerId"].Visible = false;
}
DataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
_logger.LogInformation("Загрузка заказов");
}
@ -64,7 +60,7 @@ namespace AutomobilePlant
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
var service = DependencyManager.Instance.Resolve<FormComponents>();
if (service is FormComponents form)
{
@ -74,7 +70,7 @@ namespace AutomobilePlant
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCars));
var service = DependencyManager.Instance.Resolve<FormCars>();
if (service is FormCars form)
{
@ -84,7 +80,7 @@ namespace AutomobilePlant
private void CreateOrderButton_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
if (service is FormCreateOrder form)
{
@ -216,7 +212,7 @@ namespace AutomobilePlant
private void ComponentCarsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportCarComponents));
var service = DependencyManager.Instance.Resolve<FormReportCarComponents>();
if (service is FormReportCarComponents form)
{
form.ShowDialog();
@ -225,7 +221,7 @@ namespace AutomobilePlant
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
if (service is FormReportOrders form)
{
form.ShowDialog();
@ -234,7 +230,7 @@ namespace AutomobilePlant
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
var service = DependencyManager.Instance.Resolve<FormClients>();
if (service is FormClients form)
{
form.ShowDialog();
@ -243,7 +239,7 @@ namespace AutomobilePlant
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
var service = DependencyManager.Instance.Resolve<FormImplementers>();
if (service is FormImplementers form)
{
form.ShowDialog();
@ -252,18 +248,28 @@ namespace AutomobilePlant
private void начатьРаботуToolStripMenuItem_Click(object sender, EventArgs e)
{
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMessages));
var service = DependencyManager.Instance.Resolve<FormMessages>();
if (service is FormMessages form)
{
form.ShowDialog();
}
}
private void бекапToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new FolderBrowserDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel { FolderName = dialog.SelectedPath});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

View File

@ -1,4 +1,5 @@
using AbstractShopView;
using AutomobilePlantBusinessLogic.BusinessLogics;
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
@ -36,14 +37,7 @@ namespace AutomobilePlant
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["MessageId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["SenderName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)

View File

@ -12,13 +12,13 @@ using AbstractShopView;
using AbstractShopContracts.StoragesContracts;
using AutomobilePlantBusinessLogic.MailWorker;
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.DI;
namespace AutomobilePlant
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -28,13 +28,12 @@ namespace AutomobilePlant
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
InitDependency();
try
{
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
@ -50,56 +49,53 @@ namespace AutomobilePlant
}
catch (Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
private static void InitDependency()
{
services.AddLogging(option =>
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ICarStorage, CarStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IMessageInfoStorage, MessageStorage>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ICarLogic, CarLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ICarLogic, CarLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IMessageInfoLogic, MessageLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormCar>();
services.AddTransient<FormCarComponent>();
services.AddTransient<FormCars>();
services.AddTransient<FormReportCarComponents>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormClients>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormMessages>();
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormCar>();
DependencyManager.Instance.RegisterType<FormCarComponent>();
DependencyManager.Instance.RegisterType<FormCars>();
DependencyManager.Instance.RegisterType<FormReportCarComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormMessages>();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
}
}

View File

@ -19,4 +19,8 @@
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -0,0 +1,28 @@
using AbstractShopContracts.StoragesContracts;
using AutomobilePlantContracts.DI;
using AutomobilePlantContracts.StoragesContracts;
using AutomobilePlantDataBaseImplements.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantDataBaseImplements
{
public class DBImplementationExtension : IImplementationExtension
{
public int Priority => 2;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -0,0 +1,32 @@
using AutomobilePlantContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantDataBaseImplements.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
using var context = new AutoPlantDataBase();
return context.Set<T>().ToList();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -8,17 +8,22 @@ using System.Text;
using System.Threading.Tasks;
using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.ViewModel;
using System.Runtime.Serialization;
namespace AutomobilePlantDataBaseImplements.Models
{
[DataContract]
public class Car : ICarModel
{
[DataMember]
public int Id { get; set; }
[Required]
[DataMember]
public string CarName { get; set; } = string.Empty;
[Required]
[DataMember]
public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _carComponents = null;

View File

@ -2,22 +2,28 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantDataBaseImplements.Models
{
public class CarComponent
{
public int Id { get; set; }
[Required]
public int CarId { get; set; }
[Required]
public int ComponentId { get; set; }
[Required]
public int Count { get; set; }
public virtual Component Component { get; set; } = new();

View File

@ -10,20 +10,26 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace AutomobilePlantDataBaseImplements.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; set; }
[Required]
[DataMember]
public string ClientFIO { get; set; } = string.Empty;
[Required]
[DataMember]
public string Email { get; set; } = string.Empty;
[Required]
[DataMember]
public string Password { get; set; } = string.Empty;

View File

@ -8,17 +8,22 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace AutomobilePlantDataBaseImplements.Models
{
[DataContract]
public class Component : IComponentModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public string ComponentName { get; private set; } = string.Empty;
[Required]
[DataMember]
public double Cost { get; set; }
[ForeignKey("ComponentId")]

View File

@ -8,22 +8,29 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace AutomobilePlantDataBaseImplements.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; set; }
[Required]
[DataMember]
public string ImplementerFIO { get; set; } = string.Empty;
[Required]
[DataMember]
public int WorkExperience { get; set; }
[Required]
[DataMember]
public int Qualification { get; set; }
[Required]
[DataMember]
public string Password { get; set; } = string.Empty;

View File

@ -7,24 +7,28 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantDataBaseImplements.Models
{
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[Key]
[DataMember]
public string MessageId { get; set; } = string.Empty;
[DataMember]
public int? ClientId { get; set; }
public Client? client { get; private set; }
[DataMember]
public string SenderName { get; set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; set; }
[DataMember]
public string Subject { get; set; } = string.Empty;
[DataMember]
public string Body { get; set; } = string.Empty;
public static MessageInfo? Create(MessageInfoBindingModel? model)
{
@ -33,7 +37,7 @@ namespace AutomobilePlantDataBaseImplements.Models
return null;
}
return new MessageInfo()
{
{ Id = model.Id,
MessageId = model.MessageId,
ClientId = model.ClientId,
SenderName = model.SenderName,
@ -43,7 +47,7 @@ namespace AutomobilePlantDataBaseImplements.Models
};
}
public MessageInfoViewModel GetViewModel => new()
{
{ Id = Id,
MessageId = MessageId,
ClientId = ClientId,
SenderName = SenderName,
@ -51,5 +55,7 @@ namespace AutomobilePlantDataBaseImplements.Models
Subject = Subject,
Body = Body,
};
[NotMapped]
public int Id {get; set;}
}
}

View File

@ -8,33 +8,48 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace AutomobilePlantDataBaseImplements.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public int CarId { get; private set; }
[Required]
[DataMember]
public int ClientId { get; private set; }
[DataMember]
public string ClientName { get; private set; } = string.Empty;
[DataMember]
public int? ImplementerId { get; private set; }
[DataMember]
public string? ImplementerName { get; private set; } = string.Empty;
[DataMember]
public string CarName { get; private set; } = string.Empty;
public Client client { get; private set; }
public Car car { get; private set; }
public Implementer? implementer { get; private set; }
[Required]
[DataMember]
public int Count { get; private set; }
[Required]
[DataMember]
public double Sum { get; private set; }
[Required]
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[Required]
[DataMember]
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
[DataMember]
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -11,4 +11,8 @@
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -0,0 +1,28 @@
using AbstractShopContracts.StoragesContracts;
using AutomobilePlantContracts.DI;
using AutomobilePlantContracts.StoragesContracts;
using AutomomilePlantFileImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutomomilePlantFileImplement
{
public class FileImplementationExtension : IImplementationExtension
{
public int Priority => 1;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -0,0 +1,47 @@
using AutomobilePlantContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AutomomilePlantFileImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
var context = DataFileSingleton.GetInstance();
Type myType = typeof(DataFileSingleton);
string property = $"{typeof(T).FullName}";
string nameList = "";
foreach (PropertyInfo prop in myType.GetProperties(
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
{
var list = prop.GetValue(context);
var typeList = list.GetType().GetGenericArguments().Single();
if (property.Equals($"{typeList.FullName}"))
{ nameList = prop.Name; break; }
}
var propertyInfo = myType.GetProperty(nameList);
var values = (List<T>)propertyInfo.GetValue(context);
return values;
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -4,16 +4,21 @@ using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AutomomilePlantFileImplement.Models
{
[DataContract]
public class Car : ICarModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string CarName { get; private set; } = string.Empty;
[DataMember]
public double Price { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _carComponents =

View File

@ -5,17 +5,23 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AutomomilePlantFileImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
public string Email { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty;
public static Client? Create(ClientBindingModel model)
{

View File

@ -4,16 +4,21 @@ using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AutomomilePlantFileImplement.Models
{
[DataContract]
public class Component : IComponentModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ComponentName { get; private set; } = string.Empty;
[DataMember]
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel model)
{

View File

@ -4,18 +4,25 @@ using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AutomomilePlantFileImplement.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
public int WorkExperience { get; set; }
[DataMember]
public int Qualification { get; set; }
[DataMember]
public string Password { get; private set; } = string.Empty;
public static Implementer? Create(ImplementerBindingModel model)
{

View File

@ -4,24 +4,27 @@ using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AutomomilePlantFileImplement.Models
{
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[DataMember]
public string MessageId {get;set;} = string.Empty;
public int? ClientId { get; set; }
[DataMember]
public string SenderName { get; set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; set; }
[DataMember]
public string Subject { get; set; } = string.Empty;
[DataMember]
public string Body { get; set;} = string.Empty;
public static MessageInfo? Create(MessageInfoBindingModel model)
{
@ -31,6 +34,7 @@ namespace AutomomilePlantFileImplement.Models
}
return new MessageInfo()
{
Id = model.Id,
MessageId = model.MessageId,
ClientId = model.ClientId,
SenderName = model.SenderName,
@ -47,6 +51,7 @@ namespace AutomomilePlantFileImplement.Models
}
return new MessageInfo()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
MessageId =element.Attribute("MessageId")!.Value,
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
SenderName = element.Attribute("SenderName")!.Value,
@ -58,6 +63,7 @@ namespace AutomomilePlantFileImplement.Models
public MessageInfoViewModel GetViewModel => new()
{
Id = Id,
MessageId = MessageId,
ClientId = ClientId,
SenderName = SenderName,
@ -67,11 +73,14 @@ namespace AutomomilePlantFileImplement.Models
};
public XElement GetXElement => new("MessageInfo",
new XAttribute("MessageId", MessageId),
new XAttribute("Id", Id),
new XElement("ClientId", ClientId.ToString()),
new XElement("SenderName", SenderName),
new XElement("DateDelivery", DateDelivery.ToString()),
new XElement("Subject", Subject),
new XElement("Body", Body)
);
public int Id { get; set; }
}
}

View File

@ -5,29 +5,43 @@ using AutomobilePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AutomomilePlantFileImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int CarId { get; private set; }
[DataMember]
public int ClientId { get; private set; }
[DataMember]
public string ClientName { get; private set; } = string.Empty;
public string CarName { get; private set; } = string.Empty;
[DataMember]
public string CarName { get; private set; } = string.Empty;
[DataMember]
public int? ImplementerId { get; private set; }
[DataMember]
public string? ImplementerName { get; private set; } = string.Empty;
[DataMember]
public int Count { get; private set; }
[DataMember]
public double Sum { get; private set; }
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[DataMember]
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
[DataMember]
public DateTime? DateImplement { get; private set; } = null;
[DataMember]
public int Id { get; private set; }
public static Order? Create(OrderBindingModel model)