Ejemplo n.º 1
0
        public void TestNoSunset()
        {
            var TestDate = new DateTime(2018, 6, 21);
            var Sunset   = SunSetRiseLib.SunsetAt(MurmanskLat, MurmanskLong, TestDate, 3);

            Assert.IsNull(Sunset);
        }
Ejemplo n.º 2
0
        public void TestNextDaySunset()
        {
            var TestDate = new DateTime(2018, 6, 21);
            var Expected = TestDate.DayOfYear + 1;
            var Sunset   = SunSetRiseLib.SunsetAt(ReykjavikLat, ReykjavikLong, TestDate, 0);

            Assert.AreEqual(Expected, Sunset.Value.DayOfYear);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            var services = new ServiceCollection();

            services.AddDbContext <ChronicityContext>(options =>
                                                      options.UseSqlServer(configuration["Connection"]));

            services.AddTransient <TimeLineService>();

            var service = services.BuildServiceProvider().GetService <TimeLineService>();

            if (args[0] == "reprocess")
            {
                service.RegisterReaction(new FeederRefill());
            }

            if (args[0] == "sunset")
            {
                var latitude  = 43.038902;
                var longitude = -87.906471;
                var utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours;

                var endDate     = new DateTime(2025, 1, 1);
                var startDate   = new DateTime(2018, 1, 1);
                var currentDate = startDate;

                while (currentDate < endDate)
                {
                    Console.WriteLine("Sunrise: " + SunSetRiseLib.SunriseAt(latitude, longitude, currentDate, utcOffset));
                    Console.WriteLine("SunSet: " + SunSetRiseLib.SunsetAt(latitude, longitude, currentDate, utcOffset));

                    service.RegisterEvent(new Chronicity.Core.Timeline.NewEvent()
                    {
                        Entities = new string[] { "Milwaukee" },
                        On       = SunSetRiseLib.SunriseAt(latitude, longitude, currentDate, utcOffset).ToString(),
                        Type     = "Sunrise"
                    });

                    service.RegisterEvent(new Chronicity.Core.Timeline.NewEvent()
                    {
                        Entities = new string[] { "Milwaukee" },
                        On       = SunSetRiseLib.SunsetAt(latitude, longitude, currentDate, utcOffset).ToString(),
                        Type     = "Sunset"
                    });

                    currentDate = currentDate.AddDays(1);
                }
            }
        }