private static List <HausanschlussImport> LoadMergedHausanschlussImports([NotNull] MyDb dbRaw)
        {
            var isnLocations    = dbRaw.Fetch <HausanschlussImport>();
            var isnLocationsSup = dbRaw.Fetch <HausanschlussImportSupplement>();
            var mergedLocs      = new List <HausanschlussImport>();

            foreach (var sup in isnLocationsSup)
            {
                var mainlocs = isnLocations.Where(x =>
                                                  Math.Abs(x.Lat - sup.HaLat) < 0.00000000000001 && Math.Abs(x.Lon - sup.HaLon) < 0.00000000000001 &&
                                                  x.ObjectID == sup.HaObjectid)
                               .ToList();
                if (mainlocs.Count > 1)
                {
                    throw new FlaException("found multiple candidates for " + sup.HaObjectid);
                }

                if (mainlocs.Count == 0)
                {
                    throw new FlaException("No object found to match for " + sup.HaObjectid);
                }

                HausanschlussImport hai1 = new HausanschlussImport(mainlocs[0], sup.TargetStandort);
                hai1.Adress = sup.TargetComplexName;
                hai1.Isn    = sup.TargetIsn;
                mergedLocs.Add(hai1);
            }

            foreach (var location in isnLocations)
            {
                mergedLocs.Add(location);
            }

            return(mergedLocs);
        }
Esempio n. 2
0
        public IActionResult Index(int id, ApprovalSearchParameter search)
        {
            var pageIndex = id > 0 ? id : 1;

            var where = LinqExtensions.True <Approval>();
            if (search.Department > 0)
            {
                where = where.And(a => a.DepartmentId == search.Department);
            }

            if (!string.IsNullOrWhiteSpace(search.Creator))
            {
                where = where.And(a => a.ApplicantNo == search.Creator);
            }

            if (search.CreateAtStart.HasValue)
            {
                where = where.And(a => a.CreateAt >= search.CreateAtStart.Value);
            }

            if (search.CreateAtEnd.HasValue)
            {
                where = where.And(a => a.CreateAt <= search.CreateAtEnd.Value);
            }

            if (search.Step > 0)
            {
                where = where.And(a => a.ApproveStep == search.Step);
            }

            if (search.Result > 0)
            {
                where = where.And(a => a.ApproveResult == search.Result);
            }

            if (!string.IsNullOrWhiteSpace(search.Approver))
            {
                where = where.And(a => a.ApproverNo == search.Approver || a.ConfirmNo == search.Approver);
            }

            var query = _db.Query <Approval>().Include(a => a.Department);
            var data  = query.Where(where).ToPageList(pageIndex, 20, out var recordCount);

            var result = _mapper.Map <ApprovalResult>(search);

            result.PageIndex   = pageIndex;
            result.RecordCount = recordCount;
            result.PageCount   = recordCount / 20 + (recordCount % 20 > 0 ? 1 : 0);
            result.Data        = data;

            ViewBag.Departments = new SelectList(_db.Fetch <Department>(), "Id", "Name");
            return(View(result));
        }
        private List <Localnet> LoadLocalnetData([NotNull] MyDb db)
        {
            var sw = new Stopwatch();

            sw.Start();
            var localnetEntries = db.Fetch <Localnet>();

            if (localnetEntries.Count == 0)
            {
                throw new Exception("no localnet");
            }

            sw.Stop();
            Info("Loaded localnet data in " + sw.ElapsedMilliseconds + " ms for " + localnetEntries.Count + " entries");
            return(localnetEntries);
        }
        private List <BuildingComplex> FetchCleanedComplexList([NotNull] MyDb db)
        {
            var komplexe = db.Fetch <BuildingComplex>();

            foreach (var complex in komplexe)
            {
                complex.ObjektStandorte.Clear();
            }

            var komplexeToDelete = komplexe.Where(x => x.SourceOfThisEntry == BuildingComplex.SourceOfEntry.Localnetdata).ToList();

            Info("B_KomplexeToStandorte: Deleted #:" + komplexeToDelete.Count + " komplexe from previous run");
            foreach (var complex in komplexeToDelete)
            {
                komplexe.Remove(complex);
                db.Delete(complex);
            }

            return(komplexe);
        }
        private Dictionary <string, string> LoadStandortTranslationsAsDictionary([NotNull] MyDb db)
        {
            var adresstranslations = db.Fetch <AdressTranslationEntry>();

            if (adresstranslations.Count == 0)
            {
                throw new Exception("no adresstranslations");
            }

            var loweredTranslations = new Dictionary <string, string>();

            foreach (var entry in adresstranslations)
            {
                if (entry.OriginalStandort == null)
                {
                    throw new Exception("Originalstandort was null");
                }

                loweredTranslations.Add(Helpers.CleanAdressString(entry.OriginalStandort), entry.TranslatedAdress);
            }

            Info("Loaded " + loweredTranslations.Count + " translations");
            return(loweredTranslations);
        }
