Я РЕАЛЬНО ЛЕГЕНДА ГОЛОС ВСЕХ ПОКОЛЕНИЙ

This commit is contained in:
Леонид Малафеев 2024-05-29 17:50:12 +04:00
parent 1ef713d1c8
commit 1c3c9c3b65
45 changed files with 618 additions and 60 deletions

View File

@ -16,5 +16,6 @@ namespace CarCenterContracts.BindingModels
public ToolKit ToolKit { get; set; } = ToolKit.Неизвестно;
public double Price { get; set; }
public int StorekeeperId { get; set; }
}
public DateTime DateCreate { get; set; }
}
}

View File

@ -20,5 +20,6 @@ namespace CarCenterContracts.BindingModels
public long VINnumber { get; set; }
public int FeatureID { get; set; }
public Dictionary<int, IBundlingModel> CarBundlings { get; set; } = new();
}
public DateTime DateCreate { get; set; }
}
}

View File

@ -10,5 +10,7 @@ namespace CarCenterContracts.SearchModels
{
public int? Id { get; set; }
public int? StorekeeperId { get; set; }
}
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -10,5 +10,6 @@ namespace CarCenterContracts.SearchModels
{
public int? Id { get; set; }
public int? StorekeeperId { get; set; }
public int? BundlingId { get; set; }
}
}

View File

@ -10,6 +10,7 @@ namespace CarCenterContracts.SearchModels
public class OrderSearchModel
{
public int? Id { get; set; }
public int? BundlingId { get; set; }
public int? WorkerId { get; set; }
public List<IPresaleModel> Presales { get; set; } = new();
public List<ICarModel> Cars { get; set; } = new();

View File

@ -9,5 +9,6 @@ namespace CarCenterContracts.SearchModels
public class PresaleSearchModel
{
public int? Id { get; set; }
public int? CarId { get; set; }
}
}

View File

@ -21,5 +21,7 @@ namespace CarCenterContracts.ViewModels
public ToolKit ToolKit { get; set; }
[DisplayName("Цена")]
public double Price { get; set; }
}
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; }
}
}

View File

@ -30,5 +30,7 @@ namespace CarCenterContracts.ViewModels
public long VINnumber { get; set; }
public int FeatureID { get; set; }
public Dictionary<int, IBundlingModel> CarBundlings { get; set; } = new();
}
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; }
}
}

View File

@ -13,5 +13,6 @@ namespace CarCenterDataModels.Models
TirePackage TirePackage { get; }
ToolKit ToolKit { get; }
double Price { get; }
}
DateTime DateCreate { get; }
}
}

View File

@ -17,5 +17,6 @@ namespace CarCenterDataModels.Models
long VINnumber { get; }
int FeatureID { get; }
Dictionary<int, IBundlingModel> CarBundlings { get; }
}
public DateTime DateCreate { get; set; }
}
}

View File

