PIbd-22 Kaznacheeva E.K. LabWork_6 #8
@ -0,0 +1,129 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.StoragesContracts;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ImplementerLogic : IImplementerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerStorage _implementerStorage;
|
||||
|
||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerStorage = implementerStorage;
|
||||
}
|
||||
|
||||
public bool Create(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_implementerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_implementerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}",
|
||||
model.ImplementerFIO, model.Id);
|
||||
var element = _implementerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FIO:{FIO}.Id:{ Id} ", model?.ImplementerFIO, model?.Id);
|
||||
var list = (model == null) ? _implementerStorage.GetFullList() :
|
||||
_implementerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_implementerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.WorkExperience < 0)
|
||||
{
|
||||
throw new ArgumentException("Опыт работы не должен быть отрицательным", nameof(model.WorkExperience));
|
||||
}
|
||||
if (model.Qualification < 0)
|
||||
{
|
||||
throw new ArgumentException("Квалификация не должна быть отрицательной", nameof(model.Qualification));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ImplementerFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
||||
}
|
||||
_logger.LogInformation("Implementer. Id: {Id}, FIO: {FIO}", model.Id, model.ImplementerFIO);
|
||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
static readonly object locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
@ -62,9 +63,12 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
||||
|
||||
model.Status = newStatus;
|
||||
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
model.DateImplement = DateTime.Now;
|
||||
|
||||
if (viewModel.ImplementerId.HasValue)
|
||||
model.ImplementerId = viewModel.ImplementerId;
|
||||
|
||||
model.Sum = viewModel.Sum;
|
||||
model.Count = viewModel.Count;
|
||||
model.PackageId = viewModel.PackageId;
|
||||
@ -82,7 +86,10 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
lock (locker)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
@ -140,6 +147,27 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{Sum}. PackageId: {PackageId}", model.Id, model.Sum, model.PackageId);
|
||||
}
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||
|
||||
var element = _orderStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,144 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using SoftwareInstallationDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkModeling : IWorkProcess
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly Random _rnd;
|
||||
private IOrderLogic? _orderLogic;
|
||||
public WorkModeling(ILogger<WorkModeling> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_rnd = new Random(1000);
|
||||
}
|
||||
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
||||
{
|
||||
_orderLogic = orderLogic;
|
||||
var implementers = implementerLogic.ReadList(null);
|
||||
if (implementers == null)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Исполнитель равен null");
|
||||
return;
|
||||
}
|
||||
var orders = _orderLogic.ReadList(new OrderSearchModel
|
||||
{
|
||||
Statuses = new() { OrderStatus.Принят }
|
||||
});
|
||||
if (orders == null || orders.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||
foreach (var implementer in implementers)
|
||||
{
|
||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Иммитация работы исполнителя
|
||||
/// </summary>
|
||||
/// <param name="implementer"></param>
|
||||
/// <param name="orders"></param>
|
||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await RunOrderInWork(implementer);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var order in orders)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("DoWork. Worker {Id} try get order {Order} ", implementer.Id, order.Id);
|
||||
// пытаемся назначить заказ на исполнителя
|
||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
// делаем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 10000) * order.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order} ", implementer.Id, order.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 50));
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// заканчиваем выполнение имитации в случае иной ошибки
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||
/// </summary>
|
||||
/// <param name="implementer"></param>
|
||||
/// <returns></returns>
|
||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementer.Id,
|
||||
Statuses = new() { OrderStatus.Выполняется }
|
||||
}));
|
||||
if (runOrder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
||||
// доделываем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = runOrder.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// заказа может не быть, просто игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using SoftwareInstallationDataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.BindingModels
|
||||
{
|
||||
public class ImplementerBindingModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace SoftwareInstallationContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
@ -0,0 +1,24 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IImplementerLogic
|
||||
{
|
||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||
|
||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||
|
||||
bool Create(ImplementerBindingModel model);
|
||||
|
||||
bool Update(ImplementerBindingModel model);
|
||||
|
||||
bool Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace SoftwareInstallationContracts.BusinessLogicsContracts
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkProcess
|
||||
{
|
||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.SearchModels
|
||||
{
|
||||
public class ImplementerSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? ImplementerFIO { get; set; }
|
||||
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SoftwareInstallationDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -12,5 +13,7 @@ namespace SoftwareInstallationContracts.SearchModels
|
||||
public int? ClientId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public List<OrderStatus>? Statuses { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.StoragesContracts
|
||||
{
|
||||
public interface IImplementerStorage
|
||||
{
|
||||
List<ImplementerViewModel> GetFullList();
|
||||
|
||||
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||
|
||||
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||
|
||||
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||
|
||||
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||
|
||||
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using SoftwareInstallationDataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стаж работы")]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -13,17 +13,28 @@ namespace SoftwareInstallationContracts.ViewModels
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public int ClientId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
|
||||
[DisplayName("Клиент")]
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("ФИО клиента")]
|
||||
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Изделия")]
|
||||
public string PackageName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationDataModels
|
||||
{
|
||||
public interface IImplementerModel : IId
|
||||
{
|
||||
string ImplementerFIO { get; }
|
||||
string Password { get; }
|
||||
int WorkExperience { get; }
|
||||
int Qualification { get; }
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace SoftwareInstallationDataModels.Models
|
||||
{
|
||||
int PackageId { get; }
|
||||
int ClientId { get; }
|
||||
int? ImplementerId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
|
@ -0,0 +1,70 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using SoftwareInstallationDataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationDatabaseImplement
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[Required]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Orders { get; private set; } = new();
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
WorkExperience = model.WorkExperience
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
WorkExperience = WorkExperience
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.StoragesContracts;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationDatabaseImplement
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
var res = context.Implementers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Implementers
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
|
||||
if (model.ImplementerFIO != null && model.Password != null)
|
||||
return context.Implementers
|
||||
.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO)
|
||||
&& x.Password.Equals(model.Password))
|
||||
?.GetViewModel;
|
||||
|
||||
if (model.ImplementerFIO != null)
|
||||
return context.Implementers
|
||||
.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||
?.GetViewModel;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
|
||||
if (model.ImplementerFIO != null)
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Implementers
|
||||
.Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Implementers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
var res = Implementer.Create(model);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Add(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
var res = context.Implementers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,257 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using SoftwareInstallationDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SoftwareInstallationDatabase))]
|
||||
[Migration("20240505115211_AddImplementer")]
|
||||
partial class AddImplementer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PackageName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Packages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.PackageComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("PackageComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.PackageComponent", b =>
|
||||
{
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("PackageComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Package");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Order", b =>
|
||||
{
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Package");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("PackageComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddImplementer : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ImplementerId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId",
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImplementerId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,34 @@ namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Client", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -47,7 +74,7 @@ namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Component", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -67,45 +94,7 @@ namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Package", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -125,7 +114,7 @@ namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
b.ToTable("Packages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.PackageComponent", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.PackageComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -153,28 +142,56 @@ namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Order", b =>
|
||||
{
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Client", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId");
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Package", "Package")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Navigation("Package");
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PackageId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.PackageComponent", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.PackageComponent", b =>
|
||||
{
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Component", "Component")
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("PackageComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Package", "Package")
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
@ -185,17 +202,47 @@ namespace SoftwareInstallationDatabaseImplement.Migrations
|
||||
b.Navigation("Package");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Client", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Order", b =>
|
||||
{
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("SoftwareInstallationDatabaseImplement.Models.Package", "Package")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Package");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Component", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("PackageComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Package", b =>
|
||||
modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Package", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace SoftwareInstallationDatabaseImplement
|
||||
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
@ -37,6 +38,7 @@ namespace SoftwareInstallationDatabaseImplement
|
||||
|
||||
public virtual Package Package { get; set; }
|
||||
public virtual Client Client { get; private set; }
|
||||
public virtual Implementer? Implementer { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
@ -49,6 +51,7 @@ namespace SoftwareInstallationDatabaseImplement
|
||||
{
|
||||
Id = model.Id,
|
||||
PackageId = model.PackageId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -66,12 +69,14 @@ namespace SoftwareInstallationDatabaseImplement
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PackageId = PackageId,
|
||||
ImplementerId = ImplementerId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
@ -79,7 +84,8 @@ namespace SoftwareInstallationDatabaseImplement
|
||||
DateImplement = DateImplement,
|
||||
PackageName = Package?.PackageName,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = Client?.ClientFIO
|
||||
ClientFIO = Client?.ClientFIO,
|
||||
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -39,16 +39,21 @@ namespace SoftwareInstallationDatabaseImplement.Implements
|
||||
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Package)
|
||||
.Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Orders.Include(x => x.Package)
|
||||
.Include(x => x.Client).Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
||||
return context.Orders.Include(x => x.Package).Include(x => x.Implementer)
|
||||
.Include(x => x.Client).Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) && (!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||
&&
|
||||
(model.Statuses == null || model.Statuses != null && model.Statuses.Contains(x.Status)) &&
|
||||
(!model.ImplementerId.HasValue || x.ImplementerId == model.ImplementerId)
|
||||
&& (!model.ClientId.HasValue || x.ClientId == model.ClientId)))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
@ -57,7 +62,7 @@ namespace SoftwareInstallationDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Orders.Include(x => x.Client).Include(x => x.Package).Select(x => x.GetViewModel).ToList();
|
||||
return context.Orders.Include(x => x.Client).Include(x => x.Package).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
|
@ -24,5 +24,6 @@ namespace SoftwareInstallationDatabaseImplement
|
||||
public virtual DbSet<PackageComponent> PackageComponents { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,12 @@ namespace SoftwareInstallationFileImplement
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string PackageFileName = "Package.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ImplementerFileName = "Implementer.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Package> Packages { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -32,12 +34,15 @@ namespace SoftwareInstallationFileImplement
|
||||
public void SavePackages() => SaveData(Packages, PackageFileName, "Packages", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Packages = LoadData(PackageFileName, "Package", x => Package.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
|
@ -0,0 +1,78 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using SoftwareInstallationDataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SoftwareInstallationFileImplement
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
WorkExperience = model.WorkExperience,
|
||||
Qualification = model.Qualification
|
||||
};
|
||||
}
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Qualification = model.Qualification;
|
||||
}
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
WorkExperience = WorkExperience,
|
||||
Qualification = Qualification
|
||||
};
|
||||
public static Implementer? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
||||
Password = element.Element("Password")!.Value,
|
||||
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public XElement GetXElement => new("Implementer",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ImplementerFIO", ImplementerFIO),
|
||||
new XElement("Password", Password),
|
||||
new XElement("Qualification", Qualification.ToString()),
|
||||
new XElement("WorkExperience", WorkExperience.ToString())
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.StoragesContracts;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationFileImplement
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
return source.Implementers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel
|
||||
model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Implementers
|
||||
.Where(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO.Contains(model.ImplementerFIO)) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password.Contains(model.Password)))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
return source.Implementers
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x =>
|
||||
x.Id) + 1 : 1;
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Implementers.Add(newImplementer);
|
||||
source.SaveImplementers();
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (implementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
implementer.Update(model);
|
||||
source.SaveImplementers();
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
var element = source.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Implementers.Remove(element);
|
||||
source.SaveImplementers();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace SoftwareInstallationFileImplement
|
||||
{
|
||||
public int ClientId { get; private set; }
|
||||
public int PackageId { get; private set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
@ -35,6 +36,7 @@ namespace SoftwareInstallationFileImplement
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
ImplementerId = model.ImplementerId,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
@ -53,6 +55,7 @@ namespace SoftwareInstallationFileImplement
|
||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null)
|
||||
};
|
||||
@ -69,6 +72,7 @@ namespace SoftwareInstallationFileImplement
|
||||
return;
|
||||
}
|
||||
PackageId = model.PackageId;
|
||||
ImplementerId = ImplementerId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
@ -82,6 +86,7 @@ namespace SoftwareInstallationFileImplement
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
ImplementerId = ImplementerId,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
@ -92,6 +97,7 @@ namespace SoftwareInstallationFileImplement
|
||||
new XElement("ClientId", ClientId.ToString()),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("ImplementerId", ImplementerId.ToString()),
|
||||
new XElement("Status", Status.ToString()),
|
||||
new XElement("DateCreate", DateCreate.ToString()),
|
||||
new XElement("DateImplement", DateImplement.ToString()));
|
||||
|
@ -37,6 +37,19 @@ namespace SoftwareInstallationFileImplement.Implements
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (model.ImplementerId.HasValue && model.Statuses != null)
|
||||
{
|
||||
return source.Orders
|
||||
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId &&
|
||||
model.Statuses.Contains(x.Status)) ?.GetViewModel;
|
||||
}
|
||||
|
||||
if (model.ImplementerId.HasValue)
|
||||
{
|
||||
return source.Orders
|
||||
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId) ?.GetViewModel;
|
||||
}
|
||||
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
@ -47,14 +60,12 @@ namespace SoftwareInstallationFileImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
return source.Orders.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||
)
|
||||
)
|
||||
.Select(x => GetPackageName(x.GetViewModel))
|
||||
.ToList();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetPackageName(x.GetViewModel)).ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
|
@ -14,12 +14,14 @@ namespace SoftwareInstallationListImplement
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Package> Packages { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Packages = new List<Package>();
|
||||
Clients = new List<Client>();
|
||||
Implementers = new List<Implementer>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -0,0 +1,61 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using SoftwareInstallationDataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationListImplement
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
WorkExperience = model.WorkExperience,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
WorkExperience = WorkExperience
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.StoragesContracts;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationListImplement
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||
{
|
||||
if (_source.Implementers[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Implementers[i];
|
||||
_source.Implementers.RemoveAt(i);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
foreach (var x in _source.Implementers)
|
||||
{
|
||||
if (model.Id.HasValue && x.Id == model.Id)
|
||||
return x.GetViewModel;
|
||||
|
||||
if (model.ImplementerFIO != null && model.Password != null &&
|
||||
x.ImplementerFIO.Equals(model.ImplementerFIO) &&
|
||||
x.Password.Equals(model.Password))
|
||||
return x.GetViewModel;
|
||||
|
||||
if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||
return x.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
|
||||
List<ImplementerViewModel> result = new();
|
||||
|
||||
if (model.ImplementerFIO != null)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.Id <= implementer.Id)
|
||||
{
|
||||
model.Id = implementer.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Implementers.Add(newImplementer);
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.Id == model.Id)
|
||||
{
|
||||
implementer.Update(model);
|
||||
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace SoftwareInstallationListImplement
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
public int PackageId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
@ -29,6 +30,7 @@ namespace SoftwareInstallationListImplement
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
@ -43,6 +45,7 @@ namespace SoftwareInstallationListImplement
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
@ -51,6 +54,7 @@ namespace SoftwareInstallationListImplement
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
ImplementerId = ImplementerId,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
|
@ -55,26 +55,31 @@ namespace SoftwareInstallationListImplement.Implements
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if ((!model.Id.HasValue || order.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom)
|
||||
&& (!model.DateTo.HasValue || order.DateCreate <= model.DateTo))
|
||||
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
result.Add(GetViewModelName(order.GetViewModel));
|
||||
result.Add(GetViewModelName(order));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(GetViewModelName(order.GetViewModel));
|
||||
result.Add(GetViewModelName(order));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -115,30 +120,18 @@ namespace SoftwareInstallationListImplement.Implements
|
||||
|
||||
return null;
|
||||
}
|
||||
private OrderViewModel GetViewModelName(OrderViewModel model)
|
||||
private OrderViewModel GetViewModelName(Order model)
|
||||
{
|
||||
var res = model.GetViewModel;
|
||||
foreach (var package in _source.Packages)
|
||||
{
|
||||
if (package.Id == model.PackageId)
|
||||
{
|
||||
model.PackageName = package.PackageName;
|
||||
res.PackageName = package.PackageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private OrderViewModel GetClientName(OrderViewModel viewModel)
|
||||
{
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == viewModel.ClientId)
|
||||
{
|
||||
viewModel.ClientFIO = client.ClientFIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return viewModel;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,103 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using SoftwareInstallationContracts.ViewModels;
|
||||
using SoftwareInstallationDataModels.Enums;
|
||||
|
||||
namespace SoftwareInstallationRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ImplementerController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _order;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger<ImplementerController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_order = order;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ImplementerViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetNewOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
Statuses = new() { OrderStatus.Принят }
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public OrderViewModel? GetImplementerOrder(int implementerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementerId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.TakeOrderInWork(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу",
|
||||
model.Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.FinishOrder(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,9 +12,11 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IPackageStorage, PackageStorage>();
|
||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IPackageLogic, PackageLogic>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at
|
||||
https://aka.ms/aspnetcore/swashbuckle
|
||||
|
165
SoftwareInstallation/SoftwareInstallationView/FormImplementer.Designer.cs
generated
Normal file
165
SoftwareInstallation/SoftwareInstallationView/FormImplementer.Designer.cs
generated
Normal file
@ -0,0 +1,165 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormImplementer
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelFIO = new Label();
|
||||
textBoxFio = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelQualification = new Label();
|
||||
labelWorkExperience = new Label();
|
||||
workExpNumericUpDown = new NumericUpDown();
|
||||
qualificationNumericUpDown = new NumericUpDown();
|
||||
labelPassword = new Label();
|
||||
textBoxPassword = new TextBox();
|
||||
((System.ComponentModel.ISupportInitialize)workExpNumericUpDown).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)qualificationNumericUpDown).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(22, 28);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(40, 15);
|
||||
labelFIO.TabIndex = 3;
|
||||
labelFIO.Text = "ФИО: ";
|
||||
//
|
||||
// textBoxFio
|
||||
//
|
||||
textBoxFio.Location = new Point(105, 20);
|
||||
textBoxFio.Name = "textBoxFio";
|
||||
textBoxFio.Size = new Size(200, 23);
|
||||
textBoxFio.TabIndex = 4;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(117, 194);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(97, 29);
|
||||
buttonSave.TabIndex = 17;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(234, 194);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(97, 29);
|
||||
buttonCancel.TabIndex = 16;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// labelQualification
|
||||
//
|
||||
labelQualification.AutoSize = true;
|
||||
labelQualification.Location = new Point(22, 142);
|
||||
labelQualification.Name = "labelQualification";
|
||||
labelQualification.Size = new Size(94, 15);
|
||||
labelQualification.TabIndex = 15;
|
||||
labelQualification.Text = "Квалификация: ";
|
||||
//
|
||||
// labelWorkExperience
|
||||
//
|
||||
labelWorkExperience.AutoSize = true;
|
||||
labelWorkExperience.Location = new Point(22, 101);
|
||||
labelWorkExperience.Name = "labelWorkExperience";
|
||||
labelWorkExperience.Size = new Size(87, 15);
|
||||
labelWorkExperience.TabIndex = 14;
|
||||
labelWorkExperience.Text = "Опыт работы: ";
|
||||
//
|
||||
// workExpNumericUpDown
|
||||
//
|
||||
workExpNumericUpDown.Location = new Point(126, 99);
|
||||
workExpNumericUpDown.Name = "workExpNumericUpDown";
|
||||
workExpNumericUpDown.Size = new Size(170, 23);
|
||||
workExpNumericUpDown.TabIndex = 13;
|
||||
//
|
||||
// qualificationNumericUpDown
|
||||
//
|
||||
qualificationNumericUpDown.Location = new Point(126, 140);
|
||||
qualificationNumericUpDown.Name = "qualificationNumericUpDown";
|
||||
qualificationNumericUpDown.Size = new Size(170, 23);
|
||||
qualificationNumericUpDown.TabIndex = 12;
|
||||
//
|
||||
// labelPassword
|
||||
//
|
||||
labelPassword.AutoSize = true;
|
||||
labelPassword.Location = new Point(22, 61);
|
||||
labelPassword.Name = "labelPassword";
|
||||
labelPassword.Size = new Size(55, 15);
|
||||
labelPassword.TabIndex = 11;
|
||||
labelPassword.Text = "Пароль: ";
|
||||
//
|
||||
// textBoxPassword
|
||||
//
|
||||
textBoxPassword.Location = new Point(105, 58);
|
||||
textBoxPassword.Name = "textBoxPassword";
|
||||
textBoxPassword.Size = new Size(200, 23);
|
||||
textBoxPassword.TabIndex = 10;
|
||||
//
|
||||
// FormImplementer
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(343, 244);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(labelQualification);
|
||||
Controls.Add(labelWorkExperience);
|
||||
Controls.Add(workExpNumericUpDown);
|
||||
Controls.Add(qualificationNumericUpDown);
|
||||
Controls.Add(labelPassword);
|
||||
Controls.Add(textBoxPassword);
|
||||
Controls.Add(textBoxFio);
|
||||
Controls.Add(labelFIO);
|
||||
Name = "FormImplementer";
|
||||
Text = "Исполнитель";
|
||||
((System.ComponentModel.ISupportInitialize)workExpNumericUpDown).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)qualificationNumericUpDown).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxFio;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelQualification;
|
||||
private Label labelWorkExperience;
|
||||
private NumericUpDown workExpNumericUpDown;
|
||||
private NumericUpDown qualificationNumericUpDown;
|
||||
private Label labelPassword;
|
||||
private TextBox textBoxPassword;
|
||||
}
|
||||
}
|
105
SoftwareInstallation/SoftwareInstallationView/FormImplementer.cs
Normal file
105
SoftwareInstallation/SoftwareInstallationView/FormImplementer.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using SoftwareInstallationContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormImplementer : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxPassword.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните пароль", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxFio.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните фио", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение исполнителя");
|
||||
try
|
||||
{
|
||||
var model = new ImplementerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ImplementerFIO = textBoxFio.Text,
|
||||
Password = textBoxPassword.Text,
|
||||
Qualification = (int)qualificationNumericUpDown.Value,
|
||||
WorkExperience = (int)workExpNumericUpDown.Value,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
private void FormImplementer_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFio.Text = view.ImplementerFIO;
|
||||
textBoxPassword.Text = view.Password;
|
||||
qualificationNumericUpDown.Value = view.Qualification;
|
||||
workExpNumericUpDown.Value = view.WorkExperience;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?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.
|
||||
-->
|
||||
<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">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
112
SoftwareInstallation/SoftwareInstallationView/FormImplementers.Designer.cs
generated
Normal file
112
SoftwareInstallation/SoftwareInstallationView/FormImplementers.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
partial class FormImplementers
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonAdd = new Button();
|
||||
buttonChange = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonDelete = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.Size = new Size(612, 451);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(641, 48);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(128, 40);
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonChange
|
||||
//
|
||||
buttonChange.Location = new Point(641, 94);
|
||||
buttonChange.Name = "buttonChange";
|
||||
buttonChange.Size = new Size(128, 40);
|
||||
buttonChange.TabIndex = 3;
|
||||
buttonChange.Text = "Изменить";
|
||||
buttonChange.UseVisualStyleBackColor = true;
|
||||
buttonChange.Click += buttonChange_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(641, 186);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 40);
|
||||
buttonUpdate.TabIndex = 6;
|
||||
buttonUpdate.Text = "Обновить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += buttonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(641, 140);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 40);
|
||||
buttonDelete.TabIndex = 5;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// FormImplementers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonChange);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormImplementers";
|
||||
Text = "Исполнители";
|
||||
Load += FormImplementers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonChange;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SoftwareInstallation;
|
||||
using SoftwareInstallationContracts.BindingModels;
|
||||
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SoftwareInstallationView
|
||||
{
|
||||
public partial class FormImplementers : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonChange_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление исполнителя");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ImplementerBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void FormImplementers_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?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.
|
||||
-->
|
||||
<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">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -32,15 +32,16 @@
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
изделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonRefresh = new Button();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
@ -48,16 +49,16 @@
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem });
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(958, 24);
|
||||
menuStrip.Size = new Size(1180, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -65,17 +66,31 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(145, 22);
|
||||
компонентыToolStripMenuItem.Size = new Size(149, 22);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// изделияToolStripMenuItem
|
||||
//
|
||||
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
изделияToolStripMenuItem.Size = new Size(145, 22);
|
||||
изделияToolStripMenuItem.Size = new Size(149, 22);
|
||||
изделияToolStripMenuItem.Text = "Изделия";
|
||||
изделияToolStripMenuItem.Click += изделияToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(149, 22);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click_1;
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
исполнителиToolStripMenuItem.Size = new Size(149, 22);
|
||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||
@ -104,59 +119,46 @@
|
||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
запускРаботToolStripMenuItem.Size = new Size(92, 20);
|
||||
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 27);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.Size = new Size(751, 395);
|
||||
dataGridView.Size = new Size(976, 395);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(785, 110);
|
||||
buttonCreateOrder.Location = new Point(1010, 113);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(144, 39);
|
||||
buttonCreateOrder.Size = new Size(144, 35);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += buttonCreateOrder_Click;
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(785, 155);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(144, 39);
|
||||
buttonTakeOrderInWork.TabIndex = 3;
|
||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(785, 245);
|
||||
buttonIssuedOrder.Location = new Point(1010, 197);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(144, 39);
|
||||
buttonIssuedOrder.Size = new Size(144, 35);
|
||||
buttonIssuedOrder.TabIndex = 4;
|
||||
buttonIssuedOrder.Text = "Заказ выдан";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += buttonIssuedOrder_Click;
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(785, 200);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(144, 39);
|
||||
buttonOrderReady.TabIndex = 5;
|
||||
buttonOrderReady.Text = "Заказ готов";
|
||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
buttonOrderReady.Click += buttonOrderReady_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(785, 290);
|
||||
buttonRefresh.Location = new Point(1010, 304);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(144, 39);
|
||||
buttonRefresh.Size = new Size(144, 35);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
buttonRefresh.Text = "Обновить список";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
@ -166,17 +168,15 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(958, 439);
|
||||
ClientSize = new Size(1180, 439);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonOrderReady);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonTakeOrderInWork);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
Text = "Установка ПО";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
@ -193,13 +193,14 @@
|
||||
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonRefresh;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -20,12 +20,14 @@ namespace SoftwareInstallationView
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
@ -45,6 +47,10 @@ namespace SoftwareInstallationView
|
||||
dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["PackageId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
@ -92,54 +98,6 @@ namespace SoftwareInstallationView
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -200,5 +158,29 @@ namespace SoftwareInstallationView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void клиентыToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,4 +120,7 @@
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>75</value>
|
||||
</metadata>
|
||||
</root>
|
@ -41,12 +41,15 @@ namespace SoftwareInstallation
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IPackageStorage, PackageStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IPackageLogic, PackageLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
@ -59,6 +62,8 @@ namespace SoftwareInstallation
|
||||
services.AddTransient<FormPackage>();
|
||||
services.AddTransient<FormPackageComponent>();
|
||||
services.AddTransient<FormPackages>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormReportPackageComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user