Excel
This commit is contained in:
parent
55715f945a
commit
a2c399bffd
@ -15,5 +15,6 @@ namespace Demo.Data.Repository
|
|||||||
bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup);
|
bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup);
|
||||||
GroupLocalEntity GetGroupById(int groupID);
|
GroupLocalEntity GetGroupById(int groupID);
|
||||||
bool AddGroup(GroupLocalEntity newGroup);
|
bool AddGroup(GroupLocalEntity newGroup);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -94,20 +94,18 @@ namespace Demo.Domain.UseCase
|
|||||||
|
|
||||||
foreach (var group in allGroups)
|
foreach (var group in allGroups)
|
||||||
{
|
{
|
||||||
// Получаем все записи посещаемости для группы
|
|
||||||
var groupAttendance = _presenceRepository.GetAttendanceByGroup(group.Id);
|
var groupAttendance = _presenceRepository.GetAttendanceByGroup(group.Id);
|
||||||
var attendanceRecords = new List<Excel>();
|
var attendanceRecords = new List<Excel>();
|
||||||
|
|
||||||
foreach (var record in groupAttendance)
|
foreach (var record in groupAttendance)
|
||||||
{
|
{
|
||||||
// Подбираем имена пользователей и добавляем все записи для всех занятий
|
var names = _userRepository.GetUserNames().Where(u => u.Guid == record.UserGuid);
|
||||||
var user = _userRepository.GetUserNames().FirstOrDefault(u => u.Guid == record.UserGuid);
|
foreach (var name in names)
|
||||||
if (user != null)
|
|
||||||
{
|
{
|
||||||
attendanceRecords.Add(new Excel
|
attendanceRecords.Add(new Excel
|
||||||
{
|
{
|
||||||
UserName = user.FIO,
|
UserName = name.FIO,
|
||||||
UserGuid = user.Guid,
|
UserGuid = name.Guid,
|
||||||
Date = record.Date,
|
Date = record.Date,
|
||||||
IsAttedance = record.IsAttedance,
|
IsAttedance = record.IsAttedance,
|
||||||
LessonNumber = record.LessonNumber,
|
LessonNumber = record.LessonNumber,
|
||||||
@ -129,11 +127,11 @@ namespace Demo.Domain.UseCase
|
|||||||
string reportsFolderPath = Path.Combine(projectDirectory, "Reports");
|
string reportsFolderPath = Path.Combine(projectDirectory, "Reports");
|
||||||
string filePath = Path.Combine(reportsFolderPath, "AttendanceReport.xlsx");
|
string filePath = Path.Combine(reportsFolderPath, "AttendanceReport.xlsx");
|
||||||
|
|
||||||
|
// Создаем папку, если она не существует
|
||||||
if (!Directory.Exists(reportsFolderPath))
|
if (!Directory.Exists(reportsFolderPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(reportsFolderPath);
|
Directory.CreateDirectory(reportsFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var workbook = new XLWorkbook())
|
using (var workbook = new XLWorkbook())
|
||||||
{
|
{
|
||||||
foreach (var group in attendanceByGroup)
|
foreach (var group in attendanceByGroup)
|
||||||
@ -146,15 +144,23 @@ namespace Demo.Domain.UseCase
|
|||||||
worksheet.Cell(1, 5).Value = "Статус";
|
worksheet.Cell(1, 5).Value = "Статус";
|
||||||
|
|
||||||
int row = 2;
|
int row = 2;
|
||||||
|
int lesNum = 1;
|
||||||
foreach (var record in group.Value.OrderBy(r => r.Date).ThenBy(r => r.LessonNumber))
|
foreach (var record in group.Value.OrderBy(r => r.Date).ThenBy(r => r.LessonNumber).ThenBy(r => r.UserGuid))
|
||||||
{
|
{
|
||||||
|
if (lesNum != record.LessonNumber)
|
||||||
|
{
|
||||||
|
row++;
|
||||||
|
}
|
||||||
worksheet.Cell(row, 1).Value = record.UserName;
|
worksheet.Cell(row, 1).Value = record.UserName;
|
||||||
worksheet.Cell(row, 2).Value = record.GroupName;
|
worksheet.Cell(row, 2).Value = record.GroupName;
|
||||||
worksheet.Cell(row, 3).Value = record.Date.ToString("dd.MM.yyyy");
|
worksheet.Cell(row, 3).Value = record.Date.ToString("dd.MM.yyyy");
|
||||||
worksheet.Cell(row, 4).Value = record.LessonNumber;
|
worksheet.Cell(row, 4).Value = record.LessonNumber;
|
||||||
worksheet.Cell(row, 5).Value = record.IsAttedance ? "Присутствует" : "Отсутствует";
|
worksheet.Cell(row, 5).Value = record.IsAttedance ? "Присутствует" : "Отсутствует";
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
lesNum = record.LessonNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
worksheet.Columns().AdjustToContents();
|
worksheet.Columns().AdjustToContents();
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Demo")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Demo")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+121b311f6ca5ffccb7311256bf0d59b9e67c5a90")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+55715f945aa5c1203cf2737829b38f2a99b70d80")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Demo")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Demo")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Demo")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Demo")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
cc574df25988491af8b762013ccd289442d6889574bcaf8a1b45bac2d2668432
|
53cb790fd140c3e85d741460a98394d38c0120abb8a366167b54662ab0eda961
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user