Esempio n. 1
0
        /// <summary>
        /// Sets the Start and Stop for the file
        /// </summary>
        private static BuildRangeDetail BuildStartAndStopDateTime(FileData file)
        {
            var result = new BuildRangeDetail();

            try
            {
                lock (file)
                {
                    if (file.IsCached)
                    {
                        result.FileCached = true;
                        return(result);
                    }

                    if (file.RawTextFirstLines.Count == 0)
                    {
                        result.FirstLineEmpty = true;
                        return(result);
                    }

                    if (file.RawTextLastLines.Count == 0)
                    {
                        result.LastLineEmpty = true;
                        return(result);
                    }

                    var stopWatch = new Stopwatch(MethodBase.GetCurrentMethod().Name, false);
                    try
                    {
                        /////
                        // START
                        /////
                        var start = DateTime.Now;
                        // Try DateTime first and then Date Keyword
                        var startDateTime = RegularExpression.GetFirstValue(file.RawTextStringFirstLines, "(?:\\A|\\r|\\n|\\r\\n)<(.*)>");
                        if (DateTimeExt.TryParseWithTimeZoneRemoval(startDateTime, out DateTime testDateTime))
                        {
                            file.Start = testDateTime;
                        }
                        result.StartTimeDuration = DateTime.Now - start;

                        /////
                        // END
                        /////
                        start = DateTime.Now;
                        var endDateTime = RegularExpression.GetFirstValue(file.RawTextStringLastLines, "(?:\\A|\\r|\\n|\\r\\n)<(.*)>");
                        var found       = false;
                        if (DateTimeExt.TryParseWithTimeZoneRemoval(endDateTime, out testDateTime))
                        {
                            found    = true;
                            file.End = testDateTime;
                        }
                        result.StopTimeDuration = DateTime.Now - start;

                        // We are looking for a large difference, so adding 30 seconds to the End will account for a 30 second window. - Sara
                        if (file.Start > file.End.Add(new TimeSpan(0, 0, 30)))
                        {
                            throw new DateTimeExt.InvalidDateRangeException(string.Format("Start: {0} is greater then End: {1}, End Found: {2}, endDateTime: {4}/n-----/n{3}",
                                                                                          file.Start,
                                                                                          file.End.Add(new TimeSpan(0, 0, 30)),
                                                                                          found,
                                                                                          file.RawTextStringLastLines,
                                                                                          endDateTime));
                        }
                    }
                    finally
                    {
                        stopWatch.Stop();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteError(typeof(FileService).FullName, MethodBase.GetCurrentMethod().Name, ex);
            }
            return(result);
        }
Esempio n. 2
0
 public BuildDetail()
 {
     RangeDetail         = new BuildRangeDetail();
     NonLazyValuesDetail = new BuildNonLazyValuesDetail();
     SourceTypeDetail    = new BuildSourceTypeDetail();
 }