Esempio n. 1
0
        private static Dictionary <string, Dictionary <int, double> > GetDictForVerbrauch(
            [NotNull] MonthlyElectricityUsePerStandort perStandortElectricityMonthlyValuesByTarif,
            Verbrauchsart vba)
        {
            switch (vba)
            {
            case Verbrauchsart.ElectricityLocalnet:
                return(perStandortElectricityMonthlyValuesByTarif.ElectricityLocalNetMonthlyValuesByTarif);

            case Verbrauchsart.Gas:
                return(perStandortElectricityMonthlyValuesByTarif.GasMonthlyValuesByTarif);

            case Verbrauchsart.Fernwaerme:
                return(perStandortElectricityMonthlyValuesByTarif.FernwaermeMonthlyValuesByTarif);

            case Verbrauchsart.ElectricityNetz:

                return(perStandortElectricityMonthlyValuesByTarif.ElectricityNetzMonthlyValuesByTarif);

            case Verbrauchsart.Netzuebergabe:
                return(perStandortElectricityMonthlyValuesByTarif.ElectricityNetzübergabeMonthlyValuesByTarif);

            default:
                throw new ArgumentOutOfRangeException(nameof(vba), vba, null);
            }
        }
        protected override void RunActualProcess()
        {
            var dbRaw    = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice);
            var dbEnergy = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ComplexEnergyData, Constants.PresentSlice);

            dbEnergy.RecreateTable <MonthlyElectricityUsePerStandort>();
            var localnetEntries = dbRaw.Fetch <Localnet>();

            localnetEntries.Sort(Comparison);
            var clds = new Dictionary <string, MonthlyElectricityUsePerStandort>();

            dbEnergy.BeginTransaction();
            foreach (var localnet in localnetEntries)
            {
                if (string.IsNullOrWhiteSpace(localnet.Objektstandort))
                {
                    continue;
                }

                var cleanedStandort = Helpers.CleanAdressString(localnet.Objektstandort);
                if (!clds.ContainsKey(cleanedStandort))
                {
                    var cld1 = new MonthlyElectricityUsePerStandort {
                        Standort        = localnet.Objektstandort,
                        CleanedStandort = cleanedStandort
                    };
                    clds.Add(cleanedStandort, cld1);
                }

                var cld = clds[cleanedStandort];
                ProcessVerrechnungstyp(localnet, cld);
                var totalSumFromMonthly = clds.Values.Select(x => x.YearlyElectricityUseNetz).Sum();
                if (Math.Abs(totalSumFromMonthly - _stromNetzSum) > 0.00001)
                {
                    throw new Exception("totalSumFromMonthly:" + totalSumFromMonthly + " stromNetzSum:" + _stromNetzSum);
                }
            }

            foreach (var cld in clds.Values)
            {
                cld.IntegrityCheck();
                dbEnergy.Save(cld);
            }

            dbEnergy.CompleteTransaction();
        }
        private void ProcessVerrechnungstyp([NotNull] Localnet localnet, [NotNull] MonthlyElectricityUsePerStandort meps)
        {
            var processed = false;

            switch (localnet.Verrechnungstyp)
            {
            case "Energie Tagesstrom (HT)":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "Energie Nachtstrom (NT)":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "Gutschrift Strom Energie":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "Nachbelastung Strom Energie":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "Rücklieferung Tagesstrom HT":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "Rücklieferung Nachtstrom NT":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "EVG Tagesstrom (HT)":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "EVG Nachtstrom (NT)":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityLocalnet);
                processed = true;
                break;

            case "Gutschrift Erdgas":
                break;

            case "Kosten Erdgasbezug":
                break;

            case "Erdgasverbrauch":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.Gas);
                processed = true;
                break;

            case "CO2-Abgabe":
                break;

            case "Grundpreis Erdgas":
                break;

            case "Grundgebühr Erdgas":
                break;

            case "Leistungsspitze":
                break;

            case "Arbeitspreis":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.Fernwaerme);
                processed = true;
                break;

            case "Grundpreis Wärme (kW/Mt)":
                break;

            case "Grundpreis Wärme (Zähler/Mt)":
                break;

            case "Grundpreis 1 (kW/Mt)":
                break;

            case "Grundpreis 2 (kW/Mt)":
                break;

            case "Leistung":
                break;

            case "Blindenergie (HT)":
                break;

            case "Blindenergie (NT)":
                break;

            case "Grundpreis Strom":
                break;

            case "Netz Tagesstrom (HT)":
                if (localnet.BasisVerbrauch == null)
                {
                    throw new Exception("Basisverbrauch was null");
                }

                _stromNetzSum += localnet.BasisVerbrauch.Value;
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityNetz);
                break;

            case "Netz Nachtstrom (NT)":
                if (localnet.BasisVerbrauch == null)
                {
                    throw new Exception("Basisverbrauch was null");
                }

                _stromNetzSum += localnet.BasisVerbrauch.Value;
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.ElectricityNetz);
                break;

            case "Messung und Abrechnung":
                break;

            case "Systemdienstleistungen Swissgrid (SDL)":
                break;

            case "Kostendeckende Einspeisevergütung KEV":
                break;

            case "Abgabe an Gemeinde":
                break;

            case "Gutschrift Strom Netznutzung":
                break;

            case "Bundesabgabe zum Schutz der Gewässer und Fische":
                break;

            case "Netz Rücklieferung Tagesstrom HT":
                break;

            case "Netz Rücklieferung Nachtstrom NT":
                break;

            case "Messung und Abrechung Netzübergabestelle":
                meps.AddLocalnetEntryForStandort(localnet, Verbrauchsart.Netzuebergabe);
                break;

            case "EVG Leistung":
                break;

            case "EVG Blindenergie (HT)":
                break;

            case "EVG Blindenergie (NT)":
                break;

            default:
                throw new Exception("unknown verrechnungstyp");
            }

            if (!processed && localnet.BasisVerbrauch > 0 && localnet.Vertragsart != "Netz")
            {
                Info("Verbrauch, but not processed for " + localnet.Verrechnungstyp);
            }
        }