@ -22,15 +22,15 @@ namespace CarCenterDatabaseImplement.Implements
}
public List<BundlingViewModel> GetFilteredList(BundlingSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.StorekeeperId.HasValue)
{
return context.Bundlings
.Where(x => x.StorekeeperId == model.StorekeeperId)
.Select(x => x.GetViewModel)
.ToList();
}
return new();
if (!model.StorekeeperId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
{
return new();
}
using var context = new CarCenterDatabase();
if (model.DateFrom.HasValue)
return context.Bundlings.Where(x => x.StorekeeperId == model.StorekeeperId).Where(x => x.DateCreate <= model.DateTo && x.DateCreate >= model.DateFrom).Select(x => x.GetViewModel).ToList();
else
return context.Bundlings.Where(x => x.StorekeeperId == model.StorekeeperId).Select(x => x.GetViewModel).ToList();
}
public BundlingViewModel? GetElement(BundlingSearchModel model)
{

View File

@ -29,19 +29,14 @@ namespace CarCenterDatabaseImplement.Implements
public List<CarViewModel> GetFilteredList(CarSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.DateFrom.HasValue && model.DateTo.HasValue) // Для отчета списка
if (model.DateFrom.HasValue) // Для отчета списка
{
//будет применятся в ReportLogic
return context.Cars
.Where(x => x.StorekeeperId == model.StorekeeperId)
.Include(x => x.Bundlings)
.ThenInclude(x => x.Bundling)
.Include(x => x.Feature)
.Include(x => x.Order)
.Include(x => x.Storekeeper)
.Where(x => x.Order.PaymentDate >= model.DateFrom && x.Order.PaymentDate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
.Where(x => x.StorekeeperId == model.StorekeeperId)
.Where(x => x.DateCreate <= model.DateTo && x.DateCreate >= model.DateFrom)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.StorekeeperId.HasValue)
{

View File

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace CarCenterDatabaseImplement.Migrations
{
[DbContext(typeof(CarCenterDatabase))]
[Migration("20240528175849_Initia8")]
partial class Initia8
[Migration("20240529114613_test3")]
partial class test3
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -32,6 +32,9 @@ namespace CarCenterDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("EquipmentPackage")
.HasColumnType("integer");
@ -66,6 +69,9 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<int>("CarClass")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("FeatureID")
.HasColumnType("integer");

View File

@ -6,7 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace CarCenterDatabaseImplement.Migrations
{
public partial class Initia8 : Migration
public partial class test3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@ -16,6 +16,7 @@ namespace CarCenterDatabaseImplement.Migrations
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
EquipmentPackage = table.Column<int>(type: "integer", nullable: false),
TirePackage = table.Column<int>(type: "integer", nullable: false),
@ -181,6 +182,7 @@ namespace CarCenterDatabaseImplement.Migrations
Year = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
VINnumber = table.Column<long>(type: "bigint", nullable: false),
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
FeatureID = table.Column<int>(type: "integer", nullable: false),
OrderId = table.Column<int>(type: "integer", nullable: true)
},

View File

@ -30,6 +30,9 @@ namespace CarCenterDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("EquipmentPackage")
.HasColumnType("integer");
@ -64,6 +67,9 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<int>("CarClass")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("FeatureID")
.HasColumnType("integer");

View File

@ -16,6 +16,8 @@ namespace CarCenterDatabaseImplement.Models
public class Bundling : IBundlingModel
{
public int Id { get; private set; }
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
public int StorekeeperId { get; set; }
[Required]
public EquipmentPackage EquipmentPackage { get; set; } = EquipmentPackage.Неизвестно;
@ -42,7 +44,8 @@ namespace CarCenterDatabaseImplement.Models
EquipmentPackage = model.EquipmentPackage,
TirePackage = model.TirePackage,
ToolKit = model.ToolKit,
Price = model.Price,
Price = model.Price,
DateCreate = model.DateCreate,
};
}
public static Bundling Create(BundlingViewModel model)
@ -55,6 +58,7 @@ namespace CarCenterDatabaseImplement.Models
TirePackage = model.TirePackage,
ToolKit = model.ToolKit,
Price = model.Price,
DateCreate = model.DateCreate,
};
}
public void Update(BundlingBindingModel model)
@ -63,6 +67,7 @@ namespace CarCenterDatabaseImplement.Models
{
return;
}
DateCreate = model.DateCreate;
StorekeeperId = model.StorekeeperId;
EquipmentPackage = model.EquipmentPackage;
TirePackage = model.TirePackage;
@ -76,7 +81,8 @@ namespace CarCenterDatabaseImplement.Models
EquipmentPackage = EquipmentPackage,
TirePackage = TirePackage,
ToolKit = ToolKit,
Price = Price,
Price = Price,
DateCreate = DateCreate,
};
}
}

View File

@ -30,7 +30,9 @@ namespace CarCenterDatabaseImplement.Models
public double Price { get; set; }
[Required]
public long VINnumber { get; set; }
[Required]
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
[Required]
public int FeatureID { get; set; }
public virtual Storekeeper Storekeeper { get; set; }
public virtual Feature Feature { get; set; }
@ -69,7 +71,9 @@ namespace CarCenterDatabaseImplement.Models
Price = model.Price,
VINnumber = model.VINnumber,
FeatureID = model.FeatureID,
Bundlings = model.CarBundlings.Select(x => new CarBundling
DateCreate = model.DateCreate,
Bundlings = model.CarBundlings.Select(x => new CarBundling
{
Bundling = context.Bundlings.First(y => y.Id == x.Key)
}).ToList()
@ -104,6 +108,7 @@ namespace CarCenterDatabaseImplement.Models
CarClass = model.CarClass;
Year = model.Year;
Price = model.Price;
DateCreate = model.DateCreate;
VINnumber = model.VINnumber;
FeatureID = model.FeatureID;
}
@ -120,6 +125,7 @@ namespace CarCenterDatabaseImplement.Models
VINnumber = VINnumber,
FeatureID = FeatureID,
CarBundlings = CarBundlings,
DateCreate = DateCreate,
};
}
}

