Отчет приложение к диплому и наброски отчета успеваемости
This commit is contained in:
parent
f2dcc98fa6
commit
914ab23599
@ -4,6 +4,10 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.16.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\ModuleTools\ModuleTools.csproj" />
|
||||
<ProjectReference Include="..\Department\DepartmentBusinessLogic\DepartmentBusinessLogic.csproj" />
|
||||
|
@ -15,5 +15,11 @@ namespace AcademicProgressBusinessLogic.BindingModels
|
||||
/// Путь до папки, куда выгружать отчет
|
||||
/// </summary>
|
||||
public string FolderName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id студента, для которого формируется отчет
|
||||
/// </summary>
|
||||
|
||||
public Guid? StudentId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
using AcademicProgressBusinessLogic.BindingModels;
|
||||
using AcademicProgressBusinessLogic.Interfaces;
|
||||
using DepartmentBusinessLogic.Interfaces;
|
||||
using ModuleTools.BusinessLogics;
|
||||
using ModuleTools.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.BusinessLogics
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика работы с отчетами
|
||||
/// </summary>
|
||||
public class ReportBusinessLogic : CoreBusinessLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Серивс для работы с отчетами
|
||||
/// </summary>
|
||||
private readonly IReportService _service;
|
||||
|
||||
private readonly IStudentService _studentService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Логика работы с отчетом
|
||||
/// </summary>
|
||||
/// <param name="service"></param>
|
||||
public ReportBusinessLogic(IReportService service, IStudentService _studentService)
|
||||
{
|
||||
this._studentService = _studentService;
|
||||
_service = service;
|
||||
_serviceOperation = AccessOperation.Отчет_успеваемость;
|
||||
_entity = "Отчеты для успеваемости";
|
||||
}
|
||||
|
||||
public void SaveReportToWordFile(ReportBindingModel model)
|
||||
{
|
||||
/* SaveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FolderName,
|
||||
Title = "Список заявок",
|
||||
RequestFlowers = GetRequestPlaces()
|
||||
});*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,334 @@
|
||||
using AcademicProgressBusinessLogic.BindingModels;
|
||||
using AcademicProgressBusinessLogic.BusinessLogic;
|
||||
using AcademicProgressBusinessLogic.Enums;
|
||||
using AcademicProgressBusinessLogic.HelperModels;
|
||||
using AcademicProgressBusinessLogic.Interfaces;
|
||||
using AcademicProgressBusinessLogic.ViewModels;
|
||||
using DepartmentBusinessLogic.BindingModels;
|
||||
using DepartmentBusinessLogic.BusinessLogics;
|
||||
using DepartmentBusinessLogic.Interfaces;
|
||||
using ModuleTools.BusinessLogics;
|
||||
using ModuleTools.Enums;
|
||||
using ModuleTools.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.BusinessLogics
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика работы с отчетами
|
||||
/// </summary>
|
||||
public class ReportLogic : CoreBusinessLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика для работы со студентами
|
||||
/// </summary>
|
||||
|
||||
private readonly StudentBusinessLogic _studentlogic;
|
||||
|
||||
/// <summary>
|
||||
/// Логика для работы с успеваемостью студента
|
||||
/// </summary>
|
||||
|
||||
private readonly StudentAcademicProgressBusinessLogic _studentAcademicProgresslogic;
|
||||
|
||||
/// <summary>
|
||||
/// Логика для работы с дисциплинами
|
||||
/// </summary>
|
||||
|
||||
private readonly DisciplineBusinessLogic _disciplinelogic;
|
||||
|
||||
private readonly AcademicPlanRecordBusinessLogic _academicPlanRecordlogic;
|
||||
private readonly StudentGroupBusinessLogic _studentGrouplogic;
|
||||
private readonly EducationDirectionBusinessLogic _educationDirectionlogic;
|
||||
private readonly AcademicPlanBusinessLogic _academicPlanlogic;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Логика работы с отчетом
|
||||
/// </summary>
|
||||
/// <param name="service"></param>
|
||||
public ReportLogic(AcademicPlanRecordBusinessLogic _academicPlanRecordlogic, EducationDirectionBusinessLogic _educationDirectionlogic, AcademicPlanBusinessLogic _academicPlanlogic,
|
||||
StudentGroupBusinessLogic _studentGrouplogic, StudentBusinessLogic _studentlogic, StudentAcademicProgressBusinessLogic _studentAcademicProgressService, DisciplineBusinessLogic _disciplinelogic)
|
||||
{
|
||||
this._studentGrouplogic = _studentGrouplogic;
|
||||
this._educationDirectionlogic = _educationDirectionlogic;
|
||||
this._academicPlanlogic = _academicPlanlogic;
|
||||
this._academicPlanRecordlogic = _academicPlanRecordlogic;
|
||||
this._studentAcademicProgresslogic = _studentAcademicProgressService;
|
||||
this._disciplinelogic = _disciplinelogic;
|
||||
this._studentlogic = _studentlogic;
|
||||
_serviceOperation = AccessOperation.Отчет_успеваемость;
|
||||
_entity = "Отчеты для успеваемости";
|
||||
}
|
||||
|
||||
public void SaveReportToWordFile(ReportBindingModel model)
|
||||
{
|
||||
SaveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FolderName,
|
||||
Title = "Приложение к диплому",
|
||||
StudentScores = GetStudentScores(model.StudentId)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveReportToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
SaveToExcel.CreateDoc(new ExcelInfo
|
||||
{
|
||||
FileName = model.FolderName,
|
||||
Title = "Успеваемость",
|
||||
StudentScores = GetStudentScoresForProgress(model.StudentId)
|
||||
});
|
||||
|
||||
}
|
||||
public List<StudentScoresViewModel> GetStudentScoresForProgress(Guid? studentId)
|
||||
{
|
||||
var academicProgress = _studentAcademicProgresslogic.GetList(new StudentAcademicProgressGetBindingModel());
|
||||
var discipline = _disciplinelogic.GetList(new DisciplineGetBindingModel());
|
||||
var academicPlanRecords = _academicPlanRecordlogic.GetList(new AcademicPlanRecordGetBindingModel());
|
||||
var students = _studentlogic.GetList(new StudentGetBindingModel());
|
||||
var educationDirections = _educationDirectionlogic.GetList(new EducationDirectionGetBindingModel());
|
||||
var studentGroup = _studentGrouplogic.GetList(new StudentGroupGetBindingModel());
|
||||
var academicPlans = _academicPlanlogic.GetList(new AcademicPlanGetBindingModel());
|
||||
|
||||
var list = new List<StudentScoresViewModel>();
|
||||
double average = 0;
|
||||
double count = 0;
|
||||
string score = "";
|
||||
foreach (var student in students.List.Where(rec => rec.Id == studentId))
|
||||
{
|
||||
foreach (var studGroup in studentGroup.List.Where(rec => rec.Id == student.StudentGroupId))
|
||||
{
|
||||
foreach (var educatDirection in educationDirections.List.Where(rec => rec.Id == studGroup.EducationDirectionId))
|
||||
{
|
||||
foreach (var academicPlan in academicPlans.List.Where(rec => rec.EducationDirectionId == educatDirection.Id))
|
||||
{
|
||||
foreach (var academicPlanRecord in academicPlanRecords.List.Where(rec => rec.AcademicPlanId == academicPlan.Id))
|
||||
{
|
||||
|
||||
//является ли родителем
|
||||
if (academicPlanRecord.IsParent)
|
||||
{
|
||||
bool hasScore = false;
|
||||
//ищем всех детей
|
||||
foreach (var academicPlanRecordChild in academicPlanRecords.List.Where(rec => rec.AcademicPlanRecordParentId == academicPlanRecord.Id))
|
||||
{
|
||||
//если есть оценки то заполняем
|
||||
foreach (var studProgress in academicProgress.List.Where(rec => rec.StudentId == studentId && rec.DisciplineId == academicPlanRecordChild.DisciplineId && rec.Semester == academicPlanRecordChild.Semester))
|
||||
{
|
||||
var record = new StudentScoresViewModel
|
||||
{
|
||||
DisciplineName = academicPlanRecordChild.DisciplineName,
|
||||
Scores = studProgress.ExamScoresTitle,
|
||||
StudentLastName = student.LastName,
|
||||
StudentFirstName = student.FirstName,
|
||||
Semester = (int)academicPlanRecordChild.Semester,
|
||||
Zet = academicPlanRecordChild.Zet
|
||||
};
|
||||
list.Add(record);
|
||||
hasScore = true;
|
||||
}
|
||||
}
|
||||
//если оценок нет, то вставляем имя родителя
|
||||
if (!hasScore)
|
||||
{
|
||||
|
||||
var record = new StudentScoresViewModel
|
||||
{
|
||||
DisciplineName = academicPlanRecord.DisciplineName,
|
||||
Scores = " ",
|
||||
Semester = (int)academicPlanRecord.Semester,
|
||||
StudentLastName = student.LastName,
|
||||
StudentFirstName = student.FirstName,
|
||||
Zet = academicPlanRecord.Zet
|
||||
};
|
||||
list.Add(record);
|
||||
}
|
||||
}//если не имеет детей то записываем имя без оценки
|
||||
else if (academicPlanRecord.IsChildValue == "Нет")
|
||||
{
|
||||
|
||||
var record = new StudentScoresViewModel
|
||||
{
|
||||
DisciplineName = academicPlanRecord.DisciplineName,
|
||||
Scores = " ",
|
||||
Semester = (int)academicPlanRecord.Semester,
|
||||
StudentLastName = student.LastName,
|
||||
StudentFirstName = student.FirstName,
|
||||
Zet = academicPlanRecord.Zet
|
||||
};
|
||||
list.Add(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//поставили оценки из успеваемости студента в лист
|
||||
foreach (var l in list)
|
||||
{
|
||||
foreach (var studProgress in academicProgress.List.Where(rec => rec.StudentId == studentId && l.DisciplineName == rec.DisciplineName && l.Semester == (int)rec.Semester))
|
||||
{
|
||||
|
||||
switch (studProgress.Score)
|
||||
{
|
||||
case ExamScores.Отлично:
|
||||
average += 5;
|
||||
score = "5";
|
||||
count++;
|
||||
|
||||
break;
|
||||
case ExamScores.Хорошо:
|
||||
average += 4;
|
||||
score = "4";
|
||||
count++;
|
||||
|
||||
break;
|
||||
case ExamScores.Удовлетворительно:
|
||||
average += 3;
|
||||
score = "3";
|
||||
count++;
|
||||
|
||||
break;
|
||||
case ExamScores.Зачет:
|
||||
score = "+";
|
||||
break;
|
||||
}
|
||||
|
||||
l.Scores = score;
|
||||
}
|
||||
|
||||
l.Average = Math.Round(((average) / count) , 2);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<StudentScoresViewModel> GetStudentScores(Guid? studentId)
|
||||
{
|
||||
var academicProgress = _studentAcademicProgresslogic.GetList(new StudentAcademicProgressGetBindingModel());
|
||||
var discipline = _disciplinelogic.GetList(new DisciplineGetBindingModel());
|
||||
var academicPlanRecords = _academicPlanRecordlogic.GetList(new AcademicPlanRecordGetBindingModel());
|
||||
var students = _studentlogic.GetList(new StudentGetBindingModel());
|
||||
var educationDirections = _educationDirectionlogic.GetList(new EducationDirectionGetBindingModel());
|
||||
var studentGroup = _studentGrouplogic.GetList(new StudentGroupGetBindingModel());
|
||||
var academicPlans = _academicPlanlogic.GetList(new AcademicPlanGetBindingModel());
|
||||
var list = new List<StudentScoresViewModel>();
|
||||
//записываем имена дисциплин в лист
|
||||
foreach (var student in students.List.Where(rec => rec.Id == studentId))
|
||||
{
|
||||
foreach (var studGroup in studentGroup.List.Where(rec => rec.Id == student.StudentGroupId))
|
||||
{
|
||||
foreach (var educatDirection in educationDirections.List.Where(rec => rec.Id == studGroup.EducationDirectionId))
|
||||
{
|
||||
foreach (var academicPlan in academicPlans.List.Where(rec => rec.EducationDirectionId == educatDirection.Id))
|
||||
{
|
||||
foreach (var academicPlanRecord in academicPlanRecords.List.Where(rec => rec.AcademicPlanId == academicPlan.Id).OrderBy(rec => rec.DisciplineName).ThenByDescending(rec => rec.SemesterTitle))
|
||||
{
|
||||
|
||||
//является ли родителем
|
||||
if (academicPlanRecord.IsParent)
|
||||
{
|
||||
bool hasScore = false;
|
||||
//ищем всех детей
|
||||
foreach (var academicPlanRecordChild in academicPlanRecords.List.Where(rec => rec.AcademicPlanRecordParentId == academicPlanRecord.Id))
|
||||
{
|
||||
//если есть оценки то заполняем
|
||||
foreach (var studProgress in academicProgress.List.Where(rec => rec.StudentId == studentId && rec.DisciplineId == academicPlanRecordChild.DisciplineId && rec.Semester == academicPlanRecordChild.Semester))
|
||||
{
|
||||
var record = new StudentScoresViewModel
|
||||
{
|
||||
DisciplineName = academicPlanRecordChild.DisciplineName,
|
||||
Scores = studProgress.ExamScoresTitle,
|
||||
StudentLastName = student.LastName,
|
||||
StudentFirstName = student.FirstName,
|
||||
Semester = (int)academicPlanRecordChild.Semester,
|
||||
Zet = academicPlanRecordChild.Zet
|
||||
};
|
||||
list.Add(record);
|
||||
hasScore = true;
|
||||
}
|
||||
}
|
||||
//если оценок нет, то вставляем имя родителя
|
||||
if (!hasScore)
|
||||
{
|
||||
|
||||
var record = new StudentScoresViewModel
|
||||
{
|
||||
DisciplineName = academicPlanRecord.DisciplineName,
|
||||
Scores = " ",
|
||||
Semester = (int)academicPlanRecord.Semester,
|
||||
StudentLastName = student.LastName,
|
||||
StudentFirstName = student.FirstName,
|
||||
Zet = academicPlanRecord.Zet
|
||||
};
|
||||
list.Add(record);
|
||||
}
|
||||
}//если не имеет детей то записываем имя без оценки
|
||||
else if (academicPlanRecord.IsChildValue == "Нет")
|
||||
{
|
||||
|
||||
var record = new StudentScoresViewModel
|
||||
{
|
||||
DisciplineName = academicPlanRecord.DisciplineName,
|
||||
Scores = " ",
|
||||
Semester = (int)academicPlanRecord.Semester,
|
||||
StudentLastName = student.LastName,
|
||||
StudentFirstName = student.FirstName,
|
||||
Zet = academicPlanRecord.Zet
|
||||
};
|
||||
list.Add(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var list2 = new List<StudentScoresViewModel>();
|
||||
list2.Add(list[0]);
|
||||
int z = 0;
|
||||
//в новый лист заносим только по одной дисциплине и складываем з.ешки у одинаковых дисциплин
|
||||
foreach (var l in list)
|
||||
{
|
||||
if (l.DisciplineName != list2[list2.Count - 1].DisciplineName)
|
||||
{
|
||||
list2.Add(l);
|
||||
z += l.Zet;
|
||||
}
|
||||
else
|
||||
{
|
||||
list2[list2.Count - 1].Zet += l.Zet;
|
||||
z += l.Zet;
|
||||
}
|
||||
}
|
||||
//записываем оценки в лист из успевамости
|
||||
foreach (var l in list2)
|
||||
{
|
||||
foreach (var studProgress in academicProgress.List.Where(rec => rec.StudentId == studentId))
|
||||
{
|
||||
if (l.DisciplineName == studProgress.DisciplineName && l.Semester == (int)studProgress.Semester && l.Scores != null)
|
||||
{
|
||||
l.Scores = studProgress.Score.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Clear();
|
||||
|
||||
foreach (var l in list2.OrderBy(rec => rec.Semester))
|
||||
{
|
||||
list.Add(l);
|
||||
}
|
||||
|
||||
list[list.Count - 1].Average = z;
|
||||
|
||||
return list;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,425 @@
|
||||
using AcademicProgressBusinessLogic.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class SaveToExcel
|
||||
{
|
||||
public static void CreateDoc(ExcelInfo info)
|
||||
{
|
||||
using (SpreadsheetDocument spreadsheetDocument =
|
||||
SpreadsheetDocument.Create(info.FileName+ "//" + info.Title + "5.xlsx", SpreadsheetDocumentType.Workbook))
|
||||
{
|
||||
// Создаем книгу (в ней хранятся листы)
|
||||
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
CreateStyles(workbookpart);
|
||||
// Получаем/создаем хранилище текстов для книги
|
||||
SharedStringTablePart shareStringPart =
|
||||
spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().Count() > 0
|
||||
?
|
||||
spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First() : spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
// Создаем SharedStringTable, если его нет
|
||||
if (shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
// Создаем лист в книгу
|
||||
WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
// Добавляем лист в книгу
|
||||
Sheets sheets =
|
||||
spreadsheetDocument.WorkbookPart.Workbook.AppendChild<Sheets>(new Sheets());
|
||||
Sheet sheet = new Sheet()
|
||||
{
|
||||
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
Worksheet = worksheetPart.Worksheet,
|
||||
ShareStringPart = shareStringPart,
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleIndex = 2U
|
||||
});
|
||||
uint rowIndex = 4;
|
||||
|
||||
if (info.StudentScores != null)
|
||||
{
|
||||
int indexList = 3;
|
||||
foreach (var pc in info.StudentScores)
|
||||
{
|
||||
|
||||
rowIndex = 4;
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
Worksheet = worksheetPart.Worksheet,
|
||||
ShareStringPart = shareStringPart,
|
||||
ColumnName = GetExcelColumnName(indexList),
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.DisciplineName,
|
||||
StyleIndex = 1U
|
||||
});
|
||||
rowIndex++;
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
Worksheet = worksheetPart.Worksheet,
|
||||
ShareStringPart = shareStringPart,
|
||||
ColumnName = GetExcelColumnName(indexList),
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.Scores,
|
||||
StyleIndex = 1U
|
||||
});
|
||||
indexList++;
|
||||
|
||||
|
||||
}
|
||||
indexList = 2;
|
||||
rowIndex = 1;
|
||||
/* InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
Worksheet = worksheetPart.Worksheet,
|
||||
ShareStringPart = shareStringPart,
|
||||
ColumnName = list[indexList],
|
||||
RowIndex = rowIndex,
|
||||
Text = "Cредний балл:",
|
||||
StyleIndex = 0U
|
||||
});
|
||||
rowIndex++;
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
Worksheet = worksheetPart.Worksheet,
|
||||
ShareStringPart = shareStringPart,
|
||||
ColumnName = list[indexList],
|
||||
RowIndex = rowIndex,
|
||||
Text = Convert.ToString((info.StudentScores[info.StudentScores.Count - 1].Average)),
|
||||
StyleIndex = 0U
|
||||
});*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Настройка стилей для файла
|
||||
/// </summary>
|
||||
/// <param name="workbookpart"></param>
|
||||
private static void CreateStyles(WorkbookPart workbookpart)
|
||||
{
|
||||
WorkbookStylesPart sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
Fonts fonts = new Fonts() { Count = (UInt32Value)2U, KnownFonts = true };
|
||||
Font fontUsual = new Font();
|
||||
fontUsual.Append(new FontSize() { Val = 12D });
|
||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{
|
||||
Theme
|
||||
= (UInt32Value)1U
|
||||
});
|
||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
Font fontTitle = new Font();
|
||||
fontTitle.Append(new Bold());
|
||||
fontTitle.Append(new FontSize() { Val = 14D });
|
||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{
|
||||
Theme
|
||||
= (UInt32Value)1U
|
||||
});
|
||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTitle);
|
||||
Fills fills = new Fills() { Count = (UInt32Value)2U };
|
||||
Fill fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
Fill fill2 = new Fill();
|
||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
Borders borders = new Borders() { Count = (UInt32Value)2U };
|
||||
Border borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
borderNoBorder.Append(new RightBorder());
|
||||
borderNoBorder.Append(new TopBorder());
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
Border borderThin = new Border();
|
||||
LeftBorder leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{
|
||||
Indexed = (UInt32Value)64U
|
||||
});
|
||||
RightBorder rightBorder = new RightBorder()
|
||||
{
|
||||
Style = BorderStyleValues.Thin
|
||||
};
|
||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{
|
||||
Indexed = (UInt32Value)64U
|
||||
});
|
||||
TopBorder topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{
|
||||
Indexed = (UInt32Value)64U
|
||||
});
|
||||
BottomBorder bottomBorder = new BottomBorder()
|
||||
{
|
||||
Style =
|
||||
BorderStyleValues.Thin
|
||||
};
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{
|
||||
Indexed = (UInt32Value)64U
|
||||
});
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
borderThin.Append(bottomBorder);
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
CellStyleFormats cellStyleFormats = new CellStyleFormats()
|
||||
{
|
||||
Count =
|
||||
(UInt32Value)1U
|
||||
};
|
||||
CellFormat cellFormatStyle = new CellFormat()
|
||||
{
|
||||
NumberFormatId =
|
||||
(UInt32Value)0U,
|
||||
FontId = (UInt32Value)0U,
|
||||
FillId = (UInt32Value)0U,
|
||||
BorderId =
|
||||
(UInt32Value)0U
|
||||
};
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
CellFormats cellFormats = new CellFormats() { Count = (UInt32Value)3U };
|
||||
CellFormat cellFormatFont = new CellFormat()
|
||||
{
|
||||
NumberFormatId =
|
||||
(UInt32Value)0U,
|
||||
FontId = (UInt32Value)0U,
|
||||
FillId = (UInt32Value)0U,
|
||||
BorderId =
|
||||
(UInt32Value)0U,
|
||||
FormatId = (UInt32Value)0U,
|
||||
ApplyFont = true
|
||||
};
|
||||
CellFormat cellFormatFontAndBorder = new CellFormat()
|
||||
{
|
||||
NumberFormatId =
|
||||
(UInt32Value)0U,
|
||||
FontId = (UInt32Value)0U,
|
||||
FillId = (UInt32Value)0U,
|
||||
BorderId =
|
||||
(UInt32Value)1U,
|
||||
FormatId = (UInt32Value)0U,
|
||||
ApplyFont = true,
|
||||
ApplyBorder = true
|
||||
};
|
||||
CellFormat cellFormatTitle = new CellFormat()
|
||||
{
|
||||
NumberFormatId =
|
||||
(UInt32Value)0U,
|
||||
FontId = (UInt32Value)1U,
|
||||
FillId = (UInt32Value)0U,
|
||||
BorderId =
|
||||
(UInt32Value)0U,
|
||||
FormatId = (UInt32Value)0U,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Vertical =
|
||||
VerticalAlignmentValues.Center,
|
||||
WrapText = true,
|
||||
Horizontal =
|
||||
HorizontalAlignmentValues.Center
|
||||
},
|
||||
ApplyFont = true
|
||||
};
|
||||
cellFormats.Append(cellFormatFont);
|
||||
cellFormats.Append(cellFormatFontAndBorder);
|
||||
cellFormats.Append(cellFormatTitle);
|
||||
CellStyles cellStyles = new CellStyles() { Count = (UInt32Value)1U };
|
||||
cellStyles.Append(new CellStyle()
|
||||
{
|
||||
Name = "Normal",
|
||||
FormatId =
|
||||
(UInt32Value)0U,
|
||||
BuiltinId = (UInt32Value)0U
|
||||
});
|
||||
DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats
|
||||
differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
||||
{
|
||||
Count = (UInt32Value)0U
|
||||
};
|
||||
|
||||
TableStyles tableStyles = new TableStyles()
|
||||
{
|
||||
Count = (UInt32Value)0U,
|
||||
DefaultTableStyle = "TableStyleMedium2",
|
||||
DefaultPivotStyle = "PivotStyleLight16"
|
||||
};
|
||||
StylesheetExtensionList stylesheetExtensionList = new
|
||||
StylesheetExtensionList();
|
||||
StylesheetExtension stylesheetExtension1 = new StylesheetExtension()
|
||||
{
|
||||
Uri =
|
||||
"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||
};
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14",
|
||||
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
DefaultSlicerStyle =
|
||||
"SlicerStyleLight1"
|
||||
});
|
||||
StylesheetExtension stylesheetExtension2 = new StylesheetExtension()
|
||||
{
|
||||
Uri =
|
||||
"{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
||||
};
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15",
|
||||
"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles()
|
||||
{
|
||||
DefaultTimelineStyle =
|
||||
"TimeSlicerStyleLight1"
|
||||
});
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
string columnName = "";
|
||||
|
||||
while (columnNumber > 0)
|
||||
{
|
||||
int modulo = (columnNumber - 1) % 26;
|
||||
columnName = Convert.ToChar('A' + modulo) + columnName;
|
||||
columnNumber = (columnNumber - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добааляем новую ячейку в лист
|
||||
/// </summary>
|
||||
/// <param name="worksheet"></param>
|
||||
/// <param name="columnName"></param>
|
||||
/// <param name="rowIndex"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
private static void InsertCellInWorksheet(ExcelCellParameters cellParameters)
|
||||
{
|
||||
SheetData sheetData = cellParameters.Worksheet.GetFirstChild<SheetData>();
|
||||
// Ищем строку, либо добавляем ее
|
||||
Row row;
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex ==
|
||||
cellParameters.RowIndex).Count() != 0)
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex ==
|
||||
cellParameters.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = cellParameters.RowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
// Ищем нужную ячейку
|
||||
Cell cell;
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference.Value ==
|
||||
cellParameters.CellReference).Count() > 0)
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference.Value ==
|
||||
cellParameters.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Все ячейки должны быть последовательно друг за другом расположены
|
||||
// нужно определить, после какой вставлять
|
||||
Cell refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference.Value,
|
||||
cellParameters.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Cell newCell = new Cell()
|
||||
{
|
||||
CellReference = cellParameters.CellReference
|
||||
};
|
||||
row.InsertBefore(newCell, refCell);
|
||||
cell = newCell;
|
||||
}
|
||||
// вставляем новый текст
|
||||
cellParameters.ShareStringPart.SharedStringTable.AppendChild(new
|
||||
SharedStringItem(new Text(cellParameters.Text)));
|
||||
cellParameters.ShareStringPart.SharedStringTable.Save();
|
||||
cell.CellValue = new
|
||||
CellValue((cellParameters.ShareStringPart.SharedStringTable.Elements<SharedStringItem>().
|
||||
Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = cellParameters.StyleIndex;
|
||||
}
|
||||
/// <summary>
|
||||
/// Объединение ячеек
|
||||
/// </summary>
|
||||
/// <param name="worksheet"></param>
|
||||
/// <param name="cell1Name"></param>
|
||||
/// <param name="cell2Name"></param>
|
||||
private static void MergeCells(ExcelMergeParameters mergeParameters)
|
||||
{
|
||||
MergeCells mergeCells;
|
||||
if (mergeParameters.Worksheet.Elements<MergeCells>().Count() > 0)
|
||||
{
|
||||
mergeCells = mergeParameters.Worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
if (mergeParameters.Worksheet.Elements<CustomSheetView>().Count() > 0)
|
||||
{
|
||||
mergeParameters.Worksheet.InsertAfter(mergeCells,
|
||||
mergeParameters.Worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeParameters.Worksheet.InsertAfter(mergeCells,
|
||||
mergeParameters.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
MergeCell mergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(mergeParameters.Merge)
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,265 @@
|
||||
using AcademicProgressBusinessLogic.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class SaveToWord
|
||||
{
|
||||
public static void CreateDoc(WordInfo info)
|
||||
{
|
||||
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(info.FileName + "//" + info.Title + ".docx", WordprocessingDocumentType.Document))
|
||||
{
|
||||
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
Body docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
||||
docBody.AppendChild(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { info.Title },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = true,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Center
|
||||
}
|
||||
}));
|
||||
|
||||
if (info.StudentScores != null)
|
||||
{
|
||||
foreach (var rp in info.StudentScores)
|
||||
{
|
||||
|
||||
docBody.AppendChild(CreateParagraph(new WordParagraph
|
||||
{
|
||||
|
||||
Texts = new List<string> { "Приложение к диплому студента - " + rp.StudentLastName + rp.StudentFirstName },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
|
||||
}));
|
||||
break;
|
||||
|
||||
}
|
||||
Table table = new Table();
|
||||
|
||||
TableProperties props = new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 2 },
|
||||
new BottomBorder { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 2 },
|
||||
new LeftBorder { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 2 },
|
||||
new RightBorder { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 2 },
|
||||
new InsideHorizontalBorder { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 2 },
|
||||
new InsideVerticalBorder { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 2 }
|
||||
));
|
||||
|
||||
table.AppendChild(props);
|
||||
|
||||
var tr = new TableRow();
|
||||
var tc_dis = new TableCell();
|
||||
var tc_zet = new TableCell();
|
||||
var tc_scor = new TableCell();
|
||||
|
||||
tc_dis.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { "Наименование дисциплин" },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
|
||||
tc_zet.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { "Количество з.е." },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
|
||||
tc_scor.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { "Итоговая оценка" },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
|
||||
tr.AppendChild(tc_dis);
|
||||
tr.AppendChild(tc_zet);
|
||||
tr.AppendChild(tc_scor);
|
||||
table.AppendChild(tr);
|
||||
|
||||
|
||||
|
||||
foreach (var studScore in info.StudentScores)
|
||||
{
|
||||
tr = new TableRow();
|
||||
tc_dis = new TableCell();
|
||||
tc_zet = new TableCell();
|
||||
tc_scor = new TableCell();
|
||||
|
||||
tc_dis.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { studScore.DisciplineName },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
tc_zet.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { Convert.ToString(studScore.Zet) + " з.е." },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
tc_scor.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { studScore.Scores },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
tr.AppendChild(tc_dis);
|
||||
tr.AppendChild(tc_zet);
|
||||
tr.AppendChild(tc_scor);
|
||||
table.AppendChild(tr);
|
||||
}
|
||||
|
||||
var tr2 = new TableRow();
|
||||
var tc_sr = new TableCell();
|
||||
var tc_ss = new TableCell();
|
||||
tc_sr.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { "Всего" },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
tc_ss.Append(CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<string> { Convert.ToString(info.StudentScores[info.StudentScores.Count - 1].Average) + " з.е." },
|
||||
TextProperties = new WordParagraphProperties
|
||||
{
|
||||
Bold = false,
|
||||
Size = "24",
|
||||
JustificationValues = JustificationValues.Both
|
||||
}
|
||||
}));
|
||||
|
||||
tr2.AppendChild(tc_sr);
|
||||
tr2.AppendChild(tc_ss);
|
||||
table.AppendChild(tr2);
|
||||
|
||||
docBody.AppendChild(table);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
docBody.AppendChild(CreateSectionProperties());
|
||||
wordDocument.MainDocumentPart.Document.Save();
|
||||
}
|
||||
}
|
||||
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
SectionProperties properties = new SectionProperties();
|
||||
PageSize pageSize = new PageSize { Orient = PageOrientationValues.Portrait };
|
||||
|
||||
properties.AppendChild(pageSize);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static Paragraph CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (paragraph != null)
|
||||
{
|
||||
Paragraph docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
Run docRun = new Run();
|
||||
RunProperties properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = paragraph.TextProperties.Size });
|
||||
|
||||
if (!run.StartsWith(" - ") && paragraph.TextProperties.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
|
||||
docRun.AppendChild(properties);
|
||||
docRun.AppendChild(new Text { Text = run, Space = SpaceProcessingModeValues.Preserve });
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
|
||||
return docParagraph;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ParagraphProperties CreateParagraphProperties(WordParagraphProperties paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties != null)
|
||||
{
|
||||
ParagraphProperties properties = new ParagraphProperties();
|
||||
|
||||
properties.AppendChild(new Justification() { Val = paragraphProperties.JustificationValues });
|
||||
properties.AppendChild(new SpacingBetweenLines { LineRule = LineSpacingRuleValues.Auto });
|
||||
properties.AppendChild(new Indentation());
|
||||
|
||||
ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||
}
|
||||
|
||||
if (paragraphProperties.Bold)
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new Bold());
|
||||
}
|
||||
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
public class ExcelCellParameters
|
||||
{
|
||||
public Worksheet Worksheet { get; set; }
|
||||
public string ColumnName { get; set; }
|
||||
public uint RowIndex { get; set; }
|
||||
public UInt32Value StyleIndex { get; set; }
|
||||
public string Text { get; set; }
|
||||
public SharedStringTablePart ShareStringPart { get; set; }
|
||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using AcademicProgressBusinessLogic.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
public class ExcelInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
public List<StudentScoresViewModel> StudentScores { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public Worksheet Worksheet { get; set; }
|
||||
public string CellFromName { get; set; }
|
||||
public string CellToName { get; set; }
|
||||
public string Merge => $"{CellFromName}:{CellToName}";
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
Text,
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using AcademicProgressBusinessLogic.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
public class WordInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string Title { get; set; }
|
||||
public List<StudentScoresViewModel> StudentScores { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
class WordParagraph
|
||||
{
|
||||
public List<string> Texts { get; set; }
|
||||
public WordParagraphProperties TextProperties { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.HelperModels
|
||||
{
|
||||
class WordParagraphProperties
|
||||
{
|
||||
public string Size { get; set; }
|
||||
|
||||
public bool Bold { get; set; }
|
||||
|
||||
public JustificationValues JustificationValues { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -26,15 +26,14 @@ namespace AcademicProgressBusinessLogic.ViewModels
|
||||
[ViewModelControlElementProperty("Студент", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")]
|
||||
[MapConfiguration("StudentId")]
|
||||
public Guid StudentId { get; set; }
|
||||
|
||||
[ViewModelControlListProperty("Имя", ColumnWidth = 200)]
|
||||
[MapConfiguration("Student.FirstName", IsDifficle = true)]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
[ViewModelControlListProperty("Фамилия", ColumnWidth = 250)]
|
||||
[MapConfiguration("Student.LastName", IsDifficle = true)]
|
||||
public string LastName { get; set; }
|
||||
|
||||
|
||||
[ViewModelControlListProperty("Имя", ColumnWidth = 200)]
|
||||
[MapConfiguration("Student.FirstName", IsDifficle = true)]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
[ViewModelControlElementProperty("Дисциплина", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlDisciplineList, DepartmentWindowsDesktop")]
|
||||
[MapConfiguration("DisciplineId")]
|
||||
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressBusinessLogic.ViewModels
|
||||
{
|
||||
public class StudentScoresViewModel
|
||||
{
|
||||
public string StudentLastName { get; set; }
|
||||
public string StudentFirstName { get; set; }
|
||||
public string DisciplineName { get; set; }
|
||||
public string Scores { get; set; }
|
||||
public int Zet { get; set; }
|
||||
public double Average { get; set; }
|
||||
public int Semester { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using AcademicProgressBusinessLogic.Interfaces;
|
||||
using AcademicProgressBusinessLogic.BusinessLogic;
|
||||
using AcademicProgressBusinessLogic.BusinessLogics;
|
||||
using AcademicProgressBusinessLogic.Interfaces;
|
||||
using AcademicProgressDatabaseImplementation.Implementations;
|
||||
using ModuleTools.BusinessLogics;
|
||||
using ModuleTools.Interfaces;
|
||||
@ -11,6 +13,8 @@ namespace AcademicProgressDatabaseImplementation
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IStudentAcademicProgressService, StudentAcademicProgressService>();
|
||||
DependencyManager.Instance.RegisterType<ReportLogic>();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
using AcademicProgressBusinessLogic.BindingModels;
|
||||
using AcademicProgressBusinessLogic.Interfaces;
|
||||
using ModuleTools.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AcademicProgressDatabaseImplementation.Implementations
|
||||
{
|
||||
public class ReportService : IReportService
|
||||
{
|
||||
public OperationResultModel SaveReportToWordFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -41,11 +41,12 @@ namespace AcademicProgressDatabaseImplementation.Implementations
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, StudentAcademicProgress entity, StudentAcademicProgressGetBindingModel model) { }
|
||||
|
||||
protected override StudentAcademicProgress GetUniqueEntity(StudentAcademicProgressSetBindingModel model, DbContext context) => context.Set<StudentAcademicProgress>().FirstOrDefault(x => x.StudentId == model.StudentId && x.Id != model.Id);
|
||||
protected override StudentAcademicProgress GetUniqueEntity(StudentAcademicProgressSetBindingModel model, DbContext context) => context.Set<StudentAcademicProgress>().FirstOrDefault(x => x.StudentId == model.StudentId && x.DisciplineId == model.DisciplineId && x.Semester == (int)model.Semester && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<StudentAcademicProgress> IncludingWhenReading(IQueryable<StudentAcademicProgress> query) => query.Include(x => x.Student).Include(x => x.Discipline);
|
||||
|
||||
protected override IQueryable<StudentAcademicProgress> OrderingWhenReading(IQueryable<StudentAcademicProgress> query) => query.OrderBy(x => x.Student.LastName).ThenBy(x => x.Student.FirstName);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,10 @@
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.16.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AcademicProgressBusinessLogic\AcademicProgressBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\Common\DesktopTools\DesktopTools.csproj" />
|
||||
|
@ -8,6 +8,7 @@ using DesktopTools.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DesktopTools.Enums;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AcademicProgressWindowsDesktop.EntityControls.StudentAcademicProgress
|
||||
{
|
||||
@ -44,7 +45,7 @@ namespace AcademicProgressWindowsDesktop.EntityControls.StudentAcademicProgress
|
||||
|
||||
private void LoadScore()
|
||||
{
|
||||
//загрузка оценок
|
||||
MessageBox.Show("Оценки успешно выгружены!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,7 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
this.buttonSaveSelectFolder.TabIndex = 16;
|
||||
this.buttonSaveSelectFolder.Text = "Выбрать папку";
|
||||
this.buttonSaveSelectFolder.UseVisualStyleBackColor = true;
|
||||
this.buttonSaveSelectFolder.Click += new System.EventHandler(this.buttonSaveSelectFolder_Click_1);
|
||||
//
|
||||
// ControlReportAcademicProgress
|
||||
//
|
||||
|
@ -1,26 +1,17 @@
|
||||
using AcademicProgressBusinessLogic.BusinessLogics;
|
||||
using DepartmentBusinessLogic.BindingModels;
|
||||
using DepartmentBusinessLogic.BusinessLogics;
|
||||
using DepartmentBusinessLogic.Interfaces;
|
||||
using AcademicProgressBusinessLogic.BindingModels;
|
||||
using AcademicProgressBusinessLogic.BusinessLogics;
|
||||
using DepartmentWindowsDesktop.EntityControls;
|
||||
using DesktopTools.BaseControls;
|
||||
using DesktopTools.Helpers;
|
||||
using DesktopTools.Interfaces;
|
||||
using DesktopTools.Models;
|
||||
using ModuleTools.BusinessLogics;
|
||||
using ModuleTools.Enums;
|
||||
using SecurityBusinessLogic.BindingModels;
|
||||
using SecurityBusinessLogic.BusinessLogics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
{
|
||||
/// <summary>
|
||||
@ -31,7 +22,7 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
/// <summary>
|
||||
/// Класс с бизнес-логикой работы с отчетом
|
||||
/// </summary>
|
||||
private readonly ReportBusinessLogic _reportLogic;
|
||||
private readonly ReportLogic _reportLogic;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -40,13 +31,19 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
///
|
||||
private event Action<Guid> CloseEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Событие получения значения из контрола
|
||||
/// </summary>
|
||||
private event Action<object> GetValues;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Контрол для работы с отчетом об успеваемости
|
||||
/// </summary>
|
||||
public ControlReportAcademicProgress()
|
||||
{
|
||||
InitializeComponent();
|
||||
_reportLogic = DependencyManager.Instance.Resolve<ReportBusinessLogic>();
|
||||
_reportLogic = DependencyManager.Instance.Resolve<ReportLogic>();
|
||||
Title = "Отчет об успеваемости студентов";
|
||||
ControlId = new Guid("cc2244e6-5d92-4c89-b817-4c17ec382bc1");
|
||||
AccessOperation = AccessOperation.Учет_успеваемости;
|
||||
@ -114,7 +111,22 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
|
||||
private void buttonSave_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var model = new StudentAcademicProgressSetBindingModel();
|
||||
try
|
||||
{
|
||||
GetValues(model);
|
||||
|
||||
_reportLogic.SaveReportToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FolderName = textBoxSaveFolderName.Text,
|
||||
StudentId = model.StudentId
|
||||
});
|
||||
DialogHelper.MessageInformation("Сохранение прошло успешно", "Результат");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogHelper.MessageException(ex.Message, "Ошибка при получении значений");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadGroupBoxReportInfo()
|
||||
@ -131,6 +143,7 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
};
|
||||
controlStudent.SetTitleWidth(controlStudent.SetTitle("Cтудент:"));
|
||||
groupBoxReportInfo.Controls.Add(controlStudent);
|
||||
GetValues += controlStudent.GetValue;
|
||||
|
||||
positionY += controlStudent.Height + interval;
|
||||
|
||||
@ -144,5 +157,13 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
groupBoxReportInfo.Controls.Add(controlStudentGroup);
|
||||
}
|
||||
|
||||
private void buttonSaveSelectFolder_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var fbd = new FolderBrowserDialog();
|
||||
if (fbd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
textBoxSaveFolderName.Text = fbd.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
this.groupBoxReportInfo.Controls.Add(this.label3);
|
||||
this.groupBoxReportInfo.Location = new System.Drawing.Point(3, 109);
|
||||
this.groupBoxReportInfo.Name = "groupBoxReportInfo";
|
||||
this.groupBoxReportInfo.Size = new System.Drawing.Size(460, 127);
|
||||
this.groupBoxReportInfo.Size = new System.Drawing.Size(460, 76);
|
||||
this.groupBoxReportInfo.TabIndex = 23;
|
||||
this.groupBoxReportInfo.TabStop = false;
|
||||
this.groupBoxReportInfo.Text = "Информация для отчета";
|
||||
@ -94,7 +94,7 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(330, 242);
|
||||
this.buttonSave.Location = new System.Drawing.Point(330, 203);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(133, 28);
|
||||
this.buttonSave.TabIndex = 22;
|
||||
@ -130,7 +130,7 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
this.Controls.Add(this.labelSaveFolderName);
|
||||
this.Controls.Add(this.toolStripHeader);
|
||||
this.Name = "ControlStudentGraduate";
|
||||
this.Size = new System.Drawing.Size(478, 279);
|
||||
this.Size = new System.Drawing.Size(478, 247);
|
||||
this.toolStripHeader.ResumeLayout(false);
|
||||
this.toolStripHeader.PerformLayout();
|
||||
this.groupBoxReportInfo.ResumeLayout(false);
|
||||
|
@ -22,23 +22,27 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
/// <summary>
|
||||
/// Класс с бизнес-логикой работы с отчетом
|
||||
/// </summary>
|
||||
private readonly ReportBusinessLogic _reportLogic;
|
||||
private readonly ReportLogic _reportLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Событие, вызываемое при закрытии контрола
|
||||
/// </summary>
|
||||
private event Action<Guid> CloseEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Событие получения значения из контрола
|
||||
/// </summary>
|
||||
private event Action<object> GetValues;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Контрол для работы с отчетом приложения к диплому
|
||||
/// </summary>
|
||||
public ControlStudentGraduate()
|
||||
{
|
||||
_reportLogic = DependencyManager.Instance.Resolve<ReportBusinessLogic>();
|
||||
InitializeComponent();
|
||||
_reportLogic = DependencyManager.Instance.Resolve<ReportLogic>();
|
||||
Title = "Приложение к диплому";
|
||||
//что за цифры тут откуда брать...
|
||||
ControlId = new Guid("cc3944e6-5d92-4c89-b817-4c17ec382bc1");
|
||||
AccessOperation = AccessOperation.Для_выпускников;
|
||||
toolStripButtonClose.Click += (object sender, EventArgs e) =>
|
||||
@ -88,7 +92,6 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
{
|
||||
|
||||
int positionY = 40;
|
||||
int interval = 15;
|
||||
|
||||
var controlStudent = new BaseControlGuid("StudentId", true, false, new ControlStudentList(), null)
|
||||
{
|
||||
@ -98,17 +101,8 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
};
|
||||
controlStudent.SetTitleWidth(controlStudent.SetTitle("Cтудент:"));
|
||||
groupBoxReportInfo.Controls.Add(controlStudent);
|
||||
|
||||
positionY += controlStudent.Height + interval;
|
||||
|
||||
var controlStudentGroup = new BaseControlGuid(" StudentGroupId", true, false, new ControlStudentGroupList(), null)
|
||||
{
|
||||
Location = new System.Drawing.Point(53, positionY),
|
||||
Size = new System.Drawing.Size(407, 23)
|
||||
|
||||
};
|
||||
controlStudentGroup.SetTitleWidth(controlStudentGroup.SetTitle("Группа:"));
|
||||
groupBoxReportInfo.Controls.Add(controlStudentGroup);
|
||||
GetValues += controlStudent.GetValue;
|
||||
|
||||
}
|
||||
|
||||
private void buttonSaveSelectFolder_Click(object sender, EventArgs e)
|
||||
@ -120,21 +114,24 @@ namespace AcademicProgressWindowsDesktop.SpecialControls
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var model = new StudentAcademicProgressSetBindingModel();
|
||||
try
|
||||
{
|
||||
GetValues(model);
|
||||
|
||||
_reportLogic.SaveReportToWordFile(new ReportBindingModel
|
||||
{
|
||||
FolderName = textBoxSaveFolderName.Text
|
||||
FolderName = textBoxSaveFolderName.Text,
|
||||
StudentId = model.StudentId
|
||||
});
|
||||
DialogHelper.MessageInformation("Сохранение прошло успешно", "Результат");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogHelper.MessageException(_reportLogic.Errors, "Ошибки при сохранении");
|
||||
DialogHelper.MessageException(ex.Message, "Ошибка при получении значений");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace DepartmentBusinessLogic.ViewModels
|
||||
/// <summary>
|
||||
/// Элемент дисциплина
|
||||
/// </summary>
|
||||
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)]
|
||||
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 600, Height = 500)]
|
||||
[ViewModelControlElementDependenceEntity(Title = "Записи учебного плана", Order = 1, ParentPropertyName = "DisciplineId",
|
||||
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanRecordList, DepartmentWindowsDesktop")]
|
||||
public class DisciplineViewModel : ElementViewModel
|
||||
|
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.16.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
Loading…
Reference in New Issue
Block a user