Esempio n. 1
0
        public void Seed(DbContext dbContext)
        {
            var assembly = Assembly.GetExecutingAssembly();

            var initMap1 = MapModelFactory.CreateMap("Ebene 1", assembly.GetManifestResourceStream("OpenResKit.Meter.Resources.dummy_1.jpg"));

            var mp1 = MapModelFactory.CreateMapPosition(initMap1, 100, 100);
            var mp2 = MapModelFactory.CreateMapPosition(initMap1, 200, 200);
            var mp3 = MapModelFactory.CreateMapPosition(initMap1, 300, 300);


            var meter1 = ModelFactory.CreateMeter("Stromzähler", "AB1", "kWh", mp1);
            var meter2 = ModelFactory.CreateMeter("Generatorzähler", "AB2", "kWh", mp2);
            var meter3 = ModelFactory.CreateMeter("Wasserzähler", "AB3", "m³", mp3);

            dbContext.Set <Meter>()
            .Add(meter1);
            dbContext.Set <Meter>()
            .Add(meter2);
            dbContext.Set <Meter>()
            .Add(meter3);

            var emp1 = ResponsibleSubjectModelFactory.CreateEmployee("Peter", "Lustig");

            var date = DateTime.Now.AddYears(-1);

            var s1 = SeriesModelFactory.CreateSeries("Stromrundgang", date, date.AddMinutes(30), date.AddDays(91), true, false, false, 1, 1, 13, new DayOfWeek[0]);
            var s2 = SeriesModelFactory.CreateSeries("Wasserbegehung", date, date.AddMinutes(30), date.AddDays(91), true, false, true, 2, 1, 6, new DayOfWeek[0]);

            CreateReadingSeeds(dbContext, s1, emp1, meter1, 8);
            CreateReadingSeeds(dbContext, s2, emp1, meter3, -1);
            CreateReadingSeeds(dbContext, s1, emp1, meter2, -1);
            dbContext.SaveChanges();
        }
Esempio n. 2
0
        public void Seed(DbContext dbContext)
        {
            var assembly = Assembly.GetExecutingAssembly();

            var initMap2 = MapModelFactory.CreateMap("Ebene 2", assembly.GetManifestResourceStream("OpenResKit.Waste.Resources.dummy_2.jpg"));

            var mp1 = MapModelFactory.CreateMapPosition(initMap2, 100, 100);
            var mp2 = MapModelFactory.CreateMapPosition(initMap2, 200, 200);
            var mp3 = MapModelFactory.CreateMapPosition(initMap2, 300, 300);

            var wc1 = ModelFactory.CreateWasteContainer("Restmülltonne", "AB1", 2, mp1);
            var wc2 = ModelFactory.CreateWasteContainer("Plastikmülltonne", "AB2", 2, mp2);
            var wc3 = ModelFactory.CreateWasteContainer("Schrottcontainer", "AB3", 6, mp3);

            dbContext.Set <WasteContainer>()
            .Add(wc1);
            dbContext.Set <WasteContainer>()
            .Add(wc2);
            dbContext.Set <WasteContainer>()
            .Add(wc3);

            var r1 = ResponsibleSubjectModelFactory.CreateEmployee("Shawn", "Steinfeger", "1234dqwe");

            //series 1 - two containers, weekly, 13 times, 30 minutes each
            var containers1 = new[]
            {
                wc1, wc2
            };

            var s1 = SeriesModelFactory.CreateSeries("Abfalltonnen", DateTime.Now, DateTime.Now.AddMinutes(30), DateTime.Now.AddDays(91), true, false, false, 1, 1, 13, new[]
            {
                DateTime.Now.DayOfWeek
            });

            foreach (var container in containers1)
            {
                for (var i = 0; i < s1.NumberOfRecurrences; i++)
                {
                    if (i < 5)
                    {
                        var flr = ModelFactory.CreateFillLevelReading(s1.Begin.AddDays(i * 7), s1.Begin.AddDays(i * 7)
                                                                      .AddMinutes(30), s1.Begin.AddDays((i + 1) * 7), s1.Begin.AddDays((i + 1) * 7)
                                                                      .AddMinutes(30), 0.0f, r1, r1, container, s1);

                        flr.EntryDate.Begin = s1.Begin.AddDays((i * 7) + 1);
                        flr.FillLevel       = (float)(i * 0.25);
                        dbContext.Set <FillLevelReading>()
                        .Add(flr);
                    }
                    else
                    {
                        var flr = ModelFactory.CreateFillLevelReading(s1.Begin.AddDays(i * 7), s1.Begin.AddDays(i * 7)
                                                                      .AddMinutes(30), r1, container, s1);
                        dbContext.Set <FillLevelReading>()
                        .Add(flr);
                    }
                }
            }

            //series 2 - one container, monthly, 3 times, all day
            var s2 = SeriesModelFactory.CreateSeries("Schrottrundgang", DateTime.Now, DateTime.Now.AddMinutes(30), DateTime.Now.AddDays(91), true, false, true, 2, 1, 3, new DayOfWeek[0]);


            for (var i = 0; i < s2.NumberOfRecurrences; i++)
            {
                if (i < 2)
                {
                    var flr = ModelFactory.CreateFillLevelReading(s2.Begin.AddMonths(i), s2.Begin.AddMonths(i)
                                                                  .AddMinutes(30), s2.Begin.AddMonths(i), s2.Begin.AddMonths(i)
                                                                  .AddMinutes(30), 1, r1, r1, wc2, s2);
                    flr.EntryDate.Begin = s2.Begin.AddMonths(i)
                                          .AddDays(2);
                    flr.FillLevel = (0.5f * (i + 1));
                    dbContext.Set <FillLevelReading>()
                    .Add(flr);
                }
                else
                {
                    var flr = ModelFactory.CreateFillLevelReading(s2.Begin.AddMonths(i), s2.Begin.AddMonths(i)
                                                                  .AddMinutes(30), r1, wc2, s2);

                    dbContext.Set <FillLevelReading>()
                    .Add(flr);
                }
            }

            var disposerModelFactory = new DisposerModelFactory();

            var disposer1 = disposerModelFactory.CreateDisposer("ALBA", "A1", "alba@müll.de", "An der Waterkant 1", "12345", "Berlin", null, new Collection <WasteContainer>()
            {
                wc1,
                wc2
            }, "Nur Sondermüll");

            dbContext.Set <Disposer>()
            .Add(disposer1);

            var disposer2 = disposerModelFactory.CreateDisposer("Dino Container", "DinoX", "*****@*****.**", "Holzstraße 2", "12345", "Berlin", null, new Collection <WasteContainer>()
            {
                wc3
            }, "Bauschutt");

            dbContext.Set <Disposer>()
            .Add(disposer2);

            var collection1 = ModelFactory.CreateCollection(disposer1, wc1, 20, 18, 500, 485, DateTime.Now.AddDays(2));

            dbContext.Set <WasteCollection>()
            .Add(collection1);

            var collection2 = ModelFactory.CreateCollection(disposer2, wc2, 10, 10, 449, 499, DateTime.Now.AddDays(10));

            dbContext.Set <WasteCollection>()
            .Add(collection2);

            dbContext.SaveChanges();
        }