Доделки по синхронизации
This commit is contained in:
parent
8169b49a94
commit
68c01f1801
@ -24,6 +24,20 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class OrderSyncHistoryBusinessLogic : GenericBusinessLogic<OrderSyncHistoryGetBindingModel, OrderSyncHistorySetBindingModel, OrderSyncHistoryListViewModel, OrderSyncHistoryViewModel>
|
public class OrderSyncHistoryBusinessLogic : GenericBusinessLogic<OrderSyncHistoryGetBindingModel, OrderSyncHistorySetBindingModel, OrderSyncHistoryListViewModel, OrderSyncHistoryViewModel>
|
||||||
{
|
{
|
||||||
|
private OrderSyncHistoryRecordBusinessLogic _recordLogic;
|
||||||
|
|
||||||
|
private EnviromentSettingBusinessLogic _enviromentSettingLogic;
|
||||||
|
|
||||||
|
private StudentGroupBusinessLogic _groupsLogic;
|
||||||
|
|
||||||
|
private StudentBusinessLogic _studentLogic;
|
||||||
|
|
||||||
|
private UserBusinessLogic _userLogic;
|
||||||
|
|
||||||
|
private OrderBusinessLogic _orderLogic;
|
||||||
|
|
||||||
|
private OrderStudentRecordBusinessLogic _orderStudentRecordLogic;
|
||||||
|
|
||||||
public OrderSyncHistoryBusinessLogic(IOrderSyncHistoryService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { }
|
public OrderSyncHistoryBusinessLogic(IOrderSyncHistoryService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { }
|
||||||
|
|
||||||
public async Task<bool> SyncOrders()
|
public async Task<bool> SyncOrders()
|
||||||
@ -35,16 +49,20 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var recordLogic = DependencyManager.Instance.Resolve<OrderSyncHistoryRecordBusinessLogic>();
|
_recordLogic = DependencyManager.Instance.Resolve<OrderSyncHistoryRecordBusinessLogic>();
|
||||||
|
_enviromentSettingLogic = DependencyManager.Instance.Resolve<EnviromentSettingBusinessLogic>();
|
||||||
|
_groupsLogic = DependencyManager.Instance.Resolve<StudentGroupBusinessLogic>();
|
||||||
|
_studentLogic = DependencyManager.Instance.Resolve<StudentBusinessLogic>();
|
||||||
|
_orderLogic = DependencyManager.Instance.Resolve<OrderBusinessLogic>();
|
||||||
|
_orderStudentRecordLogic = DependencyManager.Instance.Resolve<OrderStudentRecordBusinessLogic>();
|
||||||
|
_userLogic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||||
|
|
||||||
var enviromentSettingLogic = DependencyManager.Instance.Resolve<EnviromentSettingBusinessLogic>();
|
var address = (await _enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" }))?.List?.FirstOrDefault();
|
||||||
|
|
||||||
var address = (await enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" }))?.List?.FirstOrDefault();
|
|
||||||
if (address == null || address.Value.IsEmpty())
|
if (address == null || address.Value.IsEmpty())
|
||||||
{
|
{
|
||||||
Errors = enviromentSettingLogic.Errors;
|
Errors = _enviromentSettingLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить адрес серверая для получения приказов по студентам"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить адрес серверая для получения приказов по студентам"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -52,12 +70,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var username = (await enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" }))?.List?.FirstOrDefault();
|
var username = (await _enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" }))?.List?.FirstOrDefault();
|
||||||
if (username == null || username.Value.IsEmpty())
|
if (username == null || username.Value.IsEmpty())
|
||||||
{
|
{
|
||||||
Errors = enviromentSettingLogic.Errors;
|
Errors = _enviromentSettingLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить имя пользователя для получения приказов по студентам"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить имя пользователя для получения приказов по студентам"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -65,12 +83,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var password = (await enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderPassword" }))?.List?.FirstOrDefault();
|
var password = (await _enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderPassword" }))?.List?.FirstOrDefault();
|
||||||
if (password == null || password.Value.IsEmpty())
|
if (password == null || password.Value.IsEmpty())
|
||||||
{
|
{
|
||||||
Errors = enviromentSettingLogic.Errors;
|
Errors = _enviromentSettingLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить пароль для получения приказов по студентам"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить пароль для получения приказов по студентам"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -93,7 +111,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов с сервера"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов с сервера"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -103,7 +121,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
var studentFromServer = JsonSerializer.Deserialize<StudentListSyncModel>(response.Content.ReadAsStringAsync().Result);
|
var studentFromServer = JsonSerializer.Deserialize<StudentListSyncModel>(response.Content.ReadAsStringAsync().Result);
|
||||||
if (studentFromServer.CurrentStudentsList.Count == 0)
|
if (studentFromServer.CurrentStudentsList.Count == 0)
|
||||||
{
|
{
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = "Полученный список студентов пустой"
|
Information = "Полученный список студентов пустой"
|
||||||
@ -111,13 +129,12 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var groupsLogic = DependencyManager.Instance.Resolve<StudentGroupBusinessLogic>();
|
var groups = await _groupsLogic.GetListAsync(new StudentGroupGetBindingModel());
|
||||||
var groups = await groupsLogic.GetListAsync(new StudentGroupGetBindingModel());
|
|
||||||
if (groups == null || groups.List == null)
|
if (groups == null || groups.List == null)
|
||||||
{
|
{
|
||||||
Errors = groupsLogic.Errors;
|
Errors = _groupsLogic.Errors;
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список групп"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список групп"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -125,85 +142,90 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var studentLogic = DependencyManager.Instance.Resolve<StudentBusinessLogic>();
|
var students = await _studentLogic.GetListAsync(new StudentGetBindingModel());
|
||||||
var userLogic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
if (students == null || students.List == null)
|
||||||
foreach (var group in groups.List)
|
|
||||||
{
|
{
|
||||||
var students = await studentLogic.GetListAsync(new StudentGetBindingModel { StudentGroupId = group.Id });
|
Errors = _studentLogic.Errors;
|
||||||
foreach (var student in students.List)
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов"));
|
||||||
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
var studentSync = studentFromServer.CurrentStudentsList.FirstOrDefault(x => x.recordBookName == student.NumberOfBook);
|
OrderSyncHistoryId = history.Id,
|
||||||
// студент не найден, значит он ушел с кафедры, выясняем почему
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
if (studentSync == null)
|
});
|
||||||
{
|
return false;
|
||||||
await SyncStudentOrders(history, student, groups.List, client, address.Value, studentSync.iduniv);
|
}
|
||||||
}
|
|
||||||
// перевод в другую группу
|
|
||||||
else if (group.GroupName != studentSync.groupName)
|
|
||||||
{
|
|
||||||
await SyncStudentOrders(history, student, groups.List, client, address.Value, studentSync.iduniv);
|
|
||||||
}
|
|
||||||
|
|
||||||
studentFromServer.CurrentStudentsList.Remove(studentSync);
|
foreach (var student in students.List)
|
||||||
|
{
|
||||||
|
var studentSync = studentFromServer.CurrentStudentsList.FirstOrDefault(x => x.recordBookName == student.NumberOfBook);
|
||||||
|
// студент не найден, значит он ушел с кафедры, выясняем почему
|
||||||
|
if (studentSync == null)
|
||||||
|
{
|
||||||
|
await SyncStudentOrders(history, student, groups.List, client, address.Value, studentSync.iduniv);
|
||||||
}
|
}
|
||||||
// новые студенты в группе
|
// не совпадение групп
|
||||||
var studentSyncs = studentFromServer.CurrentStudentsList.Where(x => x.groupName == group.GroupName);
|
else if (student.StudentGroupName != studentSync.groupName)
|
||||||
foreach (var student in studentSyncs)
|
|
||||||
{
|
{
|
||||||
var userName = $"{student.lastName}{(student.firstName.IsNotEmpty() ? $" {student.firstName[0]}." : string.Empty)}{(student.patronymicName.IsNotEmpty() ? $"{student.patronymicName[0]}." : string.Empty)}";
|
await SyncStudentOrders(history, student, groups.List, client, address.Value, studentSync.iduniv);
|
||||||
var result = await userLogic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName });
|
}
|
||||||
|
|
||||||
var newuser = await userLogic.CreateAsync(new UserSetBindingModel
|
studentFromServer.CurrentStudentsList.Remove(studentSync);
|
||||||
{
|
}
|
||||||
Login = userName,
|
// новые студенты
|
||||||
Password = student.recordBookName
|
foreach (var student in studentFromServer.CurrentStudentsList)
|
||||||
});
|
{
|
||||||
if (newuser == null)
|
var userName = $"{student.lastName}{(student.firstName.IsNotEmpty() ? $" {student.firstName[0]}." : string.Empty)}{(student.patronymicName.IsNotEmpty() ? $"{student.patronymicName[0]}." : string.Empty)}";
|
||||||
{
|
var result = await _userLogic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName });
|
||||||
var errors = userLogic.Errors;
|
|
||||||
errors.Add(("Ошибка создания пользователя под студента", $"Не удалось создать пользователя под студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newStudent = await studentLogic.CreateAsync(new StudentSetBindingModel
|
var newuser = await _userLogic.CreateAsync(new UserSetBindingModel
|
||||||
{
|
{
|
||||||
UserId = newuser.Id,
|
Login = userName,
|
||||||
FirstName = student.firstName,
|
Password = student.recordBookName
|
||||||
LastName = student.lastName,
|
});
|
||||||
Patronymic = student.patronymicName,
|
if (newuser == null)
|
||||||
NumberOfBook = student.recordBookName,
|
{
|
||||||
StudentGroupId = group.Id,
|
var errors = _userLogic.Errors;
|
||||||
StudentState = GetStudentState(student.stateName),
|
errors.Add(("Ошибка создания пользователя под студента", $"Не удалось создать пользователя под студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
Description = student.presenatationOfRecordBook
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
});
|
|
||||||
|
|
||||||
if (newStudent == null)
|
|
||||||
{
|
|
||||||
var errors = studentLogic.Errors;
|
|
||||||
errors.Add(("Ошибка добавления студента", $"Не удалось добавить студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
|
||||||
OrderSyncHistoryId = history.Id,
|
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = $"Добавлен студент {newStudent}"
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
});
|
});
|
||||||
|
continue;
|
||||||
await SyncStudentOrders(history, newStudent, groups.List, client, address.Value, student.iduniv);
|
|
||||||
|
|
||||||
studentFromServer.CurrentStudentsList.Remove(student);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var newStudent = await _studentLogic.CreateAsync(new StudentSetBindingModel
|
||||||
|
{
|
||||||
|
UserId = newuser.Id,
|
||||||
|
FirstName = student.firstName,
|
||||||
|
LastName = student.lastName,
|
||||||
|
Patronymic = student.patronymicName,
|
||||||
|
NumberOfBook = student.recordBookName,
|
||||||
|
StudentState = GetStudentState(student.stateName),
|
||||||
|
Description = student.presenatationOfRecordBook
|
||||||
|
});
|
||||||
|
|
||||||
|
if (newStudent == null)
|
||||||
|
{
|
||||||
|
var errors = _studentLogic.Errors;
|
||||||
|
errors.Add(("Ошибка добавления студента", $"Не удалось добавить студента {student.lastName} {student.firstName} {student.patronymicName}"));
|
||||||
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"Добавлен студент {newStudent}"
|
||||||
|
});
|
||||||
|
|
||||||
|
await SyncStudentOrders(history, newStudent, groups.List, client, address.Value, student.iduniv);
|
||||||
|
|
||||||
|
studentFromServer.CurrentStudentsList.Remove(student);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -228,14 +250,11 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task SyncStudentOrders(OrderSyncHistoryViewModel history, StudentViewModel student, List<StudentGroupViewModel> groups, HttpClient client, string address, string iduniv)
|
private async Task SyncStudentOrders(OrderSyncHistoryViewModel history, StudentViewModel student, List<StudentGroupViewModel> groups, HttpClient client, string address, string iduniv)
|
||||||
{
|
{
|
||||||
var recordLogic = DependencyManager.Instance.Resolve<OrderSyncHistoryRecordBusinessLogic>();
|
|
||||||
var orderLogic = DependencyManager.Instance.Resolve<OrderBusinessLogic>();
|
|
||||||
var orderStudentRecordLogic = DependencyManager.Instance.Resolve<OrderStudentRecordBusinessLogic>();
|
|
||||||
HttpResponseMessage response = await client.GetAsync($"{address}/univer_Testing/hs/Ulstu_StudentsInfo/v1/GetStudentOrdersByIdAndRecordBook?iduniv={iduniv}&recordBookName={student.NumberOfBook}&allOrders=sppd");
|
HttpResponseMessage response = await client.GetAsync($"{address}/univer_Testing/hs/Ulstu_StudentsInfo/v1/GetStudentOrdersByIdAndRecordBook?iduniv={iduniv}&recordBookName={student.NumberOfBook}&allOrders=sppd");
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
Errors.Add(("Ошибка получения данных", "Не удалось получить список приказов по студенту"));
|
Errors.Add(("Ошибка получения данных", "Не удалось получить список приказов по студенту"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message))
|
||||||
@ -250,7 +269,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
if (orderType != OrderType.Неопределено)
|
if (orderType != OrderType.Неопределено)
|
||||||
{
|
{
|
||||||
// пытаемся найти приказ
|
// пытаемся найти приказ
|
||||||
var order = await orderLogic.GetElementAsync(new OrderGetBindingModel
|
var order = await _orderLogic.GetElementAsync(new OrderGetBindingModel
|
||||||
{
|
{
|
||||||
OrderNumber = syncOrder.clericNumber,
|
OrderNumber = syncOrder.clericNumber,
|
||||||
OrderDate = Convert.ToDateTime(syncOrder.clericDate)
|
OrderDate = Convert.ToDateTime(syncOrder.clericDate)
|
||||||
@ -258,7 +277,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
// если не нашли - пытаемся создать
|
// если не нашли - пытаемся создать
|
||||||
order = await orderLogic.CreateAsync(new OrderSetBindingModel
|
order = await _orderLogic.CreateAsync(new OrderSetBindingModel
|
||||||
{
|
{
|
||||||
OrderNumber = syncOrder.clericNumber,
|
OrderNumber = syncOrder.clericNumber,
|
||||||
OrderDate = Convert.ToDateTime(syncOrder.clericDate),
|
OrderDate = Convert.ToDateTime(syncOrder.clericDate),
|
||||||
@ -266,9 +285,9 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
});
|
});
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
var errors = orderLogic.Errors;
|
var errors = _orderLogic.Errors;
|
||||||
errors.Add(("Ошибка добавления приказа", $"Не удалось добавить приказ {syncOrder.clericNumber} {syncOrder.clericDate}"));
|
errors.Add(("Ошибка добавления приказа", $"Не удалось добавить приказ {syncOrder.clericNumber} {syncOrder.clericDate}"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
@ -278,7 +297,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ищем в приказе запись по студенту
|
// ищем в приказе запись по студенту
|
||||||
var studentOrder = await orderStudentRecordLogic.GetElementAsync(new OrderStudentRecordGetBindingModel
|
var studentOrder = await _orderStudentRecordLogic.GetElementAsync(new OrderStudentRecordGetBindingModel
|
||||||
{
|
{
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
StudentId = student.Id
|
StudentId = student.Id
|
||||||
@ -338,7 +357,7 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
|
|
||||||
// создаем, если не нашли
|
// создаем, если не нашли
|
||||||
studentOrder = await orderStudentRecordLogic.CreateAsync(new OrderStudentRecordSetBindingModel
|
studentOrder = await _orderStudentRecordLogic.CreateAsync(new OrderStudentRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderId = order.Id,
|
OrderId = order.Id,
|
||||||
StudentId = student.Id,
|
StudentId = student.Id,
|
||||||
@ -349,16 +368,41 @@ namespace DepartmentBusinessLogic.BusinessLogics
|
|||||||
});
|
});
|
||||||
if (studentOrder == null)
|
if (studentOrder == null)
|
||||||
{
|
{
|
||||||
var errors = orderStudentRecordLogic.Errors;
|
var errors = _orderStudentRecordLogic.Errors;
|
||||||
errors.Add(("Ошибка добавления записи приказа по студенту", $"Не удалось добавить запись приказаs {syncOrder.orderSubTypeName} по студенту {student}"));
|
errors.Add(("Ошибка добавления записи приказа по студенту", $"Не удалось добавить запись приказа {syncOrder.orderSubTypeName} по студенту {student}"));
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
|
||||||
|
if (student.StudentGroupId != studentGroupToId)
|
||||||
|
{
|
||||||
|
var st = Mapper.MapToClass<StudentViewModel, StudentSetBindingModel>(student, true);
|
||||||
|
st.StudentGroupId = studentGroupToId;
|
||||||
|
var studentName = student.ToString();
|
||||||
|
student = await _studentLogic.UpdateAsync(st);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
var errors = _studentLogic.Errors;
|
||||||
|
errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить группу у студента {studentName}"));
|
||||||
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = string.Join(Environment.NewLine, errors.Select(x => x.Message))
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
|
{
|
||||||
|
OrderSyncHistoryId = history.Id,
|
||||||
|
Information = $"У студента {student} сменилась группа на {student.StudentGroupName}"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await _recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel
|
||||||
{
|
{
|
||||||
OrderSyncHistoryId = history.Id,
|
OrderSyncHistoryId = history.Id,
|
||||||
Information = $"Добавили запись к приказу {order.OrderNumber} по студенту {student} с формулировкой {info}"
|
Information = $"Добавили запись к приказу {order.OrderNumber} по студенту {student} с формулировкой {info}"
|
||||||
|
@ -27,6 +27,9 @@ namespace DepartmentBusinessLogic.ViewModels
|
|||||||
[MapConfiguration("StudentGroupId")]
|
[MapConfiguration("StudentGroupId")]
|
||||||
public Guid? StudentGroupId { get; set; }
|
public Guid? StudentGroupId { get; set; }
|
||||||
|
|
||||||
|
[MapConfiguration("StudentGroup.ToString", IsDifficle = true)]
|
||||||
|
public string StudentGroupName { get; set; }
|
||||||
|
|
||||||
[ViewModelControlListProperty("Номер зачетки")]
|
[ViewModelControlListProperty("Номер зачетки")]
|
||||||
[ViewModelControlElementProperty("Номер зачетки", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)]
|
[ViewModelControlElementProperty("Номер зачетки", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)]
|
||||||
[MapConfiguration("NumberOfBook")]
|
[MapConfiguration("NumberOfBook")]
|
||||||
|
Loading…
Reference in New Issue
Block a user