Ejemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var file = txtTargetFile.Text.Trim();

            txtTargetFile.Text = file;
            if (file == "")
            {
                MessageDisplayer.Tell("File to delete is mandatory.", Text);
                txtTargetFile.Focus();
                return;
            }
            if (file.IndexOf("\"", StringComparison.Ordinal) >= 0)
            {
                MessageDisplayer.Tell("File to delete cannot contain quotes.", Text);
                txtTargetFile.Focus();
                return;
            }
            if (file.StartsWith("-"))
            {
                MessageDisplayer.Tell("File to delete cannot start with \"-\".", Text);
                txtTargetFile.Focus();
                return;
            }

            var helper = new InProcessJobIdentifyerHelper();

            JobIdentiftyerString = helper.GetIdentifyerString(InProcessJobIdentifyer.DeleteFile);
            Arguments            = DeleteFileArguments.CreateArgumentString(file, GetFileNotFoundBehaviour());
            DialogResult         = DialogResult.OK;
        }
Ejemplo n.º 2
0
        private void InProcess(IGridVisualFeedback grid, IVariableList variableList)
        {
            var inProcessJobIdentifyerHelper = new InProcessJobIdentifyerHelper();
            var jobId = inProcessJobIdentifyerHelper.GetIdentifyerFromString(Command);
            var job   = inProcessJobIdentifyerHelper.GetJob(jobId);
            var args  = new ArgumentList(Arguments);

            args = args.Decode(variableList);
            job.Begin(args);
            while (!job.HasExited)
            {
                grid.CursorBlink = !grid.CursorBlink;
                grid.Invalidate();
                Thread.Sleep(1000);
                if (DateTime.Now.Subtract(StartTime !.Value) <= Timeout)
                {
                    continue;
                }
                EndTime     = DateTime.Now;
                Status      = JobStatus.Timeout;
                FailMessage = "Timeout";
                ExitCode    = -1;
                return;
            }
            ExitCode = job.ExitCode;
            Status   = ExitCode == 0
                ? JobStatus.Completed
                : JobStatus.Failed;
            if (Status == JobStatus.Failed && job.Exception != null)
            {
                FailMessage = job.Exception.Message;
            }
        }
Ejemplo n.º 3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var sourceUrl = txtSourceUrl.Text.Trim();

            txtSourceUrl.Text = sourceUrl;
            if (sourceUrl == "")
            {
                MessageDisplayer.Tell("Source URL is mandatory.", Text);
                txtSourceUrl.Focus();
                return;
            }
            if (sourceUrl.IndexOf("\"", StringComparison.Ordinal) >= 0)
            {
                MessageDisplayer.Tell("Source URL cannot contain quotes.", Text);
                txtSourceUrl.Focus();
                return;
            }
            if (sourceUrl.StartsWith("-"))
            {
                MessageDisplayer.Tell("Source URL cannot start with \"-\".", Text);
                txtSourceUrl.Focus();
                return;
            }

            var targetFile = txtTargetFile.Text.Trim();

            txtTargetFile.Text = targetFile;
            if (targetFile == "")
            {
                MessageDisplayer.Tell("Target file is mandatory.", Text);
                txtTargetFile.Focus();
                return;
            }
            if (targetFile.IndexOf("\"", StringComparison.Ordinal) >= 0)
            {
                MessageDisplayer.Tell("Target file cannot contain quotes.", Text);
                txtTargetFile.Focus();
                return;
            }

            var helper = new InProcessJobIdentifyerHelper();

            JobIdentiftyerString = helper.GetIdentifyerString(InProcessJobIdentifyer.DownloadString);
            Arguments            = DownloadStringArguments.CreateArgumentString(sourceUrl, targetFile, GetExistsBehaviour());
            DialogResult         = DialogResult.OK;
        }
Ejemplo n.º 4
0
        private void downloadTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var helper = new InProcessJobIdentifyerHelper();
            var jobIdentiftyerString = helper.GetIdentifyerString(InProcessJobIdentifyer.DownloadString);
            var program = txtProgram.Text.Trim();

            var x = new DownloadStringDialog();

            if (string.Compare(jobIdentiftyerString, program, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                x.Arguments = txtArguments.Text.Trim();
            }

            if (x.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            txtProgram.Text   = x.JobIdentiftyerString;
            txtArguments.Text = x.Arguments;
        }