private void RunItem(TwoLines t) { if (!HasGap(t, DocumentMapGapMinDuration, out TimeSpan diff)) { return; } //var start = new DocumentEntry //{ // Name = "GAP START", // iLine = t.FirstiLine, // Text = t.FirstLine.RemoveInvalidXMLChars(), // Type = DocumentMapType.TimeGAPStart, // Level = DocumentMapLevel.Sibling, //}; var stop = new DocumentEntry { Name = diff.ToShortReadableString(), iLine = t.SecondiLine, Text = t.SecondLine.RemoveInvalidXMLChars(), Type = DocumentMapType.TimeGAPEnd, Level = DocumentMapLevel.Sibling, ValueObject = diff }; lock (Result) { //Result.Add(start); Result.Add(stop); } }
private static bool HasGap(TwoLines t, int threshold, out TimeSpan diff) { DateTime firstDate; DateTime secondDate; if ( !DateTimeExt.TryParseWithTimeZoneRemoval(RegularExpression.GetTextBetweenTwoCharacters("<", ">", t.FirstLine), out firstDate) || !DateTimeExt.TryParseWithTimeZoneRemoval(RegularExpression.GetTextBetweenTwoCharacters("<", ">", t.SecondLine), out secondDate)) { diff = new TimeSpan(0); return(false); } diff = secondDate - firstDate; return(diff.TotalMilliseconds >= threshold); }