Exemple #1
0
        private static void DownloadFiles(MediaItemCollection missingFiles, MediaItemCollection changedFiles, MediaServerClient client, string projectName, string path)
        {
            var items = missingFiles.Items;
            items.AddRange(changedFiles.Items);

            var done = 0;
            var total = missingFiles.Items.Count + changedFiles.Items.Count;
            var totalSize = (missingFiles.Items.Sum(x => x.FileSize) + changedFiles.Items.Sum(x => x.FileSize));
            Console.WriteLine("Downloading "+total+"files "+totalSize.ToFileSize()+"bytes");
            foreach (MediaItem mediaItem in items)
            {
                if (!mediaItem.Filename.EndsWith(".config"))
                {

                    var localPath = path + mediaItem.Filename;
                        Directory.CreateDirectory(Path.GetDirectoryName(localPath));
                        var remotePath = HttpUtility.UrlEncode(projectName + "/" + mediaItem.Filename);

                    try
                    {
                        var compressed = client.DownloadFile(remotePath);
                        var uncompressed = Compression.Unzip(compressed);
                        File.WriteAllBytes(localPath, uncompressed);
                        done++;
                        UpdateStatus(done, total);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error downloading " + remotePath);
                    }
                }
            }
        }
        public MediaItemCollection FindMissingFiles(MediaItemCollection localCollection)
        {
            var missing = new MediaItemCollection();

            foreach (var mediaItem in Items)
            {
                if(!localCollection.ContainsFile(mediaItem.Filename))
                {
                    missing.Items.Add(mediaItem);
                }
            }

            return missing;
        }
 public MediaItemCollection FindChangedFiles(MediaItemCollection localCollection)
 {
     var listOfDifferent = new MediaItemCollection();
     foreach (MediaItem mediaItem in Items)
     {
         var item = localCollection.FindByFilename(mediaItem.Filename);
         if (item != null)
         {
             if (item.MD5 != mediaItem.MD5)
             {
                 listOfDifferent.Items.Add(item);
             }
         }
     }
     return listOfDifferent;
 }
        public static MediaItemCollection PopulateFromPath(string mapPath)
        {
            var collection = new MediaItemCollection();

            Directory.CreateDirectory(mapPath);

            var files = Directory.GetFiles(mapPath, "*", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                if (!file.Contains("\\Cached\\"))
                {
                    collection.Items.Add(MediaItem.FromPath(file, mapPath));
                }
            }

            return collection;
        }
Exemple #5
0
        private static void UploadFiles(MediaItemCollection missingFiles, MediaItemCollection changedFiles, string path, MediaServerClient mediaClient, string projectName)
        {
            var items = missingFiles.Items;
            items.AddRange(changedFiles.Items);

            var done = 0;
            var total = missingFiles.Items.Count + changedFiles.Items.Count;
            Console.WriteLine("Uploading " + total + "files " + (missingFiles.Items.Sum(x => x.FileSize) + changedFiles.Items.Sum(x => x.FileSize) + "bytes"));
            foreach (MediaItem mediaItem in items)
            {
                var localPath = path + mediaItem.Filename;
                Directory.CreateDirectory(Path.GetDirectoryName(localPath));
                mediaClient.UploadFile(path, projectName, mediaItem);
                 done++;
                UpdateStatus(done, total);
            }
        }