Пример #1
0
        public async Task <List <string> > GetFoldersAsync(string folder)
        {
            try
            {
                var l = await CloudStore.GetFolderListAsync(folder);

                List <string> retl = new List <string>();
                foreach (var i in l)
                {
                    if (i.isFolder)
                    {
                        retl.Add(i.name);
                    }
                }

                return(retl);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.ToString());

                return(null);
            }
        }
Пример #2
0
        public async Task <List <string> > UpdateProjectAsync(string root, string project, UpdateStatus UpdateStatusRoutine)
        {
            List <string> UpdatedSongs = new List <string>();

            try
            {
                string projectPath      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), project);
                string remoteFolderName = "/" + root + "/" + project;

                // Is local folder created?
                var d = Directory.CreateDirectory(projectPath);
                if (d != null)
                {
                    var items = await cs.GetFolderListAsync(remoteFolderName);

                    foreach (var di in items)
                    {
                        if (isAudioFile(di))
                        {
                            UpdatedSongs.Add(di.name);

                            string   localFileName  = projectPath + "/" + di.name;
                            DateTime localWriteTime = File.GetLastWriteTimeUtc(localFileName);

                            if (Math.Abs((localWriteTime - di.modifiedDate).TotalSeconds) >= 1)
                            {
                                using (Stream s = new FileStream(localFileName, FileMode.OpenOrCreate))
                                {
                                    Debug.Print("downloading " + localFileName + "\n");
                                    UpdateStatusRoutine("downloading " + project + "/" + di.name);
                                    if (!await CloudStore.DownloadFileAsync(remoteFolderName + "/" + di.name, s))
                                    {
                                        Debug.Print("FAILED " + localFileName + "\n");
                                    }
                                    else
                                    {
                                        PersistentData.SetTrackNumber(projectPath, di.name, di.track);
                                    }

                                    s.Close();

                                    File.SetLastWriteTimeUtc(localFileName, di.modifiedDate);

                                    DateTime tempLastWriteTime = File.GetLastWriteTimeUtc(localFileName);
                                }
                            }
                        }
                    }

                    // Save provider
                    PersistentData.SetProvider(project, project, d.LastWriteTime.ToString(), CloudProvider);
                    PersistentData.SetCloudRoot(project, project, d.LastWriteTime.ToString(), root);
                }
            }
            catch (Exception ex)
            {
                Debug.Print("exception " + ex.Message);
                throw;
            }

            return(UpdatedSongs);
        }