Esempio n. 6
0
        private void PresentOnlyVisualisations([NotNull] Dictionary <string, HeatingSystemEntry> heatingsystemsByGuid,
                                               [NotNull] ScenarioSliceParameters slice,
                                               [NotNull][ItemNotNull] List <House> houses1,
                                               [NotNull] MyDb dbHouse)
        {
            MakeHeatingSystemMapForFeuerungstätten1();
            MakeHeatingSystemMapForFeuerungstätten2();
            MakeHeatingSystemMapForEbbe();

            void MakeHeatingSystemMapForFeuerungstätten1()
            {
                RGB GetColor(House h)
                {
                    var hse = heatingsystemsByGuid[h.Guid];

                    if (!string.IsNullOrWhiteSpace(hse.FeuerungsstättenType))
                    {
                        return(Constants.Green);
                    }

                    return(Constants.Black);
                }

                var filename      = MakeAndRegisterFullFilename("AllHousesWithFeuerungsstättenData.png", slice);
                var legendEntries = new List <MapLegendEntry> {
                    new MapLegendEntry("Feuerungsstätten-Daten vorhanden", Constants.Green),
                    new MapLegendEntry("Feuerungsstätten-Daten nicht vorhanden", Constants.Black)
                };
                var mceh = houses1.Select(x => x.GetMapColorForHouse(GetColor)).ToList();

                Services.PlotMaker.MakeOsmMap("HeatingTypeMap", filename, mceh, new List <WgsPoint>(), legendEntries, new List <LineEntry>());
            }

            void MakeHeatingSystemMapForEbbe()
            {
                var houseHeatingMethods = dbHouse.Fetch <HouseHeating>();

                RGB GetColor(House h)
                {
                    var houseHeatingMethod = houseHeatingMethods.Single(x => x.HouseGuid == h.Guid);

                    if (houseHeatingMethod.KantonHeizungEnergyDemand > 0)
                    {
                        return(Constants.Green);
                    }

                    return(Constants.Black);
                }

                var filename      = MakeAndRegisterFullFilename("AllHousesWithEbbeData.png", slice);
                var legendEntries = new List <MapLegendEntry> {
                    new MapLegendEntry("Ebbe-Daten vorhanden", Constants.Green),
                    new MapLegendEntry("Feuerungsstätten-Daten nicht vorhanden", Constants.Black)
                };
                var mceh = houses1.Select(x => x.GetMapColorForHouse(GetColor)).ToList();

                Services.PlotMaker.MakeOsmMap("HeatingTypeMap", filename, mceh, new List <WgsPoint>(), legendEntries, new List <LineEntry>());
            }

            MakeHeatingSystemMapForNoBeco();

            void MakeHeatingSystemMapForNoBeco()
            {
                var houseHeatingMethods = dbHouse.Fetch <HouseHeating>();

                RGB GetColor(House h)
                {
                    var houseHeatingMethod = houseHeatingMethods.Single(x => x.HouseGuid == h.Guid);
                    var hse = heatingsystemsByGuid[h.Guid];

                    if (string.IsNullOrWhiteSpace(hse.FeuerungsstättenType) && houseHeatingMethod.KantonHeatingMethods.Count > 0)
                    {
                        return(Constants.Blue);
                    }

                    if (!string.IsNullOrWhiteSpace(hse.FeuerungsstättenType) && houseHeatingMethod.KantonHeatingMethods.Count > 0)
                    {
                        return(Constants.Green);
                    }

                    return(Constants.Black);
                }

                var filename      = MakeAndRegisterFullFilename("AllHousesWithEbbeDataNoBeco.png", slice);
                var legendEntries = new List <MapLegendEntry> {
                    new MapLegendEntry("Ebbe-Daten & Beco vorhanden,", Constants.Green),
                    new MapLegendEntry("Ebbe-Daten & kein Beco vorhanden,", Constants.Blue),
                    new MapLegendEntry("Feuerungsstätten-Daten nicht vorhanden", Constants.Black)
                };
                var mceh = houses1.Select(x => x.GetMapColorForHouse(GetColor)).ToList();

                Services.PlotMaker.MakeOsmMap("HeatingTypeMap", filename, mceh, new List <WgsPoint>(), legendEntries, new List <LineEntry>());
            }

            void MakeHeatingSystemMapForFeuerungstätten2()
            {
                RGB GetColor(House h)
                {
                    var hse = heatingsystemsByGuid[h.Guid];

                    if (hse.FeuerungsstättenType == "Gas")
                    {
                        return(Constants.Green);
                    }

                    if (hse.FeuerungsstättenType == "Oel")
                    {
                        return(Constants.Blue);
                    }

                    if (hse.FeuerungsstättenType == "Oel,Gas")
                    {
                        return(Constants.Türkis);
                    }

                    if (!string.IsNullOrWhiteSpace(hse.FeuerungsstättenType))
                    {
                        throw new FlaException("Unbekannter Beco typ: " + hse.FeuerungsstättenType);
                    }

                    return(Constants.Black);
                }

                var filename      = MakeAndRegisterFullFilename("AllHousesWithFeuerungstättenByType.png", slice);
                var legendEntries = new List <MapLegendEntry> {
                    new MapLegendEntry("Beco Gas", Constants.Green),
                    new MapLegendEntry("Beco Öl", Constants.Blue),
                    new MapLegendEntry("Beco Öl/Gas", Constants.Türkis),
                    new MapLegendEntry("Feuerungsstätten-Daten nicht vorhanden", Constants.Black)
                };
                var mceh = houses1.Select(x => x.GetMapColorForHouse(GetColor)).ToList();

                Services.PlotMaker.MakeOsmMap("HeatingTypeMap", filename, mceh, new List <WgsPoint>(), legendEntries, new List <LineEntry>());
            }
        }