public async Task <SolarAndUtilityReport> generateReport()
        {
            LOGGER.Info("Downloading Green Button Data from Orange & Rockland");
            GreenButtonData greenButtonData = await orangeRocklandService.greenButton.fetchGreenButtonData();

            GreenButtonData.MeterReading mostRecentOrangeRocklandBill = greenButtonData.meterReadings.Last();
            LOGGER.Info("Downloading bill from Orange & Rockland");
            int energyPurchasedOrSold = await orangeRocklandService.billDocuments.fetchEnergyPurchasedOrSoldKWh(
                mostRecentOrangeRocklandBill
                .billingInterval.End);

            LOGGER.Debug("Paid ${0} to use {1} kWh of electricity between {2} and {3}",
                         mostRecentOrangeRocklandBill.costCents / 100,
                         energyPurchasedOrSold, mostRecentOrangeRocklandBill.billingInterval.Start,
                         mostRecentOrangeRocklandBill.billingInterval.End);

            SolarReport solarReport = await generateSolarReport(mostRecentOrangeRocklandBill.billingInterval);

            return(new SolarAndUtilityReport(solarReport.billingInterval, solarReport.powerGenerated,
                                             energyPurchasedOrSold, mostRecentOrangeRocklandBill.costCents));
        }
Пример #2
0
        public async Task <int> sendSolarReport()
        {
            LOGGER.Info("Dad's Energy Reporter {0}", Assembly.GetExecutingAssembly().GetName().Version);

            LOGGER.Debug("Validating options");
            try {
                validateOptions(options);
            } catch (Exception) {
                return(1);
            }

            LOGGER.Debug("Validating settings");
            try {
                validateSettings(settings);
            } catch (SettingsException) {
                return(1);
            }

            try {
                LOGGER.Info("Logging in...");
                await logIn();

                LOGGER.Info("Logged in.");

                SolarReport report =
                    await reportGenerator.generateSolarReport(new DateInterval(options.startDate, options.endDate));

                Console.WriteLine($"{report.powerGenerated:N2}");

                return(0);
            } catch (Exception e) {
                LOGGER.Error(e, "Aborted report generation due to exception " + e);
                return(1);
            } finally {
                LOGGER.Info("Logging out");
                await ownerApiService.authentication.logOut();

                LOGGER.Info("Done");
            }
        }