Репорт ворд Егор готово, но отображение на сайте не работает
This commit is contained in:
parent
27d38f78fc
commit
d93f31f42c
@ -31,11 +31,13 @@ public class ReportLogic : IReportLogic
|
|||||||
private readonly AbstractSaveToWordWorker _saveToWordWorker;
|
private readonly AbstractSaveToWordWorker _saveToWordWorker;
|
||||||
//private readonly AbstractSaveToPdfWorker _saveToPdfWorker;
|
//private readonly AbstractSaveToPdfWorker _saveToPdfWorker;
|
||||||
|
|
||||||
|
private readonly AbstractSaveToExcelWorker _saveToExcelStorekeeper;
|
||||||
|
//private readonly AbstractSaveToPdfWorker _saveToPdfWorker;
|
||||||
private readonly AbstractSaveToWordStorekeeper _saveToWordStorekeeper;
|
private readonly AbstractSaveToWordStorekeeper _saveToWordStorekeeper;
|
||||||
public ReportLogic (ITeacherStorage teacherStorage, IDisciplineStorage
|
public ReportLogic (ITeacherStorage teacherStorage, IDisciplineStorage
|
||||||
disciplineStorage, IStudentStorage studentStorage, IStatementStorage statementStorage,
|
disciplineStorage, IStudentStorage studentStorage, IStatementStorage statementStorage,
|
||||||
IPlanOfStudyStorage planOfStudyStorage, AbstractSaveToExcelWorker saveToExcelWorker, AbstractSaveToWordWorker saveToWordWorker
|
IPlanOfStudyStorage planOfStudyStorage, AbstractSaveToExcelWorker saveToExcelWorker, AbstractSaveToWordWorker saveToWordWorker
|
||||||
/* , AbstractSaveToPdfWorker saveToPdfWorker */)
|
/* , AbstractSaveToPdfWorker saveToPdfWorker */, AbstractSaveToWordStorekeeper saveToWordStorekeeper)
|
||||||
{
|
{
|
||||||
_teacherStorage = teacherStorage;
|
_teacherStorage = teacherStorage;
|
||||||
_disciplineStorage = disciplineStorage;
|
_disciplineStorage = disciplineStorage;
|
||||||
@ -46,10 +48,15 @@ public class ReportLogic : IReportLogic
|
|||||||
_saveToExcelWorker = saveToExcelWorker;
|
_saveToExcelWorker = saveToExcelWorker;
|
||||||
_saveToWordWorker = saveToWordWorker;
|
_saveToWordWorker = saveToWordWorker;
|
||||||
// _saveToPdfWorker = saveToPdfWorker;
|
// _saveToPdfWorker = saveToPdfWorker;
|
||||||
|
|
||||||
|
_saveToWordStorekeeper = saveToWordStorekeeper ;
|
||||||
}
|
}
|
||||||
public List<ReportTeacherViewModel> GetTeachers()
|
public List<ReportTeacherViewModel> GetTeachers(int userId)
|
||||||
{
|
{
|
||||||
var teachers = _teacherStorage.GetFullList();
|
var teachers = _teacherStorage.GetFilteredList(new TeacherSearchModel
|
||||||
|
{
|
||||||
|
UserId = userId
|
||||||
|
});
|
||||||
|
|
||||||
// Создаем список для результатов
|
// Создаем список для результатов
|
||||||
var result = new List<ReportTeacherViewModel>();
|
var result = new List<ReportTeacherViewModel>();
|
||||||
@ -235,8 +242,8 @@ public class ReportLogic : IReportLogic
|
|||||||
_saveToWordStorekeeper.CreateDoc(new WordInfoStorekeeper
|
_saveToWordStorekeeper.CreateDoc(new WordInfoStorekeeper
|
||||||
{
|
{
|
||||||
FileName = option.FileName,
|
FileName = option.FileName,
|
||||||
Title = "Список пакетов документов",
|
Title = "Список преподавателей",
|
||||||
TeacherInfo = GetTeachers()
|
TeacherInfo = GetTeachers(0)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,9 +174,47 @@ namespace UniversityClientApp.Controllers
|
|||||||
});
|
});
|
||||||
Response.Redirect("Teachers");
|
Response.Redirect("Teachers");
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
public IActionResult Report() {
|
public IActionResult Report() {
|
||||||
return View();
|
if (APIStorekeeper.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View("Report", APIStorekeeper.GetRequest<List<ReportTeacherViewModel>>($"api/teacher/getteachersreport?userId={APIStorekeeper.Client.Id}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Report(string type)
|
||||||
|
{
|
||||||
|
if (APIStorekeeper.Client == null)
|
||||||
|
{
|
||||||
|
Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(type))
|
||||||
|
{
|
||||||
|
throw new Exception("Error, wrong type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "docx")
|
||||||
|
{
|
||||||
|
APIStorekeeper.PostRequest("api/teacher/loadreporttoword", new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = $"C:\\Users\\{Environment.UserName}\\Desktop\\TeachersAndStudents{Environment.TickCount}.docx"
|
||||||
|
});
|
||||||
|
Response.Redirect("Report");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "xlsx")
|
||||||
|
{
|
||||||
|
APIStorekeeper.PostRequest("api/teacher/loadreporttoexcel", new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = $"C:\\Users\\{Environment.UserName}\\Desktop\\TeachersAndStudents{Environment.TickCount}.xlsx"
|
||||||
|
});
|
||||||
|
Response.Redirect("Report");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
@{
|
@using UniversityContracts.ViewModels
|
||||||
ViewData["Title"] = "Student List by Teacher";
|
@model List<ReportTeacherViewModel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Report by teachers and students";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -8,33 +10,59 @@
|
|||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Teachers:</div>
|
<div class="col-8 btn-group"></div>
|
||||||
<div class="col-8">
|
<div class="col-4 mt-2">
|
||||||
<select id="teachers" name="teachers" class="form-control" multiple asp-items="ViewBag.Teachers"></select>
|
<form method="post">
|
||||||
</div>
|
<input type="hidden" name="type" value="docx" />
|
||||||
</div>
|
<input type="submit" value="Save in Word" class="btn btn-primary" />
|
||||||
<div class="row">
|
</form>
|
||||||
<div class="col-4">File Format:</div>
|
|
||||||
<div class="col-8">
|
<form method="post">
|
||||||
<select id="fileFormat" name="fileFormat" class="form-control" asp-items="ViewBag.FileFormats"></select>
|
<input type="hidden" name="type" value="xlsx" />
|
||||||
</div>
|
<input type="submit" value="Save in Excel" class="btn btn-success" />
|
||||||
</div>
|
</form>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="col-4">File Name:</div>
|
<div class="col-4 mt-2">
|
||||||
<div class="col-8">
|
</div>
|
||||||
<input type="text" name="fileName" id="fileName" class="form-control" />
|
</div>
|
||||||
</div>
|
<table class="table">
|
||||||
</div>
|
<thead>
|
||||||
<div class="row">
|
<tr>
|
||||||
<div class="col-4">File Location:</div>
|
<th>Id</th>
|
||||||
<div class="col-8">
|
<th>Teacher name</th>
|
||||||
<input type="text" name="fileLocation" id="fileLocation" class="form-control" />
|
<th>Student</th>
|
||||||
</div>
|
<th>Student</th>
|
||||||
</div>
|
</tr>
|
||||||
<div class="row">
|
</thead>
|
||||||
<div class="col-8"></div>
|
<tbody>
|
||||||
<div class="col-4">
|
@foreach (var item in Model)
|
||||||
<input type="submit" value="Get Student List" class="btn btn-primary" />
|
{
|
||||||
</div>
|
<tr>
|
||||||
</div>
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.TeacherId)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.TeacherName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@foreach (var st in item.Students)
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
@Html.DisplayFor(modelItem => st)
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
@foreach (var student in item.Students)
|
||||||
|
{
|
||||||
|
<td>
|
||||||
|
@student.Name
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@student.PhoneNumber
|
||||||
|
</td>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</form>
|
</form>
|
@ -16,7 +16,7 @@ namespace UniversityContracts.BusinessLogicContracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<ReportTeacherViewModel> GetTeachers();
|
List<ReportTeacherViewModel> GetTeachers(int userId);
|
||||||
List<ReportDisciplineViewModel> GetDisciplines(ReportBindingModel model);
|
List<ReportDisciplineViewModel> GetDisciplines(ReportBindingModel model);
|
||||||
List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines(int userId);
|
List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines(int userId);
|
||||||
List<ReportPlanOfStudyAndStudentViewModel> GetPlanOfStudyAndStudents(ReportDateRangeBindingModel model);
|
List<ReportPlanOfStudyAndStudentViewModel> GetPlanOfStudyAndStudents(ReportDateRangeBindingModel model);
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace University.ViewModels
|
namespace UniversityContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ReportTeacherViewModel
|
public class ReportTeacherViewModel
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement
|
|||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
|
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -88,11 +88,11 @@ namespace UniversityRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<ReportTeacherViewModel>? GetDisciplinesReport()
|
public List<ReportTeacherViewModel>? GetTeachersReport(int userId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _reportLogic.GetTeachers();
|
return _reportLogic.GetTeachers(userId);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -100,5 +100,32 @@ namespace UniversityRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void LoadReportToWord(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveTeachersToWord(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void LoadReportToExcel(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveTeachersToExcel(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ builder.Services.AddTransient<IStudentStorage, StudentStorage>();
|
|||||||
builder.Services.AddTransient<AbstractSaveToExcelWorker, SaveToExcelWorker>();
|
builder.Services.AddTransient<AbstractSaveToExcelWorker, SaveToExcelWorker>();
|
||||||
builder.Services.AddTransient<AbstractSaveToWordWorker, SaveToWordWorker>();
|
builder.Services.AddTransient<AbstractSaveToWordWorker, SaveToWordWorker>();
|
||||||
builder.Services.AddTransient<AbstractSaveToPdfWorker, SaveToPdfWorker>();
|
builder.Services.AddTransient<AbstractSaveToPdfWorker, SaveToPdfWorker>();
|
||||||
|
// builder.Services.AddTransient<AbstractSaveToExcelStorekeeper, SaveToExcelStorekeeper>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToWordStorekeeper, SaveToWordStorekeeper>();
|
||||||
|
// builder.Services.AddTransient<AbstractSaveToPdfStorekeeper, SaveToPdfStorekeeper>();
|
||||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||||
builder.Services.AddTransient<IDisciplineLogic, DisciplineLogic>();
|
builder.Services.AddTransient<IDisciplineLogic, DisciplineLogic>();
|
||||||
|
Loading…
Reference in New Issue
Block a user