/// <summary>
        /// Writes the data for this export to the file specified.
        /// </summary>
        /// <param name="filename">The file to write to.</param>
        /// <param name="geographyProvider">The geography data provider.</param>
        /// <param name="booksReadProvider">The books data provider.</param>
        /// <param name="errorMessage">The error message if unsuccessful.</param>
        /// <returns>True if written successfully, false otherwise.</returns>
        public bool WriteToFile(
            string filename,
            IGeographyProvider geographyProvider,
            IBooksReadProvider booksReadProvider,
            out string errorMessage)
        {
            errorMessage        = string.Empty;
            _selectedMonthTally = booksReadProvider.SelectedMonthTally;
            _reportsTallies     = booksReadProvider.ReportsTallies;

            try
            {
                // Set up the file content.
                string title;
                string content;
                GetMonthlyReportTitleAndContent(out title, out content);

                // Write out the content
                TextWriter textWriter = new StreamWriter(filename, false, Encoding.Default); //overwrite original file
                textWriter.Write(content);

                // Tidy up
                textWriter.Close();
            }
            catch (Exception e)
            {
                errorMessage = e.ToString();
                return(false);
            }

            return(true);
        }
        public void Setup(IList <BookRead> books, IGeographyProvider geographyProvider)
        {
            _geographyProvider = geographyProvider;

            BooksRead.Clear();
            foreach (BookRead book in books.OrderBy(x => x.Date))
            {
                BooksRead.Add(book);
            }

            UpdateBookDeltas();
            UpdateBookPerYearDeltas();
            UpdateAuthors();
            UpdateWorldCountryLookup();
            int  booksReadWorldwide;
            uint pagesReadWorldwide;

            UpdateCountries(out booksReadWorldwide, out pagesReadWorldwide);
            UpdateLanguages(booksReadWorldwide, pagesReadWorldwide);
            BookLocationDeltas = new ObservableCollection <BookLocationDelta>();
            UpdateBookLocationDeltas();
            UpdateBooksPerMonth();
            UpdateBookTags();
            UpdateTalliedBooks();
            SelectedMonthTally = TalliedMonths.FirstOrDefault();
            _selectedMonth     = DateTime.Now;
            if (SelectedMonthTally != null)
            {
                _selectedMonth = SelectedMonthTally.MonthDate;
            }
        }
 public MonthlyReportsTally(TalliedMonth selectedMonthTally)
 {
     DisplayTitle        = selectedMonthTally.DisplayString;
     TotalDays           = selectedMonthTally.DaysInTheMonth;
     TotalBooks          = selectedMonthTally.TotalBooks;
     TotalPagesRead      = selectedMonthTally.TotalPagesRead;
     TotalBookFormat     = selectedMonthTally.TotalBookFormat;
     TotalComicFormat    = selectedMonthTally.TotalComicFormat;
     TotalAudioFormat    = selectedMonthTally.TotalAudioFormat;
     PercentageInEnglish = selectedMonthTally.PercentageInEnglish;
 }
 public ExportMonthlyReportToToHtml(
     TalliedMonth selectedMonthTally,
     IList <ReportsViewModel.MonthlyReportsTally> reportsTallies,
     IList <string> chartFiles,
     bool forBlog = false)
 {
     _forBlog            = forBlog;
     _selectedMonthTally = selectedMonthTally;
     _reportsTallies     = reportsTallies;
     _chartFiles         = chartFiles;
     OutputFilePath      = Properties.Settings.Default.MonthlyReportFile;
 }
        public MonthlyTally(TalliedMonth talliedBook)
        {
            MonthDate               = talliedBook.MonthDate;
            Name                    = talliedBook.DisplayString;
            DaysInTheMonth          = talliedBook.DaysInTheMonth;
            TotalBooks              = (int)talliedBook.TotalBooks;
            TotalPagesRead          = (int)talliedBook.TotalPagesRead;
            TotalBookFormat         = (int)talliedBook.TotalBookFormat;
            TotalComicFormat        = (int)talliedBook.TotalComicFormat;
            TotalAudioFormat        = (int)talliedBook.TotalAudioFormat;
            PercentageInEnglish     = (float)talliedBook.PercentageInEnglish;
            PercentageInTranslation = (float)talliedBook.PercentageInTranslation;
            PageRate                = (float)talliedBook.PageRate;
            DaysPerBook             = (float)talliedBook.DaysPerBook;
            PagesPerBook            = (float)talliedBook.PagesPerBook;
            BooksPerYear            = (float)talliedBook.BooksPerYear;

            Books = new Book[talliedBook.BooksRead.Count];
            for (int i = 0; i < talliedBook.BooksRead.Count; i++)
            {
                Books[i] = new Book(talliedBook.BooksRead[i]);
            }
        }