Beispiel #1
0
        public static void InitializeFrecContent(string fileContent, Frec frec)
        {
            Debug.Assert(!frec.IsInitialized);
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                frec.IsInitialized = true;

                //get start and end
                int startFrecIndex = frec.Match.Index + frec.Match.Length;
                int endFrecIndex   = FindEndOfFrec(fileContent, frec);

                //parse content
                ParseRequestContent(fileContent, frec, startFrecIndex, endFrecIndex);
                ParseResponceContent(fileContent, frec, startFrecIndex, endFrecIndex);
                ParseQcSensePerformanceData(fileContent, frec, startFrecIndex, endFrecIndex);
            }
            finally
            {
                stopWatch.Stop();
                frec.ParseDuration = (int)stopWatch.ElapsedMilliseconds;
            }
        }
Beispiel #2
0
        public static List <Frec> ParseFrecsHeaders(FrecCollection frecParent, string fileContent, IList <string> excludedFrecs)
        {
            Regex           startExtractorRegex = new Regex(WebGateConst.PATTERN_START, RegexOptions.Multiline | RegexOptions.Compiled);
            MatchCollection matchCollection     = startExtractorRegex.Matches(fileContent);

            int         defaultSize = 200;
            List <Frec> list        = new List <Frec>(defaultSize);

            foreach (Match match in matchCollection)
            {
                string frecName = match.Groups[PatternGroup.FREC_NAME].Value;
                if (excludedFrecs.Contains(frecName))
                {
                    continue;
                }


                string strTime = match.Groups[PatternGroup.TIME].Value;

                Frec frec = new Frec(
                    frecParent,
                    frecName,
                    match.Groups[PatternGroup.THREAD_ID].Value,
                    TimeSpan.Parse(strTime),
                    match);

                list.Add(frec);
                frec.Id = list.Count;
            }
            return(list);
        }
Beispiel #3
0
        public void SetFrec(Frec frec)
        {
            m_currentFrec = frec;
            Text          = string.Format("{0} - {1}", frec.Id, frec.Title);

            //raw frec
            webBrowser1.DocumentText = frec.GetRawFrec();

            //performance data
            dataGridView1.Rows.Clear();
            string performanceXML = frec.GetResponsePerformanceXML();

            if (!string.IsNullOrEmpty(performanceXML))
            {
                DataSet ds = new DataSet();

                using (TextReader tr = new StringReader(performanceXML))
                {
                    ds.ReadXml(tr);
                    DataRow row = ds.Tables[0].Rows[0];
                    foreach (DataColumn column in ds.Tables[0].Columns)
                    {
                        dataGridView1.Rows.Add(column.ColumnName, row[column]);
                    }
                }
            }


            UpdateCommands();
        }
        public override IList <BaseBookmark> GetBookmarks(Frec frec)
        {
            List <BaseBookmark> list = new List <BaseBookmark>();

            BaseBookmark    bookmark;
            string          tableNameFromRequest = GetMainTableName(frec);
            string          regex   = GetResponceRegexMatcher(frec);
            MatchCollection matches = Regex.Matches(frec.Response, regex);

            foreach (Match match in matches)
            {
                bookmark = new BaseBookmark();

                int countOfCharsForFind = Math.Min(frec.Response.Length - match.Index, TABLE_NAME_STRING.Length + 20);
                if (frec.Response.IndexOf(TABLE_NAME_STRING, match.Index, countOfCharsForFind) > 0)
                {
                    bookmark.Title      = GetExternalTableFromResponce(frec, match.Index);
                    bookmark.IsInjected = true;
                }
                else
                {
                    bookmark.Title = tableNameFromRequest;
                }

                bookmark.Bookmark = match.Value;
                list.Add(bookmark);
            }

            return(list);
        }
Beispiel #5
0
        private void OnFilterFromCurrentRow(object sender, EventArgs e)
        {
            Frec focused = m_filterGridControl.FocusedObject <Frec>();

            if (focused != null)
            {
                AddToFilter(Consts.FrecProperty.ID, focused.Id.ToString());
            }
        }
