Ejemplo n.º 1
0
        //files that have a newer version in the cloud -- download them and replace local files
        public static int ReplaceOutDatedLocalFiles(List <FileInfoX> localFiles, List <FileInfoX> remoteFiles, bool confirmDownload)
        {
            var localQuery = from l in localFiles
                             join r in remoteFiles on l.LocalFileName equals r.LocalFileName
                             where (r.LastModifiedUtc - l.LastModifiedUtc).TotalSeconds >= 2
                             select r;

            var shouldDownloadLocalQuery = localQuery.Where(f => OwnCloudClient.ShouldDownload(f)).ToList();

            if (shouldDownloadLocalQuery.Count > 0)
            {
                NLogger.Current.Info("Found Downloads:");
                foreach (var x in localQuery)
                {
                    NLogger.Current.Info(x.LocalFileName);
                }
            }

            List <FileInfoX> confirmedToDownload = shouldDownloadLocalQuery;

            if (confirmDownload)
            {
                confirmedToDownload = FillConfirmationList(shouldDownloadLocalQuery, ConfirmRequest.Download);
            }

            foreach (var x in confirmedToDownload)
            {
                OwnCloudClient.DownloadFile(x.CloudFileNameWithEmbeddedData);
            }

            return(confirmedToDownload.Count);
        }
Ejemplo n.º 2
0
 public static void DownloadAll()
 {
     foreach (var f in GetRemoteFileList())
     {
         if (ShouldDownload(f))
         {
             OwnCloudClient.DownloadFile(f.CloudFileNameWithEmbeddedData);
         }
     }
 }