View File

@ -16,4 +16,10 @@
<Folder Include="wwwroot\Images\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.26" />
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

View File

@ -106,9 +106,11 @@ namespace CarCenterStorekeeperApp.Controllers
[HttpPost]
public IActionResult CreateBundling(BundlingBindingModel model)
{
if (model.Id == 0)
{
model.StorekeeperId = UserStorekeeper.user!.Id;
model.DateCreate = DateTime.Now;
model.StorekeeperId = UserStorekeeper.user!.Id;
if (_data.CreateBundling(model))
return RedirectToAction("IndexBundling");
}
@ -211,7 +213,8 @@ namespace CarCenterStorekeeperApp.Controllers
model.CarBrand = CarBrand;
model.CarClass = CarClass;
model.FeatureID = FeatureId;
model.Model = Model;
model.DateCreate = DateTime.Now;
model.Model = Model;
model.StorekeeperId = UserStorekeeper.user!.Id;
var bundlings = _data.GetBundlings(UserStorekeeper.user!.Id);
double sum = 0;
@ -274,8 +277,138 @@ namespace CarCenterStorekeeperApp.Controllers
}
return View(user);
}
[HttpGet]
public IActionResult BundlingTimeChoose()
{
if (!IsLoggedIn)
return RedirectToAction("IndexNonReg");
return View();
}
[HttpPost]
public IActionResult SendReport(DateTime startDate, DateTime endDate)
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
return Ok();
}
[HttpGet]
public IActionResult BundlingTimeReport()
{
var startDateStr = HttpContext.Session.GetString("StartDate");
var endDateStr = HttpContext.Session.GetString("EndDate");
if (string.IsNullOrEmpty(startDateStr) || string.IsNullOrEmpty(endDateStr))
{
return RedirectToAction("BundlingTimeChoose");
}
var startDate = DateTime.Parse(startDateStr);
var endDate = DateTime.Parse(endDateStr).AddDays(1);
var values = _data.GetTimeReport(startDate, endDate, UserId);
ViewBag.StartDate = startDate;
ViewBag.EndDate = endDate;
return View(values);
}
[HttpPost]
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
{
if (!IsLoggedIn)
return RedirectToAction("IndexNonReg");
HttpContext.Session.SetString("StartDate", startDate.ToString("yyyy-MM-dd"));
HttpContext.Session.SetString("EndDate", endDate.ToString("yyyy-MM-dd"));
return RedirectToAction("BundlingTimeReport");
}
[HttpPost]
public void BundlingTimeMail()
{
var startDateStr = HttpContext.Session.GetString("StartDate");
var endDateStr = HttpContext.Session.GetString("EndDate");
var startDate = DateTime.Parse(startDateStr);
var endDate = DateTime.Parse(endDateStr).AddDays(1);
using (MemoryStream memoryStream = new MemoryStream())
{
_data.SendMailReport(startDate, endDate, UserId, memoryStream);
}
Response.Redirect("BundlingTimeReport");
}
[HttpGet]
public IActionResult CarPresaleChoose()
{
if (!IsLoggedIn)
return RedirectToAction("IndexNonReg");
var details = _data.GetCars(UserId);
return View(details);
}
[HttpPost]
public IActionResult CarPresaleChoose(List<int> selectedItems, string reportType)
{
string value = string.Join("/", selectedItems);
HttpContext.Session.SetString("Cars", value);
if (reportType.Equals("default"))
return RedirectToAction("CarPresaleReport");
else if (reportType.Equals("excel"))
return RedirectToAction("ExcelGenerate");
else
return RedirectToAction("WordGenerate");
}
public async Task<IActionResult> ExcelGenerate()
{
var value = HttpContext.Session.GetString("Cars");
if (value != null)
{
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
using (MemoryStream memoryStream = new MemoryStream())
{
_data.SaveReportExcel(rawReports, memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
var outputStream = new MemoryStream();
await memoryStream.CopyToAsync(outputStream);
outputStream.Seek(0, SeekOrigin.Begin);
return File(outputStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ReportExcel.xlsx");
}
}
return RedirectToAction("CarPresaleChoose");
}
public async Task<IActionResult> WordGenerate()
{
var value = HttpContext.Session.GetString("Cars");
if (value != null)
{
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
using (MemoryStream memoryStream = new MemoryStream())
{
_data.SaveReportWord(rawReports, memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
var outputStream = new MemoryStream();
await memoryStream.CopyToAsync(outputStream);
outputStream.Seek(0, SeekOrigin.Begin);
return File(outputStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ReportWord.docx");
}
}
return RedirectToAction("CarPresaleChoose");
}
[HttpGet]
public IActionResult CarPresaleReport()
{
var value = HttpContext.Session.GetString("Cars");
if (value != null)
{
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
var reports = _data.GetPresaleReports(rawReports);
return View(reports);
}
return View(new List<ReportCarViewModel>());
}
public IActionResult ReportMenu()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });

View File

@ -12,7 +12,8 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient<IBundlingStorage, BundlingStorage>();
builder.Services.AddTransient<ICarStorage, CarStorage>();
@ -36,8 +37,24 @@ builder.Services.AddTransient<AbstractSaveToPdfStorekeeper, SaveToPdfStorekeeper
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
builder.Services.AddTransient<StorekeeperData>();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
var app = builder.Build();
var mailSender = app.Services.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new()
{
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
});
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
@ -51,7 +68,7 @@ app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseSession();
app.UseAuthorization();
app.MapControllerRoute(

View File

@ -3,6 +3,9 @@ using CarCenterContracts.ViewModels;
using CarCenterContracts.BindingModels;
using CarCenterContracts.StoragesContracts;
using CarCenterContracts.SearchModels;
using CarCenterBusinessLogic.MailWorker;
using CarCenterBusinessLogic.OfficePackage;
using ImplementerApp;
namespace StorekeeperApp
{
@ -13,15 +16,33 @@ namespace StorekeeperApp
private readonly IBundlingLogic _bundlingLogic;
private readonly IFeatureLogic _featureLogic;
private readonly ICarLogic _carLogic;
private readonly IPresaleLogic _presaleLogic;
private readonly IOrderLogic _orderLogic;
private readonly AbstractSaveToExcelStorekeeper _excel;
private readonly AbstractSaveToWordStorekeeper _word;
private readonly AbstractSaveToPdfStorekeeper _pdf;
private readonly AbstractMailWorker _mail;
public StorekeeperData(ILogger<StorekeeperData> logger, IStorekeeperLogic storekeeperLogic, IBundlingLogic bundlingLogic, IFeatureLogic featureLogic, ICarLogic carLogic)
public StorekeeperData(ILogger<StorekeeperData> logger, IStorekeeperLogic storekeeperLogic,
IBundlingLogic bundlingLogic, IFeatureLogic featureLogic, ICarLogic carLogic,
IPresaleLogic presaleLogic, IOrderLogic orderLogic,
AbstractSaveToExcelStorekeeper excel,
AbstractSaveToWordStorekeeper word,
AbstractMailWorker mail,
AbstractSaveToPdfStorekeeper pdf)
{
_logger = logger;
_storekeeperLogic = storekeeperLogic;
_bundlingLogic = bundlingLogic;
_featureLogic = featureLogic;
_carLogic = carLogic;
}
_presaleLogic = presaleLogic;
_orderLogic = orderLogic;
_excel = excel;
_word = word;
_mail = mail;
_pdf = pdf;
}
public StorekeeperViewModel? Login(string email, string password)
{
@ -82,7 +103,7 @@ namespace StorekeeperApp
}
public List<CarViewModel>? GetCars(int userId)
{
return _carLogic.ReadList(new() { StorekeeperId = userId });
return _carLogic.ReadList(new CarSearchModel() { StorekeeperId = userId });
}
public CarViewModel? GetCar(int id)
{
@ -100,6 +121,95 @@ namespace StorekeeperApp
{
return _carLogic.Delete(new() { Id = carId });
}
public List<ReportBundlingViewModel> GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId)
{
var bundlings = _bundlingLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, StorekeeperId = UserId });
if (bundlings == null)
return new();
List<ReportBundlingViewModel> bundlingTimeReports = new List<ReportBundlingViewModel>();
foreach (var bundling in bundlings)
{
var report = new ReportBundlingViewModel();
report.BundlingId = bundling.Id;
var features = _featureLogic.ReadList(new() { BundlingId = bundling.Id, StorekeeperId = UserId });
if (features != null)
report.Features = features.Select(p => p.Id.ToString()).ToList();
var orders = _orderLogic.ReadList(new() { BundlingId = bundling.Id, WorkerId = UserId });
if (orders != null)
report.Orders = orders.Select(p => p.Id.ToString()).ToList();
bundlingTimeReports.Add(report);
}
return bundlingTimeReports;
}
public List<PresaleViewModel>? GetPresales()
{
return _presaleLogic.ReadList(null);
}
public List<OrderViewModel>? GetOrders()
{
return _orderLogic.ReadList(null);
}
public List<ReportCarViewModel>? GetPresaleReports(List<int> bundlings)
{
List<ReportCarViewModel> reports = new();
foreach (int i in bundlings)
{
ReportCarViewModel report = new();
var bundling = _bundlingLogic.ReadElement(new() { Id = i });
report.CarId = bundling!.Id;
var presales = _presaleLogic.ReadList(new() { CarId = i });
if (presales != null)
report.Presales = presales.Select(w => w.Id.ToString()).ToList();
reports.Add(report);
}
return reports;
}
public void SaveReportExcel(List<int> bundlings, MemoryStream stream)
{
var reports = GetPresaleReports(bundlings);
if (reports == null)
return;
int maxsize = 0;
foreach (var report in reports) { maxsize = Math.Max(maxsize, report.Presales.Count); }
_excel.CreateReport(new()
{
carPresalesReport = reports,
Title = "Отчет Номер_автомобиля предпродажные",
memoryStream = stream,
maxleng = maxsize
});
}
public void SaveReportWord(List<int> bundlings, MemoryStream stream)
{
var reports = GetPresaleReports(bundlings);
if (reports == null)
return;
_word.CreateDoc(new()
{
memoryStream = stream,
Title = "Отчет.Номер автомобиля: - предпродажные",
carPresalesReport = reports
});
}
public void SendMailReport(DateTime? startDate, DateTime? endDate, int UserId, MemoryStream stream)
{
var reports = GetTimeReport(startDate, endDate, UserId);
if (reports == null)
return;
_pdf.CreateDoc(new()
{
DateFrom = startDate!.Value,
DateTo = endDate!.Value,
FileName = stream,
reportBundling = reports,
Title = "Отчет"
});
byte[] report = stream.GetBuffer();
_mail.MailSendAsync(new() { MailAddress = UserStorekeeper.user!.Email, Subject = "Отчет", FileName = "PdfReport.pdf", Pdf = report });
}
}
}

