Exemple #1
0
        private void OverwriteExecute(OverwritePromptInfo aInfo)
        {
            DialogResult dr;

            using (var form = new OverwriteForm(
                       aInfo.dest.FullName,
                       aInfo.dest.Length.ToFormattedSize(),
                       aInfo.entry.Name,
                       aInfo.entry.Size.ToFormattedSize()
                       )) {
                form.Owner   = this;
                dr           = form.ShowDialog();
                aInfo.Action = form.Action;
            }

            switch (dr)
            {
            case DialogResult.Retry:
                aInfo.task.Action = aInfo.Action;
                break;

            case DialogResult.Abort:
                actionRemembered = aInfo.Action;
                break;

            default:
                break;
            }
        }
        public void External_OutputTest(string sourcePath, string destinationFolder, string destinationFile, string expectedPath, string fileContent, OverwriteAction overwriteAction = default(OverwriteAction))
        {
            var factory = new ChannelFactory<IService>(new FileAdapterBinding { OverwriteAction = overwriteAction },
                new EndpointAddress(new FileAdapterConnectionUri { Path = destinationFolder, FileName = destinationFile }.Uri.ToString()));
            var channel = factory.CreateChannel();

            try
            {
                channel.Execute(CreateMessage(sourcePath, GetTestStream(fileContent)));

                Assert.IsTrue(System.IO.File.Exists(expectedPath));
                Assert.AreEqual(fileContent, System.IO.File.ReadAllText(expectedPath));
            }
            finally
            {
                var innerChannel = channel as IChannel;

                if (innerChannel != null)
                {
                    if (innerChannel.State == CommunicationState.Opened)
                        innerChannel.Close();
                    else
                        innerChannel.Abort();
                }
            }
        }
Exemple #3
0
        private void Run()
        {
            actionRemembered = OverwriteAction.Unspecified;

            running = true;
            aborted = false;
            stopped = false;
            DecompressDirectory.Enabled         =
                BrowseDest.Enabled              =
                    Exit.Enabled                =
                        OpenSettings.Enabled    =
                            AddPassword.Enabled =
                                false;

            UnrarIt.Click += Stop_Click;
            UnrarIt.Click -= UnRarIt_Click;
            UnrarIt.Image  = UnRarIt.Properties.Resources.process_stop;
            UnrarIt.Text   = "Stop";

            Progress.Visible = true;
            var threads = UnRarIt.Properties.Settings.Default.Threads;

            Progress.Value   = 0;
            Progress.Maximum = 0;

            RunTasks(threads);

            Details.Text                            = string.Empty;
            Progress.Value                          = 0;
            Progress.Visible                        = false;
            DecompressDirectory.Enabled             =
                BrowseDest.Enabled                  =
                    Exit.Enabled                    =
                        OpenSettings.Enabled        =
                            UnrarIt.Enabled         =
                                AddPassword.Enabled =
                                    true;
            running        = false;
            UnrarIt.Text   = "Extract Files";
            UnrarIt.Image  = UnRarIt.Properties.Resources.extract;
            UnrarIt.Click += UnRarIt_Click;
            UnrarIt.Click -= Stop_Click;
            UnrarIt.Click -= Abort_Click;
        }
Exemple #4
0
        private void ImportTreeToConfig(ImportNode tree, RepositoryNode target, OverwriteAction action)
        {
            foreach (var entry in tree.SubNodes)
            {
                if (entry.Type == EntryType.Folder)
                {
                    if (!target.TryGetFolder(entry.Name, out var folderNode))
                    {
                        folderNode = target.AddItem(EntryType.Folder, entry.Name);
                    }

                    ImportTreeToConfig(entry, folderNode, action);
                }
                else if (entry.Type == EntryType.Template)
                {
                    if (target.TryGetFile(entry.Name, out var fileNode))
                    {
                        switch (action)
                        {
                        case OverwriteAction.OverwriteAll:
                            fileNode.Content = File.ReadAllText(entry.Path);
                            break;

                        case OverwriteAction.SkipAll:
                            break;

                        case OverwriteAction.PromptEvery:
                            // TODO: prompt user for file overwriting
                            break;
                        }
                    }
                    else
                    {
                        target.AddItem(EntryType.Template, entry.Name, File.ReadAllText(entry.Path));
                    }
                }
            }
        }
        public void Internal_OutputTest(string sourcePath, string destinationFolder, string destinationFile, string expectedPath, string fileContent, OverwriteAction overwriteAction = default(OverwriteAction))
        {
            var adapter = new FileAdapter { OverwriteAction = overwriteAction };
            var connectionUri = new FileAdapterConnectionUri { Path = destinationFolder, FileName = destinationFile };
            var factory = new FileAdapterConnectionFactory(connectionUri, new ClientCredentials(), adapter);

            var connection = factory.CreateConnection();
            var outputHandler = connection.BuildHandler<FileAdapterOutboundHandler>(null);

            outputHandler.Execute(CreateMessage(sourcePath, GetTestStream(fileContent)), TimeSpan.MaxValue);

            Assert.IsTrue(System.IO.File.Exists(expectedPath));
            Assert.AreEqual(fileContent, System.IO.File.ReadAllText(expectedPath));
        }
Exemple #6
0
        private void Run()
        {
            actionRemembered = OverwriteAction.Unspecified;

              running = true;
              aborted = false;
              stopped = false;
              DecompressDirectory.Enabled =
            BrowseDest.Enabled =
            Exit.Enabled =
            OpenSettings.Enabled =
            AddPassword.Enabled =
            false;

              UnrarIt.Click += Stop_Click;
              UnrarIt.Click -= UnRarIt_Click;
              UnrarIt.Image = UnRarIt.Properties.Resources.process_stop;
              UnrarIt.Text = "Stop";

              Progress.Visible = true;
              var threads = UnRarIt.Properties.Settings.Default.Threads;

              Progress.Value = 0;
              Progress.Maximum = 0;

              RunTasks(threads);

              Details.Text = string.Empty;
              Progress.Value = 0;
              Progress.Visible = false;
              DecompressDirectory.Enabled =
            BrowseDest.Enabled =
            Exit.Enabled =
            OpenSettings.Enabled =
            UnrarIt.Enabled =
            AddPassword.Enabled =
            true;
              running = false;
              UnrarIt.Text = "Extract Files";
              UnrarIt.Image = UnRarIt.Properties.Resources.extract;
              UnrarIt.Click += UnRarIt_Click;
              UnrarIt.Click -= Stop_Click;
              UnrarIt.Click -= Abort_Click;
        }
Exemple #7
0
        private void OverwriteExecute(OverwritePromptInfo aInfo)
        {
            DialogResult dr;
              using (var form = new OverwriteForm(
              aInfo.dest.FullName,
              aInfo.dest.Length.ToFormattedSize(),
              aInfo.entry.Name,
              aInfo.entry.Size.ToFormattedSize()
              )) {
            form.Owner = this;
            dr = form.ShowDialog();
            aInfo.Action = form.Action;
              }

              switch (dr) {
            case DialogResult.Retry:
              aInfo.task.Action = aInfo.Action;
              break;
            case DialogResult.Abort:
              actionRemembered = aInfo.Action;
              break;
            default:
              break;
              }
        }