feat(esppScheduleSync): доделал метод ParseStrToEsppObject
This commit is contained in:
@@ -99,6 +99,10 @@ namespace PARR.EsppScheduleSync
|
||||
|
||||
bool.TryParse(splittedContent[1].Trim(), out var isActive);
|
||||
|
||||
var typeSchedule = GetTypeScheduleByString(splittedContent[7]);
|
||||
if (!typeSchedule.HasValue)
|
||||
return null;
|
||||
|
||||
var esppObject = new EsppObjectSchedule
|
||||
{
|
||||
TemplateName = templateName,
|
||||
@@ -107,8 +111,7 @@ namespace PARR.EsppScheduleSync
|
||||
IsActive = isActive,
|
||||
ResponseArea = splittedContent[5],
|
||||
WorkGroup = splittedContent[3],
|
||||
//TODO:!!!
|
||||
//TypeSchedule = splittedContent[7],
|
||||
TypeSchedule = typeSchedule.Value,
|
||||
Interval = splittedContent[8],
|
||||
Dayofweek = splittedContent[15],
|
||||
Dayofmonth = splittedContent[14],
|
||||
@@ -131,6 +134,40 @@ namespace PARR.EsppScheduleSync
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Преобразовать из строки в Тип Повторения
|
||||
/// </summary>
|
||||
/// <param name="typeSchedule"></param>
|
||||
/// <returns></returns>
|
||||
private EsppSchTypeScheduleEnum? GetTypeScheduleByString(string typeSchedule)
|
||||
{
|
||||
typeSchedule = typeSchedule.ToLower();
|
||||
|
||||
//Regularly, Регулярно (значение в ЕСПП и в БД не совпадают, в бд Regularly, в ЕСПП simple)
|
||||
if (typeSchedule == "simple" || typeSchedule == EsppSchTypeScheduleEnum.Regularly.ToString().ToLower())
|
||||
return EsppSchTypeScheduleEnum.Regularly;
|
||||
|
||||
if (typeSchedule == EsppSchTypeScheduleEnum.Weekly.ToString().ToLower())
|
||||
return EsppSchTypeScheduleEnum.Weekly;
|
||||
|
||||
if (typeSchedule == EsppSchTypeScheduleEnum.Monthly.ToString().ToLower())
|
||||
return EsppSchTypeScheduleEnum.Monthly;
|
||||
|
||||
if (typeSchedule == EsppSchTypeScheduleEnum.Monthly2.ToString().ToLower())
|
||||
return EsppSchTypeScheduleEnum.Monthly2;
|
||||
|
||||
if (typeSchedule == EsppSchTypeScheduleEnum.Annually.ToString().ToLower())
|
||||
return EsppSchTypeScheduleEnum.Annually;
|
||||
|
||||
if (typeSchedule == EsppSchTypeScheduleEnum.Annually2.ToString().ToLower())
|
||||
return EsppSchTypeScheduleEnum.Annually2;
|
||||
|
||||
logger.LogError($"Не смог преобразовать Тип повторения из ЕСПП в EsppSchTypeScheduleEnum. Получено значение {typeSchedule}");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Проверка имени шаблона и расписание на соответствие префиксу из настроек
|
||||
/// </summary>
|
||||
@@ -166,98 +203,81 @@ namespace PARR.EsppScheduleSync
|
||||
// т.е. если стояло Ежедненвно:понедельник, а изменили например на Еженедельно..., то в ежедневно значения останутся, но будут отрабатывать значения из Еженедельно.
|
||||
// Т е значения из Ежедненвно проверять не нужно, вот их и будем очищать
|
||||
|
||||
//TODO: сделать миграцию в БД: Еженежельно
|
||||
|
||||
//TODO:!!!
|
||||
////Regularly, Регулярно (значение в ЕСПП и в БД не совпадают, в бд Regularly, в ЕСПП simple)
|
||||
//if (esppObject.TypeSchedule.ToLower() == "simple" || esppObject.TypeSchedule.ToLower() == EsppSchTypeScheduleEnum.Regularly.ToString().ToLower())
|
||||
//{
|
||||
// //esppObject.Interval = string.Empty;
|
||||
// esppObject.Dayofweek = string.Empty;
|
||||
// esppObject.Dayofmonth = string.Empty;
|
||||
// esppObject.Md1 = string.Empty;
|
||||
// esppObject.Md2 = string.Empty;
|
||||
// esppObject.Annualm = string.Empty;
|
||||
// esppObject.Annualday = string.Empty;
|
||||
// esppObject.An1 = string.Empty;
|
||||
// esppObject.An2 = string.Empty;
|
||||
// esppObject.An3 = string.Empty;
|
||||
//}
|
||||
|
||||
////Weekly, Еженедельно
|
||||
//if (esppObject.TypeSchedule == "weekly")
|
||||
//{
|
||||
// esppObject.Interval = string.Empty;
|
||||
// //esppObject.Dayofweek = string.Empty;
|
||||
// esppObject.Dayofmonth = string.Empty;
|
||||
// esppObject.Md1 = string.Empty;
|
||||
// esppObject.Md2 = string.Empty;
|
||||
// esppObject.Annualm = string.Empty;
|
||||
// esppObject.Annualday = string.Empty;
|
||||
// esppObject.An1 = string.Empty;
|
||||
// esppObject.An2 = string.Empty;
|
||||
// esppObject.An3 = string.Empty;
|
||||
//}
|
||||
|
||||
////Monthly, Ежемесячно
|
||||
//if (esppObject.TypeSchedule == "monthly")
|
||||
//{
|
||||
// esppObject.Interval = string.Empty;
|
||||
// esppObject.Dayofweek = string.Empty;
|
||||
// //esppObject.Dayofmonth = string.Empty;
|
||||
// esppObject.Md1 = string.Empty;
|
||||
// esppObject.Md2 = string.Empty;
|
||||
// esppObject.Annualm = string.Empty;
|
||||
// esppObject.Annualday = string.Empty;
|
||||
// esppObject.An1 = string.Empty;
|
||||
// esppObject.An2 = string.Empty;
|
||||
// esppObject.An3 = string.Empty;
|
||||
//}
|
||||
|
||||
////Monthly2, Ежемесячно-2
|
||||
//if (esppObject.TypeSchedule == "monthly2")
|
||||
//{
|
||||
// esppObject.Interval = string.Empty;
|
||||
// esppObject.Dayofweek = string.Empty;
|
||||
// esppObject.Dayofmonth = string.Empty;
|
||||
// //esppObject.Md1 = string.Empty;
|
||||
// //esppObject.Md2 = string.Empty;
|
||||
// esppObject.Annualm = string.Empty;
|
||||
// esppObject.Annualday = string.Empty;
|
||||
// esppObject.An1 = string.Empty;
|
||||
// esppObject.An2 = string.Empty;
|
||||
// esppObject.An3 = string.Empty;
|
||||
//}
|
||||
|
||||
////Annually, Ежегодно
|
||||
//if (esppObject.TypeSchedule == "annually")
|
||||
//{
|
||||
// esppObject.Interval = string.Empty;
|
||||
// esppObject.Dayofweek = string.Empty;
|
||||
// esppObject.Dayofmonth = string.Empty;
|
||||
// esppObject.Md1 = string.Empty;
|
||||
// esppObject.Md2 = string.Empty;
|
||||
// //esppObject.Annualm = string.Empty;
|
||||
// //esppObject.Annualday = string.Empty;
|
||||
// esppObject.An1 = string.Empty;
|
||||
// esppObject.An2 = string.Empty;
|
||||
// esppObject.An3 = string.Empty;
|
||||
//}
|
||||
|
||||
////Annually2, Ежегодно-2
|
||||
//if (esppObject.TypeSchedule == "annually2")
|
||||
//{
|
||||
// esppObject.Interval = string.Empty;
|
||||
// esppObject.Dayofweek = string.Empty;
|
||||
// esppObject.Dayofmonth = string.Empty;
|
||||
// esppObject.Md1 = string.Empty;
|
||||
// esppObject.Md2 = string.Empty;
|
||||
// esppObject.Annualm = string.Empty;
|
||||
// esppObject.Annualday = string.Empty;
|
||||
// //esppObject.An1 = string.Empty;
|
||||
// //esppObject.An2 = string.Empty;
|
||||
// //esppObject.An3 = string.Empty;
|
||||
//}
|
||||
switch (esppObject.TypeSchedule)
|
||||
{
|
||||
case EsppSchTypeScheduleEnum.Regularly:
|
||||
//esppObject.Interval = string.Empty;
|
||||
esppObject.Dayofweek = string.Empty;
|
||||
esppObject.Dayofmonth = string.Empty;
|
||||
esppObject.Md1 = string.Empty;
|
||||
esppObject.Md2 = string.Empty;
|
||||
esppObject.Annualm = string.Empty;
|
||||
esppObject.Annualday = string.Empty;
|
||||
esppObject.An1 = string.Empty;
|
||||
esppObject.An2 = string.Empty;
|
||||
esppObject.An3 = string.Empty;
|
||||
break;
|
||||
case EsppSchTypeScheduleEnum.Weekly:
|
||||
esppObject.Interval = string.Empty;
|
||||
//esppObject.Dayofweek = string.Empty;
|
||||
esppObject.Dayofmonth = string.Empty;
|
||||
esppObject.Md1 = string.Empty;
|
||||
esppObject.Md2 = string.Empty;
|
||||
esppObject.Annualm = string.Empty;
|
||||
esppObject.Annualday = string.Empty;
|
||||
esppObject.An1 = string.Empty;
|
||||
esppObject.An2 = string.Empty;
|
||||
esppObject.An3 = string.Empty;
|
||||
break;
|
||||
case EsppSchTypeScheduleEnum.Monthly:
|
||||
esppObject.Interval = string.Empty;
|
||||
esppObject.Dayofweek = string.Empty;
|
||||
//esppObject.Dayofmonth = string.Empty;
|
||||
esppObject.Md1 = string.Empty;
|
||||
esppObject.Md2 = string.Empty;
|
||||
esppObject.Annualm = string.Empty;
|
||||
esppObject.Annualday = string.Empty;
|
||||
esppObject.An1 = string.Empty;
|
||||
esppObject.An2 = string.Empty;
|
||||
esppObject.An3 = string.Empty;
|
||||
break;
|
||||
case EsppSchTypeScheduleEnum.Monthly2:
|
||||
esppObject.Interval = string.Empty;
|
||||
esppObject.Dayofweek = string.Empty;
|
||||
esppObject.Dayofmonth = string.Empty;
|
||||
//esppObject.Md1 = string.Empty;
|
||||
//esppObject.Md2 = string.Empty;
|
||||
esppObject.Annualm = string.Empty;
|
||||
esppObject.Annualday = string.Empty;
|
||||
esppObject.An1 = string.Empty;
|
||||
esppObject.An2 = string.Empty;
|
||||
esppObject.An3 = string.Empty;
|
||||
break;
|
||||
case EsppSchTypeScheduleEnum.Annually:
|
||||
esppObject.Interval = string.Empty;
|
||||
esppObject.Dayofweek = string.Empty;
|
||||
esppObject.Dayofmonth = string.Empty;
|
||||
esppObject.Md1 = string.Empty;
|
||||
esppObject.Md2 = string.Empty;
|
||||
//esppObject.Annualm = string.Empty;
|
||||
//esppObject.Annualday = string.Empty;
|
||||
esppObject.An1 = string.Empty;
|
||||
esppObject.An2 = string.Empty;
|
||||
esppObject.An3 = string.Empty;
|
||||
break;
|
||||
case EsppSchTypeScheduleEnum.Annually2:
|
||||
esppObject.Interval = string.Empty;
|
||||
esppObject.Dayofweek = string.Empty;
|
||||
esppObject.Dayofmonth = string.Empty;
|
||||
esppObject.Md1 = string.Empty;
|
||||
esppObject.Md2 = string.Empty;
|
||||
esppObject.Annualm = string.Empty;
|
||||
esppObject.Annualday = string.Empty;
|
||||
//esppObject.An1 = string.Empty;
|
||||
//esppObject.An2 = string.Empty;
|
||||
//esppObject.An3 = string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
return esppObject;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user