Пример #1
0
        public void FolderMarkersContainMetaData()
        {
            _sut = new ZipFolder(_root, "xyz");
            _sut.CreateNewArchive();

            var actual = File.ReadAllText(Path.Combine(_root, ZipFolder.MarkerFileName));

            Assert.AreEqual("xyz", actual);
        }
Пример #2
0
        protected string PackageHtml5(PublicationInformation projInfo, InProcess inProcess, string path)
        {
            inProcess.SetStatus("Packaging for Html5");

            string fileNameV3     = CreateFileNameFromTitle(projInfo);
            var    resultFileName = Path.Combine(projInfo.DictionaryPath, fileNameV3 + ".zip");
            var    zf             = new ZipFolder();

            zf.CreateZip(path, resultFileName, 0);
#if (TIME_IT)
            TimeSpan tsTotal = DateTime.Now - dt1;
            Debug.WriteLine("Exportepub: time spent in .epub conversion: " + tsTotal);
#endif
            inProcess.PerformStep();
            return(resultFileName);
        }
Пример #3
0
        private void BrowseButton_Click(object sender, EventArgs e)
        {
            if (ZipFolder.ShowDialog() == DialogResult.OK)
            {
                FolderTextBox.Text = ZipFolder.SelectedPath;

                string zipFileName = @"C:\Projects\Chapter3\TestFolder\result.zip";

                var zipFile = new Zipper(zipFileName);
                zipFile.CompressFile(FolderTextBox.Text);

                MessageBox.Show("You folder has been zipped.",
                                "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                var fileList = zipFile.ListArchive(zipFileName);
                FileListBox.Items.AddRange(fileList.ToArray());
            }
        }
Пример #4
0
        public void ExportLogs(object sender, EventArgs e)
        {
            SpeechDetector.LogManager.StopPlayingLogs();

            if (!ZipFolder.FilesToCopy)
            {
                ShowError("No Logs!", "There are no logs to export");
                return;
            }

            if (ZipFolder.ChooseDirectory())
            {
                var success = false;
                var worker  = new BackgroundWorker();

                worker.DoWork             += (sen, args) => success = ZipFolder.Create();
                worker.RunWorkerCompleted += (sen, args) =>
                {
                    if (success)
                    {
                        Switch.GetSwitchable <OutputPage>().Finished();
                        Switch.Window.Title = "Export Finished";
                    }
                    else
                    {
                        Switch.Window.Title = "Kinect Log";
                        Switch.SwitchTo <MainPage>();
                    }
                };

                Switch.GetSwitchable <OutputPage>().Zip = ZipFolder;
                Switch.Window.Title = "Creating File ...";
                Switch.SwitchTo <OutputPage>();

                worker.RunWorkerAsync();
            }
        }
Пример #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((File != null ? File.GetHashCode() : 0) * 397) ^ (ZipFolder != null ? ZipFolder.GetHashCode() : 0));
     }
 }
Пример #6
0
 public void SetUp()
 {
     _root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
     Directory.CreateDirectory(_root);
     _sut = new ZipFolder(_root);
 }
Пример #7
0
        private void Compress(string sourceFolder, string ldmlFullName)
        {
            var mODT = new ZipFolder();

            mODT.CreateZip(sourceFolder, ldmlFullName, 0);
        }
Пример #8
0
        private ActionBase ParseObjectAction(JObject node, ActionType action_type)
        {
            switch (action_type)
            {
            case ActionType.ControlFlow:
                var condition = (node["condition"].ToString());

                if (condition.Equals("dialog"))
                {
                    return(ParseDialogControlFlow(node));
                }

                return(null);

            case ActionType.Execute:

                string filename         = mroot.substitue_enviro_vars(node["filename"].ToString());
                string paramxs          = node.ContainsKey("params") ? mroot.substitue_enviro_vars(node["params"].ToString()) : "";
                bool   onlyIfnotRunning = node.ContainsKey("onlyIfNotRunning") ? node["params"].Value <bool>() : true;

                ExecuteProcess executeAction = new ExecuteProcess();
                executeAction.FileName         = filename;
                executeAction.Params           = paramxs;
                executeAction.OnlyIfNotRunning = onlyIfnotRunning;

                return(executeAction);


            case ActionType.Wait:
                int waittime = (node["duration_ms"].Value <Int32>());

                WaitAction wait = new WaitAction();
                wait.Milliseconds = waittime;
                return(wait);

            case ActionType.ShowDialog:

                ShowDialog showDialog = new ShowDialog();
                showDialog.Message = mroot.substitue_enviro_vars(node["message"].ToString());
                if (node.ContainsKey("messagetype"))
                {
                    showDialog.MessageType = (ShowDialog.Type)Enum.Parse(typeof(ShowDialog.Type), node["messagetype"].ToString(), true);
                }
                return(showDialog);

            case ActionType.CopyFolder:

                string source       = mroot.substitue_enviro_vars(node["source"].ToString());
                string destination  = mroot.substitue_enviro_vars(node["destination"].ToString());
                string file_pattern = node.ContainsKey("desc") ? node["copy_filepattern"].ToString() : null;
                string dir_pattern  = node.ContainsKey("desc") ? node["copy_dirpattern"].ToString() : null;

                CopyFolder copyFolder = new CopyFolder();
                copyFolder.Source          = source ?? copyFolder.Source;
                copyFolder.Destination     = destination ?? copyFolder.Destination;
                copyFolder.CopyFilePattern = file_pattern ?? copyFolder.CopyFilePattern;
                copyFolder.CopyDirPattern  = dir_pattern ?? copyFolder.CopyDirPattern;

                return(copyFolder);

            case ActionType.CopyFile:

                source      = mroot.substitue_enviro_vars(node["source"].ToString());
                destination = mroot.substitue_enviro_vars(node["destination"].ToString());

                CopyFile copyFile = new CopyFile();
                copyFile.Source      = source;
                copyFile.Destination = destination;
                return(copyFile);

            case ActionType.DeleteFile:
            {
                string sourceFile = mroot.substitue_enviro_vars(node["source"].ToString());

                DeleteFile delteFiles = new DeleteFile();
                delteFiles.SourceFile = sourceFile;
                return(delteFiles);
            }

            case ActionType.DeleteFiles:
            {
                string sourceFolder     = mroot.substitue_enviro_vars(node["source"].ToString());
                string delete_pattern   = node.ContainsKey("pattern") ? node["pattern"].ToString() : "(.)";
                bool   recursive_delete = node.ContainsKey("recursive") ? node["recursive"].Value <bool>() : false;

                DeleteFiles delteFiles = new DeleteFiles();
                delteFiles.SourceFolder    = sourceFolder;
                delteFiles.DeletePattern   = delete_pattern;
                delteFiles.RecursiveDelete = recursive_delete;
                return(delteFiles);
            }

            case ActionType.DeleteFolder:
            {
                string dirPath = mroot.substitue_enviro_vars(node["source"].ToString());

                DeleteFolder deleteFolder = new DeleteFolder();
                deleteFolder.FolderPath = dirPath;
                return(deleteFolder);
            }

            case ActionType.DeleteFolders:
            {
                string sourceFolder   = mroot.substitue_enviro_vars(node["source"].ToString());
                string delete_pattern = node.ContainsKey("pattern") ? node["pattern"].ToString() : "(.)";

                DeleteFolders deleteFolders = new DeleteFolders();
                deleteFolders.SourceFolder  = sourceFolder;
                deleteFolders.DeletePattern = delete_pattern;
                return(deleteFolders);
            }

            case ActionType.ZipFolder:
            {
                string sourceFolder        = mroot.substitue_enviro_vars(node["source"].ToString());
                string zipfile_destination = mroot.substitue_enviro_vars(node["zipfile"].ToString());

                ZipFolder zipFolder = new ZipFolder();
                zipFolder.SourceFolder   = sourceFolder;
                zipFolder.DestinationZip = zipfile_destination;
                return(zipFolder);
            }
            }

            return(null);
        }