View File

@ -0,0 +1,85 @@
@{
ViewData["Title"] = "Создание отчета";
}
<div class="text-center">
<h2 class="display-4">Создание отчета</h2>
</div>
<form id="TimeReportWeb" asp-controller="Home" method="post">
<div class="row mb-3">
<div class="col-4 text-right">
<label for="startDate">Дата начала:</label>
</div>
<div class="col-6">
<input type="date" id="startDate" name="startDate" class="form-control" required />
<span id="startDateError" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<div class="col-4 text-right">
<label for="endDate">Дата окончания:</label>
</div>
<div class="col-6">
<input type="date" id="endDate" name="endDate" class="form-control" required />
<span id="endDateError" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<div class="col-6 text-right">
<button type="button" id="generateReport" class="btn btn-primary">Создать отчет</button>
</div>
</div>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
function validateDates() {
var startDate = $('#startDate').val();
var endDate = $('#endDate').val();
var today = new Date().toISOString().split('T')[0];
var isValid = true;
$('#startDateError').text('');
$('#endDateError').text('');
if (!startDate) {
$('#startDateError').text('Пожалуйста, выберите дату начала.');
isValid = false;
}
if (!endDate) {
$('#endDateError').text('Пожалуйста, выберите дату окончания.');
isValid = false;
}
if (isValid) {
if (startDate > today) {
$('#startDateError').text('Дата начала не может быть больше сегодняшней даты.');
isValid = false;
}
if (endDate > today) {
$('#endDateError').text('Дата окончания не может быть больше сегодняшней даты.');
isValid = false;
}
if (startDate > endDate) {
$('#endDateError').text('Дата окончания не может быть раньше даты начала.');
isValid = false;
}
}
return isValid;
}
$('#generateReport').click(function () {
if (validateDates()) {
var formData = $('#TimeReportWeb').serialize();
$.post('/Home/TimeReportWeb', formData, function (response) {
window.location.href = '/Home/BundlingTimeReport';
}).fail(function () {
alert('Произошла ошибка при создании отчета.');
});
}
});
});
</script>

