Example #1
0
        private async void updateCollection(string html, bool fromFreshDownloadFlag)
        {
            string htmllink = html;
            //Debug.WriteLine(htmllink);
            Debug.WriteLine("in UpdateCollection");
            artists.Clear();
            RootObjectArtist rartist = new RootObjectArtist();
            rartist.art = new List<lineupArt>();
            bool artistsFileExists = await library.checkIfFileExists("artistsFile");
            if (fromFreshDownloadFlag == true || artistsFileExists == false)
            {
                while (html.IndexOf("class=\"band \" id=") != -1)
                {
                    //Debug.WriteLine("In While loop");
                    htmllink = html;
                    int indexlink = htmllink.IndexOf("class=\"band \" id");
                    string subtemp = htmllink.Substring(indexlink);
                    indexlink = subtemp.IndexOf("href=\"");
                    string sublink = subtemp.Substring(indexlink + 38);
                    sublink = sublink.Substring(0, sublink.IndexOf("\""));

                    int index = html.IndexOf("class=\"band \" id=");
                    string sub = html.Substring(index);
                    index = sub.IndexOf(">");
                    int index1 = sub.IndexOf("<");
                    string sub1 = sub.Substring(index + 1, index1 - index - 1);
                    if (sub1.Contains("&amp;"))
                    {
                        sub1 = sub1.Substring(0, sub1.IndexOf("&amp;") - 1) + " & " + sub1.Substring(sub1.IndexOf("&amp;") + 1 + 4);
                    }
                    html = sub.Substring(index1);
                    Debug.WriteLine(sub1);
                    lineupArt lart = new lineupArt();
                    lart.name = sub1;
                    lart.link = "http://lineup.bonnaroo.com/band/" + sublink;
                    lart.sublink = sublink;
                    if (await library.checkIfFileExists(sublink + "profilepic"))
                    {
                        lart.artistPhotoPath = "ms-appdata:///local/" + sublink + "profilepic";
                    }
                    else
                    {
                        lart.artistPhotoPath = "/assets/member_photo.jpg";
                    }
                    artists.Add(lart);
                    rartist.art.Add(lart);
                }
                string res = lineupArtists.artistDataSerializer(rartist);
                Debug.WriteLine(res);
                await library.writeFile("artistsFile", res);
            }
            else          // if the artistsFile exists and we don't need to fo a fresh refresh, read from the file, deserialize and add to the observable collection
            {
                Debug.WriteLine("in else on lineup page");
                string res = await library.readFile("artistsFile");
                rartist = lineupArtists.artistDataDeserializer(res);
                var rartinfo = rartist.art;
                foreach (var rart in rartinfo)
                {
                    artists.Add(rart);
                }
            }
        }
Example #2
0
 public static string artistDataSerializer(RootObjectArtist rartist)
 {
     string response = JsonConvert.SerializeObject(rartist);
     return response;
 }