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); }
//Sets the normal start end time for current workorder private static void setNormalStartEndTime(DataTable workOrderdt, string startString, string endString) { DateTimeParser.Parse(startString, out _start); DateTimeParser.Parse(endString, out _end); }
private static Dictionary <string, int> scrollThroughTimes(string labelValueText, Dictionary <string, RichTextBox> tagMap, Dictionary <string, Dictionary <string, int> > syncMap) { Dictionary <string, int> posTags = new Dictionary <string, int>(); if (!String.IsNullOrEmpty(labelValueText.ToString())) { DateTime scrollerValue = new DateTime(); List <string> labels = labelValueText.Split(' ')[1].Split(':').ToList <string>(); string trackbarString = labels[0] + ":" + labels[1]; DateTimeParser.Parse(trackbarString, out scrollerValue); string checkString = labels[2]; double milliSecondsCheck = Double.Parse(checkString); foreach (var item in tagMap) { double minDiff = 0.00; string finalKey = ""; bool setUpLoop = true; foreach (var entry in syncMap[item.Key]) { if (!String.IsNullOrEmpty(entry.Key)) { string label = entry.Key; List <string> timeSplit = label.Split(':').ToList <string>(); string hour = timeSplit[0]; int hr = Int32.Parse(hour); string minute = timeSplit[1]; int min = Int32.Parse(minute); string milliSeconds = timeSplit[2]; double ms = Double.Parse(milliSeconds); DateTime hashMapTime = new DateTime(); DateTimeParser.Parse(hr + ":" + min, out hashMapTime); if (scrollerValue == hashMapTime) { double diff = ms - milliSecondsCheck; if (diff < 0) { diff *= (-1); } if (setUpLoop) { setUpLoop = false; minDiff = diff; finalKey = entry.Key; } else if (diff < minDiff) { minDiff = diff; finalKey = entry.Key; } } } } if (!String.IsNullOrEmpty(finalKey)) { int position = syncMap[item.Key][finalKey]; posTags.Add(item.Key, position); } } } return(posTags); }
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); }