private void bgwSearchForMatches_DoWork(object sender, DoWorkEventArgs e)
        {
            BackGroundWorkerObject bgWorkerObject = ((DoWorkEventArgs)e).Argument as BackGroundWorkerObject;

            // ComplexCaptureMatchObject complexCaptureMatchObject = new ComplexCaptureMatchObject();
            int Jcounter = 0;
            for (int i = 0; i < currentlyUsedCaptures.Count; i++) {
                ComplexCaptureMatchObject complexCaptureMatchObject = new ComplexCaptureMatchObject();

                complexCaptureMatchObject.captureEvent = Advanced_Recommendations.SelectAdvancedRecByIdAndIncrementUsage(currentlyUsedCaptures[i].CaptureEventId, currentlyUsedCaptures[i].captureEventUsageCount);

                for (int j = 0; j < bgWorkerObject.targetedFiles.Count; j++) {
                    string readText = string.Empty;
                    readText = CommonUtils.ReadFile(bgWorkerObject.targetedFiles[j].fileName);
                    ParseTargetedFile(complexCaptureMatchObject.captureEvent, readText, complexCaptureMatchObject, bgWorkerObject.targetedFiles[j].fileName);
                    bgWorkerObject.targetedFiles[j].parsed = true;
                    bgwSearchForMatches.ReportProgress((int)Math.Round(((double)(((i) + (Jcounter))) / ((currentlyUsedCaptures.Count) * (bgWorkerObject.targetedFiles.Count + 1))) * 100, 0), bgWorkerObject);
                    Jcounter++;
                }
                bgWorkerObject.returnedComplexCaptureMatchObject.Add(complexCaptureMatchObject);
            }

            //for (int i = 0; i < bgWorkerObject.targetedFiles.Count; i++) {

            //    StartParsingInput(currentlyUsedCaptures, readText, fileName, complexCaptureMatchObject);

            //    bgWorkerObject.targetedFiles[i].parsed = true;
            //    bgWorkerObject.returnedComplexCaptureMatchObject.Add(complexCaptureMatchObject);
            //    bgwSearchForMatches.ReportProgress((int)Math.Round(((double)(i + 1) / bgWorkerObject.targetedFiles.Count) * 100, 0), bgWorkerObject);

            //}
            e.Result = bgWorkerObject;
        }
 private void ParseTargetedFile(AdvancedRecomendation captureEvent, string readText, ComplexCaptureMatchObject complexCaptureMatchObject, string fileName)
 {
     captureEvent = GetCapturePointListType(captureEvent);
     XDocument xdoc = XDocument.Parse(readText);
     List<string> foundEvents = new List<string>();
     if (captureEvent.capturePointListType == CapturePointListType.SimpleList) {
         List<XNode> foundNodes = ParseUsingSimpleList(captureEvent, xdoc, foundEvents);
         totalFoundNodes = totalFoundNodes + foundNodes.Count;
         if (foundNodes.Count > 0) {
             FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
             fileAndNumberOfMatches.fileName = fileName;
             fileAndNumberOfMatches.matchedNodes = foundNodes;
             complexCaptureMatchObject.fileNamesHit.Add(fileAndNumberOfMatches);
         }
     } else {
         List<XNode> foundNodes = ParseUsingAdvancedList(captureEvent, xdoc);
         totalFoundNodes = totalFoundNodes + foundNodes.Count;
         if (foundNodes.Count > 0) {
             FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
             fileAndNumberOfMatches.fileName = fileName;
             fileAndNumberOfMatches.matchedNodes = foundNodes;
             complexCaptureMatchObject.fileNamesHit.Add(fileAndNumberOfMatches);
         }
     }
 }
 private void StartParsingInput(List<AdvancedRecomendation> currentlyUsedCaptures, string readText, string fileName, ComplexCaptureMatchObject complexCaptureMatchObject)
 {
     XDocument xdoc = XDocument.Parse(readText);
     for (int i = 0; i < currentlyUsedCaptures.Count; i++) {
         complexCaptureMatchObject.captureEvent = currentlyUsedCaptures[i];
         currentlyUsedCaptures[i] = GetCapturePointListType(currentlyUsedCaptures[i]);
         List<string> foundEvents = new List<string>();
         if (currentlyUsedCaptures[i].capturePointListType == CapturePointListType.SimpleList) {
             List<XNode> foundNodes = ParseUsingSimpleList(currentlyUsedCaptures[i], xdoc, foundEvents);
             totalFoundNodes = totalFoundNodes + foundNodes.Count;
             if (foundNodes.Count > 0) {
                 FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
                 fileAndNumberOfMatches.fileName = fileName;
                 fileAndNumberOfMatches.matchedNodes = foundNodes;
                 complexCaptureMatchObject.fileNamesHit.Add(fileAndNumberOfMatches);
             }
         } else {
             List<XNode> foundNodes = ParseUsingAdvancedList(currentlyUsedCaptures[i], xdoc);
             totalFoundNodes = totalFoundNodes + foundNodes.Count;
             if (foundNodes.Count > 0) {
                 FileAndNumberOfMatches fileAndNumberOfMatches = new FileAndNumberOfMatches();
                 fileAndNumberOfMatches.fileName = fileName;
                 fileAndNumberOfMatches.matchedNodes = foundNodes;
                 complexCaptureMatchObject.fileNamesHit.Add(fileAndNumberOfMatches);
             }
         }
     }
 }