Работает list
This commit is contained in:
parent
8207be80a7
commit
3134b5f6e1
@ -1,4 +1,5 @@
|
|||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.SearchModels;
|
using CaseAccountingContracts.SearchModels;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
@ -17,32 +18,66 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
private readonly ISpecializationStorage _specializationStorage;
|
private readonly ISpecializationStorage _specializationStorage;
|
||||||
private readonly IHearingStorage _hearingStorage;
|
private readonly IHearingStorage _hearingStorage;
|
||||||
private readonly ILawyerStorage _lawyerStorage;
|
private readonly ILawyerStorage _lawyerStorage;
|
||||||
|
private readonly WordBuilderProvider _wordBuilder;
|
||||||
|
private readonly ExcelBuilderProvider _excelBuilder;
|
||||||
|
/*private readonly PdfBuilderProvider _pdfBuilder;
|
||||||
|
private readonly MailSender _mailSender;*/
|
||||||
|
|
||||||
public ReportProviderLogic(ICaseStorage caseStorage, ISpecializationStorage specializationStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage)
|
public ReportProviderLogic(ICaseStorage caseStorage, ISpecializationStorage specializationStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, WordBuilderProvider wordBuilder, ExcelBuilderProvider excelBuilder)
|
||||||
{
|
{
|
||||||
_caseStorage = caseStorage ?? throw new ArgumentNullException(nameof(caseStorage));
|
_caseStorage = caseStorage ?? throw new ArgumentNullException(nameof(caseStorage));
|
||||||
_specializationStorage = specializationStorage ?? throw new ArgumentNullException(nameof(specializationStorage));
|
_specializationStorage = specializationStorage ?? throw new ArgumentNullException(nameof(specializationStorage));
|
||||||
_hearingStorage = hearingStorage ?? throw new ArgumentNullException(nameof(hearingStorage));
|
_hearingStorage = hearingStorage ?? throw new ArgumentNullException(nameof(hearingStorage));
|
||||||
_lawyerStorage = lawyerStorage ?? throw new ArgumentNullException(nameof(lawyerStorage));
|
_lawyerStorage = lawyerStorage ?? throw new ArgumentNullException(nameof(lawyerStorage));
|
||||||
|
_wordBuilder = wordBuilder ?? throw new ArgumentNullException(nameof(wordBuilder));
|
||||||
|
_excelBuilder = excelBuilder ?? throw new ArgumentNullException(nameof(excelBuilder));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportCaseSpecializationViewModel> GetCaseSpecialization(List<CaseViewModel> models)
|
public List<ReportCaseSpecializationViewModel> GetCaseSpecialization(List<CaseViewModel> models)
|
||||||
{
|
{
|
||||||
var сases = new List<CaseViewModel>();
|
List<ReportCaseSpecializationViewModel> list = new();
|
||||||
foreach (var model in models)
|
foreach (var model in models)
|
||||||
сases.Add(_caseStorage.GetElement(new CaseSearchModel { Id = model.Id }));
|
{
|
||||||
return сases.Select(x => new ReportCaseSpecializationViewModel {
|
var specialization = _specializationStorage.GetElement(new SpecializationSearchModel { Id = model.SpecializationId });
|
||||||
CaseName = x.Name,
|
var caseModel = _caseStorage.GetElement(new CaseSearchModel { Id = model.Id });
|
||||||
Applicant = x.Applicant,
|
if (specialization == null)
|
||||||
Defendant = x.Defendant,
|
{
|
||||||
Date = x.Date,
|
throw new Exception("Некоректные данные по специализации");
|
||||||
Specialization = x.Specialization,
|
}
|
||||||
}).ToList();
|
if (caseModel == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Некоректные данные по делу");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasSpec = false;
|
||||||
|
if (list.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var report in list)
|
||||||
|
{
|
||||||
|
if (hasSpec = report.Specialization.Equals(specialization.Name))
|
||||||
|
{
|
||||||
|
report.Cases.Add("Дело #" + caseModel.Id.ToString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasSpec)
|
||||||
|
{
|
||||||
|
var newElement = new ReportCaseSpecializationViewModel
|
||||||
|
{
|
||||||
|
Specialization = specialization.Name,
|
||||||
|
Cases = new()
|
||||||
|
};
|
||||||
|
newElement.Cases.Add("Дело #" + caseModel.Id.ToString());
|
||||||
|
list.Add(newElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model)
|
public List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
var hearings = _hearingStorage
|
/*var hearings = _hearingStorage
|
||||||
.GetFilteredList(new HearingSearchModel { UserId = model.UserId})
|
.GetFilteredList(new HearingSearchModel { UserId = model.UserId})
|
||||||
.Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date);
|
.Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date);
|
||||||
var list = new List<ReportHearingLawyerViewModel>();
|
var list = new List<ReportHearingLawyerViewModel>();
|
||||||
@ -60,25 +95,50 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
list.Add(record);
|
list.Add(record);
|
||||||
}
|
}
|
||||||
return list;
|
return list;*/
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveCaseSpecializationToExcelFile(ReportBindingModel model)
|
public byte[] SaveListFile(CaseSpecializationListBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
byte[] file = Array.Empty<byte>();
|
||||||
//TODO
|
|
||||||
|
string title = "Список дисциплин по выбранным студентам";
|
||||||
|
|
||||||
|
if (model.FileType == "docx")
|
||||||
|
{
|
||||||
|
_wordBuilder.CreateDocument();
|
||||||
|
_wordBuilder.CreateTitle(title);
|
||||||
|
_wordBuilder.CreateCaseSpecializationTable(GetCaseSpecialization(model.Cases));
|
||||||
|
file = _wordBuilder.GetFile();
|
||||||
|
}
|
||||||
|
else if (model.FileType == "xlsx")
|
||||||
|
{
|
||||||
|
_excelBuilder.CreateDocument();
|
||||||
|
_excelBuilder.CreateTitle(title);
|
||||||
|
_excelBuilder.CreateCaseSpecializationTable(GetCaseSpecialization(model.Cases));
|
||||||
|
file = _excelBuilder.GetFile();
|
||||||
|
}
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveCaseSpecializationToWordFile(ReportBindingModel model)
|
/*public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
byte[] file = _pdfBuilder.GetEducationStatusReportFile(new()
|
||||||
//TODO
|
{
|
||||||
}
|
Title = "Отчет по статусам обучения",
|
||||||
|
DateFrom = reportModel.DateFrom,
|
||||||
public void SaveHearingLawyerToPdfFile(ReportBindingModel model)
|
DateTo = reportModel.DateTo,
|
||||||
{
|
Records = GetStreamStudentEdStatPeriod(reportModel)
|
||||||
throw new NotImplementedException();
|
});
|
||||||
//TODO
|
_mailSender.SendMailAsync(new()
|
||||||
}
|
{
|
||||||
|
MailAddress = reportModel.UserEmail,
|
||||||
|
Subject = "Отчет по статусам обучения",
|
||||||
|
Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
|
||||||
|
$"по {reportModel.DateTo.ToShortDateString()}.",
|
||||||
|
File = file
|
||||||
|
});
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateLawyersHearingsTable(List<ReportLawyerHearingViewModel> data)
|
/*public void CreateLawyersHearingsTable(List<ReportLawyerHearingViewModel> data)
|
||||||
{
|
{
|
||||||
if (worksheet == null || shareStringPart == null)
|
if (worksheet == null || shareStringPart == null)
|
||||||
{
|
{
|
||||||
@ -357,6 +357,6 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
currentRow++;
|
currentRow++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using CaseAccountingBusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using CaseAccountingContracts.ViewModels;
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
using ComputersShopBusinessLogic.OfficePackage.HelperModels;
|
||||||
using DocumentFormat.OpenXml;
|
using DocumentFormat.OpenXml;
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
@ -285,7 +287,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateStudentsDisciplineTable(List<ReportStudentsDisciplineViewModel> data)
|
public void CreateCaseSpecializationTable(List<ReportCaseSpecializationViewModel> data)
|
||||||
{
|
{
|
||||||
if (worksheet == null || shareStringPart == null)
|
if (worksheet == null || shareStringPart == null)
|
||||||
{
|
{
|
||||||
@ -303,25 +305,25 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = 2,
|
RowIndex = 2,
|
||||||
Text = "Студент",
|
Text = "Специализация:",
|
||||||
StyleIndex = 2
|
StyleIndex = 2
|
||||||
});
|
});
|
||||||
InsertCellInWorksheet(new ExcelCellData
|
InsertCellInWorksheet(new ExcelCellData
|
||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = 2,
|
RowIndex = 2,
|
||||||
Text = "Дисциплина",
|
Text = "Дела:",
|
||||||
StyleIndex = 2
|
StyleIndex = 2
|
||||||
});
|
});
|
||||||
|
|
||||||
uint currentRow = 3;
|
uint currentRow = 3;
|
||||||
foreach (ReportStudentsDisciplineViewModel student in data)
|
foreach (ReportCaseSpecializationViewModel specialization in data)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellData
|
InsertCellInWorksheet(new ExcelCellData
|
||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = currentRow,
|
RowIndex = currentRow,
|
||||||
Text = student.Student,
|
Text = specialization.Specialization,
|
||||||
StyleIndex = 1
|
StyleIndex = 1
|
||||||
});
|
});
|
||||||
InsertCellInWorksheet(new ExcelCellData
|
InsertCellInWorksheet(new ExcelCellData
|
||||||
@ -332,7 +334,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
StyleIndex = 1
|
StyleIndex = 1
|
||||||
});
|
});
|
||||||
currentRow++;
|
currentRow++;
|
||||||
foreach (string discipline in student.Disciplines)
|
foreach (string caseName in specialization.Cases)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellData
|
InsertCellInWorksheet(new ExcelCellData
|
||||||
{
|
{
|
||||||
@ -345,7 +347,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = currentRow,
|
RowIndex = currentRow,
|
||||||
Text = discipline,
|
Text = caseName,
|
||||||
StyleIndex = 1
|
StyleIndex = 1
|
||||||
});
|
});
|
||||||
currentRow++;
|
currentRow++;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using UniversityBusinessLogic.OfficePackage.Models;
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using UniversityContracts.ViewModels;
|
using CaseAccountingContracts.ViewModels;
|
||||||
using DocumentFormat.OpenXml;
|
using DocumentFormat.OpenXml;
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
@ -141,26 +141,26 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateStudentsDisciplineTable(List<ReportStudentsDisciplineViewModel> data)
|
public void CreateCaseSpecializationTable(List<ReportCaseSpecializationViewModel> data)
|
||||||
{
|
{
|
||||||
List<List<string>> rows = new();
|
List<List<string>> rows = new();
|
||||||
foreach (ReportStudentsDisciplineViewModel student in data)
|
foreach (ReportCaseSpecializationViewModel specializationl in data)
|
||||||
{
|
{
|
||||||
List<string> studentCells = new() { student.Student, "" };
|
List<string> specializationlCells = new() { specializationl.Specialization, "" };
|
||||||
rows.Add(studentCells);
|
rows.Add(specializationlCells);
|
||||||
List<string> disciplineCells;
|
List<string> caseCells;
|
||||||
foreach (string discipline in student.Disciplines)
|
foreach (string caseString in specializationl.Cases)
|
||||||
{
|
{
|
||||||
disciplineCells = new() { "", discipline };
|
caseCells = new() { "", caseString };
|
||||||
rows.Add(disciplineCells);
|
rows.Add(caseCells);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WordTableData wordTable = new()
|
WordTableData wordTable = new()
|
||||||
{
|
{
|
||||||
Columns = new List<(string, int)>()
|
Columns = new List<(string, int)>()
|
||||||
{
|
{
|
||||||
("Студент", 3000),
|
("Специализация", 3000),
|
||||||
("Дисциплина", 3000)
|
("Дела", 3000)
|
||||||
},
|
},
|
||||||
Rows = rows
|
Rows = rows
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CaseAccountingContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class CaseSpecializationListBindingModel
|
||||||
|
{
|
||||||
|
public string FileType { get; set; } = string.Empty;
|
||||||
|
public List<CaseViewModel> Cases { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -14,10 +14,6 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
|||||||
|
|
||||||
List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model);
|
List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model);
|
||||||
|
|
||||||
void SaveCaseSpecializationToWordFile(ReportBindingModel model);
|
byte[] SaveListFile(CaseSpecializationListBindingModel model);
|
||||||
|
|
||||||
void SaveCaseSpecializationToExcelFile(ReportBindingModel model);
|
|
||||||
|
|
||||||
void SaveHearingLawyerToPdfFile(ReportBindingModel model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,7 @@ namespace CaseAccountingContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportCaseSpecializationViewModel
|
public class ReportCaseSpecializationViewModel
|
||||||
{
|
{
|
||||||
public string CaseName { get; set; } = string.Empty;
|
|
||||||
public string Applicant { get; set; } = string.Empty;
|
|
||||||
public string Defendant { get; set; } = string.Empty;
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
public string Specialization { get; set; } = string.Empty;
|
public string Specialization { get; set; } = string.Empty;
|
||||||
|
public List<string> Cases { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
|
|||||||
Host=localhost;
|
Host=localhost;
|
||||||
Port=5432;
|
Port=5432;
|
||||||
Database=CaseAccountingDatabase;
|
Database=CaseAccountingDatabase;
|
||||||
Username=postgres;
|
Username=courseuser;
|
||||||
Password=postgres");
|
Password=courseuser");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -43,5 +43,25 @@ namespace CaseAccountingProviderView
|
|||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static O? PostRequestWithResult<I, O>(string requestUrl, I model)
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = _user.PostAsync(requestUrl, data);
|
||||||
|
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
|
if (response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var temp = JsonConvert.DeserializeObject<O>(result);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,25 @@ namespace CaseAccountingProviderView.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
public IActionResult SpecializationCaselist()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public int[]? SpecializationCaselist([FromBody] CaseSpecializationListBindingModel listModel)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Array.Empty<int>();
|
||||||
|
}
|
||||||
|
byte[]? file = APIUser.PostRequestWithResult<CaseSpecializationListBindingModel, byte[]>
|
||||||
|
("api/reportprovider/specializationcaselist", listModel);
|
||||||
|
return file!.Select(b => (int)b).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
public void Login(string login, string password)
|
public void Login(string login, string password)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||||
@ -73,15 +91,8 @@ namespace CaseAccountingProviderView.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
/*if (page == 0)
|
|
||||||
{
|
|
||||||
page = 1;
|
|
||||||
}*/
|
|
||||||
ViewBag.Cases = APIUser.GetRequest<List<CaseViewModel>>
|
ViewBag.Cases = APIUser.GetRequest<List<CaseViewModel>>
|
||||||
($"api/case/getallbyuser?userId={APIUser.User.Id}");
|
($"api/case/getallbyuser?userId={APIUser.User.Id}");
|
||||||
/*ViewBag.Page = page;
|
|
||||||
ViewBag.NumberOfPages = APIUser.GetRequest<int>
|
|
||||||
($"api/student/getnumberofpages?userId={APIUser.User.Id}");*/
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,16 +10,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<select id="file-type">
|
<select id="file-type" class="form-control mb-3">
|
||||||
<option>docx</option>
|
<option>docx</option>
|
||||||
<option>xlsx</option>
|
<option>xlsx</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<button id="create-button" type="button" class="button-primary text-button">
|
<button id="create-button" type="button" class="btn btn-success text-button">
|
||||||
Показать итоговый вариант
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button id="save-button" type="button" class="button-primary text-button">
|
|
||||||
Сохранить результат
|
Сохранить результат
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@ -28,11 +24,12 @@
|
|||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Имя</th>
|
<th>Номер дела:</th>
|
||||||
<th>Фамилия</th>
|
<th>Истец:</th>
|
||||||
<th>Дата рождения</th>
|
<th>Ответчик:</th>
|
||||||
<th>Номер студ. билета</th>
|
<th>Дата составления:</th>
|
||||||
<th>Статус обучения</th>
|
<th>Примечание:</th>
|
||||||
|
<th>Специализация:</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="scrollable-table__tbody">
|
<tbody id="scrollable-table__tbody">
|
@ -21,7 +21,7 @@
|
|||||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Cases">Дела</a>
|
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Cases">Дела</a>
|
||||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Deals">Договора</a>
|
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Deals">Договора</a>
|
||||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
|
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
|
||||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Получение список</a>
|
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="SpecializationCaselist">Получение список</a>
|
||||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Получение отчёта</a>
|
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Получение отчёта</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,91 @@
|
|||||||
|
const createBtn = document.getElementById("create-button")
|
||||||
|
const tbody = document.getElementById("scrollable-table__tbody")
|
||||||
|
const nameInput = document.getElementById("name-input")
|
||||||
|
var fileType = document.getElementById("file-type")
|
||||||
|
var cases = []
|
||||||
|
var dataArray = [];
|
||||||
|
const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||||
|
const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
|
||||||
|
window.addEventListener('load', async () => {
|
||||||
|
try {
|
||||||
|
await $.ajax({
|
||||||
|
url: `/case/getallbyuser`,
|
||||||
|
type: "GET",
|
||||||
|
contentType: "json"
|
||||||
|
}).done((result) => {
|
||||||
|
cases = result;
|
||||||
|
cases.forEach((caseModel) => {
|
||||||
|
const { id, name, applicant, defendant, annotation, date, specialization } = caseModel;
|
||||||
|
const row = tbody.insertRow();
|
||||||
|
row.setAttribute("data-id", id);
|
||||||
|
|
||||||
|
const cells = [name, applicant, defendant, annotation, date, specialization];
|
||||||
|
cells.forEach((value) => {
|
||||||
|
const cell = row.insertCell();
|
||||||
|
cell.textContent = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
createBtn.addEventListener('click', () => {
|
||||||
|
let listModel = {
|
||||||
|
"Cases": Array.from(dataArray),
|
||||||
|
"FileType": fileType.value
|
||||||
|
};
|
||||||
|
$.ajax({
|
||||||
|
url: "/home/specializationcaselist",
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/json",
|
||||||
|
data: JSON.stringify(listModel)
|
||||||
|
}).done((file) => {
|
||||||
|
let byteArray = new Uint8Array(file);
|
||||||
|
saveFile(byteArray, fileType);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
const saveFile = async function (bytes, fileType) {
|
||||||
|
if (window.showSaveFilePicker) {
|
||||||
|
let type;
|
||||||
|
if (fileType.value == "docx") {
|
||||||
|
type = {
|
||||||
|
description: "Microsoft Word (OpenXML)",
|
||||||
|
accept: { [wordMIME]: [".docx"] }
|
||||||
|
};
|
||||||
|
} else if (fileType.value == "xlsx") {
|
||||||
|
type = {
|
||||||
|
description: "Microsoft Excel (OpenXML)",
|
||||||
|
accept: { [excelMIME]: [".xlsx"] }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
suggestedName: `case-specialization-list.${fileType.value}`,
|
||||||
|
types: [type],
|
||||||
|
};
|
||||||
|
const handle = await showSaveFilePicker(opts);
|
||||||
|
const writable = await handle.createWritable();
|
||||||
|
await writable.write(bytes);
|
||||||
|
writable.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const addAndRemoveFromList = (row) => {
|
||||||
|
var id = parseInt(row.dataset.id);
|
||||||
|
console.log(cases.find(x => x.id === id))
|
||||||
|
var index = dataArray.indexOf(cases.find(x => x.id === id));
|
||||||
|
if (index === -1) {
|
||||||
|
dataArray.push(cases.find(x => x.id === id));
|
||||||
|
row.classList.add("bg-primary");
|
||||||
|
} else {
|
||||||
|
dataArray.splice(index, 1);
|
||||||
|
row.classList.remove("bg-primary");
|
||||||
|
}
|
||||||
|
console.log(dataArray);
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
using CaseAccountingContracts.BindingModels;
|
||||||
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CaseAccountingRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ReportProviderController : Controller
|
||||||
|
{
|
||||||
|
private readonly IReportProviderLogic reportLogic;
|
||||||
|
|
||||||
|
public ReportProviderController(IReportProviderLogic reportLogic)
|
||||||
|
{
|
||||||
|
this.reportLogic = reportLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public byte[] SpecializationCaselist(CaseSpecializationListBindingModel listModel)
|
||||||
|
{
|
||||||
|
byte[] file = reportLogic.SaveListFile(listModel);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using CaseAccountingBusinessLogic.BusinessLogics;
|
using CaseAccountingBusinessLogic.BusinessLogics;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
using CaseAccountingDataBaseImplement.Implements;
|
using CaseAccountingDataBaseImplement.Implements;
|
||||||
@ -26,6 +27,11 @@ builder.Services.AddTransient<ILawyerLogic, LawyerLogic>();
|
|||||||
builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
|
builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
|
||||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IReportProviderLogic, ReportProviderLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<WordBuilderProvider>();
|
||||||
|
builder.Services.AddTransient<ExcelBuilderProvider>();
|
||||||
|
|
||||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
Loading…
Reference in New Issue
Block a user