Beispiel #6
0
        protected string ParseTableName(Frec frec, string prefix)
        {
            string temp = Helpers.FrecUtilities.GetValue(frec.Request, prefix);

            if (temp == null)
            {
                temp = string.Empty;
            }
            return(temp);
        }
Beispiel #7
0
        public virtual string GetTableName(Frec frec)
        {
            string table = ParseTableName(frec, TABLE_NAME);

            if (table == string.Empty)
            {
                table = ParseTableName(frec, TABLE_NAME2);
            }
            return(table);
        }
Beispiel #8
0
 public static BaseTableNameParser GetParser(Frec frec)
 {
     if (m_map.ContainsKey(frec.Title))
     {
         return(m_map[frec.Title]);
     }
     else
     {
         return(m_map["GetSimpleKeyEntity"]);
     }
 }
 protected override string GetResponceRegexMatcher(Frec frec)
 {
     if (frec.TableName == TEST_TABLE)
     {
         return(VC_TEST_ID_REGEX_STRING);
     }
     else
     {
         return(base.GetResponceRegexMatcher(frec));
     }
 }
Beispiel #10
0
        public override string GetTableName(Frec frec)
        {
            string table = string.Empty;

            if (frec.Request.Contains("req.tds") &&
                frec.Request.Contains("testplan.tds") &&
                frec.Request.Contains("resources.tds"))
            {
                return(string.Empty);
            }


            table = ExtractTableNameAfterString(frec.Request, CHECKOUT_PATH_PREFIX);
            if (table != null)
            {
                return(VC_PREFIX + table);
            }

            table = ExtractTableNameAfterString(frec.Request, HIST_PATH_PREFIX);
            if (table != null)
            {
                return(HIST_PREFIX + table);
            }


            if (frec.Request.IndexOf(@"\components", 0, StringComparison.OrdinalIgnoreCase) > 0)
            {
                return("COMPONENT");
            }
            else if (frec.Request.IndexOf(@"\resources", 0, StringComparison.OrdinalIgnoreCase) > 0)
            {
                return("RESOURCES");
            }
            else if (frec.Request.IndexOf(@"\req", 0, StringComparison.OrdinalIgnoreCase) > 0)
            {
                return("REQ");
            }
            else if (frec.Request.IndexOf(@"\Step", 0, StringComparison.OrdinalIgnoreCase) > 0)
            {
                return("STEP");
            }
            else if (frec.Request.IndexOf(@"\Run", 0, StringComparison.OrdinalIgnoreCase) > 0)
            {
                return("RUN");
            }
            else if (frec.Request.IndexOf(@"\Test", 0, StringComparison.OrdinalIgnoreCase) > 0)
            {
                return(TEST_TABLE);
            }

            return(string.Empty);
        }
 public override string GetMainTableName(Frec frec)
 {
     if (!string.IsNullOrEmpty(frec.TableName))
     {
         return(frec.TableName);
     }
     else
     {
         string name  = m_mapTitle2RegexMatcher[frec.Title];
         int    index = name.IndexOf(":");
         return(name.Substring(0, index));
     }
 }
Beispiel #12
0
        private Color BackColorDelegate(object frecObject)
        {
            Frec frec = (Frec)frecObject;

            if (frec.Thread == m_frecs.MainThread)
            {
                return(m_options.GridMainRequestColor);
            }
            else
            {
                return(m_options.GridSecondaryRequestColor);
            }
        }
        public static BaseBookmarkParser GetParser(Frec frec)
        {
            if (frec.IsFailed)
            {
                return(m_map[ERROR_FREC]);
            }

            else if (m_map.ContainsKey(frec.Title))
            {
                return(m_map[frec.Title]);
            }

            return(m_map["GetSimpleKeyEntity"]);
        }
