示例#1
0
        /// <summary>
        /// Processes a specific report request.
        /// </summary>
        private void processReportRequest(StackHashBugReportData request)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

            // Determine what the report type is. The report type is reported to the plugin. It indicates
            // whether this manual report is for a whole product, file, event, cab, script or what.
            m_ReportType = getReportType(request);

            if (request.Product == null)
            {
                // Loop through all products.
                StackHashProductCollection allProducts = m_Index.LoadProductList();

                foreach (StackHashProduct product in allProducts)
                {
                    processProduct(request, product);
                }
            }
            else
            {
                StackHashProduct product = m_Index.GetProduct(request.Product.Id);

                if (product != null)
                {
                    processProduct(request, product);
                }
            }
        }
示例#2
0
        public void Conflict2EventsAndEventSameAsSecondDifferentProductAndFile()
        {
            StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashFile    file1    = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4");
            StackHashEvent   event1   = new StackHashEvent(1, "EventTypeName1");
            StackHashEvent   event2   = new StackHashEvent(2, "EventTypeName1");

            StackHashBugReportData           data1    = new StackHashBugReportData(product1, file1, event1, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportData           data2    = new StackHashBugReportData(product1, file1, event2, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1,
                data2,
            };

            StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashFile    file2    = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4");

            StackHashBugReportData           data3    = new StackHashBugReportData(product2, file2, event2, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data3
            };

            Assert.AreEqual(true, allData1.IsConflicting(allData2));
        }
示例#3
0
        /// <summary>
        /// Get the total number of events to be reported for this request.
        /// </summary>
        /// <param name="request">Full request.</param>
        /// <param name="reportType">The type of the request.</param>
        /// <returns>Number of events.</returns>
        private long getNumberOfEvents(StackHashBugReportData request, BugTrackerReportType reportType)
        {
            long             totalEvents = 0;
            StackHashProduct product     = null;

            switch (reportType)
            {
            case BugTrackerReportType.ManualFull:
                totalEvents = m_Index.TotalStoredEvents;
                break;

            case BugTrackerReportType.ManualProduct:
                product = m_Index.GetProduct(request.Product.Id);
                if (product != null)
                {
                    totalEvents = product.TotalStoredEvents;
                }
                break;

            case BugTrackerReportType.ManualFile:
                product = m_Index.GetProduct(request.Product.Id);
                if (product != null)
                {
                    totalEvents = product.TotalStoredEvents;
                }
                break;

            default:
                totalEvents = 1;
                break;
            }

            return(totalEvents);
        }
示例#4
0
        /// <summary>
        /// Processes a specific product.
        /// </summary>
        private void processProduct(StackHashBugReportData request, StackHashProduct product)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

            BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id);

            if (((request.Options & StackHashReportOptions.IncludeProducts) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                m_TaskParameters.PlugInContext.ProductAdded(m_PlugIns, m_ReportType, btProduct);
                checkPlugInStatus(m_PlugIns);
            }

            if (request.File == null)
            {
                StackHashFileCollection allFiles = m_Index.LoadFileList(product);

                foreach (StackHashFile file in allFiles)
                {
                    processFile(request, product, file);
                }
            }
            else
            {
                StackHashFile file = m_Index.GetFile(product, request.File.Id);

                if (file != null)
                {
                    processFile(request, product, file);
                }
            }
        }
示例#5
0
        public void ConflictBothFull()
        {
            StackHashBugReportData           data1    = new StackHashBugReportData(null, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1
            };

            StackHashBugReportData           data2    = new StackHashBugReportData(null, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data2
            };

            Assert.AreEqual(true, allData1.IsConflicting(allData2));
            Assert.AreEqual(true, allData2.IsConflicting(allData1));
        }
