Пример #1
0
        /// <summary>
        /// Parses the traces.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static TraceInfoCollection ParseTraces(string[] input)
        {
            string itemlow;
            TraceInfoCollection traceinfos = new TraceInfoCollection();
            TraceInfo           traceinfo  = new TraceInfo();

            try
            {
                foreach (string item in input)
                {
                    traceinfo = new TraceInfo();
                    //item = " " + Parser.Clean(item1);
                    itemlow = item.ToLower();
                    if (itemlow.IndexOf(" from ") != -1)
                    {
                        traceinfo.From = item.Substring(itemlow.IndexOf(" from ") + 6, item.IndexOf(" ", itemlow.IndexOf(" from ") + 6) - (itemlow.IndexOf(" from ") + 6)).TrimEnd(';');
                    }
                    if (itemlow.IndexOf(" by ") != -1)
                    {
                        traceinfo.By = item.Substring(itemlow.IndexOf(" by ") + 4, item.IndexOf(" ", itemlow.IndexOf(" by ") + 4) - (itemlow.IndexOf(" by ") + 4)).TrimEnd(';');
                    }
                    if (itemlow.IndexOf(" for ") != -1)
                    {
                        traceinfo.For = item.Substring(itemlow.IndexOf(" for ") + 5, item.IndexOf(" ", itemlow.IndexOf(" for ") + 5) - (itemlow.IndexOf(" for ") + 5)).TrimEnd(';');
                    }
                    if (itemlow.IndexOf(" id ") != -1)
                    {
                        traceinfo.Id = item.Substring(itemlow.IndexOf(" id ") + 4, item.IndexOf(" ", itemlow.IndexOf(" id ") + 4) - (itemlow.IndexOf(" id ") + 4)).TrimEnd(';');
                    }
                    if (itemlow.IndexOf(" via ") != -1)
                    {
                        traceinfo.Via = item.Substring(itemlow.IndexOf(" via ") + 5, item.IndexOf(" ", itemlow.IndexOf(" via ") + 5) - (itemlow.IndexOf(" via ") + 5)).TrimEnd(';');
                    }
                    if (itemlow.IndexOf(" with ") != -1)
                    {
                        traceinfo.With = item.Substring(itemlow.IndexOf(" with ") + 6, item.IndexOf(" ", itemlow.IndexOf(" with ") + 6) - (itemlow.IndexOf(" with ") + 6)).TrimEnd(';');
                    }
                    traceinfo.Date = ParseAsUniversalDateTime(item.Split(';')[item.Split(';').Length - 1].Trim(' '));
                    traceinfos.Add(traceinfo);
                }
            }
            catch { }

            return(traceinfos);
        }
Пример #2
0
		public static TraceInfo ParseTrace(string input)
		{
			TraceInfo traceInfo = new TraceInfo();
            System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(input, @"from.+?(?=(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success) traceInfo.From = m.Value;
            m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=by ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success) traceInfo.By = m.Value;
            m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=via ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success) traceInfo.Via = m.Value;
            m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=with ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success) traceInfo.With = m.Value;
            m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=for ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success) traceInfo.For = m.Value;
            m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=id ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success) traceInfo.Id = m.Value;
            traceInfo.Date = Parser.ParseAsUniversalDateTime(input.Substring(input.LastIndexOf(';')+1));
            return traceInfo;
		}
