public static bool SetStartEndTimeForWorkOrder(string workOrder, bool isTransition, out DateTime start, out DateTime end, out DataTable workOrderdt, out List <string> woDetails) { _workOrder = workOrder; bool moveAhead = false; workOrderdt = new DataTable(); try { workOrderdt = getWorkOrderSequenceDetails(); moveAhead = ProcessLogsForTime(workOrderdt, isTransition); } catch (IndexOutOfRangeException exception) { MessageBox.Show("Entered Work Order cannot be found."); _logger.WriteLog("Exception Occured : " + exception.Message); throw new IndexOutOfRangeException("No Work Order Found", exception); } woDetails = new List <string>(); woDetails.AddRange(_WODetails); start = new DateTime(); end = new DateTime(); start = _start; end = _end; return(moveAhead); }
// This function can be used to query a paprticular db by passing db name, table name , conditions etc public DataTable queryDB(string dbName, string tableName, string columnsNeeded, string conditions) { SqlConnection conn = makeConnection(dbName); SqlCommand cmd = new SqlCommand(); cmd.CommandText = getQueryString(tableName, columnsNeeded, conditions); cmd.CommandType = CommandType.Text; cmd.Connection = conn; try { conn.Open(); } catch (SqlException ex) { MessageBox.Show("Cannot Connect to the DataBase : " + ex.Message.ToString()); _logger.WriteLog("Exception Occured when Connecting to DB : " + ex.Message.ToString()); } DataTable dt = executeCommand(cmd); conn.Close(); return(dt); }
//Is triggered when the user searches a work Order by inputing a work order number private void searchButton_Click(object sender, EventArgs e) { try { bool checkCrash = false; SystemSpecificLogForm form = new SystemSpecificLogForm(workOrderTextBox.Text.ToString(), checkCrash); form.ShowDialog(); } catch (ObjectDisposedException exception) { _logger.WriteLog(exception.Message); } }
private static void SettingMinMaxTimesAsStartEnd(List <DateTime> listTimes, out DateTime end, out DateTime start) { ErrorLogger logger = new ErrorLogger(); start = new DateTime(); end = new DateTime(); try { end = listTimes.Max <DateTime>(); start = listTimes.Min <DateTime>(); } catch (InvalidOperationException ex) { MessageBox.Show("Cannot find any Text."); logger.WriteLog("Exception Occured : Cannot Find any Text : Reason :" + ex.Message); } }
private void ScrollToPosition(Dictionary <string, int> posTags) { foreach (var item in _tagsDictionary) { int position = 0; try { position = posTags[item.Key]; } catch (Exception ex) { _logger.WriteLog("Exception Encountered : The given key wasn't available in the Tags when looking to scroll to a particular location : " + item.Key + " : " + ex.Message); } _textHighlighter.RemoveHighLights(item.Key); _textHighlighter.HighLightText(position, 30, item.Key); item.Value.ScrollToCaret(); } }
private bool GetRangeValsInterval(out double rangeValsInterval) { bool normalLabel = true; double startTick = 0.0; double endTick = 0.0; try { startTick = Double.Parse(_startTick); endTick = Double.Parse(_endTick); } catch (FormatException ex) { ErrorLogger logger = new ErrorLogger(); logger.WriteLog("Exception when Setting Track Bar Value Label : " + ex.Message); normalLabel = false; } rangeValsInterval = endTick - startTick; return(normalLabel); }
//fetches the data for each workOrder private void GetLogs(WorkOrderLoader loader) { try { vbEventLogTextBox.Text = string.Join("\n", loader._logs[ConfigurationManager.AppSettings["vbEventLogKey"].ToString()]); } catch (Exception ex) { _logger.WriteLog("Exception ---------- : " + ex.Message); } try { vbLogTextBox.Text = string.Join("\n", loader._logs[ConfigurationManager.AppSettings["vbLogKey"].ToString()]); } catch (Exception ex) { _logger.WriteLog("Exception ---------- : " + ex.Message); } try { witStatusLogTextBox.Text = string.Join("\n", loader._logs[ConfigurationManager.AppSettings["witStatusLogKey"].ToString()]); } catch (Exception ex) { _logger.WriteLog("Exception ---------- : " + ex.Message); } try { mainLogTextBox.Text = string.Join("\n", loader._logs[ConfigurationManager.AppSettings["mainLogKey"].ToString()]); } catch (Exception ex) { _logger.WriteLog("Exception ---------- : " + ex.Message); } try { serialOutputLogTextBox.Text = string.Join("\n\n", loader._logs[ConfigurationManager.AppSettings["serialOutputLogKey"].ToString()]); } catch (Exception ex) { _logger.WriteLog("Exception ---------- : " + ex.Message); } }
private static bool ParseLineForTimeStamp(string line, out DateTime createdTime) { ErrorLogger logger = new ErrorLogger(); string time = line.Split(',')[0].Replace('\"', ' ').Trim() + " " + line.Split(',')[1].Replace('\"', ' ').Trim(); DateTimeParser.Parse(time, out createdTime); bool ExceptionOccured = false; try { double value = Double.Parse(line.Split(',')[2]); int seconds = (Int32)value / 1000; int milliSeconds = (Int32)value % 1000; createdTime = createdTime.AddSeconds(seconds); createdTime = createdTime.AddMilliseconds(milliSeconds); } catch (FormatException ex) { ExceptionOccured = true; logger.WriteLog("Moving to Old Build : Reason: " + ex.Message); } return(ExceptionOccured); }
private static string SetLabelValue(DateTime START, DateTime END, int value, string start, string end) { string labelText = ""; string labelString = ""; double ss = 0.0; bool normalLabel = true; double startTick = 0.0; double endTick = 0.0; try { startTick = Double.Parse(start); endTick = Double.Parse(end); } catch (FormatException ex) { ErrorLogger logger = new ErrorLogger(); logger.WriteLog("Exception when Setting Track Bar Value Label : " + ex.Message); normalLabel = false; } double rangeValsInterval = endTick - startTick; double rangeUnit = rangeValsInterval / 1000; double calculatedValue = startTick + (rangeUnit * value); double valTrack = value; double val = valTrack / 1000; double diff = (END - START).TotalMilliseconds; diff = val * diff; int seconds = (Int32)diff / 1000; double milliSeconds = diff % 1000; DateTime labelTimeValue = START; labelTimeValue = labelTimeValue.AddSeconds(seconds); labelTimeValue = labelTimeValue.AddMilliseconds(milliSeconds); int fractionOfMilliSecond = (Int32)(diff * 100) % 100000; int tempss = (Int32)calculatedValue / 1000; ss = tempss; double fff = calculatedValue % 1000; fff = fff * 100; int tempFFF = (Int32)fff; fff = tempFFF; fff = fff / 100; labelString = labelTimeValue.ToString("d/M/yy HH:mm"); if (normalLabel) { ss = (ss * 1000) + fff; labelText = labelString + ":" + ss.ToString(); } else { labelText = labelString; } return(labelText); }
public static bool SyncWithTime(Dictionary <string, RichTextBox> tagMap, out Dictionary <string, Dictionary <string, int> > syncMap, out string startTick, out string endTick) { Cursor.Current = Cursors.WaitCursor; ErrorLogger logger = new ErrorLogger(); syncMap = new Dictionary <string, Dictionary <string, int> >(); bool oldBuild = false; List <double> findStartEndTime = new List <double>(); foreach (var entry in tagMap) { string text = entry.Value.Text; List <string> lines = text.Split('\n').ToList <string>(); string tempLine = ""; string tempTime = ""; bool setSettings = true; Dictionary <string, int> posDict = new Dictionary <string, int>(); foreach (string line in lines) { if (!String.IsNullOrEmpty(line)) { if (line.Contains(",")) { tempLine = line; string time = line.Split(',')[1].Replace('\"', ' ').Trim(); string milliSeconds = line.Split(',')[2].Replace('\"', ' ').Trim(); DateTime parsedTime = new DateTime(); DateTimeParser.Parse(time, out parsedTime); time = parsedTime.ToString("HH:mm") + ":" + milliSeconds; try { findStartEndTime.Add(Double.Parse(milliSeconds)); if (setSettings) { setSettings = false; tempTime = time; } if (!tempTime.Equals(time)) { posDict.Add(tempTime, entry.Value.Find(line)); tempTime = time; } } catch (FormatException ex) { oldBuild = true; logger.WriteLog("Moving to Old Build : Reason: " + ex.Message); } } } } posDict.Add(tempTime, entry.Value.Find(tempLine)); syncMap.Add(entry.Key, posDict); } if (oldBuild) { MessageBox.Show("Old Build Detected : Only Approximate Synchronization Available."); } endTick = findStartEndTime.Max <double>().ToString(); startTick = findStartEndTime.Min <double>().ToString(); Cursor.Current = Cursors.Default; return(oldBuild); }
DateTime _end = new DateTime(); //Stores End time of a particular Work Order //Constructor which fetches relevant data from each log file public LogFilesGrabber(string workOrder) { _logger.WriteLog("LogFilesGrabber Invoked :: Execution STARTS --- "); InitializeGlobalParams(workOrder); _logger.WriteLog("LogFilesGrabber Invoked :: Execution FINISHES --- "); }
//This function is used to parse the logs in text format inside the errors folder of each system public List <string> ParseLogs(string key, int cs, int m) { List <string> priorityLines = new List <string>(); DataTable workOrderdt = new DataTable(); _logger.WriteLog("Finding Logs for : " + key + " |||STARTS"); List <string> files = findFiles(key, cs, m, _isLoomSystem); if (files.Count > 0) { _logger.WriteLog("Number of Files Found : " + files.Count.ToString()); if (!key.Equals(ConfigurationManager.AppSettings["mainLogKey"].ToString())) { priorityLines = readFiles(files, key); } else { priorityLines = parseMainLog(key, files); } _logger.WriteLog("Number of Relevant Lines Found inside all the files under this Key: " + priorityLines.Count.ToString()); } _logger.WriteLog("Finding Logs for : " + key + " |||FINISHES"); return(priorityLines); }