示例#1
0
        private async Task <bool> UpdateFolderList()
        {
            if (pi != null && await pi.CheckAuthenitcationAsync() && CurrentFolder != null)
            {
                BusyOn(true);
                ppd.BusyText = "Refreshing folder view from " + CurrentProvider.ToString() + " " + CurrentDisplayFolder;
                List <string> folders = await pi.GetFoldersAsync(CurrentFolder);

                //FolderList.ItemsSource = folders;
                DirectoryList.Clear();

                foreach (string d in folders)
                {
                    DirectoryList.Add(new DirectoryEntry()
                    {
                        DirectoryName = d
                    });
                }

                BusyOn(false);

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        private async Task SyncProjectsAsync()
        {
            Dictionary <string, List <string> > AllSongs = new Dictionary <string, List <string> >();

            foreach (MixLocation ml in PersistentData.MixLocationList)
            {
                UpdateStatus(ml.Provider.ToString() + " " + ml.Path);

                ProviderInfo pi = await ProviderInfo.GetCloudProviderAsync(ml.Provider);

                if (await pi.CheckAuthenitcationAsync())
                {
                    List <string> l = await pi.GetFoldersAsync(ml.Path);

                    if (l != null)
                    {
                        foreach (string f in l)
                        {
                            UpdateStatus(ml.Provider.ToString() + " " + ml.Path + " " + f);
                            var retList = await pi.UpdateProjectAsync(ml.Path, f, UpdateStatus);

                            if (AllSongs.ContainsKey(f))
                            {
                                AllSongs[f].AddRange(retList);
                            }
                            else
                            {
                                AllSongs[f] = retList;
                            }
                        }
                    }
                }
            }

            string rootPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            foreach (string p in Directory.GetDirectories(rootPath))
            {
                if (!AllSongs.ContainsKey(Path.GetFileName(p)))
                {
                    Debug.Print("Remove dir " + p + "\n");
                    UpdateStatus("Removing " + p);
                    Directory.Delete(p, true);
                }
                else
                {
                    foreach (string s in Directory.GetDirectories(p))
                    {
                        if (AllSongs[p].Contains(Path.GetFileName(s)))
                        {
                            UpdateStatus("Removing " + s);
                            Debug.Print("Remove file " + s + "\n");
                            File.Delete(s);
                        }
                    }
                }
            }

            foreach (string p in AllSongs.Keys)
            {
                foreach (string f in AllSongs[p])
                {
                    UpdateStatus(p + " " + f);
                }
            }

            PersistentData.Save();
        }