示例#6
0
        /// <summary>
        /// Get the level of report that has been requested.
        /// </summary>
        /// <param name="request">Full request.</param>
        /// <returns>Report level.</returns>
        private BugTrackerReportType getReportType(StackHashBugReportData request)
        {
            BugTrackerReportType reportType = BugTrackerReportType.ManualFull;

            // Determin what the report type is. The report type is reported to the plugin. It indicates
            // whether this manual report is for a whole product, file, event, cab, script or what.
            if (request.Product == null)
            {
                reportType = BugTrackerReportType.ManualFull;
            }
            else
            {
                if (request.File == null)
                {
                    reportType = BugTrackerReportType.ManualProduct;
                }
                else
                {
                    if (request.TheEvent == null)
                    {
                        reportType = BugTrackerReportType.ManualFile;
                    }
                    else
                    {
                        if (request.Cab == null)
                        {
                            m_ReportType = BugTrackerReportType.ManualEvent;
                        }
                        else
                        {
                            if (request.ScriptName == null)
                            {
                                m_ReportType = BugTrackerReportType.ManualCab;
                            }
                            else
                            {
                                // TODO: Support manual script writing.
                                m_ReportType = BugTrackerReportType.ManualScript;
                            }
                        }
                    }
                }
            }
            return(reportType);
        }
示例#7
0
        public void ConflictFullAndProduct()
        {
            StackHashBugReportData           data1    = new StackHashBugReportData(null, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1
            };

            StackHashProduct       product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashBugReportData data2    = new StackHashBugReportData(product2, null, null, null, null, StackHashReportOptions.IncludeAllObjects);

            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data2
            };

            Assert.AreEqual(true, allData1.IsConflicting(allData2));
        }
示例#8
0
        public void NoConflictProductAndDifferentProduct()
        {
            StackHashProduct                 product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashBugReportData           data1    = new StackHashBugReportData(product1, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1
            };

            StackHashProduct       product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 2, "StackHash", 0, 0, "1.2.3.4");
            StackHashBugReportData data2    = new StackHashBugReportData(product2, null, null, null, null, StackHashReportOptions.IncludeAllObjects);

            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data2
            };

            Assert.AreEqual(false, allData1.IsConflicting(allData2));
            Assert.AreEqual(false, allData2.IsConflicting(allData1));
        }
示例#9
0
        public void ConflictEventAndSameProduct()
        {
            StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");

            StackHashBugReportData           data1    = new StackHashBugReportData(product1, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1
            };

            StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashFile    file2    = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4");
            StackHashEvent   event2   = new StackHashEvent(1, "EventTypeName1");

            StackHashBugReportData           data2    = new StackHashBugReportData(product2, file2, event2, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data2
            };

            Assert.AreEqual(true, allData2.IsConflicting(allData1));
        }
示例#10
0
        /// <summary>
        /// Processes a specific file.
        /// </summary>
        private void processFile(StackHashBugReportData request, StackHashProduct product, StackHashFile file)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

            BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id);
            BugTrackerFile    btFile    = new BugTrackerFile(file.Name, file.Version, file.Id);

            if (((request.Options & StackHashReportOptions.IncludeFiles) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                m_TaskParameters.PlugInContext.FileAdded(m_PlugIns, m_ReportType, btProduct, btFile);
                checkPlugInStatus(m_PlugIns);
            }

            if (request.TheEvent == null)
            {
                // Parse the events.
                StackHashSortOrderCollection sortOrder = new StackHashSortOrderCollection()
                {
                    new StackHashSortOrder(StackHashObjectType.Event, "Id", true),
                    new StackHashSortOrder(StackHashObjectType.Event, "EventTypeName", true)
                };

                StackHashSearchOptionCollection searchOptions = new StackHashSearchOptionCollection()
                {
                    new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.Equal, product.Id, 0),
                    new IntSearchOption(StackHashObjectType.File, "Id", StackHashSearchOptionType.Equal, file.Id, 0),
                };

                StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
                {
                    new StackHashSearchCriteria(searchOptions)
                };


                int startRow     = 1;
                int numberOfRows = 100;
                StackHashEventPackageCollection allPackages = null;
                do
                {
                    allPackages = m_Index.GetEvents(allCriteria, startRow, numberOfRows, sortOrder, null);

                    foreach (StackHashEventPackage eventPackage in allPackages)
                    {
                        processEventPackage(request, product, file, eventPackage);
                    }

                    startRow += numberOfRows;
                } while (allPackages.Count > 0);
            }
            else
            {
                StackHashSearchOptionCollection searchOptions = new StackHashSearchOptionCollection()
                {
                    new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.Equal, product.Id, 0),
                    new IntSearchOption(StackHashObjectType.File, "Id", StackHashSearchOptionType.Equal, file.Id, 0),
                    new IntSearchOption(StackHashObjectType.Event, "Id", StackHashSearchOptionType.Equal, request.TheEvent.Id, 0),
                    new StringSearchOption(StackHashObjectType.Event, "EventTypeName", StackHashSearchOptionType.Equal, request.TheEvent.EventTypeName, request.TheEvent.EventTypeName, false),
                };

                StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
                {
                    new StackHashSearchCriteria(searchOptions)
                };

                StackHashEventPackageCollection eventPackages = m_Index.GetEvents(allCriteria, null);

                if ((eventPackages != null) && (eventPackages.Count == 1))
                {
                    processEventPackage(request, product, file, eventPackages[0]);
                }
            }
        }
