Exemplo n.º 1
0
        public static int Submit(IModel channel, RunOptions opt, ITaskDivider divider)
        {
            var(subs, global) = ArgsToRawTasks(opt.Commands);
            var subsWithFile = LoadFiles(subs);
            var source       = File.ReadAllText(opt.Executor);

            if (!File.Exists("wn_executor.zip") || opt.ReZip == true)
            {
                ZipHelper.CreateFromDirectory(
                    ".", "wn_executor.zip",
                    CompressionLevel.Fastest, false, Encoding.UTF8,
                    path => !path.Contains("/wn_") && !path.Contains("\\wn_"));
            }
            var executor = new Executor()
            {
                source = source,
                worker = new FileBytes(File.ReadAllBytes("wn_executor.zip"))
            };

            SubmitRawTask(channel, new RawTaskGroup()
            {
                executor   = executor,
                subtasks   = subsWithFile.ToList(),
                parameters = global
            }, divider, opt.Id);
            return(0);
        }
Exemplo n.º 2
0
        protected override void Run()
        {
            var solution         = ProjectHelper.GetCurrentSolution();
            var solutionFullPath = solution.BaseDirectory.FullPath;
            var progressMonitor  = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor("Archiving {solutionFullPath}", Stock.StatusSolutionOperation, false, true, false);

            try
            {
                progressMonitor.Log.WriteLine($"Archiving {solutionFullPath}");

                var zipFileName = $"{solution.Name.AppendTimeStamp()}.zip";

                var output = ZipHelper.CreateFromDirectory(solutionFullPath, zipFileName);

                progressMonitor.Log.WriteLine(output);

                progressMonitor.ReportSuccess($"Zip file created: {zipFileName}");
            }
            catch (Exception ex)
            {
                progressMonitor.ReportError($"Archiving failed.", ex);
            }
            finally
            {
                progressMonitor.EndTask();
                progressMonitor.Dispose();
            }
        }
Exemplo n.º 3
0
        public MemoryStream GetCurrentStateAsZip(string courseSubdirectoryInRepo = null)
        {
            log.Info($"Start load '{repoDirName}' to zip");
            var dir = reposBaseDir.GetSubdirectory(repoDirName).FullName;

            dir = courseSubdirectoryInRepo == null ? dir : Path.Combine(dir, courseSubdirectoryInRepo);
            var zip = ZipHelper.CreateFromDirectory(dir, CompressionLevel.Optimal, false, Encoding.UTF8,
                                                    s => !s.StartsWith(".git"));

            log.Info($"Successfully load '{repoDirName}' to zip");
            return(zip);
        }
Exemplo n.º 4
0
        public FilePair AddPath(string path)
        {
            var self = $"data/out/wn_prefix_{path}_wn.zip";

            ZipHelper.CreateFromDirectory(
                $"data/out/{path}",
                $"data/out/wn_prefix_{path}_wn.zip", CompressionLevel.Fastest, false, Encoding.UTF8,
                path => path != self);
            var ret = new FilePair()
            {
                filename = path + ".zip",
                file     = new FileBytes(File.ReadAllBytes($"data/out/wn_prefix_{path}_wn.zip"), true)
            };

            return(ret);
        }
Exemplo n.º 5
0
        public string CompressFiles(string buildFileName, List <string> ignoredFileExts = null, List <string> ignoredFileNames = null)
        {
            // handle the list as an optional parameter
            ignoredFileExts  = ignoredFileExts ?? new List <string>();
            ignoredFileNames = ignoredFileNames ?? new List <string>();

            DirectoryHelper.CreateIfNoneExists(_buildPath);

            var fullPath = Path.Combine(_buildPath, buildFileName);

            if (File.Exists(fullPath))
            {
                File.Delete(fullPath);
            }

            ZipHelper.CreateFromDirectory(_gamePath, fullPath, CompressionLevel.Fastest, false, x => CheckFile(x, ignoredFileExts, ignoredFileNames));

            return(fullPath);
        }
Exemplo n.º 6
0
        public override void Apply(HealthAnalysis analysis, FixStatus status)
        {
            status.Description = "Creating a backup in the parent folder...";
            var directory = Path.GetDirectoryName(analysis.FileName) ?? ".\\";

            if (!directory.EndsWith("\\"))
            {
                directory += "\\";
            }
            var zipFileName = $"{Path.GetFileNameWithoutExtension(analysis.FileName)}_Backup_{DateTime.Now:yyyy-MM-dd-HHmmssfff}.zip";
            var tmpZipName  = Path.Combine(Path.GetTempPath(), zipFileName);

            ZipHelper.CreateFromDirectory(directory, tmpZipName, CompressionLevel.Fastest, false, path => OnlyInterestingFiles(directory, path));
            var backupDirectory = new DirectoryInfo(Path.Combine(directory, "..\\"));

            File.Copy(tmpZipName, Path.Combine(backupDirectory.FullName, zipFileName));
            File.Delete(tmpZipName);
            status.Description = "Backup created";
        }
Exemplo n.º 7
0
 void Test3()
 {
     ZipHelper.ExtraToDirectory(@"C:\Users\XJH001\AppData\Local\Temp\MAutoUpdate\temp\1.1.0.0.zip", @"D:\Test");
     ZipHelper.CreateFromDirectory(@"C:\Users\XJH001\AppData\Local\Temp\MAutoUpdate\bak", @"D:\Test\1.1.0.0.zip");
 }