Синхронизация оценок

This commit is contained in:
kotcheshir73 2022-12-24 09:10:07 +04:00
parent 42dad18c0f
commit 97ae32a479
19 changed files with 2293 additions and 16 deletions

View File

@ -90,7 +90,7 @@ namespace CoreDatabase
.WithMany(x => x.OrderStudentRecords)
.OnDelete(DeleteBehavior.NoAction);
modelBuilder.Entity<StudentMarkPassedDiscipline>().HasIndex(d => new { d.StudentId, d.DisciplineId, d.Semester, d.Mark }).IsUnique();
modelBuilder.Entity<StudentMarkPassedDiscipline>().HasIndex(d => new { d.StudentId, d.DisciplineId, d.Semester, d.DisciplineReportingType, d.Mark }).IsUnique();
}
#region Security

View File

@ -0,0 +1,86 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UpdateStudentMarkPassedDisciplineModel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_StudentMarkPassedDisciplines_StudentId_DisciplineId_Semester_Mark",
table: "StudentMarkPassedDisciplines");
migrationBuilder.AddColumn<string>(
name: "AddiionalInfo",
table: "StudentMarkPassedDisciplines",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "DisciplineReportingType",
table: "StudentMarkPassedDisciplines",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<Guid>(
name: "LecturerId",
table: "StudentMarkPassedDisciplines",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_StudentMarkPassedDisciplines_LecturerId",
table: "StudentMarkPassedDisciplines",
column: "LecturerId");
migrationBuilder.CreateIndex(
name: "IX_StudentMarkPassedDisciplines_StudentId_DisciplineId_Semester_DisciplineReportingType_Mark",
table: "StudentMarkPassedDisciplines",
columns: new[] { "StudentId", "DisciplineId", "Semester", "DisciplineReportingType", "Mark" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_StudentMarkPassedDisciplines_Lecturers_LecturerId",
table: "StudentMarkPassedDisciplines",
column: "LecturerId",
principalTable: "Lecturers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_StudentMarkPassedDisciplines_Lecturers_LecturerId",
table: "StudentMarkPassedDisciplines");
migrationBuilder.DropIndex(
name: "IX_StudentMarkPassedDisciplines_LecturerId",
table: "StudentMarkPassedDisciplines");
migrationBuilder.DropIndex(
name: "IX_StudentMarkPassedDisciplines_StudentId_DisciplineId_Semester_DisciplineReportingType_Mark",
table: "StudentMarkPassedDisciplines");
migrationBuilder.DropColumn(
name: "AddiionalInfo",
table: "StudentMarkPassedDisciplines");
migrationBuilder.DropColumn(
name: "DisciplineReportingType",
table: "StudentMarkPassedDisciplines");
migrationBuilder.DropColumn(
name: "LecturerId",
table: "StudentMarkPassedDisciplines");
migrationBuilder.CreateIndex(
name: "IX_StudentMarkPassedDisciplines_StudentId_DisciplineId_Semester_Mark",
table: "StudentMarkPassedDisciplines",
columns: new[] { "StudentId", "DisciplineId", "Semester", "Mark" },
unique: true);
}
}
}

View File

