public static LogHelper NewLogger(Type type, String logPath) { LogHelper logHelper = null; if (loggers.TryGetValue(type, out logHelper)) { loggers.Remove(type); logHelper.sw.Close(); } try { logHelper = new LogHelper(); logHelper.sw = new StreamWriter(logPath + "\\" + type.Name + "_" + String.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".log"); logHelper.Log("LOGGER: Logger instance for " + type.FullName + " initiated\n\n"); loggers.Add(type, logHelper); } catch (Exception ex) { // do nothing } return logHelper; }
public string Form_Execute(LogHelper logger, bool slient) { string toReturn = ""; string file = Config.GET_STOCK_DATA_EXE; string command = textBox_stockCode.Text + " "; command += monthCalendar_startDate.SelectionStart.Year + " "; command += monthCalendar_startDate.SelectionStart.Month + " "; command += monthCalendar_startDate.SelectionStart.Day + " "; command += monthCalendar_endDate.SelectionStart.Year + " "; command += monthCalendar_endDate.SelectionStart.Month + " "; command += monthCalendar_endDate.SelectionStart.Day + " "; command += textBox_outPath.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; }
public string Form_Validate(LogHelper logger) { string toReturn = ""; toReturn += Validator.fastCheck(textBox_stockCode, Validator.Identifier.INT); // no need to check monthCalendar_startDate // no need to check monthCalendar_endDate toReturn += Validator.fastCheck(textBox_outPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_logPath, Validator.Identifier.PATH); if (logger != null) logger.Log("Invalid: [ " + toReturn + "]"); return toReturn; }
public string Form_Validate(LogHelper logger) { string toReturn = ""; toReturn += Validator.fastCheck(textBox_noctbd, Validator.Identifier.INT); toReturn += Validator.fastCheck(textBox_stockPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_genusPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_logPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_refPeriod, Validator.Identifier.INT); if (logger != null) logger.Log("Invalid: [ " + toReturn + "]"); return toReturn; }
public string Form_Validate(LogHelper logger) { string toReturn = ""; toReturn += Validator.fastCheck(textBox_noDays, Validator.Identifier.INT); toReturn += Validator.fastCheck(textBox_stockInput, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_stockOutput, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_log, Validator.Identifier.PATH); if (logger != null) logger.Log("Invalid: [ " + toReturn + "]"); return toReturn; }
public string Form_Validate(LogHelper logger) { string toReturn = ""; toReturn += Validator.fastCheck(textBox_noctbd, Validator.Identifier.INT); toReturn += Validator.fastCheck(textBox_stockPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_clusterPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_logPath, Validator.Identifier.PATH); toReturn += Validator.fastCheck(textBox_multiper, Validator.Identifier.DOUBLE); if (logger != null) logger.Log("Invalid: [ " + toReturn + "]"); return toReturn; }