done base part, added order report page with mail support, added check for role of user
This commit is contained in:
parent
bf9efc105f
commit
ae9d5eb54c
@ -81,17 +81,28 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public List<ReportOrdersWorkerViewModel> GetOrders(ReportWorkerBindingModel model)
|
||||
public Tuple<List<ReportOrdersWorkerViewModel>, double> GetOrders(ReportWorkerBindingModel model)
|
||||
{
|
||||
var orderInfos = _orderInfoStorage
|
||||
.GetFilteredList(new OrderInfoSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||
.GetFilteredList(new OrderInfoSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo, UserId = model.UserId });
|
||||
List<int> orderInfoIds = new List<int>();
|
||||
foreach (var orderInfo in orderInfos)
|
||||
{
|
||||
orderInfoIds.Add(orderInfo.Id);
|
||||
}
|
||||
var orders = _orderStorage.GetFilteredList(new OrderSearchModel { OrderInfoId = orderInfoIds });
|
||||
var sets = _setStorage.GetFullList();
|
||||
var orders = _orderStorage.GetFilteredList(new OrderSearchModel
|
||||
{
|
||||
OrderInfoId = orderInfoIds
|
||||
});
|
||||
List<SetViewModel> sets = new List<SetViewModel>();
|
||||
foreach (var order in orders)
|
||||
{
|
||||
sets.Add(_setStorage.GetElement(new SetSearchModel
|
||||
{
|
||||
Id = order.SetId
|
||||
}));
|
||||
}
|
||||
|
||||
var furnitureModules = _furnitureModuleStorage.GetFullList();
|
||||
var list = new List<ReportOrdersWorkerViewModel>();
|
||||
|
||||
@ -108,13 +119,23 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
if (orderInfo.Id == order.OrderInfoId)
|
||||
{
|
||||
var currentSet = _setStorage.GetElement(new SetSearchModel { Id = order.SetId });
|
||||
string setName = "";
|
||||
if (order.Count > 1)
|
||||
{
|
||||
setName = order.SetName + " X" + order.Count;
|
||||
} else
|
||||
{
|
||||
setName = order.SetName;
|
||||
}
|
||||
record = new ReportOrdersWorkerViewModel
|
||||
{
|
||||
Id = order.Id,
|
||||
SetName = order.SetName,
|
||||
SetName = setName,
|
||||
DateCreate = orderInfo.DateCreate,
|
||||
FurnitureModules = new List<(string, double)>(),
|
||||
TotalCount = 0
|
||||
TotalCount = order.Count,
|
||||
Sum = currentSet.Cost.ToString() + "x" + order.Count.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -134,8 +155,9 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
double fullSum = orderInfos.Sum(x => x.Sum);
|
||||
|
||||
return list;
|
||||
return Tuple.Create(list, fullSum);
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение компонент в файл-Word
|
||||
|
@ -0,0 +1,70 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using System.Net.Mime;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.MailWorker
|
||||
{
|
||||
public class MailWorker
|
||||
{
|
||||
protected string _mailLogin = "yankalyshev@outlook.com";
|
||||
protected string _mailPassword = "250303zyzf";
|
||||
protected string _smtpClientHost = "smtp-mail.outlook.com";
|
||||
protected int _smtpClientPort = 587;
|
||||
private readonly ILogger _logger;
|
||||
public MailWorker(ILogger<MailWorker> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
||||
await SendMailAsync(info);
|
||||
}
|
||||
protected async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
using var objMailMessage = new MailMessage();
|
||||
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||
try
|
||||
{
|
||||
objMailMessage.From = new MailAddress(_mailLogin);
|
||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||
objMailMessage.Subject = info.Subject;
|
||||
objMailMessage.Body = info.Text;
|
||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||
Attachment attachment = new Attachment("C:\\temp\\pdf_worker.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||
objMailMessage.Attachments.Add(attachment);
|
||||
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
objSmtpClient.EnableSsl = true;
|
||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||
|
||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var order in info.Orders)
|
||||
foreach (var order in info.Orders.Item1)
|
||||
{
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
@ -35,29 +35,37 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
CreateTable(new List<string> { "2cm", "3cm", "3cm", "3cm" });
|
||||
CreateTable(new List<string> { "2cm", "3cm", "7cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Мебельный модуль", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
int i = 1;
|
||||
foreach (var furnitureModule in order.FurnitureModules)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), furnitureModule.Name, furnitureModule.Cost.ToString() },
|
||||
Texts = new List<string> { i.ToString(), order.DateCreate.ToShortDateString(), furnitureModule.Name, furnitureModule.Cost.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
i++;
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
||||
Text = $"Итого: {order.Sum}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.Orders.Item2}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -13,6 +13,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public List<ReportOrdersWorkerViewModel> Orders { get; set; } = new();
|
||||
public Tuple<List<ReportOrdersWorkerViewModel>, double> Orders { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class MailSendInfoBindingModel
|
||||
{
|
||||
public string MailAddress { get; set; } = string.Empty;
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -12,5 +12,6 @@ namespace FurnitureAssemblyContracts.BindingModels
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public List<int>? SetIds { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace FurnitureAssemblyContracts.BusinessLogicContracts
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
List<ReportOrdersWorkerViewModel> GetOrders(ReportWorkerBindingModel model);
|
||||
Tuple<List<ReportOrdersWorkerViewModel>, double> GetOrders(ReportWorkerBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение материалов в файл-Word
|
||||
/// </summary>
|
||||
|
@ -14,6 +14,6 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public string SetName { get; set; } = string.Empty;
|
||||
public List<(string Name, double Cost)> FurnitureModules { get; set; } = new();
|
||||
public int TotalCount { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public string Sum { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
return context.OrderInfos
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Where(x => x.DateCreate >= model.DateFrom.Value.ToUniversalTime() && x.DateCreate <= model.DateTo.Value.ToUniversalTime() && model.UserId == x.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Presentation;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using FurnitureAssemblyBusinessLogic.MailWorker;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
@ -15,10 +17,12 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportWorkerLogic _reportWorkerLogic;
|
||||
public ReportController(ILogger<ReportController> logger, IReportWorkerLogic reportWorkerLogic)
|
||||
private readonly MailWorker _mail;
|
||||
public ReportController(ILogger<ReportController> logger, IReportWorkerLogic reportWorkerLogic, MailWorker mailWorker)
|
||||
{
|
||||
_logger = logger;
|
||||
_reportWorkerLogic = reportWorkerLogic;
|
||||
_mail = mailWorker;
|
||||
}
|
||||
|
||||
|
||||
@ -48,5 +52,31 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateReportOrdersToPdf(ReportWorkerBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportWorkerLogic.SaveOrdersToPdfFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SendPdfToMail(MailSendInfoBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mail.MailSendAsync(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отправки письма");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyDatabaseImplement.Implements;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using FurnitureAssemblyBusinessLogic.MailWorker;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -32,6 +33,7 @@ builder.Services.AddTransient<IScopeLogic, ScopeLogic>();
|
||||
builder.Services.AddTransient<ISetLogic, SetLogic>();
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
builder.Services.AddTransient<IReportWorkerLogic, ReportWorkerLogic>();
|
||||
builder.Services.AddTransient<MailWorker, MailWorker>();
|
||||
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToWord, SaveToWord>();
|
||||
|
@ -42,6 +42,25 @@ namespace FurnitureAssemblyWorkerClientApp
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
} else
|
||||
{
|
||||
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
public static List<ReportOrdersWorkerViewModel>? PostRequestReportOrders<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<List<ReportOrdersWorkerViewModel>>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
@ -7,16 +7,23 @@ using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using System.Web.Helpers;
|
||||
using System.Reflection;
|
||||
using FurnitureAssemblyBusinessLogic.BusinessLogics;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
|
||||
namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private readonly IReportWorkerLogic _report;
|
||||
public HomeController(ILogger<HomeController> logger, IReportWorkerLogic report)
|
||||
{
|
||||
_logger = logger;
|
||||
_report = report;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
@ -79,10 +86,16 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
APIClient.User = APIClient.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}");
|
||||
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
if (APIClient.User.RoleName != "Работник")
|
||||
{
|
||||
APIClient.User = null;
|
||||
throw new Exception("Данному сотруднику вход запрещен");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
@ -307,6 +320,10 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
{
|
||||
return new PhysicalFileResult("C:\\temp\\excel_worker.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
}
|
||||
public IActionResult GetPdfFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\temp\\pdf_worker.pdf", "application/pdf");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult FurnitureModules()
|
||||
{
|
||||
@ -600,8 +617,99 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Response.Redirect("Orders");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult OrdersReport()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View("OrdersReport");
|
||||
}
|
||||
[HttpPost]
|
||||
public void OrdersReport(DateTime dateFrom, DateTime dateTo, string customerEmail)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(customerEmail))
|
||||
{
|
||||
throw new Exception("Email пуст");
|
||||
}
|
||||
APIClient.PostRequest("api/report/createreportorderstopdf", new ReportWorkerBindingModel
|
||||
{
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
APIClient.PostRequest("api/report/sendpdftomail", new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = customerEmail,
|
||||
Subject = "Отчет по заказам",
|
||||
Text = "Отчет по заказам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString()
|
||||
});
|
||||
Response.Redirect("OrdersReport");
|
||||
}
|
||||
[HttpGet]
|
||||
public string GetOrdersReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
Tuple<List<ReportOrdersWorkerViewModel>,double> result;
|
||||
try
|
||||
{
|
||||
result = _report.GetOrders(new ReportWorkerBindingModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
string html = "";
|
||||
foreach (var report in result.Item1)
|
||||
{
|
||||
html += $"<h2>{report.SetName}</h2>";
|
||||
html += $"<table>";
|
||||
html += "<thead>";
|
||||
html += "<tr>";
|
||||
html += $"<th>Номер</th>";
|
||||
html += $"<th>Дата заказа</th>";
|
||||
html += $"<th>Мебельный модуль</th>";
|
||||
html += $"<th>Сумма</th>";
|
||||
html += "</tr>";
|
||||
html += "</thead>";
|
||||
int i = 1;
|
||||
html += "<tbody>";
|
||||
foreach (var furnitureModule in report.FurnitureModules)
|
||||
{
|
||||
html += "<tr>";
|
||||
html += $"<td>{i}</td>";
|
||||
html += $"<td>{report.DateCreate}</td>";
|
||||
html += $"<td>{furnitureModule.Name}</td>";
|
||||
html += $"<td>{furnitureModule.Cost}</td>";
|
||||
html += "</tr>";
|
||||
i++;
|
||||
}
|
||||
html += "</tbody>";
|
||||
html += "</table>";
|
||||
html += $"<p style=\"align-self: self-end;\">Итого: {report.Sum}</p>";
|
||||
}
|
||||
html += $"<h3 style=\"align-self: self-start;\">Итого: {result.Item2}</h3>";
|
||||
return html;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.9" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||
<ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -3,7 +3,7 @@ namespace FurnitureAssemblyWorkerClientApp.Models
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public int? Code { get; set; }
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
@ -1,6 +1,20 @@
|
||||
using FurnitureAssemblyBusinessLogic.BusinessLogics;
|
||||
using FurnitureAssemblyBusinessLogic.OfficePackage;
|
||||
using FurnitureAssemblyBusinessLogic.OfficePackage.Implements;
|
||||
using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.StorageContracts;
|
||||
using FurnitureAssemblyDatabaseImplement.Implements;
|
||||
using FurnitureAssemblyWorkerClientApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddTransient<IReportWorkerLogic, ReportWorkerLogic>();
|
||||
builder.Services.AddTransient<ISetStorage, SetStorage>();
|
||||
builder.Services.AddTransient<IFurnitureModuleStorage, FurnitureModuleStorage>();
|
||||
builder.Services.AddTransient<IOrderInfoStorage, OrderInfoStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToPdf, SaveToPdf>();
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToWord, SaveToWord>();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
@ -8,12 +22,12 @@ builder.Services.AddControllersWithViews();
|
||||
var app = builder.Build();
|
||||
APIClient.Connect(builder.Configuration);
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
//if (app.Environment.IsDevelopment())
|
||||
//{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
//}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
@ -1,5 +1,5 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
ViewData["Title"] = "Вход";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
@ -17,4 +17,8 @@
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 mt-3"><a asp-action="Register" class="btn btn-primary">Регистрация</a></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,13 @@
|
||||
@page "{code?}"
|
||||
@model ErrorViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Ошибка";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Произошла ошибка</h1>
|
||||
@if (Model.ShowRequestId)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||
</p>
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Отчет по заказам";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Отчет по заказам</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<form method="post">
|
||||
<div class="mt-3">
|
||||
<div class="form-check form-check-inline">
|
||||
<label class="form-check-label" for="dateFrom">
|
||||
От
|
||||
</label>
|
||||
<input type="datetime-local" id="dateFrom" name="dateFrom" />
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<label class="form-check-label" for="dateTo">
|
||||
До
|
||||
</label>
|
||||
<input type="datetime-local" id="dateTo" name="dateTo" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
Ваш email
|
||||
<input type="text" name="customerEmail" />
|
||||
<button class="btn btn-primary ms-3" type="submit">Сгенерировать на почту</button>
|
||||
</div>
|
||||
<div class="mt-3" id="report" style="display: flex; flex-direction: column;">
|
||||
</div>
|
||||
</form>
|
||||
<button class="btn btn-primary" type="button" id="genonform">Сгенерировать на форму</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetOrdersReport",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#genonform').on('click', (e) => check());
|
||||
</script>
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - FurnitureAssemblyWorkerClientApp</title>
|
||||
<title>@ViewData["Title"] - Приложение сотрудника мебельной компании</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/FurnitureAssemblyClientApp.styles.css" asp-append-version="true" />
|
||||
@ -20,16 +20,10 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Заказы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="OrdersReport">Отчет по заказам</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Sets">Гарнитуры</a>
|
||||
@ -37,14 +31,14 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="FurnitureModules">Мебельные модули</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ListSetsFurnitureModulesToFile">Получение списка</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="AddFurnitureModulesInSet">Добавление мебельных модулей в гарнитуру</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Заказы</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ListSetsFurnitureModulesToFile">Получение списка</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -59,7 +53,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2023 - FurnitureAssemblyWorkerClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2023 - Приложение сотрудника мебельной компании - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user