@ -886,6 +886,9 @@ namespace CoreDatabase.Migrations
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("AddiionalInfo")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateAffixing")
.HasColumnType("datetime2");
@ -898,6 +901,9 @@ namespace CoreDatabase.Migrations
b.Property<Guid>("DisciplineId")
.HasColumnType("uniqueidentifier");
b.Property<int>("DisciplineReportingType")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
@ -907,6 +913,9 @@ namespace CoreDatabase.Migrations
b.Property<bool>("IsIncreaseMark")
.HasColumnType("bit");
b.Property<Guid?>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<int>("Mark")
.HasColumnType("int");
@ -920,7 +929,9 @@ namespace CoreDatabase.Migrations
b.HasIndex("DisciplineId");
b.HasIndex("StudentId", "DisciplineId", "Semester", "Mark")
b.HasIndex("LecturerId");
b.HasIndex("StudentId", "DisciplineId", "Semester", "DisciplineReportingType", "Mark")
.IsUnique();
b.ToTable("StudentMarkPassedDisciplines");
@ -1445,6 +1456,10 @@ namespace CoreDatabase.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("StudentMarkPassedDisciplines")
.HasForeignKey("LecturerId");
b.HasOne("CoreDatabase.Models.Department.Student", "Student")
.WithMany("StudentMarkPassedDisciplines")
.HasForeignKey("StudentId")
@ -1453,6 +1468,8 @@ namespace CoreDatabase.Migrations
b.Navigation("Discipline");
b.Navigation("Lecturer");
b.Navigation("Student");
});
@ -1562,6 +1579,8 @@ namespace CoreDatabase.Migrations
b.Navigation("LecturerPosts");
b.Navigation("StudentGroups");
b.Navigation("StudentMarkPassedDisciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>

View File

@ -90,6 +90,9 @@ namespace CoreDatabase.Models.Department
[ForeignKey("LecturerId")]
public virtual List<BasicDepartment> BasicDepartments { get; set; }
[ForeignKey("LecturerId")]
public virtual List<StudentMarkPassedDiscipline> StudentMarkPassedDisciplines { get; set; }
//-------------------------------------------------------------------------
public Lecturer SecurityCheck(Lecturer entity, bool allowFullData)

View File

@ -18,10 +18,17 @@ namespace CoreDatabase.Models.Department
[Required(ErrorMessage = "required")]
public Guid DisciplineId { get; set; }
[DataMember]
public Guid? LecturerId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Semester Semester { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public DisciplineReportingType DisciplineReportingType { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public MarkDisciplinePassedType Mark { get; set; }
@ -38,12 +45,17 @@ namespace CoreDatabase.Models.Department
[Required(ErrorMessage = "required")]
public bool IsDirection { get; set; }
[DataMember]
public string AddiionalInfo { get; set; }
//-------------------------------------------------------------------------
public virtual Discipline Discipline { get; set; }
public virtual Student Student { get; set; }
public virtual Lecturer Lecturer { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
@ -60,6 +72,6 @@ namespace CoreDatabase.Models.Department
return entity;
}
public override string ToString() => $"{Student} {Discipline} {Semester + 1} семестр {Mark}";
public override string ToString() => $"{Student} {Discipline} {Semester} семестр {Mark}";
}
}

View File

@ -0,0 +1,20 @@
namespace CoreModels.Enums.Department
{
/// <summary>
/// Тип отчетности по дисциплине
/// </summary>
public enum DisciplineReportingType
{
Неопределено = -1,
Зачет = 1,
ЗачетСОценкой = 2,
КурсоваяРабота = 3,
КурсовойПроект = 4,
Экзамен
}
}

View File

@ -21,6 +21,10 @@
Седьмой = 7,
Восьмой = 8
Восьмой = 8,
Девятый = 9,
Десятый = 10
}
}

View File

@ -8,17 +8,25 @@ namespace CoreModels.ModelsDepartment
[EntityDescription("StudentMarkPassedDiscipline", "Оценка студента по сданной дисципилне")]
[EntityDependency("Discipline", "DisciplineId", "Дисциплина, по которой выставлена оценка")]
[EntityDependency("Student", "StudentId", "Студент, сдающий дисциплину")]
[EntityDependency("Lecturer", "LecturerId", "Преподаватель, принимавший дисциплину")]
public interface IStudentMarkPassedDisciplineModel : IId
{
Guid StudentId { get; }
Guid DisciplineId { get; }
Guid? LecturerId { get; }
/// <summary>
/// Семестр, в котором сдавался экзамен/зачет по дисциплине
/// </summary>
Semester Semester { get; }
/// <summary>
/// Тип отчетности по дисциплине
/// </summary>
DisciplineReportingType DisciplineReportingType { get; }
/// <summary>
/// Результат сдачи
/// </summary>
@ -38,5 +46,10 @@ namespace CoreModels.ModelsDepartment
/// Является сдачей по направлению
/// </summary>
bool IsDirection { get; }
/// <summary>
/// Дополнительная информация, которую не удалось распознать из данных с 1С
/// </summary>
string AddiionalInfo { get; }
}
}

View File