Beispiel #14
0
        public override string GetTableName(Frec frec)
        {
            string tableName = base.GetTableName(frec);

            if (string.IsNullOrEmpty(tableName))
            {
                string value = Helpers.FrecUtilities.GetValue(frec.Request, OBJ_TYPE);
                if (value == TEST_OBJ_TYPE)
                {
                    tableName = TEST_TABLE;
                }
            }

            return(tableName);
        }
        public override string GetMainTableName(Frec frec)
        {
            string isPublicRegexString = @"Private:(\w)";
            Match  match = Regex.Match(frec.Request, isPublicRegexString);
            string value = match.Groups[1].Value;

            if (match.Groups[1].Value == "Y")
            {
                return("PRIVATE");
            }
            else
            {
                return("PUBLIC");
            }
        }
Beispiel #16
0
        public static int FindEndOfFrec(string fileContent, Frec frec)
        {
            int    startFrecIndex = frec.Match.Index;
            string endPattern     = string.Format(WebGateConst.END_FORMAT, frec.Title);
            int    endFrecIndex   = fileContent.IndexOf(endPattern, startFrecIndex);

            if (endFrecIndex == -1)
            {
                endFrecIndex = fileContent.Length;
            }
            else
            {
                endFrecIndex += endPattern.Length;
            }
            return(endFrecIndex);
        }
 public override IList <BaseBookmark> GetBookmarks(Frec frec)
 {
     try
     {
         List <BaseBookmark> list     = new List <BaseBookmark>();
         BaseBookmark        bookmark = new BaseBookmark();
         bookmark.Title    = "ERROR_CODE";
         bookmark.Bookmark = frec.ErrorCode.ToString();
         list.Add(bookmark);
         return(list);
     }
     catch
     {
         return(null);
     }
 }
Beispiel #18
0
        private void UpdateContent()
        {
            int currentRow = m_filterGridControl.FocusedIndex;

            int rowCount = m_filterGridControl.DataSource.Count;

            m_btnTop.Enabled    = (rowCount > 0 && currentRow > 0);
            m_btnBottom.Enabled = ((rowCount > 0) && (currentRow < rowCount - 1));

            m_btnLoadedSource.Enabled = true;

            Frec focused = m_filterGridControl.FocusedObject <Frec>();

            m_mvcManager.SetMvcContext(focused);
            UpdateBookmarks(focused);
        }
Beispiel #19
0
        private static void ParseQcSensePerformanceData(string fileContent, Frec frec, int startSearchIndex, int endFrecIndex)
        {
            frec.ResponcePerformanceData = string.Empty;
            int responseStartIndex = fileContent.IndexOf(WebGateConst.RESPONSE_INDICATION, startSearchIndex, endFrecIndex - startSearchIndex);

            if (responseStartIndex > 0)
            {
                Regex regex = new Regex(WebGateConst.RESPONSE_PERFORMANCE_DATA);

                Match match = regex.Match(fileContent, responseStartIndex, endFrecIndex - responseStartIndex);
                if (match.Success)
                {
                    frec.ResponcePerformanceData = match.Groups[PatternGroup.PERFORMANCE].Value;
                }
            }
        }
Beispiel #20
0
        private ImageStatus GetFrecStatusImage(object frecObject)
        {
            Frec frec = (Frec)frecObject;

            if (frec.IsFailed)
            {
                String message = "Error : " + frec.Response;
                return(ImageStatus.Create(Resources.breakpoint, message));
            }
            else if (frec.HasIllegalCharacters)
            {
                String message = "Responce has xml illegal characters : " + String.Join <int>(";", frec.IllegalCharacters);
                return(ImageStatus.Create(Resources.cube_molecule, message));
            }

            return(null);
        }
