Exemple #1
0
        public async void ReadMyXML(string year, string month)
        {
            Albums = new Albums();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlalbums.aspx?ay=" + year + "&am=" + month));
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("Albums");
            Count = 0;
            while (reader.IsStartElement())
            {
                string albumid = reader[0];
                string album = reader[2];
                string str = reader[1];
                str = str.Replace("_s.jpg", "");
                uint count = 0;
                if (uint.TryParse(reader[3], out count))
                {
                    Album m = new Album(albumid, album, str, count);
                    Albums.Add(m);
                    Count += m.Count;
                }
                await reader.ReadAsync();
            }
        }
Exemple #2
0
        public async void ReadMyXML(string albumid)
        {
            Images = new Images();
            AllImages = new Images();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlonealbum.aspx?ah=" + albumid));
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("PhotoList");
            Count = 0;
            string albumtitle = "";
            while (reader.IsStartElement())
            {
                string main = reader[3];
                albumtitle = reader[2];
                string phototitle = reader[1];
                string str = reader[0];
                str = str.Replace(".jpg", "");

                OneImage oi = new OneImage(phototitle, str, Count);
                AllImages.Add(oi);
                if (char.ToUpper(main[0]) == 'Y')
                {
                    MainImage = oi;
                }
                else
                {
                    Images.Add(oi);
                }
                //var donotuse = oi.MediumSizeStream; // Access it here - so that the download for it kicks off
                Count++;

                await reader.ReadAsync();
            }
            AlbumTitle = albumtitle;
        }
Exemple #3
0
        public async void ReadMyXML(string year)
        {
            Months = new Months();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlmonths.aspx?ay=" + year));
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("Months");
            Count = 0;
            while (reader.IsStartElement())
            {
                string month = reader[0];
                string str = reader[1];
                str = str.Replace("_s.jpg", "");
                if (!String.IsNullOrEmpty(str))
                {
                    uint count = 0;
                    if (uint.TryParse(reader[2], out count))
                    {
                        Month m = new Month(month, str, count);
                        Months.Add(m);
                        Count += m.Count;
                    }
                }
                await reader.ReadAsync();
            }
        }
Exemple #4
0
        public async void ReadMyXML()
        {
            Uri uriYears = ToAbsoluteUri("xmlyears.aspx");

            App app = (App)Application.Current;
            if (app.BackgroundDownloader != null)
            {
                if (app.BackgroundDownloader.Status == TaskStatus.RanToCompletion)
                {
                    bool b = await app.BackgroundDownloader;
                    if (b)
                    {
                        try
                        {
                            var y = Windows.Storage.ApplicationData.Current.LocalFolder;
                            string subdir = BasicFileDownloader.UriToSubDirectory(uriYears);
                            string fname = BasicFileDownloader.UriToFilename(uriYears);
                            string backupfname = BasicFileDownloader.UriToFilename(uriYears) + ".bak";

                            var sf = await y.GetFileAsync(subdir + "\\" + fname);
                            await sf.DeleteAsync();
                            sf = await y.GetFileAsync(subdir + "\\" + backupfname);
                            await sf.RenameAsync(fname);
                        }
                        catch { }
                    }
                }
            } 
                    
            Years = new Years();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(uriYears);
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("Years");
            Count = 0;
            while (reader.IsStartElement())
            {
                string year = reader[0];
                string str = reader[1];
                str = str.Replace("_s.jpg", "");
                if (!String.IsNullOrEmpty(str))
                {
                    uint count = 0;
                    if (uint.TryParse(reader[2], out count))
                    {
                        Year y = new Year(year, str, count);
                        if (FirstYear == null)
                            FirstYear = y;
                        else
                            Years.Add(y);
                        Count += y.Count;
                    }
                }
                await reader.ReadAsync();
            }

            s.Dispose();

            BasicFileDownloader bfdlForce = new BasicFileDownloader(uriYears);
            app.BackgroundDownloader = bfdlForce.DownloadAsyncForce(null);
        }