2023-04-07 20:23:14 +04:00
|
|
|
|
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
|
|
|
|
|
using SchoolAgainStudyBusinessLogic.OfficePackage;
|
2023-04-07 14:25:31 +04:00
|
|
|
|
using SchoolAgainStudyBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using SchoolAgainStudyContracts.BindingModel;
|
|
|
|
|
using SchoolAgainStudyContracts.BusinessLogicContracts;
|
|
|
|
|
using SchoolAgainStudyContracts.SearchModel;
|
|
|
|
|
using SchoolAgainStudyContracts.StorageContracts;
|
|
|
|
|
using SchoolAgainStudyContracts.ViewModel;
|
2023-04-07 20:23:14 +04:00
|
|
|
|
using SchoolAgainStudyDataBaseImplements.Models;
|
2023-04-07 14:25:31 +04:00
|
|
|
|
using SchoolAgainStudyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolAgainStudyBusinessLogic.BusinessLogic
|
|
|
|
|
{
|
|
|
|
|
public class ReportLogic : IReportLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly IInterestStorage _interestStorage;
|
|
|
|
|
private readonly IMaterialStorage _materialStorage;
|
|
|
|
|
private readonly IProductStorage _productStorage;
|
|
|
|
|
private readonly IDiyStorage _diyStorage;
|
|
|
|
|
private readonly ITaskStorage _taskStorage;
|
|
|
|
|
private readonly ILessonStorage _lessonStorage;
|
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToExcelTeacher _saveToExcelTeacher;
|
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToWordTeacher _saveToWordTeacher;
|
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToPdfTeacher _saveToPdfTeacher;
|
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToExcelStudent _saveToExcelStudent;
|
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToWordStudent _saveToWordStudent;
|
|
|
|
|
|
|
|
|
|
private readonly AbstractSaveToPdfStudent _saveToPdfStudent;
|
|
|
|
|
|
|
|
|
|
public ReportLogic(IInterestStorage interestStorage, IMaterialStorage materialStorage, IProductStorage productStorage, IDiyStorage diyStorage, ITaskStorage taskStorage, ILessonStorage lessonStorage, AbstractSaveToExcelTeacher saveToExcelTeacher, AbstractSaveToWordTeacher saveToWordTeacher, AbstractSaveToPdfTeacher saveToPdfTeacher, AbstractSaveToExcelStudent saveToExcelStudent, AbstractSaveToWordStudent saveToWordStudent, AbstractSaveToPdfStudent saveToPdfStudent)
|
|
|
|
|
{
|
2023-05-18 22:22:03 +04:00
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
_interestStorage = interestStorage;
|
|
|
|
|
_materialStorage = materialStorage;
|
|
|
|
|
_productStorage = productStorage;
|
|
|
|
|
_diyStorage = diyStorage;
|
|
|
|
|
_taskStorage = taskStorage;
|
|
|
|
|
_lessonStorage = lessonStorage;
|
|
|
|
|
_saveToExcelTeacher = saveToExcelTeacher;
|
|
|
|
|
_saveToWordTeacher = saveToWordTeacher;
|
|
|
|
|
_saveToPdfTeacher = saveToPdfTeacher;
|
|
|
|
|
_saveToExcelStudent = saveToExcelStudent;
|
|
|
|
|
_saveToWordStudent = saveToWordStudent;
|
|
|
|
|
_saveToPdfStudent = saveToPdfStudent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<ReportDiyMaterialViewModel> GetDiyMaterial(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var tasks = _taskStorage.GetFilteredList(new TaskSearchModel{
|
|
|
|
|
TeacherId=model.TeacherId
|
|
|
|
|
});
|
|
|
|
|
var diys = _diyStorage.GetFullList();
|
|
|
|
|
var list = new List<ReportDiyMaterialViewModel>();
|
|
|
|
|
|
|
|
|
|
foreach (MaterialViewModel material in model.Materials)
|
|
|
|
|
{
|
|
|
|
|
var record = new ReportDiyMaterialViewModel
|
|
|
|
|
{
|
|
|
|
|
Title = material.Title
|
|
|
|
|
};
|
|
|
|
|
foreach(TaskViewModel task in tasks)
|
|
|
|
|
{
|
|
|
|
|
if (task.TaskMaterials.ContainsKey(material.Id))
|
|
|
|
|
{
|
|
|
|
|
foreach(DiyViewModel diy in diys)
|
|
|
|
|
{
|
|
|
|
|
if (diy.TaskId == task.Id)
|
|
|
|
|
record.Diys.Add(diy.Title);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(record);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportInterestLessonViewModel> GetInterestLesson(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
var products = _productStorage.GetFilteredList(new ProductSearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = model.StudentId
|
|
|
|
|
});
|
|
|
|
|
var lessons = _lessonStorage.GetFullList();
|
|
|
|
|
var list = new List<ReportInterestLessonViewModel>();
|
|
|
|
|
foreach(InterestViewModel interest in model.Interests)
|
|
|
|
|
{
|
|
|
|
|
var record = new ReportInterestLessonViewModel
|
|
|
|
|
{
|
|
|
|
|
Title = interest.Title
|
|
|
|
|
};
|
|
|
|
|
foreach(ProductViewModel product in products)
|
|
|
|
|
{
|
|
|
|
|
if (product.ProductInterests.ContainsKey(interest.Id))
|
|
|
|
|
{
|
|
|
|
|
foreach(LessonViewModel lesson in lessons)
|
|
|
|
|
{
|
|
|
|
|
if(lesson.ProductId == product.Id)
|
|
|
|
|
{
|
|
|
|
|
record.Lessons.Add(lesson.Title);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(record);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportInterestViewModel> GetInterests(ReportBindingModel model)
|
|
|
|
|
{
|
2023-05-18 22:22:03 +04:00
|
|
|
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
2023-04-07 14:25:31 +04:00
|
|
|
|
var interests = _interestStorage.GetFilteredList(new InterestSearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = model.StudentId
|
|
|
|
|
});
|
|
|
|
|
var products = _productStorage.GetFilteredList(new ProductSearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = model.StudentId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
|
|
|
|
var diys = _diyStorage.GetFilteredList(new DiySearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = model.StudentId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
|
|
|
|
var list = new List<ReportInterestViewModel>();
|
2023-04-07 20:23:14 +04:00
|
|
|
|
foreach (ProductViewModel product in products)
|
2023-04-07 14:25:31 +04:00
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
foreach (DiyViewModel diy in diys)
|
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
|
|
|
|
|
foreach (int interestProduct in product.ProductInterests.Keys)
|
2023-04-07 14:25:31 +04:00
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
if (diy.DiyInterests.ContainsKey(interestProduct))
|
2023-04-07 14:25:31 +04:00
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
list.Add(new ReportInterestViewModel
|
|
|
|
|
{
|
2023-05-18 22:22:03 +04:00
|
|
|
|
InterestTitle = interests.FirstOrDefault(x => x.Id == interestProduct).Title,
|
2023-04-07 20:23:14 +04:00
|
|
|
|
ProductTitle = product.Title,
|
|
|
|
|
DateCreateProduct = product.DateCreate,
|
|
|
|
|
DiyTitle = diy.Title,
|
|
|
|
|
DateCreateDiy = diy.DateCreate
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-07 20:23:14 +04:00
|
|
|
|
|
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
}
|
2023-04-07 20:23:14 +04:00
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportLessonTaskViewModel> GetLessonTask(ReportBindingModel model)
|
|
|
|
|
{
|
2023-05-19 14:20:04 +04:00
|
|
|
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
|
|
|
|
var tasks = _taskStorage.GetFilteredList(new TaskSearchModel
|
2023-04-07 14:25:31 +04:00
|
|
|
|
{
|
|
|
|
|
TeacherId = model.TeacherId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
|
|
|
|
var lessons = _lessonStorage.GetFilteredList(new LessonSearchModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = model.TeacherId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
|
|
|
|
var list = new List<ReportLessonTaskViewModel>();
|
|
|
|
|
|
|
|
|
|
foreach (TaskViewModel task in tasks)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach(LessonViewModel lesson in lessons)
|
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
foreach (int materialTask in task.TaskMaterials.Keys)
|
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
if (lesson.LessonMaterials.ContainsKey(materialTask))
|
2023-04-07 14:25:31 +04:00
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
list.Add(new ReportLessonTaskViewModel
|
2023-04-07 14:25:31 +04:00
|
|
|
|
{
|
2023-04-07 20:23:14 +04:00
|
|
|
|
TitleLesson = lesson.Title,
|
|
|
|
|
TitleTask = task.Title,
|
|
|
|
|
DateEventLesson = lesson.DateEvent,
|
|
|
|
|
DateIssueTask = task.DateIssue
|
|
|
|
|
});
|
|
|
|
|
break;
|
2023-04-07 14:25:31 +04:00
|
|
|
|
}
|
2023-04-07 20:23:14 +04:00
|
|
|
|
|
2023-04-07 14:25:31 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveDiyMaterialToExcelFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcelTeacher.CreateReport(new ExcelInfoTeacher
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список поделок по материалам",
|
|
|
|
|
DiyMaterials = GetDiyMaterial(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveDiyMaterialToWordFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToWordTeacher.CreateDoc(new WordInfoTeacher
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список поделок по материалам",
|
|
|
|
|
DiyMaterials = GetDiyMaterial(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveInterestLessonToExcelFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcelStudent.CreateReport(new ExcelInfoStudent
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список занятий по интресам",
|
|
|
|
|
InterestLessons = GetInterestLesson(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveInterestLessonToWordFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToWordStudent.CreateDoc(new WordInfoStudent
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список занятий по интресам",
|
|
|
|
|
InterestLessons = GetInterestLesson(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveInterestsToPdfFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToPdfStudent.CreateDoc(new PdfInfoStudent
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список интересов",
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
|
|
|
|
Interests = GetInterests(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveLessonTaskToPdfFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
_saveToPdfTeacher.CreateDoc(new PdfInfoTeacher
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
2023-05-19 14:20:04 +04:00
|
|
|
|
Title = "Список заданий и занятий с общими материалами",
|
2023-04-07 14:25:31 +04:00
|
|
|
|
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
|
|
|
|
LessonTasks = GetLessonTask(model)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|