Beispiel #21
0
        private static void ParseRequestContent(string fileContent, Frec frec, int startFrecIndex, int endFrecIndex)
        {
            //Parse prefix
            Regex prefixRegex = new Regex(WebGateConst.PATTERN_REQUEST_PREFIX + frec.Title, RegexOptions.Singleline);
            Match prefixMatch = prefixRegex.Match(fileContent, startFrecIndex, endFrecIndex - startFrecIndex);

            if (prefixMatch.Success)
            {
                frec.RequestId = prefixMatch.Groups[PatternGroup.REQUEST_ID].Value;
                frec.Server    = prefixMatch.Groups[PatternGroup.SERVER].Value;
            }
            else
            {
                //no request
                return;
            }

            //parse content
            int prefixEndIndex = prefixMatch.Index + prefixMatch.Length;
            //first try with session
            Regex lengthRegex = new Regex(WebGateConst.PATTERN_REQUEST_CONTENT_LENGTH_WITH_SESSION, RegexOptions.Singleline);
            Match match       = lengthRegex.Match(fileContent, prefixEndIndex, endFrecIndex - prefixEndIndex);

            //try without session
            if (!match.Success)
            {
                lengthRegex = new Regex(WebGateConst.PATTERN_REQUEST_CONTENT_LENGTH, RegexOptions.Singleline);
                match       = lengthRegex.Match(fileContent, prefixEndIndex, endFrecIndex - prefixEndIndex);
            }

            if (match.Success)
            {
                bool isTruncated;
                frec.Request = ExtractContentByLength(fileContent, match);
                //frec.AddIllegalCharacters(Helpers.IOUtilities.GetIllegalCharacters(frec.Request));
                frec.Request   = TruncateIfRequired(frec.Request, int.MaxValue, out isTruncated);
                frec.Request   = RemoveUnnessessoryCharacters(frec.Request, int.MaxValue);
                frec.SessionId = match.Groups["SESSION"].Value;
            }
            else
            {
                //no content
                return;
            }
        }
        public override IList <BaseBookmark> GetBookmarks(Frec frec)
        {
            List <BaseBookmark> list = new List <BaseBookmark>();

            try
            {
                BaseBookmark bookmark = new BaseBookmark();
                bookmark.Title = frec.TableName;

                int graphNumber = Helpers.FrecUtilities.GetValueAsInt(frec.Request, "ChartGroup");
                bookmark.Bookmark = "GRAPH_TYPE: " + m_mapNumber2GraphName[graphNumber];
                list.Add(bookmark);
            }
            catch
            {
            }

            return(list);
        }
Beispiel #23
0
        private void UpdateBookmarks(Frec focused)
        {
            //Bookmarks
            m_idsGrid.ColumnHeadersVisible = false;
            m_idsGrid.RowTemplate.Height   = 18;
            m_idsGrid.AutoGenerateColumns  = false;

            if (focused != null)
            {
                IList <BaseBookmark> ids = m_frecs.GetBookmarks(focused);
                m_txtIdsCount.Text   = "Total : " + ids.Count;
                m_idsGrid.DataSource = ids;
            }
            else
            {
                m_idsGrid.DataSource = null;
                m_txtIdsCount.Text   = string.Empty;
            }
        }
        public override IList <BaseBookmark> GetBookmarks(Frec frec)
        {
            IList <BaseBookmark> bookmarks = base.GetBookmarks(frec);

            if (bookmarks != null && bookmarks.Count > 1)
            {
                //recognize release ids
                MatchCollection matches = Regex.Matches(frec.Response, TEST_RECOGNIZER, RegexOptions.Singleline);
                foreach (Match match in matches)
                {
                    for (int i = bookmarks.Count - 1; i >= 1; i--)
                    {
                        if (match.Value.EndsWith(bookmarks[i].Bookmark))
                        {
                            bookmarks[i].Title      = TEST_TABLE;
                            bookmarks[i].IsInjected = true;
                            break;
                        }
                    }
                }
            }

            return(bookmarks);
        }
Beispiel #25
0
 public override string GetTableName(Frec frec)
 {
     return(m_mapTitle2TableName[frec.Title]);
 }
Beispiel #26
0
 public override string GetTableName(Frec frec)
 {
     return(ParseTableName(frec, TABLE));
 }
Beispiel #27
0
        public override string GetTableName(Frec frec)
        {
            string prefix = m_mapTitle2RegexMatcher[frec.Title];

            return(base.ParseTableName(frec, prefix));
        }
Beispiel #28
0
 public override string GetTableName(Frec frec)
 {
     return(string.Empty);
 }
Beispiel #29
0
        public override string GetTableName(Frec frec)
        {
            string table = base.GetTableName(frec);

            return(VC_PREFIX + table);
        }
 public abstract IList <BaseBookmark> GetBookmarks(Frec frec);