示例#11
0
        /// <summary>
        /// Processes a specific event.
        /// </summary>
        private void processEventPackage(StackHashBugReportData request, StackHashProduct product, StackHashFile file,
                                         StackHashEventPackage eventPackage)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

            StackHashEvent theEvent = eventPackage.EventData;

            BugTrackerProduct   btProduct      = new BugTrackerProduct(product.Name, product.Version, product.Id);
            BugTrackerFile      btFile         = new BugTrackerFile(file.Name, file.Version, file.Id);
            NameValueCollection eventSignature = new NameValueCollection();

            foreach (StackHashParameter param in theEvent.EventSignature.Parameters)
            {
                eventSignature.Add(param.Name, param.Value);
            }
            BugTrackerEvent btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature);

            if (((request.Options & StackHashReportOptions.IncludeEvents) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                String newBugId = m_TaskParameters.PlugInContext.EventAdded(m_PlugIns, m_ReportType, btProduct, btFile, btEvent);
                checkPlugInStatus(m_PlugIns);
                theEvent = setPlugInBugReference(product, file, theEvent, newBugId);
                // Reset this in case it has changed.
                btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature);
            }

            if (((request.Options & StackHashReportOptions.IncludeEventNotes) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                StackHashNotes notes = m_Index.GetEventNotes(product, file, theEvent);
                foreach (StackHashNoteEntry note in notes)
                {
                    if (this.CurrentTaskState.AbortRequested)
                    {
                        throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
                    }

                    BugTrackerNote btEventNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note);
                    String         newBugId    = m_TaskParameters.PlugInContext.EventNoteAdded(m_PlugIns, m_ReportType, btProduct, btFile, btEvent, btEventNote);
                    checkPlugInStatus(m_PlugIns);
                    theEvent = setPlugInBugReference(product, file, theEvent, newBugId);
                    // Reset this in case it has changed.
                    btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature);
                }
            }

            if (request.Cab == null)
            {
                foreach (StackHashCabPackage cab in eventPackage.Cabs)
                {
                    processCab(request, product, file, theEvent, cab.Cab, btProduct, btFile, btEvent);
                    // Reset this in case it has changed.
                    btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature);
                }
            }
            else
            {
                StackHashCab cab = m_Index.GetCab(product, file, theEvent, request.Cab.Id);
                if (cab != null)
                {
                    theEvent = processCab(request, product, file, theEvent, cab, btProduct, btFile, btEvent);
                    // Reset this in case it has changed.
                    btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature);
                }
            }

            // Signal the completion of this event.
            if (((request.Options & StackHashReportOptions.IncludeEvents) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                String newBugId = m_TaskParameters.PlugInContext.EventManualUpdateCompleted(m_PlugIns, m_ReportType, btProduct, btFile, btEvent);
                checkPlugInStatus(m_PlugIns);
                theEvent = setPlugInBugReference(product, file, theEvent, newBugId);
                // Reset this in case it has changed.
                btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature);
            }

            m_CurrentEvent++;
            reportProgress(m_CurrentEvent, m_TotalEvents, eventPackage.EventData.Id);
        }
