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;
            }
        }
        /// <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);
        }
Esempio n. 3
0
        /// <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;

            try
            {
                // Set up the nations file.
                NationsFile nationsFile = new NationsFile();
                foreach (Nation nation in geographyProvider.Nations.OrderBy(x => x.Name))
                {
                    nationsFile.Nations.Add(nation);
                }

                // Serialize the XML
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(NationsFile));
                TextWriter    textWriter    = new StreamWriter(filename, false, Encoding.Default); //overwrite original file
                xmlSerializer.Serialize(textWriter, nationsFile);

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

            return(true);
        }
Esempio n. 4
0
 public AuthorCountry(IGeographyProvider mainModel)
 {
     _mainModel          = mainModel;
     Country             = string.Empty;
     AuthorsFromCountry  = new List <BookAuthor>();
     TotalPagesWorldWide = 1;
     TotalBooksWorldWide = 1;
 }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the GeographyFactory class
        /// </summary>
        /// <param name="coordinateSystem">The coordinate system</param>
        internal GeographyFactory(CoordinateSystem coordinateSystem)
        {
            var builder = SpatialBuilder.Create();

            this.provider   = builder;
            this.buildChain = SpatialValidator.Create().ChainTo(builder).StartingLink;
            this.buildChain.SetCoordinateSystem(coordinateSystem);
        }
Esempio n. 6
0
        /// <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;

            try
            {
                StreamWriter sw = new StreamWriter(filename, false, Encoding.Default); //overwrite original file

                // write the header
                sw.WriteLine(
                    "Date,DD/MM/YYYY,Author,Title,Pages,Note,Nationality,Original Language,Book,Comic,Audio,Image,Tags"
                    );

                // write the records
                CsvWriter csv = new CsvWriter(sw);
                foreach (BookRead book in booksReadProvider.BooksRead)
                {
                    csv.WriteField(book.DateString);
                    csv.WriteField(book.Date.ToString("d/M/yyyy"));
                    csv.WriteField(book.Author);
                    csv.WriteField(book.Title);
                    csv.WriteField(book.Pages > 0 ? book.Pages.ToString() : "");
                    csv.WriteField(book.Note);
                    csv.WriteField(book.Nationality);
                    csv.WriteField(book.OriginalLanguage);
                    csv.WriteField(book.Format == BookFormat.Book ? "x" : "");
                    csv.WriteField(book.Format == BookFormat.Comic ? "x" : "");
                    csv.WriteField(book.Format == BookFormat.Audio ? "x" : "");
                    csv.WriteField(book.ImageUrl);
                    csv.WriteField(book.DisplayTags);
                    csv.NextRecord();
                }

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

            return(true);
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialBuilder"/> class.
 /// </summary>
 /// <param name="geographyInput">The geography input.</param>
 /// <param name="geometryInput">The geometry input.</param>
 /// <param name="geographyOutput">The geography output.</param>
 /// <param name="geometryOutput">The geometry output.</param>
 public SpatialBuilder(GeographyPipeline geographyInput, GeometryPipeline geometryInput, IGeographyProvider geographyOutput, IGeometryProvider geometryOutput)
     : base(geographyInput, geometryInput)
 {
     this.geographyOutput = geographyOutput;
     this.geometryOutput  = geometryOutput;
 }
Esempio n. 8
0
 /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.SpatialBuilder" /> class.</summary>
 /// <param name="geographyInput">The geography input.</param>
 /// <param name="geometryInput">The geometry input.</param>
 /// <param name="geographyOutput">The geography output.</param>
 /// <param name="geometryOutput">The geometry output.</param>
 public SpatialBuilder(GeographyPipeline geographyInput, GeometryPipeline geometryInput, IGeographyProvider geographyOutput, IGeometryProvider geometryOutput)
     : base(geographyInput, geometryInput)
 {
     this.geographyOutput = geographyOutput;
     this.geometryOutput = geometryOutput;
 }
Esempio n. 9
0
 public BaseDiagramViewModel(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
 {
     GeographyProvider = geographyProvider;
     BooksReadProvider = booksReadProvider;
 }
 public PagesByCountryDiagramViewModel(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
     : base(geographyProvider, booksReadProvider)
 {
 }
 /// <summary>
 /// Sets up the providers then gets plot model to be displayed.
 /// </summary>
 /// <param name="geographyProvider">The geography data source.</param>
 /// <param name="booksReadProvider">The books data source.</param>
 /// <returns>The user view item model.</returns>
 public PlotModel SetupPlot(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
 {
     GeographyProvider = geographyProvider;
     BooksReadProvider = booksReadProvider;
     return(SetupPlot());
 }
 public BooksReadByCountryViewModel(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
     : base(geographyProvider, booksReadProvider)
 {
 }
Esempio n. 13
0
 public void UpdateData(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
 {
     GeographyProvider = geographyProvider;
     BooksReadProvider = booksReadProvider;
     Model             = _plotGenerator.SetupPlot(geographyProvider, booksReadProvider);
 }
Esempio n. 14
0
 /// <summary>
 /// Sets up the providers then gets plot model to be displayed.
 /// </summary>
 /// <param name="geographyProvider">The geography data source.</param>
 /// <param name="booksReadProvider">The books data source.</param>
 /// <returns>The user view item model.</returns>
 public void SetupPlot(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
 {
     GeographyProvider = geographyProvider;
     BooksReadProvider = booksReadProvider;
     SetupSeries();
 }
 /// <summary>
 /// Sets up the providers then gets editor to be displayed.
 /// </summary>
 /// <param name="geographyProvider">The geography data source.</param>
 /// <param name="booksReadProvider">The books data source.</param>
 public void SetupEditor(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
 {
     GeographyProvider = geographyProvider;
     BooksReadProvider = booksReadProvider;
     SetupEditor();
 }
Esempio n. 16
0
 public void Update(IGeographyProvider geographyProvider, IBooksReadProvider booksReadProvider)
 {
     _plotPairViewModel.UpdateData(geographyProvider, booksReadProvider);
     OnPropertyChanged(() => ViewController);
     OnPropertyChanged(() => Model);
 }