using AsbCloudApp.Data; using AsbCloudDb.Model; using AsbCloudInfrastructure.Services.DailyReport; using Mapster; using Microsoft.EntityFrameworkCore; using System; using System.Linq; namespace ConsoleApp1 { class Cron { public DateTimeOffset Origin { get; set; } public TimeSpan Period { get; set; } public DateTimeOffset Next() { var delta = DateTimeOffset.Now - Origin; var n = Math.Ceiling(delta / Period); return Origin + n * Period; } } class Program { static void Main(/*string[] args*/) { TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .MapWith((source) => source.DateTime); TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .MapWith((source) => source == default ? new DateTime(0, DateTimeKind.Utc) : source); TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .MapWith((source) => source == default? default: source.MakeTimeOnly()); TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .MapWith((source) => new (source)); var sh = new ScheduleDto{ ShiftStart = new TimeDto { Hour = 11, Minute = 30, } }; var en = sh.Adapt(); var aa = en.Adapt(); // use ServiceFactory to make services var op = ServiceFactory.MakeWellOperationsService(); var d = op.FirstOperationDate(90); var period = TimeSpan.FromHours(5); var c = new Cron { Period = period, Origin = new DateTimeOffset(2022, 5, 8, 0, 0, 7, TimeSpan.FromHours(5)), }; Console.WriteLine($"origin: {c.Origin} next: {c.Next()}"); Console.WriteLine("End of Test"); Console.ReadLine(); } } }