feat(dal, templateDistributor): шаблон для templateDistributor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Extensions;
|
||||
@@ -322,5 +323,43 @@ namespace PARR.DAL.TransformServices
|
||||
|
||||
calcDay = calcDay.AddDays(daysOffset);
|
||||
}
|
||||
|
||||
|
||||
public DateTimeOffset GetNextDateForDistributionRun(DateTimeOffset lastRun, DistributionPeriodTypeEnum periodType, string distributionPeriod)
|
||||
{
|
||||
switch (periodType)
|
||||
{
|
||||
case (DistributionPeriodTypeEnum.Day):
|
||||
return lastRun.AddDays(ParseInt(distributionPeriod));
|
||||
|
||||
case (DistributionPeriodTypeEnum.Month):
|
||||
return lastRun.AddMonths(ParseInt(distributionPeriod));
|
||||
|
||||
case (DistributionPeriodTypeEnum.Year):
|
||||
return lastRun.AddYears(ParseInt(distributionPeriod));
|
||||
|
||||
//case (DistributionPeriodTypeEnum.TimeSpan):
|
||||
// var timeSpan = ParseTimeSpan(distributionPeriod);
|
||||
// return timeSpan.Days > 0 ? startPeriod.AddDays();
|
||||
}
|
||||
|
||||
|
||||
//return startPeriod.AddDays(duration.Days).AddDays(-1);
|
||||
return lastRun;
|
||||
}
|
||||
|
||||
|
||||
private int ParseInt(string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return int.Parse(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, $"{nameof(this.GetType)}, получение конца периода. Не смог распарсить string в int для значения {value}.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.DomainModels;
|
||||
|
||||
namespace PARR.DAL.TransformServices
|
||||
{
|
||||
@@ -38,5 +39,15 @@ namespace PARR.DAL.TransformServices
|
||||
/// <param name="lastRun"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DateTimeOffset>> GetNextScheduleAsync(Guid applicationInWorkId, DateTimeOffset lastRun);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить следующую дату срабатывания в указанном периоде
|
||||
/// </summary>
|
||||
/// <param name="lastRun"></param>
|
||||
/// <param name="periodType"></param>
|
||||
/// <param name="distributionPeriod"></param>
|
||||
/// <returns></returns>
|
||||
DateTimeOffset GetNextDateForDistributionRun(DateTimeOffset lastRun, DistributionPeriodTypeEnum periodType, string distributionPeriod);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user