Не работает список
This commit is contained in:
parent
900c5f1fb4
commit
762525822b
@ -1,4 +1,6 @@
|
|||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.SearchModels;
|
using CaseAccountingContracts.SearchModels;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
@ -17,13 +19,18 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
private readonly IHearingStorage _hearingStorage;
|
private readonly IHearingStorage _hearingStorage;
|
||||||
private readonly ILawyerStorage _lawyerStorage;
|
private readonly ILawyerStorage _lawyerStorage;
|
||||||
private readonly ISpecializationStorage _specializationStorage;
|
private readonly ISpecializationStorage _specializationStorage;
|
||||||
|
private readonly WordBuilderCustomer _wordBuilder;
|
||||||
|
private readonly ExcelBuilderCustomer _excelBuilder;
|
||||||
|
|
||||||
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage)
|
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
||||||
|
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder)
|
||||||
{
|
{
|
||||||
_caseStorage = caseStorage;
|
_caseStorage = caseStorage;
|
||||||
_hearingStorage = hearingStorage;
|
_hearingStorage = hearingStorage;
|
||||||
_lawyerStorage = lawyerStorage;
|
_lawyerStorage = lawyerStorage;
|
||||||
_specializationStorage = specializationStorage;
|
_specializationStorage = specializationStorage;
|
||||||
|
_wordBuilder = wordBuilder;
|
||||||
|
_excelBuilder = excelBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||||
@ -47,32 +54,26 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<ReportLawyerHearingViewModel> GetLawyerHearing(List<LawyerViewModel> models)
|
public List<ReportLawyerHearingViewModel> GetLawyerHearing(List<LawyerViewModel> models)
|
||||||
{
|
{
|
||||||
var lawyers = new List<LawyerViewModel>();
|
throw new NotImplementedException();
|
||||||
foreach (var model in models)
|
}
|
||||||
{
|
|
||||||
lawyers.Add(_lawyerStorage.GetElement(new LawyerSearchModel { Id = model.Id}));
|
|
||||||
}
|
|
||||||
var list = new List<ReportLawyerHearingViewModel>();
|
|
||||||
|
|
||||||
foreach(var lawyer in lawyers)
|
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
||||||
|
{
|
||||||
|
var reportRecords = new List<ReportLawyerHearingViewModel>();
|
||||||
|
foreach (var lawyer in lawyers)
|
||||||
{
|
{
|
||||||
var record = new ReportLawyerHearingViewModel
|
var hearings = _lawyerStorage.GetLawyerCases(new() { Id = lawyer.Id })
|
||||||
|
.SelectMany(_case => _caseStorage.GetCaseHearings(new() { Id = _case.Id }))
|
||||||
|
.Select(hearing => hearing.Information)
|
||||||
|
.ToList();
|
||||||
|
ReportLawyerHearingViewModel reportRecord = new()
|
||||||
{
|
{
|
||||||
Name = lawyer.Name,
|
Lawyer = lawyer.Name + " " + lawyer.Surname + ", " + lawyer.Patronymic,
|
||||||
Surname = lawyer.Surname,
|
Hearings = hearings
|
||||||
Patronymic = lawyer.Patronymic,
|
|
||||||
Hearings = new List<(DateTime Date, string Information)>()
|
|
||||||
};
|
};
|
||||||
var cases = _caseStorage.GetFullList()
|
reportRecords.Add(reportRecord);
|
||||||
.Where(x => x.Lawyers.ContainsKey(lawyer.Id));
|
|
||||||
foreach (var _case in cases)
|
|
||||||
{
|
|
||||||
record.Hearings.Add((_hearingStorage.GetElement(new HearingSearchModel { CaseId = _case.Id}).Date,
|
|
||||||
_hearingStorage.GetElement(new HearingSearchModel { CaseId = _case.Id })?.Information ?? "Не удалось найти информацию."));
|
|
||||||
}
|
|
||||||
list.Add(record);
|
|
||||||
}
|
}
|
||||||
return list;
|
return reportRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
|
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
|
||||||
@ -89,5 +90,28 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] SaveListFile(LawyerHearingListBindingModel model)
|
||||||
|
{
|
||||||
|
byte[] file = Array.Empty<byte>();
|
||||||
|
|
||||||
|
string title = "Список слушаний по выбранным юристам";
|
||||||
|
|
||||||
|
if (model.FileType == "docx")
|
||||||
|
{
|
||||||
|
_wordBuilder.CreateDocument();
|
||||||
|
_wordBuilder.CreateTitle(title);
|
||||||
|
_wordBuilder.CreateLawyersHearingTable(GetLawyersHearing(model.Lawyers));
|
||||||
|
file = _wordBuilder.GetFile();
|
||||||
|
}
|
||||||
|
else if (model.FileType == "xlsx")
|
||||||
|
{
|
||||||
|
_excelBuilder.CreateDocument();
|
||||||
|
_excelBuilder.CreateTitle(title);
|
||||||
|
_excelBuilder.CreateLawyersHearingTable(GetLawyersHearing(model.Lawyers));
|
||||||
|
file = _excelBuilder.GetFile();
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
|
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\CaseAccountingDataBaseImplement\CaseAccountingDataBaseImplement.csproj" />
|
||||||
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
|
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
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;
|
||||||
@ -291,7 +290,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateLawyersHearingsTable(List<ReportLawyerHearingViewModel> data)
|
public void CreateLawyersHearingTable(List<ReportLawyerHearingViewModel> data)
|
||||||
{
|
{
|
||||||
if (worksheet == null || shareStringPart == null)
|
if (worksheet == null || shareStringPart == null)
|
||||||
{
|
{
|
||||||
@ -338,7 +337,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
StyleIndex = 1
|
StyleIndex = 1
|
||||||
});
|
});
|
||||||
currentRow++;
|
currentRow++;
|
||||||
foreach (string discipline in student.Disciplines)
|
foreach (string hearing in lawyer.Hearings)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellData
|
InsertCellInWorksheet(new ExcelCellData
|
||||||
{
|
{
|
||||||
@ -351,7 +350,7 @@ namespace CaseAccountingBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = currentRow,
|
RowIndex = currentRow,
|
||||||
Text = discipline,
|
Text = hearing,
|
||||||
StyleIndex = 1
|
StyleIndex = 1
|
||||||
});
|
});
|
||||||
currentRow++;
|
currentRow++;
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelCellParameters
|
public class ExcelCellParameters
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelMergeParameters
|
public class ExcelMergeParameters
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfParagraph
|
public class PdfParagraph
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfRowParameters
|
public class PdfRowParameters
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordParagraph
|
public class WordParagraph
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordTextProperties
|
public class WordTextProperties
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,174 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordBuilderCustomer
|
||||||
|
{
|
||||||
|
private readonly string tempFileName = "temp.docx";
|
||||||
|
private WordprocessingDocument? wordDocument;
|
||||||
|
private Body? documentBody;
|
||||||
|
|
||||||
|
public void CreateDocument()
|
||||||
|
{
|
||||||
|
wordDocument = WordprocessingDocument.Create(tempFileName,
|
||||||
|
WordprocessingDocumentType.Document);
|
||||||
|
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new Document();
|
||||||
|
documentBody = mainPart.Document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateParagraph(string text)
|
||||||
|
{
|
||||||
|
if (documentBody == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Paragraph paragraph = new();
|
||||||
|
Run run = new();
|
||||||
|
run.AppendChild(new Text
|
||||||
|
{
|
||||||
|
Text = text
|
||||||
|
});
|
||||||
|
paragraph.AppendChild(run);
|
||||||
|
documentBody.AppendChild(paragraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateTitle(string text)
|
||||||
|
{
|
||||||
|
if (documentBody == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Paragraph paragraph = new();
|
||||||
|
Run run = new();
|
||||||
|
RunProperties properties = new();
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
run.AppendChild(properties);
|
||||||
|
run.AppendChild(new Text
|
||||||
|
{
|
||||||
|
Text = text
|
||||||
|
});
|
||||||
|
paragraph.AppendChild(run);
|
||||||
|
documentBody.AppendChild(paragraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableCell CreateTableCell(string text, bool inHead = false, int? cellWidth = null)
|
||||||
|
{
|
||||||
|
Run run = new();
|
||||||
|
TableCell tableCell = new();
|
||||||
|
TableCellProperties cellProperties = new()
|
||||||
|
{
|
||||||
|
TableCellWidth = new()
|
||||||
|
{
|
||||||
|
Width = cellWidth.ToString()
|
||||||
|
},
|
||||||
|
TableCellMargin = new()
|
||||||
|
{
|
||||||
|
LeftMargin = new()
|
||||||
|
{
|
||||||
|
Width = "100"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (inHead)
|
||||||
|
{
|
||||||
|
Shading shading = new()
|
||||||
|
{
|
||||||
|
Color = "auto",
|
||||||
|
Fill = "e0e8ff",
|
||||||
|
Val = ShadingPatternValues.Clear
|
||||||
|
};
|
||||||
|
cellProperties.Append(shading);
|
||||||
|
RunProperties properties = new();
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
run.AppendChild(properties);
|
||||||
|
}
|
||||||
|
run.AppendChild(new Text
|
||||||
|
{
|
||||||
|
Text = text
|
||||||
|
});
|
||||||
|
Paragraph paragraph = new(run);
|
||||||
|
tableCell.AppendChild(paragraph);
|
||||||
|
tableCell.Append(cellProperties);
|
||||||
|
return tableCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void CreateTable(WordTableData tableData)
|
||||||
|
{
|
||||||
|
if (documentBody == null || tableData == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var table = new Table();
|
||||||
|
|
||||||
|
TableProperties tableProperties = new(
|
||||||
|
new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 }
|
||||||
|
)
|
||||||
|
);
|
||||||
|
table.AppendChild(tableProperties);
|
||||||
|
|
||||||
|
table.Append(new TableRow(tableData.Columns.Select(x => CreateTableCell(x.Item1, true, x.Item2))));
|
||||||
|
table.Append(tableData.Rows.Select(x => new TableRow(x.Select(y => CreateTableCell(y)))));
|
||||||
|
|
||||||
|
documentBody.AppendChild(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save()
|
||||||
|
{
|
||||||
|
if (documentBody == null || wordDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wordDocument.MainDocumentPart!.Document.Save();
|
||||||
|
wordDocument.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetFile()
|
||||||
|
{
|
||||||
|
Save();
|
||||||
|
byte[] file = File.ReadAllBytes(tempFileName);
|
||||||
|
File.Delete(tempFileName);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateLawyersHearingTable(List<ReportLawyerHearingViewModel> data)
|
||||||
|
{
|
||||||
|
List<List<string>> rows = new();
|
||||||
|
foreach (ReportLawyerHearingViewModel lawyer in data)
|
||||||
|
{
|
||||||
|
List<string> lawyerCells = new() { lawyer.Lawyer, "" };
|
||||||
|
rows.Add(lawyerCells);
|
||||||
|
List<string> hearingCells;
|
||||||
|
foreach (string hearing in lawyer.Hearings)
|
||||||
|
{
|
||||||
|
hearingCells = new() { "", hearing };
|
||||||
|
rows.Add(hearingCells);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WordTableData wordTable = new()
|
||||||
|
{
|
||||||
|
Columns = new List<(string, int)>()
|
||||||
|
{
|
||||||
|
("Юрист", 3000),
|
||||||
|
("Слушание", 3000)
|
||||||
|
},
|
||||||
|
Rows = rows
|
||||||
|
};
|
||||||
|
CreateTable(wordTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 LawyerHearingListBindingModel
|
||||||
|
{
|
||||||
|
public string FileType { get; set; } = string.Empty;
|
||||||
|
public List<LawyerViewModel> Lawyers { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
|||||||
|
|
||||||
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
|
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
|
||||||
|
|
||||||
|
byte[] SaveListFile(LawyerHearingListBindingModel model);
|
||||||
|
|
||||||
void SaveLawyerHearingToWordFile(ReportBindingModel model);
|
void SaveLawyerHearingToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
void SaveLawyerHearingToExcelFile(ReportBindingModel model);
|
void SaveLawyerHearingToExcelFile(ReportBindingModel model);
|
||||||
|
@ -17,5 +17,7 @@ namespace CaseAccountingContracts.StoragesContracts
|
|||||||
CaseViewModel? Insert(CaseBindingModel model);
|
CaseViewModel? Insert(CaseBindingModel model);
|
||||||
CaseViewModel? Update(CaseBindingModel model);
|
CaseViewModel? Update(CaseBindingModel model);
|
||||||
CaseViewModel? Delete(CaseBindingModel model);
|
CaseViewModel? Delete(CaseBindingModel model);
|
||||||
|
|
||||||
|
List<HearingViewModel> GetCaseHearings(CaseSearchModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,7 @@ namespace CaseAccountingContracts.StoragesContracts
|
|||||||
LawyerViewModel? Insert(LawyerBindingModel model);
|
LawyerViewModel? Insert(LawyerBindingModel model);
|
||||||
LawyerViewModel? Update(LawyerBindingModel model);
|
LawyerViewModel? Update(LawyerBindingModel model);
|
||||||
LawyerViewModel? Delete(LawyerBindingModel model);
|
LawyerViewModel? Delete(LawyerBindingModel model);
|
||||||
|
|
||||||
|
List<CaseViewModel> GetLawyerCases(LawyerSearchModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,7 @@ namespace CaseAccountingContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportLawyerHearingViewModel
|
public class ReportLawyerHearingViewModel
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Lawyer { get; set; } = string.Empty;
|
||||||
|
public List<string> Hearings { get; set; } = new();
|
||||||
public string Surname { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Patronymic { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public List<(DateTime Date, string Information)> Hearings { get; set; } = new();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,25 @@ namespace CaseAccountingCustomerView
|
|||||||
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 = _client.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,5 +100,22 @@ namespace CaseAccountingCustomerView.Controllers
|
|||||||
{
|
{
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public int[]? HearingLawyerList([FromBody] LawyerHearingListBindingModel listModel)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Array.Empty<int>();
|
||||||
|
}
|
||||||
|
byte[]? file = APIUser.PostRequestWithResult<LawyerHearingListBindingModel, byte[]>
|
||||||
|
("api/reportcustomer/lawyerhearinglist", listModel);
|
||||||
|
return file!.Select(b => (int)b).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult HearingLawyerList()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Список слушаний по юристам";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h4 class="fw-bold">Список слушаний по юристам</h4>
|
||||||
|
|
||||||
|
<div id="error-div-shell" class="error-div-shell mb-2">
|
||||||
|
<div>
|
||||||
|
<p id="error-p" class="error-p"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<select id="file-type">
|
||||||
|
<option>docx</option>
|
||||||
|
<option>xlsx</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button id="create-button" type="button" class="button-primary text-button">
|
||||||
|
Показать итоговый вариант
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button id="save-button" type="button" class="button-primary text-button">
|
||||||
|
Сохранить результат
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="scrollable-table">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead class="thead-light">
|
||||||
|
<tr>
|
||||||
|
<th>Имя</th>
|
||||||
|
<th>Фамилия</th>
|
||||||
|
<th>Отчество</th>
|
||||||
|
<th>Опыт работы</th>
|
||||||
|
<th>Специализация</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="scrollable-table__tbody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="~/js/Report/reportlist.js" asp-append-version="true"></script>
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>@ViewData["Title"] - CaseAccountingCustomerView</title>
|
<title>@ViewData["Title"] - Юридическая фирма «Вас обманут» "Заказчик"</title>
|
||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
<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="~/css/site.css" asp-append-version="true" />
|
||||||
<link rel="stylesheet" href="~/CaseAccountingCustomerView.styles.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/CaseAccountingCustomerView.styles.css" asp-append-version="true" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">CaseAccountingCustomerView</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Юридическая фирма «Вас обманут» "Заказчик"</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<footer class="border-top footer text-muted">
|
<footer class="border-top footer text-muted">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© 2023 - CaseAccountingCustomerView - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
© Юридическая фирма «Вас обманут» "Заказчик" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
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 lawyers = []
|
||||||
|
var dataArray = [];
|
||||||
|
const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||||
|
const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
$.ajax({
|
||||||
|
url: "/lawyers/getallbyuser",
|
||||||
|
type: "GET",
|
||||||
|
contentType: "json"
|
||||||
|
}).done((result) => {
|
||||||
|
lawyers = result;
|
||||||
|
lawyers.forEach((lawyer) => createRowForLawyersTable(lawyer));
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
createBtn.addEventListener('click', () => {
|
||||||
|
let listModel = {
|
||||||
|
"Lawyers": Array.from(dataArray),
|
||||||
|
"FileType": fileType.value
|
||||||
|
};
|
||||||
|
console.log(listModel);
|
||||||
|
$.ajax({
|
||||||
|
url: "/home/hearinglawyerlist",
|
||||||
|
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: `lawyer-hearing-list.${fileType.value}`,
|
||||||
|
types: [type],
|
||||||
|
};
|
||||||
|
const handle = await showSaveFilePicker(opts);
|
||||||
|
const writable = await handle.createWritable();
|
||||||
|
await writable.write(bytes);
|
||||||
|
writable.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const createRowForLawyersTable = (lawyer) => {
|
||||||
|
const { id, name, surname, patronymic, experience, specialization } = lawyer;
|
||||||
|
const row = tbody.insertRow();
|
||||||
|
row.setAttribute("data-id", id);
|
||||||
|
|
||||||
|
const cells = [name, surname, patronymic, experience, specialization];
|
||||||
|
cells.forEach((value) => {
|
||||||
|
const cell = row.insertCell();
|
||||||
|
cell.textContent = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (dateString) => {
|
||||||
|
const date = new Date(dateString);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = ('0' + (date.getMonth() + 1)).slice(-2);
|
||||||
|
const day = ('0' + date.getDate()).slice(-2);
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addAndRemoveFromList = (row) => {
|
||||||
|
var id = parseInt(row.dataset.id);
|
||||||
|
console.log(lawyers.find(x => x.id === id))
|
||||||
|
var index = dataArray.indexOf(lawyers.find(x => x.id === id));
|
||||||
|
if (index === -1) {
|
||||||
|
dataArray.push(lawyers.find(x => x.id === id));
|
||||||
|
row.classList.add("bg-success");
|
||||||
|
} else {
|
||||||
|
dataArray.splice(index, 1);
|
||||||
|
row.classList.remove("bg-success");
|
||||||
|
}
|
||||||
|
console.log(dataArray);
|
||||||
|
}
|
@ -170,5 +170,20 @@ namespace CaseAccountingDataBaseImplement.Implements
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<HearingViewModel> GetCaseHearings(CaseSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new CaseAccountingDatabase();
|
||||||
|
var hearings = context.Hearings
|
||||||
|
.Where(x => x.CaseId == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
return hearings;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,5 +138,19 @@ namespace CaseAccountingDataBaseImplement.Implements
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CaseViewModel> GetLawyerCases(LawyerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new CaseAccountingDatabase();
|
||||||
|
var cases = context.CaseLawyers
|
||||||
|
.Where(x => x.LawyerId == model.Id)
|
||||||
|
.Select(x => x.Case.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
return cases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
using CaseAccountingContracts.BindingModels;
|
||||||
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CaseAccountingRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ReportCustomerController : Controller
|
||||||
|
{
|
||||||
|
private readonly IReportCustomerLogic _reportCustomerLogic;
|
||||||
|
|
||||||
|
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
||||||
|
{
|
||||||
|
_reportCustomerLogic = reportLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public byte[] LawyerHearingList(LawyerHearingListBindingModel listModel)
|
||||||
|
{
|
||||||
|
byte[] file = _reportCustomerLogic.SaveListFile(listModel);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using CaseAccountingBusinessLogic.BusinessLogics;
|
using CaseAccountingBusinessLogic.BusinessLogics;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
using CaseAccountingDataBaseImplement.Implements;
|
using CaseAccountingDataBaseImplement.Implements;
|
||||||
@ -26,6 +28,9 @@ 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<WordBuilderCustomer>();
|
||||||
|
builder.Services.AddTransient<ExcelBuilderCustomer>();
|
||||||
|
|
||||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
Loading…
Reference in New Issue
Block a user