@ -1,13 +1,24 @@
using DepartmentContract.BindingModels;
using CoreModels.Enums.Department;
using DepartmentBusinessLogic.HelperModels;
using DepartmentContract.BindingModels;
using DepartmentContract.Logics.IGenericEntityLogic;
using DepartmentContract.Services.IGenericEntityService;
using DepartmentContract.ViewModels;
using SecurityContract.BindingModels;
using SecurityContract.Logics.IGenericEntityLogic;
using SecurityContract.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using ToolsModule.ManagmentDependency;
using ToolsModule.ManagmentEntity;
using ToolsModule.ManagmentExtension;
using ToolsModule.ManagmentMapping;
using ToolsModule.ManagmentSecurity;
namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic
@ -17,16 +28,353 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic
/// </summary>
public class StudentMarkSyncHistoryBusinessLogic : GenericBusinessLogic<StudentMarkSyncHistoryGetBindingModel, StudentMarkSyncHistorySetBindingModel, StudentMarkSyncHistoryListViewModel, StudentMarkSyncHistoryViewModel>, IStudentMarkSyncHistoryLogic
{
private IStudentMarkSyncHistoryRecordLogic _recordLogic;
private IEnviromentSettingLogic _enviromentSettingLogic;
private IStudentLogic _studentLogic;
private IDisciplineLogic _disciplineLogic;
private ILecturerLogic _lecturerLogic;
private IStudentMarkPassedDisciplineLogic _studentMarkPassedDisciplineLogic;
private StudentMarkSyncHistoryViewModel _history;
public StudentMarkSyncHistoryBusinessLogic(IStudentMarkSyncHistoryService service) : base(service, "Синхронизация Оценок", AccessOperation.ОценкиСтудентов) { }
public Task<bool> SyncMarks()
public async Task<bool> SyncMarks()
{
throw new NotImplementedException();
InitLogics();
// создание логов по операции синхронизации приказов
if (!CreateHistory())
{
return false;
}
public Task<bool> SyncStudentMarks(Guid studentId)
// получение адреса сервера с приказами
var address = GetAddress();
if (address == null)
{
throw new NotImplementedException();
return false;
}
// подключение клиента для отправки запросов к серверу
var client = GetClinet(address);
if (client == null)
{
return false;
}
// получение списка оценок
var response = await client.GetAsync($"{address.Value}/univer/hs/Ulstu_StudentsInfo/v1/GetCurrentStudentsOfDepartmentGrades");
if (!response.IsSuccessStatusCode)
{
SaveLog("Не удалось получить список оценок студента с сервера");
return false;
}
var studentFromServer = JsonSerializer.Deserialize<StudentInfoListForMarkSyncModel>(await response.Content.ReadAsStringAsync());
if (studentFromServer == null || studentFromServer.arrayOfStudentsGrades == null)
{
SaveLog("Не удалось распознать список приказов по студенту");
return false;
}
if (studentFromServer.arrayOfStudentsGrades.Length == 0)
{
SaveLog("Полученный список студентов пустой");
return false;
}
var students = _studentLogic.GetList(new StudentGetBindingModel());
if (students == null || students.List == null)
{
SaveErrors(_studentLogic.Errors, "Ошибка получения данных", "Не удалось получить список студентов с базы");
return false;
}
foreach (var student in students.List)
{
var marks = studentFromServer.arrayOfStudentsGrades.FirstOrDefault(x => x.recordBook == student.NumberOfBook);
if (marks == null || marks.bills == null || marks.bills.Length == 0)
{
SaveLog($"По студенту {student} ({student.NumberOfBook}) не найдено оценок");
continue;
}
SyncMarks(student, marks.bills);
}
return true;
}
/// <summary>
/// Инициализаия всех логик для получения от них данных и сохранения новых
/// </summary>
private void InitLogics()
{
_recordLogic = DependencyManager.Instance.Resolve<IStudentMarkSyncHistoryRecordLogic>();
_enviromentSettingLogic = DependencyManager.Instance.Resolve<IEnviromentSettingLogic>();
_studentLogic = DependencyManager.Instance.Resolve<IStudentLogic>();
_disciplineLogic = DependencyManager.Instance.Resolve<IDisciplineLogic>();
_lecturerLogic = DependencyManager.Instance.Resolve<ILecturerLogic>();
_studentMarkPassedDisciplineLogic = DependencyManager.Instance.Resolve<IStudentMarkPassedDisciplineLogic>();
}
/// <summary>
/// Создаение логера действий при синхронизации приказов
/// </summary>
/// <returns></returns>
private bool CreateHistory()
{
_history = Create(new StudentMarkSyncHistorySetBindingModel { SyncDate = DateTime.Now });
if (_history == null)
{
Errors.Add(("Ошибка создание истории", "Не удалось создать историю"));
return false;
}
return true;
}
/// <summary>
/// Получение адреса сервера
/// </summary>
/// <returns></returns>
private EnviromentSettingViewModel GetAddress()
{
var address = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" })?.List?.FirstOrDefault();
if (address == null || address.Value.IsEmpty())
{
SaveErrors(_enviromentSettingLogic.Errors, "Ошибка получения данных", "Не удалось получить адрес сервера для получения приказов по студентам");
return null;
}
return address;
}
/// <summary>
/// Получение клиента для работы с сервисом приказов
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
private HttpClient GetClinet(EnviromentSettingViewModel address)
{
var username = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" })?.List?.FirstOrDefault();
if (username == null || username.Value.IsEmpty())
{
SaveErrors(_enviromentSettingLogic.Errors, "Ошибка получения данных", "Не удалось получить имя пользователя для получения приказов по студентам");
return null;
}
var password = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderPassword" })?.List?.FirstOrDefault();
if (password == null || password.Value.IsEmpty())
{
SaveErrors(_enviromentSettingLogic.Errors, "Ошибка получения данных", "Не удалось получить пароль для получения приказов по студентам");
return null;
}
var client = new HttpClient
{
BaseAddress = new Uri(address.Value),
Timeout = TimeSpan.FromMinutes(10)
};
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username.Value}:{password.Value}")));
return client;
}
private void SyncMarks(StudentViewModel student, StudentMarkSyncModel[] bills)
{
var marks = _studentMarkPassedDisciplineLogic.GetList(new StudentMarkPassedDisciplineGetBindingModel { StudentId = student.Id });
if (marks == null || marks.List == null)
{
SaveErrors(_studentLogic.Errors, "Ошибка получения данных", $"Не удалось получить список оценок студента {student} с базы");
return;
}
var studentBills = bills.ToList();
foreach (var bill in bills)
{
var disciplines = _disciplineLogic.GetList(new DisciplineGetBindingModel { DisciplineName = bill.disciplineName });
if (disciplines == null || disciplines.List == null || disciplines.List.Count == 0)
{
SaveLog($"Не найдена дисциплина {bill.disciplineName}");
continue;
}
var discipline = disciplines.List.First();
var sb = new StringBuilder();
LecturerViewModel lecturer = null;
var teachers = bill.teacher.Split(",", StringSplitOptions.RemoveEmptyEntries);
foreach (var retacher in teachers)
{
var lecturers = _lecturerLogic.GetList(new LecturerGetBindingModel { FIO = bill.teacher });
if (lecturers != null && lecturers.List != null && lecturers.List.Count > 0)
{
lecturer = lecturers.List.First();
break;
}
}
if (lecturer == null)
{
sb.Append($"Преподаватель: {bill.teacher} ");
}
var semester = GetSemester(bill);
if (semester == Semester.Нулевой)
{
sb.Append($"Семестр: {bill.semester} ");
}
var type = GetDisicplineReportingType(bill);
if (type == DisciplineReportingType.Неопределено)
{
sb.Append($"Тип: {bill.controlType} ");
}
var mark = GetMark(bill);
if (mark == MarkDisciplinePassedType.НеСдано)
{
sb.Append($"Оценка: {bill.grade} ");
}
var date = Convert.ToDateTime(bill.controlTypeDate);
var isDirection = bill.documentType != "Аттестационная ведомость";
var markFound = marks.List.FirstOrDefault(x => x.DisciplineId == discipline.Id && x.StudentId == student.Id &&
x.Semester == semester && x.DisciplineReportingType == type && x.DateAffixing.Date == date.Date);
if (markFound != null)
{
if (markFound.Mark != mark || markFound.IsDirection != isDirection || markFound.LecturerId != lecturer?.Id)
{
markFound.Mark = mark;
markFound.IsDirection = isDirection;
markFound.LecturerId = lecturer?.Id;
markFound = _studentMarkPassedDisciplineLogic.Update(Mapper.MapToClass<StudentMarkPassedDisciplineViewModel, StudentMarkPassedDisciplineSetBindingModel>(markFound, true));
if (markFound == null)
{
SaveErrors(_studentMarkPassedDisciplineLogic.Errors, "Ошибка изменения данных", $"Не удалось обновить оценку студента {student}");
}
else
{
SaveLog($"Оценка обновлена: {student}, {bill.disciplineName}, {semester}, {type}, {mark}, {lecturer?.ToString()}");
}
}
if (markFound != null)
{
marks.List.RemoveAll(x => x.Id == markFound.Id);
}
}
else
{
var newMark = _studentMarkPassedDisciplineLogic.Create(new StudentMarkPassedDisciplineSetBindingModel
{
DisciplineId = discipline.Id,
StudentId = student.Id,
Semester = semester,
DisciplineReportingType = type,
Mark = mark,
DateAffixing = date,
IsDirection = isDirection,
LecturerId = lecturer?.Id,
AddiionalInfo = sb.ToString()
});
if (newMark == null)
{
SaveErrors(_studentMarkPassedDisciplineLogic.Errors, "Ошибка добавления данных", $"Не удалось добавить оценку студента {student}");
}
else
{
SaveLog($"Оценка добавлена: {student}, {bill.disciplineName}, {semester}, {type}, {mark}, {lecturer?.ToString()}");
}
}
}
if (marks.List.Count > 0)
{
foreach (var mark in marks.List)
{
SaveLog($"Попытка удаления оценки: {student}, {mark}");
if (!_studentMarkPassedDisciplineLogic.Delete(new StudentMarkPassedDisciplineGetBindingModel { Id = mark.Id }))
{
SaveErrors(_studentMarkPassedDisciplineLogic.Errors, "Ошибка удаления данных", $"Не удалось удалить оценку студента {student}");
}
}
}
}
/// <summary>
/// Получение семестра
/// </summary>
/// <param name="bill"></param>
/// <returns></returns>
private static Semester GetSemester(StudentMarkSyncModel bill) => Convert.ToInt32(bill.semester) switch
{
1 => Semester.Первый,
2 => Semester.Второй,
3 => Semester.Третий,
4 => Semester.Четвертый,
5 => Semester.Пятый,
6 => Semester.Шестой,
7 => Semester.Седьмой,
8 => Semester.Восьмой,
9 => Semester.Девятый,
10 => Semester.Десятый,
_ => Semester.Нулевой,
};
/// <summary>
/// Получение типа отчетности: зачет, экзамен..
/// </summary>
/// <param name="bill"></param>
/// <returns></returns>
private static DisciplineReportingType GetDisicplineReportingType(StudentMarkSyncModel bill) => bill.controlType switch
{
"Зачет" => DisciplineReportingType.Зачет,
"Дифференцированный зачет" => DisciplineReportingType.ЗачетСОценкой,
"Курсовая работа" => DisciplineReportingType.КурсоваяРабота,
"Курсовой проект" => DisciplineReportingType.КурсовойПроект,
"Экзамен" => DisciplineReportingType.Экзамен,
_ => DisciplineReportingType.Неопределено,
};
/// <summary>
/// Определение результата сдачи зачета/экзамена
/// </summary>
/// <param name="bill"></param>
/// <returns></returns>
private static MarkDisciplinePassedType GetMark(StudentMarkSyncModel bill) => bill.grade switch
{
"Неявка" => MarkDisciplinePassedType.НеЯвился,
"Зачтено" => MarkDisciplinePassedType.Зачет,
"Неудовлетворительно" => MarkDisciplinePassedType.НеУдовлетворительно,
"Удовлетворительно" => MarkDisciplinePassedType.Удовлетворительно,
"Хорошо" => MarkDisciplinePassedType.Хорошо,
"Отлично" => MarkDisciplinePassedType.Отлично,
_ => MarkDisciplinePassedType.НеСдано,
};
/// <summary>
/// Сохранение лога с ошибками
/// </summary>
/// <param name="errors"></param>
/// <param name="title"></param>
/// <param name="message"></param>
private void SaveErrors(List<(string Title, string Message)> errors, string title, string message)
{
if (_history == null)
{
return;
}
Errors = errors ?? new List<(string Title, string Message)>();
Errors.Add((title, message));
SaveLog(string.Join(Environment.NewLine, Errors.Select(x => x.Message)));
}
/// <summary>
/// Сохранение лога
/// </summary>
/// <param name="info"></param>
private void SaveLog(string info)
{
_recordLogic.Create(new StudentMarkSyncHistoryRecordSetBindingModel
{
StudentMarkSyncHistoryId = _history.Id,
Information = info
});
}
}
}