示例#12
0
        private StackHashEvent processCab(StackHashBugReportData request, StackHashProduct product, StackHashFile file,
                                          StackHashEvent theEvent, StackHashCab cab, BugTrackerProduct btProduct, BugTrackerFile btFile, BugTrackerEvent btEvent)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

            NameValueCollection analysis = new NameValueCollection();

            analysis.Add("DotNetVersion", cab.DumpAnalysis.DotNetVersion);
            analysis.Add("MachineArchitecture", cab.DumpAnalysis.MachineArchitecture);
            analysis.Add("OSVersion", cab.DumpAnalysis.OSVersion);
            analysis.Add("ProcessUpTime", cab.DumpAnalysis.ProcessUpTime);
            analysis.Add("SystemUpTime", cab.DumpAnalysis.SystemUpTime);

            String cabFileName = m_Index.GetCabFileName(product, file, theEvent, cab);

            BugTrackerCab btCab = new BugTrackerCab(cab.Id, cab.SizeInBytes, cab.CabDownloaded, cab.Purged, analysis, cabFileName);

            if (((request.Options & StackHashReportOptions.IncludeCabs) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                String newBugId = m_TaskParameters.PlugInContext.CabAdded(m_PlugIns, m_ReportType, btProduct, btFile, btEvent, btCab);
                checkPlugInStatus(m_PlugIns);
                theEvent = setPlugInBugReference(product, file, theEvent, newBugId);
                // Reset this in case it has changed.
                btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, btEvent.Signature);
            }

            if (((request.Options & StackHashReportOptions.IncludeCabNotes) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                StackHashNotes notes = m_Index.GetCabNotes(product, file, theEvent, cab);
                foreach (StackHashNoteEntry note in notes)
                {
                    if (this.CurrentTaskState.AbortRequested)
                    {
                        throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
                    }

                    BugTrackerNote btEventNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note);
                    String         newBugId    = m_TaskParameters.PlugInContext.CabNoteAdded(m_PlugIns, m_ReportType, btProduct, btFile, btEvent, btCab, btEventNote);
                    checkPlugInStatus(m_PlugIns);
                    theEvent = setPlugInBugReference(product, file, theEvent, newBugId);
                    // Reset this in case it has changed.
                    btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, btEvent.Signature);
                }
            }

            if (((request.Options & StackHashReportOptions.IncludeScriptResults) != 0) ||
                ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0))
            {
                StackHashScriptResultFiles scriptResults = m_TaskParameters.TheScriptResultsManager.GetResultFiles(product, file, theEvent, cab);

                foreach (StackHashScriptResultFile scriptResultFile in scriptResults)
                {
                    if (this.CurrentTaskState.AbortRequested)
                    {
                        throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
                    }
                    try
                    {
                        StackHashScriptResult scriptResult = m_TaskParameters.TheScriptResultsManager.GetResultFileData(product, file, theEvent, cab, scriptResultFile.ScriptName);

                        if (scriptResult != null)
                        {
                            BugTrackerScriptResult btScriptResult = new BugTrackerScriptResult(scriptResult.Name, scriptResult.ScriptVersion,
                                                                                               scriptResult.LastModifiedDate, scriptResult.RunDate, scriptResult.ToString());

                            String newBugId = m_TaskParameters.PlugInContext.DebugScriptExecuted(m_PlugIns, m_ReportType, btProduct, btFile, btEvent, btCab, btScriptResult);
                            checkPlugInStatus(m_PlugIns);
                            theEvent = setPlugInBugReference(product, file, theEvent, newBugId);
                            // Reset this in case it has changed.
                            btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, btEvent.Signature);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        DiagnosticsHelper.LogException(DiagSeverity.Information,
                                                       "Failed to load script file for reporting " + cab.Id.ToString(CultureInfo.InvariantCulture) + " " + scriptResultFile.ScriptName,
                                                       ex);
                    }
                }
            }

            return(theEvent);
        }