299 lines
12 KiB
C#
299 lines
12 KiB
C#
|
using SchoolAgainStudyBusinessLogic.OfficePackage;
|
|||
|
using SchoolAgainStudyBusinessLogic.OfficePackage.HelperModels;
|
|||
|
using SchoolAgainStudyContracts.BindingModel;
|
|||
|
using SchoolAgainStudyContracts.BusinessLogicContracts;
|
|||
|
using SchoolAgainStudyContracts.SearchModel;
|
|||
|
using SchoolAgainStudyContracts.StorageContracts;
|
|||
|
using SchoolAgainStudyContracts.ViewModel;
|
|||
|
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)
|
|||
|
{
|
|||
|
_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)
|
|||
|
{
|
|||
|
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>();
|
|||
|
foreach(InterestViewModel interest in interests)
|
|||
|
{
|
|||
|
foreach(ProductViewModel product in products)
|
|||
|
{
|
|||
|
if (product.ProductInterests.ContainsKey(interest.Id))
|
|||
|
{
|
|||
|
list.Add(new ReportInterestViewModel
|
|||
|
{
|
|||
|
InterestTitle=interest.Title,
|
|||
|
InterestDesc = interest.Description,
|
|||
|
WorkType = "Изделие",
|
|||
|
WorkTitle = product.Title,
|
|||
|
WorkDesc = product.Description,
|
|||
|
DateCreate = product.DateCreate
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
foreach (InterestViewModel interest in interests)
|
|||
|
{
|
|||
|
foreach (DiyViewModel diy in diys)
|
|||
|
{
|
|||
|
if (diy.DiyInterests.ContainsKey(interest.Id))
|
|||
|
{
|
|||
|
list.Add(new ReportInterestViewModel
|
|||
|
{
|
|||
|
InterestTitle = interest.Title,
|
|||
|
InterestDesc = interest.Description,
|
|||
|
WorkType = "Поделка",
|
|||
|
WorkTitle = diy.Title,
|
|||
|
WorkDesc = diy.Description,
|
|||
|
DateCreate=diy.DateCreate
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return list;
|
|||
|
}
|
|||
|
|
|||
|
public List<ReportLessonTaskViewModel> GetLessonTask(ReportBindingModel model)
|
|||
|
{
|
|||
|
var materials = _materialStorage.GetFilteredList(new MaterialSearchModel
|
|||
|
{
|
|||
|
TeacherId = model.TeacherId
|
|||
|
});
|
|||
|
var tasks = _taskStorage.GetFilteredList(new TaskSearchModel
|
|||
|
{
|
|||
|
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)
|
|||
|
{
|
|||
|
bool check = false;
|
|||
|
foreach (int materialTask in task.TaskMaterials.Keys)
|
|||
|
{
|
|||
|
if (check)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
foreach (int materialLesson in lesson.LessonMaterials.Keys)
|
|||
|
{
|
|||
|
if (materialLesson == materialTask)
|
|||
|
{
|
|||
|
list.Add(new ReportLessonTaskViewModel
|
|||
|
{
|
|||
|
TitleLesson = lesson.Title,
|
|||
|
TitleTask = task.Title,
|
|||
|
DateEventLesson = lesson.DateEvent,
|
|||
|
DateIssueTask = task.DateIssue
|
|||
|
});
|
|||
|
check=true;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
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,
|
|||
|
Title = "Список заданий и занятий со сохожими материалами",
|
|||
|
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
|
|||
|
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
|
|||
|
LessonTasks = GetLessonTask(model)
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|