View File

@ -0,0 +1,32 @@
namespace DepartmentBusinessLogic.HelperModels
{
/// <summary>
/// Класс-модель для оценок студента из 1С
/// </summary>
public class StudentInfoForMarkSyncModel
{
public string login { get; set; }
public string iduniv { get; set; }
public string fullName { get; set; }
public string recordBook { get; set; }
public string studyPlan { get; set; }
public string studyPlanFaculty { get; set; }
public string studyPlanUnit { get; set; }
public string studyPlanSpecialtyCode { get; set; }
public string studyPlanSpecialtyName { get; set; }
public string studyPlanSpecialtyProfile { get; set; }
public string studyPlanEducationForm { get; set; }
public StudentMarkSyncModel[] bills { get; set; }
}
}

View File

@ -0,0 +1,10 @@
namespace DepartmentBusinessLogic.HelperModels
{
/// <summary>
/// Класс-модель для синхронизации оценок студента из 1С
/// </summary>
public class StudentInfoListForMarkSyncModel
{
public StudentInfoForMarkSyncModel[] arrayOfStudentsGrades { get; set; }
}
}

View File

@ -0,0 +1,26 @@
namespace DepartmentBusinessLogic.HelperModels
{
/// <summary>
/// Класс-модель для оценки студента из 1С
/// </summary>
public class StudentMarkSyncModel
{
public string semester { get; set; }
public string disciplineName { get; set; }
public string grade { get; set; }
public string controlType { get; set; }
public string controlTypeDate { get; set; }
public string documentType { get; set; }
public string gradeType { get; set; }
public string billStudyPlan { get; set; }
public string teacher { get; set; }
}
}

