예제 #1
0
        private List <string> BuildArguments()
        {
            bool          setTestArgument     = false;
            List <string> arguments           = new List <string>();
            string        applicationFilePath = textBox1.Text;

            if (!string.IsNullOrWhiteSpace(applicationFilePath) && !File.Exists(applicationFilePath))
            {
                throw new ApplicationException(Properties.Resources.MessageApplicationNotFound);
            }
            if (!string.IsNullOrWhiteSpace(applicationFilePath))
            {
                arguments.Add("/i");
                arguments.Add(ArgumentParser.EscapeArgument(applicationFilePath));
            }
            else if (Program.IsDebugging)
            {
                arguments.Add("/i");
                arguments.Add(ArgumentParser.EscapeArgument(Application.ExecutablePath));
                setTestArgument = true;
            }
            else
            {
                throw new ApplicationException(Properties.Resources.MessageApplicationNotSet);
            }
            if (comboBox1.SelectedIndex > 0)
            {
                string[] spanUnit = new string[] { "day", "month", "year" };
                if (numericUpDown1.Value > 0)
                {
                    arguments.Add("/r");
                    arguments.Add("+" + Math.Abs(numericUpDown1.Value).ToString("#") + spanUnit[comboBox2.SelectedIndex]);
                }
                else if (numericUpDown1.Value < 0)
                {
                    arguments.Add("/r");
                    arguments.Add("-" + Math.Abs(numericUpDown1.Value).ToString("#") + spanUnit[comboBox2.SelectedIndex]);
                }
                else
                {
                    throw new ApplicationException(Properties.Resources.ExceptionMessageZ);
                }
            }
            else
            {
                arguments.Add("/d");
                arguments.Add(dateTimePicker.Value.ToString("yyyy-MM-dd"));
            }
            if (!string.IsNullOrWhiteSpace(textBox2.Text))
            {
                arguments.Add("/a");
                arguments.Add(ArgumentParser.EscapeArgument(textBox2.Text));
            }
            else if (setTestArgument)
            {
                arguments.Add("/a");
                arguments.Add("\"/t\"");
            }
            if (Directory.Exists(textBox3.Text))
            {
                arguments.Add("/w");
                arguments.Add(ArgumentParser.EscapeArgument(textBox3.Text));
            }
            if (checkBox.Checked)
            {
                arguments.Add("/o");
            }
            arguments.Add("/s");
            arguments.Add(numericUpDown2.Value.ToString());
            return(arguments);
        }