View File

@ -0,0 +1,50 @@
@using CarCenterContracts.ViewModels
@model List<ReportBundlingViewModel>
@{
ViewData["Title"] = "Bundlings on Time Bundlings";
}
<div class="text-center">
<h1 class="display-4">Список комплектаций в диапазоне времени</h1>
</div>
<form asp-action="BundlingTimeMail" asp-controller="Home" method="post">
<button type="submit" class="btn btn-primary">Отправить отчет на почту</button>
</form>
<table class="table">
<thead>
<tr>
<th>Комплектация</th>
<th>Заказ</th>
<th>Особенность</th>
</tr>
</thead>
<tbody>
@foreach (var detail in Model)
{
<tr>
<td>@detail.BundlingId</td>
<td>
<ul>
@foreach (var product in detail.Orders)
{
<li>@product</li>
}
</ul>
</td>
<td>
<ul>
@foreach (var production in detail.Features)
{
<li>@production</li>
}
</ul>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,54 @@
@using CarCenterContracts.ViewModels;
@model List<CarViewModel>
@{
ViewData["Title"] = "Выбор машин для отчета";
}
<h2>Выберите детали для отчета</h2>
<form asp-controller="Home" asp-action="CarPresaleChoose" method="post" onsubmit="return validateForm()">
<table class="table">
<thead>
<tr>
<th>Select</th>
<th>Выберите автомобиль с номером:</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.Count; i++)
{
<tr>
<td>
<input type="checkbox" name="selectedItems" value="@Model[i].Id" />
</td>
<td>@Model[i].Id</td>
</tr>
}
</tbody>
</table>
<input type="hidden" id="reportType" name="reportType" value="default" />
<button type="submit" class="btn btn-primary" onclick="setReportType('default')">Сгенерировать отчет</button>
<button type="submit" class="btn btn-secondary" onclick="setReportType('excel')">Сгенерировать отчет в Excel</button>
<button type="submit" class="btn btn-secondary" onclick="setReportType('word')">Сгенерировать отчет в Word</button>
<div id="validationMessage" style="display:none;color:red;">Пожалуйста, выберите хотя бы одну деталь.</div>
</form>
@section Scripts {
<script>
function validateForm() {
var checkboxes = document.querySelectorAll('input[name="selectedItems"]:checked');
if (checkboxes.length === 0) {
document.getElementById('validationMessage').style.display = 'block';
return false;
} else {
document.getElementById('validationMessage').style.display = 'none';
return true;
}
}
function setReportType(type) {
document.getElementById('reportType').value = type;
}
</script>
}