View File

@ -15,6 +15,8 @@ namespace DepartmentContract.BindingModels
public Guid? LecturerAcademicRankId { get; set; }
public Guid? LecturerAcademicDegreeId { get; set; }
public string FIO { get; set; }
}
/// <summary>

View File

@ -17,6 +17,8 @@ namespace DepartmentContract.BindingModels
public Guid? DisciplineId { get; set; }
public Guid? LecturerId { get; set; }
public DateTime? DateStart { get; set; }
public DateTime? DateFinish { get; set; }
@ -33,9 +35,14 @@ namespace DepartmentContract.BindingModels
[Required(ErrorMessage = "required")]
public Guid DisciplineId { get; set; }
public Guid? LecturerId { get; set; }
[Required(ErrorMessage = "required")]
public Semester Semester { get; set; }
[Required(ErrorMessage = "required")]
public DisciplineReportingType DisciplineReportingType { get; set; }
[Required(ErrorMessage = "required")]
public MarkDisciplinePassedType Mark { get; set; }
@ -47,5 +54,7 @@ namespace DepartmentContract.BindingModels
[Required(ErrorMessage = "required")]
public bool IsDirection { get; set; }
public string AddiionalInfo { get; set; }
}
}

View File

@ -1,6 +1,5 @@
using DepartmentContract.BindingModels;
using DepartmentContract.ViewModels;
using System;
using System.Threading.Tasks;
using ToolsModule.ManagmentEntity;
@ -12,7 +11,5 @@ namespace DepartmentContract.Logics.IGenericEntityLogic
public interface IStudentMarkSyncHistoryLogic : IGenericEntityLogic<StudentMarkSyncHistoryGetBindingModel, StudentMarkSyncHistorySetBindingModel, StudentMarkSyncHistoryListViewModel, StudentMarkSyncHistoryViewModel>
{
Task<bool> SyncMarks();
Task<bool> SyncStudentMarks(Guid studentId);
}
}