Пример #9
0
        private ActionBase ParseAction(XmlNode node, ActionType action_type)
        {
            switch (action_type)
            {
            case ActionType.Wait:
                int waittime = Convert.ToInt32(node.Attributes["duration_ms"].Value);

                WaitAction wait = new WaitAction();
                wait.Milliseconds = waittime;
                return(wait);

            case ActionType.Execute:

                string filename = mroot.substitue_enviro_vars(node.Attributes["filename"].Value);
                string paramxs  = mroot.substitue_enviro_vars(node.Attributes["params"].Value);

                bool onlyIfnotRunning = true;
                if (node.Attributes["onlyIfNotRunning"] != null)
                {
                    onlyIfnotRunning = Boolean.Parse(node.Attributes["onlyIfNotRunning"].Value);
                }

                ExecuteProcess executeAction = new ExecuteProcess();
                executeAction.FileName         = filename;
                executeAction.Params           = paramxs;
                executeAction.OnlyIfNotRunning = onlyIfnotRunning;

                return(executeAction);


            case ActionType.CopyFolder:

                string source       = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                string destination  = mroot.substitue_enviro_vars(node.Attributes["destination"].Value);
                string file_pattern = node.Attributes["copy_filepattern"].Value;
                string dir_pattern  = node.Attributes["copy_dirpattern"].Value;

                CopyFolder copyFolder = new CopyFolder();
                copyFolder.Source          = source;
                copyFolder.Destination     = destination;
                copyFolder.CopyFilePattern = file_pattern;
                copyFolder.CopyDirPattern  = dir_pattern;

                return(copyFolder);

            case ActionType.CopyFile:

                source      = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                destination = mroot.substitue_enviro_vars(node.Attributes["destination"].Value);

                CopyFile copyFile = new CopyFile();
                copyFile.Source      = source;
                copyFile.Destination = destination;
                return(copyFile);

            case ActionType.DeleteFiles:

                string sourceFolder     = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                string delete_pattern   = node.Attributes["pattern"].Value;
                bool   recursive_delete = Convert.ToBoolean(node.Attributes["recursive"].Value);

                DeleteFiles delteFiles = new DeleteFiles();
                delteFiles.SourceFolder    = sourceFolder;
                delteFiles.DeletePattern   = delete_pattern;
                delteFiles.RecursiveDelete = recursive_delete;
                return(delteFiles);

            case ActionType.DeleteFolders:

                sourceFolder   = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                delete_pattern = node.Attributes["pattern"].Value;

                DeleteFolders deleteFolders = new DeleteFolders();
                deleteFolders.SourceFolder  = sourceFolder;
                deleteFolders.DeletePattern = delete_pattern;
                return(deleteFolders);

            case ActionType.ZipFolder:

                sourceFolder = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                string zipfile_destination = mroot.substitue_enviro_vars(node.Attributes["zipfile"].Value);

                ZipFolder zipFolder = new ZipFolder();
                zipFolder.SourceFolder   = sourceFolder;
                zipFolder.DestinationZip = zipfile_destination;
                return(zipFolder);


            case ActionType.ShowDialog:

                ShowDialog showDialog = new ShowDialog();
                showDialog.Message     = mroot.substitue_enviro_vars(node.Attributes["message"].Value);
                showDialog.MessageType = (ShowDialog.Type)Enum.Parse(typeof(ShowDialog.Type), node.Attributes["messagetype"].Value, true);

                return(showDialog);

            default:
                return(null);
            }
        }