View File

@ -0,0 +1,35 @@
@using CarCenterContracts.ViewModels
@model List<ReportCarViewModel>
@{
ViewData["Title"] = "Отчет машина - предпродажные";
}
<div class="text-center">
<h1 class="display-4">Список машин с предпродажными</h1>
</div>
<table class="table">
<thead>
<tr>
<th>Машина</th>
<th>Предпродажные</th>
</tr>
</thead>
<tbody>
@foreach (var detail in Model)
{
<tr>
<td>@detail.CarId</td>
<td>
<ul>
@foreach (var workshop in detail.Presales)
{
<li>@workshop</li>
}
</ul>
</td>
</tr>
}
</tbody>
</table>

View File

@ -9,7 +9,7 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexFeature">Особенности</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexCar">Автомобили</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
@* <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportsMenu">Меню отчетов</a> *@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportMenu">Меню отчетов</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a>
</div>

View File

@ -0,0 +1,11 @@
@{
ViewData["Title"] = "Report Menu";
}
<div class="text-center">
<h1 class="display-4">Меню создания отчетов</h1>
<div class="list-group">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CarPresaleChoose">Отчет машина - предпродажные</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="BundlingTimeChoose">Отчет по комплектаций по покупкам и особенностям</a>
</div>
</div>

View File

@ -5,5 +5,12 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
"AllowedHosts": "*",
"SmtpClientHost": "smtp.mail.ru",
"SmtpClientPort": "587",
"PopHost": "pop.mail.ru",
"PopPort": "995",
"MailLogin": "aboba.russian@mail.ru",
"MailPassword": "5qnSMftuH4MPnFMyW7rD"
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="c:/temp/GoWorkCourse.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
</layout>
</appender>
<root>
<level value="TRACE" />
<appender-ref ref="RollingFile" />
</root>
</log4net>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long