View File

@ -20,9 +20,12 @@ namespace DepartmentContract.ViewModels
[ViewModelControlElementProperty("Студент", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, SecurityWindowsDesktop")]
public Guid StudentId { get; set; }
[ViewModelControlElementProperty("Дисциплина", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")]
[ViewModelControlElementProperty("Дисциплина", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")]
public Guid DisciplineId { get; set; }
[ViewModelControlElementProperty("Преподаватель", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")]
public Guid? LecturerId { get; set; }
[ViewModelControlListProperty("Студент", ColumnWidth = 120)]
[MapConfiguration("Student.ToString")]
public string Student { get; set; }
@ -37,6 +40,12 @@ namespace DepartmentContract.ViewModels
[ViewModelControlListProperty("Семестр", ColumnWidth = 120)]
public string SemesterTitle => Semester.ToString("G");
[ViewModelControlElementProperty("Тип отчетности", ControlType.ControlEnum, MustHaveValue = true)]
public DisciplineReportingType DisciplineReportingType { get; set; }
[ViewModelControlListProperty("Тип отчетности", ColumnWidth = 120)]
public string DisciplineReportingTypeTitle => DisciplineReportingType.ToString("G");
[ViewModelControlElementProperty("Оценка", ControlType.ControlEnum, MustHaveValue = true)]
public MarkDisciplinePassedType Mark { get; set; }
@ -58,5 +67,9 @@ namespace DepartmentContract.ViewModels
[ViewModelControlListProperty("По направлению", ColumnWidth = 100)]
public string IsDirectionValue => IsDirection ? "Да" : "Нет";
[ViewModelControlListProperty("Доп. информация", ColumnWidth = 120)]
[ViewModelControlElementProperty("Доп. информация", ControlType.ControlText, MustHaveValue = false)]
public string AddiionalInfo { get; set; }
}
}

View File

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using ToolsModule.ManagmentEntity;
using ToolsModule.ManagmentExtension;
namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntityService
{
@ -50,6 +51,22 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
if (model.LecturerAcademicRankId.HasValue)
{
query = query.Where(x => x.LecturerAcademicRankId == model.LecturerAcademicRankId);
}
if (model.FIO.IsNotEmpty())
{
var fio = model.FIO.Split(' ');
if (fio.Length > 1)
{
query = query.Where(x => x.LastName == fio[0]);
}
if (fio.Length > 1)
{
query = query.Where(x => x.FirstName == fio[1]);
}
if (fio.Length > 2)
{
query = query.Where(x => x.Patronymic == fio[2]);
}
}
return query;
}

View File

@ -35,6 +35,10 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
{
query = query.Where(x => x.Student.StudentGroupId == model.StudentGroupId);
}
if (model.LecturerId.HasValue)
{
query = query.Where(x => x.LecturerId == model.LecturerId);
}
if (model.DateStart.HasValue && model.DateFinish.HasValue)
{
query = query.Where(x => x.DateAffixing >= model.DateStart.Value && x.DateAffixing <= model.DateFinish.Value);
@ -50,11 +54,12 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
}
protected override StudentMarkPassedDiscipline GetUniqueEntity(StudentMarkPassedDisciplineSetBindingModel model, IQueryable<StudentMarkPassedDiscipline> query) => query.FirstOrDefault(x => x.StudentId == model.StudentId && x.DisciplineId == model.DisciplineId &&
x.Semester == model.Semester && x.Mark == model.Mark && x.Id != model.Id);
x.Semester == model.Semester && x.DisciplineReportingType == model.DisciplineReportingType && x.Mark == model.Mark && x.Id != model.Id);
protected override IQueryable<StudentMarkPassedDiscipline> IncludingWhenReading(IQueryable<StudentMarkPassedDiscipline> query) => query
.Include(x => x.Student)
.Include(x => x.Discipline);
.Include(x => x.Discipline)
.Include(x => x.Lecturer);
protected override IQueryable<StudentMarkPassedDiscipline> OrderingWhenReading(IQueryable<StudentMarkPassedDiscipline> query) => query
.OrderByDescending(x => x.Student)