feat(esppScheduleSync, esppTemplateSync): в шаблонах синхронизируется поле Исполнитель. В расписаниях исправлена логика поиска связанного шаблона. Добавлен атрибут SkipComparision - исключить поля для сравнения
This commit is contained in:
@@ -10,9 +10,9 @@ using PARR.DAL.Models;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.EsppScheduleSync.Domain;
|
||||
using PARR.EsppScheduleSync.Settings;
|
||||
using PARR.EsppSync;
|
||||
using PARR.EsppSync.Domain;
|
||||
using PARR.EsppSync.Helpers;
|
||||
|
||||
namespace PARR.EsppScheduleSync
|
||||
@@ -125,10 +125,24 @@ namespace PARR.EsppScheduleSync
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var templateService = scope.ServiceProvider.GetRequiredService<ITemplateService>();
|
||||
|
||||
var candidates = await templateService.Get()
|
||||
.Include(t => t.RobotConfigurations)
|
||||
.Where(t => t.Name == esppTemplateName || t.ScheduleEsppId == esppScheduleId)
|
||||
.ToListAsync();
|
||||
// это не очень, так как esppScheduleId может быть null или empty, а в БД таких значений может быть много
|
||||
//var candidates = await templateService.Get()
|
||||
// .Include(t => t.RobotConfigurations)
|
||||
// .Where(t => t.Name == esppTemplateName || t.ScheduleEsppId == esppScheduleId)
|
||||
// .ToListAsync();
|
||||
|
||||
IQueryable<Template> query = templateService.Get().Include(t => t.RobotConfigurations);
|
||||
if (string.IsNullOrEmpty(esppScheduleId))
|
||||
{
|
||||
query = query.Where(t => t.Name == esppTemplateName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//ScheduleEsppId не нулл и не пустой, поизем по нему тоже
|
||||
query = query.Where(t => t.Name == esppTemplateName || t.ScheduleEsppId == esppScheduleId);
|
||||
}
|
||||
|
||||
var candidates = await query.ToListAsync();
|
||||
|
||||
var templateByName = candidates.FirstOrDefault(t => t.Name == esppTemplateName);
|
||||
var templateByScheduleId = candidates.FirstOrDefault(t => t.ScheduleEsppId == esppScheduleId);
|
||||
@@ -592,11 +606,14 @@ namespace PARR.EsppScheduleSync
|
||||
/// <returns></returns>
|
||||
private EsppObjectSchedule ClearOptionalFields(EsppObjectSchedule esppObject)
|
||||
{
|
||||
esppObject.Code = string.Empty;
|
||||
esppObject.ScheduleName = string.Empty;
|
||||
esppObject.ResponseArea = string.Empty;
|
||||
esppObject.WorkGroup = string.Empty;
|
||||
esppObject.CompleteAfter = string.Empty;
|
||||
#region Отключение синхронизации не нужных полей настраивается через атрибут SkipComparison в моделе
|
||||
// Обнуляем ЕСПП ИД, потому что У НАС РЕАЛЬНЫЙ ЕСПП ИД И ЕСПП ИД В БД МОГУ РАСХОДИТЬСЯ!!! УЖАССС!!!
|
||||
//esppObject.Code = string.Empty;
|
||||
//esppObject.ScheduleName = string.Empty;
|
||||
//esppObject.ResponseArea = string.Empty;
|
||||
//esppObject.WorkGroup = string.Empty;
|
||||
//esppObject.CompleteAfter = string.Empty;
|
||||
#endregion
|
||||
|
||||
if (esppObject.TypeV60calendar == noneExcludeCalendarEsppValue)
|
||||
esppObject.V60calendar = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user