Пример #3
0
        /// <summary>
        /// Parses the trace.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static TraceInfo ParseTrace(string input)
        {
            TraceInfo traceInfo = new TraceInfo();
            Match     m         = Regex.Match(input, @"from.+?(?=(from|by|via|with|for|id|;|\r?\n))");

            if (m.Success)
            {
                traceInfo.From = m.Value.Trim(' ', '\t');
            }
            m = Regex.Match(input, @"(?<=by ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success)
            {
                traceInfo.By = m.Value.Trim(' ', '\t');
            }
            m = Regex.Match(input, @"(?<=via ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success)
            {
                traceInfo.Via = m.Value.Trim(' ', '\t');
            }
            m = Regex.Match(input, @"(?<=with ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success)
            {
                traceInfo.With = m.Value.Trim(' ', '\t');
            }
            m = Regex.Match(input, @"(?<=for ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success)
            {
                traceInfo.For = m.Value.Trim(' ', '\t');
            }
            m = Regex.Match(input, @"(?<=id ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
            if (m.Success)
            {
                traceInfo.Id = m.Value.Trim(' ', '\t');
            }
            traceInfo.Date = ParseAsUniversalDateTime(input.Substring(input.LastIndexOf(';') + 1));
            return(traceInfo);
        }
 public void Add(TraceInfo traceInfo)
 {
     this.InnerList.Add(traceInfo);
 }
Пример #5
0
 /// <summary>
 /// Parses the traces.
 /// </summary>
 /// <param name="input">The input.</param>
 /// <returns></returns>
 public static TraceInfoCollection ParseTraces(string[] input)
 {
     string itemlow;
     TraceInfoCollection traceinfos = new TraceInfoCollection();
     TraceInfo traceinfo = new TraceInfo();
     try
     {
         foreach (string item in input)
         {
             traceinfo = new TraceInfo();
             //item = " " + Parser.Clean(item1);
             itemlow = item.ToLower();
             if (itemlow.IndexOf(" from ") != -1) traceinfo.From = item.Substring(itemlow.IndexOf(" from ") + 6, item.IndexOf(" ", itemlow.IndexOf(" from ") + 6) - (itemlow.IndexOf(" from ") + 6)).TrimEnd(';');
             if (itemlow.IndexOf(" by ") != -1) traceinfo.By = item.Substring(itemlow.IndexOf(" by ") + 4, item.IndexOf(" ", itemlow.IndexOf(" by ") + 4) - (itemlow.IndexOf(" by ") + 4)).TrimEnd(';');
             if (itemlow.IndexOf(" for ") != -1) traceinfo.For = item.Substring(itemlow.IndexOf(" for ") + 5, item.IndexOf(" ", itemlow.IndexOf(" for ") + 5) - (itemlow.IndexOf(" for ") + 5)).TrimEnd(';');
             if (itemlow.IndexOf(" id ") != -1) traceinfo.Id = item.Substring(itemlow.IndexOf(" id ") + 4, item.IndexOf(" ", itemlow.IndexOf(" id ") + 4) - (itemlow.IndexOf(" id ") + 4)).TrimEnd(';');
             if (itemlow.IndexOf(" via ") != -1) traceinfo.Via = item.Substring(itemlow.IndexOf(" via ") + 5, item.IndexOf(" ", itemlow.IndexOf(" via ") + 5) - (itemlow.IndexOf(" via ") + 5)).TrimEnd(';');
             if (itemlow.IndexOf(" with ") != -1) traceinfo.With = item.Substring(itemlow.IndexOf(" with ") + 6, item.IndexOf(" ", itemlow.IndexOf(" with ") + 6) - (itemlow.IndexOf(" with ") + 6)).TrimEnd(';');
             traceinfo.Date = Parser.ParseAsUniversalDateTime(item.Split(';')[item.Split(';').Length - 1].Trim(' '));
             traceinfos.Add(traceinfo);
         }
     }
     catch { };
     return traceinfos;
 }
Пример #6
0
 /// <summary>
 /// Parses the trace.
 /// </summary>
 /// <param name="input">The input.</param>
 /// <returns></returns>
 public static TraceInfo ParseTrace(string input)
 {
     TraceInfo traceInfo = new TraceInfo();
     System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(input, @"from.+?(?=(from|by|via|with|for|id|;|\r?\n))");
     if (m.Success) traceInfo.From = m.Value.Trim(' ','\t');
     m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=by ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
     if (m.Success) traceInfo.By = m.Value.Trim(' ', '\t');
     m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=via ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
     if (m.Success) traceInfo.Via = m.Value.Trim(' ', '\t');
     m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=with ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
     if (m.Success) traceInfo.With = m.Value.Trim(' ', '\t');
     m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=for ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
     if (m.Success) traceInfo.For = m.Value.Trim(' ', '\t');
     m = System.Text.RegularExpressions.Regex.Match(input, @"(?<=id ).+?(?= ?(from|by|via|with|for|id|;|\r?\n))");
     if (m.Success) traceInfo.Id = m.Value.Trim(' ', '\t');
     traceInfo.Date = Parser.ParseAsUniversalDateTime(input.Substring(input.LastIndexOf(';') + 1));
     return traceInfo;
 }
Пример #7
0
        /// <summary>
        /// Parses the traces.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static TraceInfoCollection ParseTraces(string[] input)
        {
            var traceinfos = new TraceInfoCollection();
            try
            {
                foreach (var item in input)
                {
                    var traceinfo = new TraceInfo();
                    var itemlow = item.ToLower();

                    var found_index = itemlow.IndexOf(" from ", StringComparison.Ordinal);
                    if (found_index != -1) 
                        traceinfo.From = item.Substring(found_index + 6, item.IndexOf(" ", found_index + 6, StringComparison.Ordinal) - (found_index + 6)).TrimEnd(';');
                    
                    found_index = itemlow.IndexOf(" by ", StringComparison.Ordinal);
                    if (found_index != -1) 
                        traceinfo.By = item.Substring(found_index + 4, item.IndexOf(" ", found_index + 4, StringComparison.Ordinal) - (found_index + 4)).TrimEnd(';');
                    
                    found_index = itemlow.IndexOf(" for ", StringComparison.Ordinal);
                    if (found_index != -1) 
                        traceinfo.For = item.Substring(found_index + 5, item.IndexOf(" ", found_index + 5, StringComparison.Ordinal) - (found_index + 5)).TrimEnd(';');
                    
                    found_index = itemlow.IndexOf(" id ", StringComparison.Ordinal);
                    if (found_index != -1) 
                        traceinfo.Id = item.Substring(found_index + 4, item.IndexOf(" ", found_index + 4, StringComparison.Ordinal) - (found_index + 4)).TrimEnd(';');
                    
                    found_index = itemlow.IndexOf(" via ", StringComparison.Ordinal);
                    if (found_index != -1) 
                        traceinfo.Via = item.Substring(found_index + 5, item.IndexOf(" ", found_index + 5, StringComparison.Ordinal) - (found_index + 5)).TrimEnd(';');
                    
                    found_index = itemlow.IndexOf(" with ", StringComparison.Ordinal);
                    if (found_index != -1) 
                        traceinfo.With = item.Substring(found_index + 6, item.IndexOf(" ", found_index + 6, StringComparison.Ordinal) - (found_index + 6)).TrimEnd(';');
                    
                    traceinfo.Date = ParseAsUniversalDateTime(item.Split(';')[item.Split(';').Length - 1].Trim(' '));
                    traceinfos.Add(traceinfo);
                }
            }
            catch { }
            return traceinfos;
        }
Пример #8
0
        /// <summary>
        /// Parses the trace.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static TraceInfo ParseTrace(string input)
        {
            var trace_info = new TraceInfo();
            
            var m = _regxTraceFrom.Match(input);
            if (m.Success) trace_info.From = m.Value.Trim(' ','\t');

            m = _regxTraceBy.Match(input);
            if (m.Success) trace_info.By = m.Value.Trim(' ', '\t');

            m = _regxTraceVia.Match(input);
            if (m.Success) trace_info.Via = m.Value.Trim(' ', '\t');

            m = _regxTraceWith.Match(input);
            if (m.Success) trace_info.With = m.Value.Trim(' ', '\t');

            m = _regxTraceFor.Match(input);
            if (m.Success) trace_info.For = m.Value.Trim(' ', '\t');

            m = _regxTraceId.Match(input);
            if (m.Success) trace_info.Id = m.Value.Trim(' ', '\t');
            
            trace_info.Date = ParseAsUniversalDateTime(input.Substring(input.LastIndexOf(';') + 1));
            
            return trace_info;
        }
Пример #9
0
        public static bool TryParseTrace(string input, out TraceInfo trace_info)
        {
            trace_info = null;
            try
            {
                trace_info = ParseTrace(input);
                return true;
            }
            catch { }

            return false;
        }
Пример #10
0
 public void Add(TraceInfo traceInfo)
 {
     this.InnerList.Add(traceInfo);
 }