Esempio n. 1
0
 public string Form_Execute(FYP_Common.LogHelper logger, bool slient)
 {
     throw new NotImplementedException();
 }
        public string Form_Execute(FYP_Common.LogHelper logger, bool slient)
        {
            string toReturn = "";
            String file = Config.COMPILE_STOCK_DATA_EXE;
            String command = textBox_stockPath.Text + " " + textBox_indexPath.Text + " " +
                textBox_tbillPath.Text + " " + textBox_outputPath.Text;

            if (Config.LIVE_STATUS == true && slient == false)
            {
                textBox_status.Text = "";
                ProcessStartInfo psi = new ProcessStartInfo(file, command);
                psi.UseShellExecute = false;
                psi.ErrorDialog = false;
                psi.CreateNoWindow = true;
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardError = true;
                button_start.Enabled = false;
                button_cancel.Enabled = false;

                if (process != null)
                {
                    process.Dispose();
                }

                process = new Process();
                process.StartInfo = psi;
                process.EnableRaisingEvents = true;
                // process.SynchronizingObject = this;
                process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
                process.Exited += new EventHandler(process_OnExited);
                process.Start();
                process.BeginOutputReadLine();
            }
            else
            {
                // **********
                // Note: Simple std-out capture from: http://www.java2s.com/Code/CSharp/Development-Class/RedirectingProcessOutput.htm
                // **********
                textBox_status.Text = "You have turned off live status update, please wait until the process finish.";

                if (slient || MessageBox.Show(this,
                    "Start now? The program will be helt for a while, please wait until the process finish.",
                    "Running Seperate Process",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    process = new Process();
                    process.StartInfo.FileName = file;
                    process.StartInfo.Arguments = command;
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.CreateNoWindow = true;
                    process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    process.Start();

                    toReturn = process.StandardOutput.ReadToEnd();
                    textBox_status.Text = toReturn;
                    if (logger != null) logger.Log(toReturn);
                }
            }
            return toReturn;
        }
Esempio n. 3
0
 public string Form_Validate(FYP_Common.LogHelper logger)
 {
     string toReturn = "";
     toReturn += Validator.fastCheck(textBox_stockPath, Validator.Identifier.PATH);
     toReturn += Validator.fastCheck(textBox_clusterPath, Validator.Identifier.PATH);
     toReturn += Validator.fastCheck(textBox_minStocksInCluster, Validator.Identifier.INT);
     toReturn += Validator.fastCheck(textBox_logPath, Validator.Identifier.PATH);
     if (logger != null) logger.Log("Invalid: [ " + toReturn + "]");
     return toReturn;
 }
 public string Form_Validate(FYP_Common.LogHelper logger)
 {
     string toReturn = "";
     toReturn += Validator.fastCheck(textBox_stockPath, Validator.Identifier.PATH);
     toReturn += Validator.fastCheck(textBox_indexPath, Validator.Identifier.PATH);
     toReturn += Validator.fastCheck(textBox_tbillPath, Validator.Identifier.PATH);
     toReturn += Validator.fastCheck(textBox_outputPath, Validator.Identifier.PATH);
     toReturn += Validator.fastCheck(textBox_logPath, Validator.Identifier.PATH);
     if (logger != null) logger.Log("Invalid: [ " + toReturn + "]");
     return toReturn;
 }