DD.WellWorkover.Cloud/ConsoleApp1/Program.cs
2022-05-06 16:35:16 +05:00

44 lines
1.1 KiB
C#

using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.DailyReport;
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*/)
{
// 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();
}
}
}