예제 #1
0
        public void ScriptResultsAddedNullScriptData()
        {
            IBugTrackerV1Control plugInControl = new FaultDatabaseControl();

            Assert.AreNotEqual(null, plugInControl);

            IBugTrackerV1Context context = plugInControl.CreateContext();

            Assert.AreNotEqual(null, context);
            Assert.AreEqual(1, GetNumberOfActiveProfiles(plugInControl));

            BugTrackerProduct product  = new BugTrackerProduct("StackHash", "1.2.3.4", 1234568);
            BugTrackerFile    file     = new BugTrackerFile("StackHash.dll", "1.2.3.4", 234567);
            BugTrackerEvent   theEvent = new BugTrackerEvent("Reference", "Plugin bug ref", 1111111, "CLR20 - Crash", 122, new NameValueCollection());

            theEvent.Signature["Exception"] = "0x23434";
            BugTrackerCab cab = new BugTrackerCab(12243, 12121, false, true, new NameValueCollection(), "c:\\test\\my.cab");

            cab.AnalysisData["New1"] = "Data1";
            cab.AnalysisData["New2"] = "Data2";

            BugTrackerScriptResult result = new BugTrackerScriptResult("ScriptName", 1, DateTime.Now, DateTime.Now, null);

            context.DebugScriptExecuted(BugTrackerReportType.Automatic, product, file, theEvent, cab, result);

            plugInControl.ReleaseContext(context);
            Assert.AreEqual(0, GetNumberOfActiveProfiles(plugInControl));
        }
예제 #2
0
        public void CabToString()
        {
            NameValueCollection diagnostics = new NameValueCollection();

            diagnostics.Add("Exception", "0x123456");
            diagnostics.Add("Offset", "0x123457");

            BugTrackerCab theCab = new BugTrackerCab(11111111, 98765432, true, false, diagnostics, "c:\\test\\somecab.cab");

            String result = theCab.ToString();

            Assert.AreEqual("Cab: Id=11111111, Size=98765432, Downloaded=True, Purged=False, Path=c:\\test\\somecab.cab\r\n   Exception=0x123456\r\n   Offset=0x123457\r\n", result);
        }
예제 #3
0
        /// <summary>
        /// Process a cab note table update. This may indicate a new item or the change to an existing item.
        /// </summary>
        private bool processCabNoteUpdate(StackHashBugTrackerUpdate update)
        {
            // Get the associated product and file information.
            StackHashProduct   product  = m_Index.GetProduct((int)update.ProductId);
            StackHashFile      file     = m_Index.GetFile(product, (int)update.FileId);
            StackHashEvent     theEvent = m_Index.GetEvent(product, file, new StackHashEvent((int)update.EventId, update.EventTypeName));
            StackHashCab       cab      = m_Index.GetCab(product, file, theEvent, (int)update.CabId);
            StackHashNoteEntry note     = m_Index.GetCabNote((int)update.ChangedObjectId);

            if ((product == null) || (file == null) || (theEvent == null) || (cab == null) || (note == null))
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Cab Note: Inconsistent Update Table Entry");
                return(false);
            }

            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);

            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);

            BugTrackerNote btCabNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note);

            String newBugId = null;

            if (update.TypeOfChange == StackHashChangeType.NewEntry)
            {
                newBugId = m_TaskParameters.PlugInContext.CabNoteAdded(null, BugTrackerReportType.Automatic, btProduct, btFile, btEvent, btCab, btCabNote);
            }

            setPlugInBugReference(product, file, theEvent, newBugId);

            return(true);
        }
예제 #4
0
        /// <summary>
        /// If the report type is automatic then this call indicates that a Debug Script Result has been added to the
        /// StackHash database by way the Cab Analysis task running or the StackHash client manually running a script
        /// on a cab.
        ///
        /// If the report type is manual then this call indicates that an Debug Script Result already exists in the
        /// StackHash database. This is the result of a BugReport task being run.
        ///
        /// scriptResult.ToString() can be used to format the string for addition to a Fault Database system.
        ///
        /// Automatic reports may arrived interleaved with manual reports. This may happen when, say a WinQual sync
        /// is happening at the same time as a manual report is requested.
        ///
        /// A Plugin Bug Reference is stored with the Event data in the StackHash database. This can be manually changed
        /// by the StackHash client user. The plug-in can also change the plugin bug reference by returning the desired
        /// bug reference from this call.
        /// Return null if you do NOT want to change the bug reference stored in the StackHash database.
        /// Return any other string (including an empty string) and this value will be used to overwrite the
        /// plugin bug reference in the StackHash database.
        /// Note that there are 2 bug references:
        ///   The BugReference can be set by the StackHash client user manually. This cannot be changed by the plugin.
        ///   The PlugInBugReference can be set by the StackHash client user manually AND/OR set by the plugin.
        /// </summary>
        /// <param name="reportType">Manual or automatic. If manual identifies what level of report is taking place.</param>
        /// <param name="product">The product to which the file belongs.</param>
        /// <param name="file">The file to which the event belongs.</param>
        /// <param name="theEvent">The event to which the cab belongs.</param>
        /// <param name="cab">The cab to which the debug script result belongs.</param>
        /// <param name="scriptResult">The result of running a debug script on the cab dump file.</param>
        /// <returns>Null - if the plugin bug reference in the StackHash database should not be changed, Otherwise the new value for the plugin bug reference.</returns>
        public string DebugScriptExecuted(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab, BugTrackerScriptResult scriptResult)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (cab == null)
            {
                throw new ArgumentNullException("cab");
            }
            if (scriptResult == null)
            {
                throw new ArgumentNullException("scriptResult");
            }

            // Note that all of the interface objects have a built in ToString() which formats the fields suitably.
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, m_Control.PlugInName, "Debug Script Added: " + scriptResult.ToString());

            // Don't change the plugin bug reference.
            return(null);
        }
예제 #5
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);
        }
예제 #6
0
        /// <summary>
        /// Process a debug script change.
        /// </summary>
        private bool processDebugScriptUpdate(StackHashBugTrackerUpdate update)
        {
            // Get the associated product and file information.
            StackHashProduct product  = m_Index.GetProduct((int)update.ProductId);
            StackHashFile    file     = m_Index.GetFile(product, (int)update.FileId);
            StackHashEvent   theEvent = m_Index.GetEvent(product, file, new StackHashEvent((int)update.EventId, update.EventTypeName));

            DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: getting cab data1");
            StackHashCab cab = m_Index.GetCab(product, file, theEvent, (int)update.CabId);

            DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: getting cab data2");
            StackHashNoteEntry note = m_Index.GetCabNote((int)update.ChangedObjectId);

            if ((product == null) || (file == null) || (theEvent == null) || (cab == null) || (note == null))
            {
                if (product == null)
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: Inconsistent Update Table Entry : product");
                }
                if (file == null)
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: Inconsistent Update Table Entry : file");
                }
                if (theEvent == null)
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: Inconsistent Update Table Entry : the Event");
                }
                if (cab == null)
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: Inconsistent Update Table Entry : cab: " + update.CabId.ToString(CultureInfo.InvariantCulture));
                }
                if (note == null)
                {
                    DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Debug Script: Inconsistent Update Table Entry : note");
                }
                return(false);
            }

            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);

            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);

            BugTrackerNote btCabNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note);

            // A note entry will be written when a script is run. Pick out the name of the script.
            // Format is "Script {0} executed".
            int    startIndex = btCabNote.Note.IndexOf("Script ", StringComparison.OrdinalIgnoreCase) + "Script ".Length;
            int    endIndex   = btCabNote.Note.IndexOf("executed", StringComparison.OrdinalIgnoreCase) - 2;
            int    length     = endIndex - startIndex + 1;
            String scriptName = btCabNote.Note.Substring(startIndex, length);

            StackHashScriptResult stackHashScriptResult = m_TaskParameters.TheScriptResultsManager.GetResultFileData(product, file, theEvent, cab, scriptName);

            if (stackHashScriptResult == null)
            {
                return(false);
            }

            BugTrackerScriptResult btScriptResult = new BugTrackerScriptResult(stackHashScriptResult.Name, stackHashScriptResult.ScriptVersion,
                                                                               stackHashScriptResult.LastModifiedDate, stackHashScriptResult.RunDate, stackHashScriptResult.ToString());

            String newBugId = null;

            if (update.TypeOfChange == StackHashChangeType.NewEntry)
            {
                newBugId = m_TaskParameters.PlugInContext.DebugScriptExecuted(null, BugTrackerReportType.Automatic, btProduct, btFile, btEvent, btCab, btScriptResult);
            }
            setPlugInBugReference(product, file, theEvent, newBugId);

            return(true);
        }
예제 #7
0
        public void LogInCallback()
        {
            // Empty so shouldn't report anything.
            StackHashBugTrackerPlugInSelectionCollection plugIns = new StackHashBugTrackerPlugInSelectionCollection();

            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerTrace.LogMessageHook += new EventHandler <BugTrackerTraceEventArgs>(LogPlugInEvent);

            try
            {
                BugTrackerManager manager = new BugTrackerManager(folders);

                StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();
                plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
                plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
                plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
                plugInSettings.PlugInSettings[0].Enabled = true;

                BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

                Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);
                Assert.AreEqual(true, m_CallBackCount > 0);

                StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
                Assert.AreEqual(1, fullDiagnostics.Count);
                NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

                Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
                Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["FileAddedCount"]);
                Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventAddedCount"]);
                Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);

                BugTrackerProduct product  = new BugTrackerProduct("Name", "Version", 1);
                BugTrackerFile    file     = new BugTrackerFile("FileName", "FileVersion", 2);
                BugTrackerEvent   theEvent = new BugTrackerEvent("BugRef", "PlugInBugRef", 1, "EventTypeName", 1, new NameValueCollection());
                BugTrackerCab     cab      = new BugTrackerCab(1, 100, false, false, new NameValueCollection(), "c:\\test.cab");

                plugInContext.ProductAdded(plugIns, BugTrackerReportType.Automatic, product);
                plugInContext.ProductUpdated(plugIns, BugTrackerReportType.Automatic, product);

                plugInContext.FileAdded(plugIns, BugTrackerReportType.Automatic, product, file);
                plugInContext.FileUpdated(plugIns, BugTrackerReportType.Automatic, product, file);

                plugInContext.EventAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
                plugInContext.EventUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
                plugInContext.EventManualUpdateCompleted(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
                plugInContext.EventNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, new BugTrackerNote());

                plugInContext.CabAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
                plugInContext.CabUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
                plugInContext.CabNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab, new BugTrackerNote());


                fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
                Assert.AreEqual(1, fullDiagnostics.Count);
                diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

                Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
                Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["FileAddedCount"]);
                Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventAddedCount"]);
                Assert.AreEqual("0", diagnostics["EventCompleteCount"]);
                Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);
            }
            finally
            {
                BugTrackerTrace.LogMessageHook -= new EventHandler <BugTrackerTraceEventArgs>(LogPlugInEvent);
            }
        }
예제 #8
0
        public string DebugScriptExecuted(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab, BugTrackerScriptResult scriptResult)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (cab == null)
            {
                throw new ArgumentNullException("cab");
            }
            if (scriptResult == null)
            {
                throw new ArgumentNullException("scriptResult");
            }
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Script Added: " + scriptResult.ToString());
            // If the SetBugId is set then the plugin should have set the bug reference so subsequent calls using that event should
            // also contain the bug reference.
            if (m_Properties["SetBugId"] == "True")
            {
                if (theEvent.PlugInBugReference != "TestPlugInBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture))
                {
                    throw new ArgumentException("Bug ref not set", "theEvent");
                }
            }
            m_ScriptRunCount++;
            String bugId = null;

            if (m_Properties["DebugScriptExecutedBugId"] == "True")
            {
                bugId = "TestDebugScriptExecutedPlugInBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture);
            }

            return(bugId);
        }
예제 #9
0
        public void InvokeEachMethodSpecifyCorrectPlugIn()
        {
            StackHashBugTrackerPlugInSelectionCollection plugIns = new StackHashBugTrackerPlugInSelectionCollection();

            plugIns.Add(new StackHashBugTrackerPlugInSelection("TestPlugIn"));


            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerManager manager = new BugTrackerManager(folders);

            StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();

            plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
            plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
            plugInSettings.PlugInSettings[0].Enabled = true;

            BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

            Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);

            StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");

            Assert.AreEqual(1, fullDiagnostics.Count);
            NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);

            BugTrackerProduct product  = new BugTrackerProduct("Name", "Version", 1);
            BugTrackerFile    file     = new BugTrackerFile("FileName", "FileVersion", 2);
            BugTrackerEvent   theEvent = new BugTrackerEvent("BugRef", "PlugInBugRef", 1, "EventTypeName", 1, new NameValueCollection());
            BugTrackerCab     cab      = new BugTrackerCab(1, 100, false, false, new NameValueCollection(), "c:\\test.cab");

            plugInContext.ProductAdded(plugIns, BugTrackerReportType.Automatic, product);
            plugInContext.ProductUpdated(plugIns, BugTrackerReportType.Automatic, product);

            plugInContext.FileAdded(plugIns, BugTrackerReportType.Automatic, product, file);
            plugInContext.FileUpdated(plugIns, BugTrackerReportType.Automatic, product, file);

            plugInContext.EventAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
            plugInContext.EventUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
            plugInContext.EventManualUpdateCompleted(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
            plugInContext.EventNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, new BugTrackerNote());

            plugInContext.CabAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
            plugInContext.CabUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
            plugInContext.CabNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab, new BugTrackerNote());


            fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
            Assert.AreEqual(1, fullDiagnostics.Count);
            diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("1", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("1", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["FileAddedCount"]);
            Assert.AreEqual("1", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["EventAddedCount"]);
            Assert.AreEqual("1", diagnostics["EventCompleteCount"]);
            Assert.AreEqual("1", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("1", diagnostics["CabAddedCount"]);
            Assert.AreEqual("1", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["CabNoteAddedCount"]);
        }
예제 #10
0
        public string CabNoteAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab, BugTrackerNote note)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (cab == null)
            {
                throw new ArgumentNullException("cab");
            }
            if (note == null)
            {
                throw new ArgumentNullException("note");
            }
            if (cab.CabPathAndFileName == null)
            {
                throw new ArgumentException("Cab path is null", "cab");
            }
            m_LastCabNote = note.Note;
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Cab Note Added: " + note.ToString());

            // If the SetBugId is set then the plugin should have set the bug reference so subsequent calls using that event should
            // also contain the bug reference.
            if (m_Properties["SetBugId"] == "True")
            {
                if (theEvent.PlugInBugReference != "TestPlugInBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture))
                {
                    throw new ArgumentException("Bug ref not set", "theEvent");
                }
            }
            m_CabNoteAddedCount++;

            String bugId = null;

            if (m_Properties["CabNoteAddedBugId"] == "True")
            {
                bugId = "TestCabNoteAddedPlugInBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture);
            }
            if ((m_Properties["ManualCabAddedSetBugId"] == "True") && (reportType != BugTrackerReportType.Automatic))
            {
                bugId = "ManualCabAddedSetBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture);
            }

            return(bugId);
        }
예제 #11
0
        public string CabAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (cab == null)
            {
                throw new ArgumentNullException("cab");
            }
            if (cab.CabPathAndFileName == null)
            {
                throw new ArgumentException("Cab path is null", "cab");
            }
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Cab Added: " + cab.ToString());

            // If the SetBugId is set then the plugin should have set the bug reference so subsequent calls using that event should
            // also contain the bug reference.
            if (m_Properties["SetBugId"] == "True")
            {
                if (theEvent.PlugInBugReference != "TestPlugInBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture))
                {
                    throw new ArgumentException("Bug ref not set", "theEvent");
                }
            }

            String bugId = null;

            if (m_Properties["CabAddedSetBugId"] == "True")
            {
                bugId = "TestCabAddedPlugInBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture);
            }

            if ((m_Properties["ManualCabAddedSetBugId"] == "True") && (reportType != BugTrackerReportType.Automatic))
            {
                if (m_CabsPerEvent.ContainsKey(theEvent.EventId))
                {
                    if (!theEvent.PlugInBugReference.StartsWith("ManualCabAddedSetBugId", StringComparison.OrdinalIgnoreCase))
                    {
                        throw new ArgumentException("Plug-in bug reference should be set already", "theEvent");
                    }
                    m_CabsPerEvent[theEvent.EventId]++;
                }
                else
                {
                    m_CabsPerEvent[theEvent.EventId] = 1;
                }
                bugId = "ManualCabAddedSetBugId" + theEvent.EventId.ToString(CultureInfo.InvariantCulture);
            }
            m_CabAddedCount++;
            return(bugId);
        }
예제 #12
0
 /// <summary>
 /// If the report type is automatic then this call indicates that a Debug Script Result has been added to the
 /// StackHash database by way the Cab Analysis task running or the StackHash client manually running a script
 /// on a cab.
 ///
 /// If the report type is manual then this call indicates that an Debug Script Result already exists in the
 /// StackHash database. This is the result of a BugReport task being run.
 ///
 /// scriptResult.ToString() can be used to format the string for addition to a Fault Database system.
 ///
 /// Automatic reports may arrived interleaved with manual reports. This may happen when, say a WinQual sync
 /// is happening at the same time as a manual report is requested.
 ///
 /// A Plugin Bug Reference is stored with the Event data in the StackHash database. This can be manually changed
 /// by the StackHash client user. The plug-in can also change the plugin bug reference by returning the desired
 /// bug reference from this call.
 /// Return null if you do NOT want to change the bug reference stored in the StackHash database.
 /// Return any other string (including an empty string) and this value will be used to overwrite the
 /// plugin bug reference in the StackHash database.
 /// Note that there are 2 bug references:
 ///   The BugReference can be set by the StackHash client user manually. This cannot be changed by the plugin.
 ///   The PlugInBugReference can be set by the StackHash client user manually AND/OR set by the plugin.
 ///
 /// </summary>
 /// <param name="reportType">Manual or automatic. If manual identifies what level of report is taking place.</param>
 /// <param name="product">The product to which the file belongs.</param>
 /// <param name="file">The file to which the event belongs.</param>
 /// <param name="theEvent">The event to which the cab belongs.</param>
 /// <param name="cab">The cab to which the debug script result belongs.</param>
 /// <param name="scriptResult">The result of running a debug script on the cab dump file.</param>
 /// <returns>Null - if the plugin bug reference in the StackHash database should not be changed, Otherwise the new value for the plugin bug reference.</returns>
 public string DebugScriptExecuted(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab, BugTrackerScriptResult scriptResult)
 {
     return(null);
 }
예제 #13
0
 /// <summary>
 /// If the report type is automatic then this call indicates that a Cab Note has been added to the
 /// StackHash database by way of the StackHash user adding one.
 ///
 /// If the report type is manual then this call indicates that an Cab Note already exists in the
 /// StackHash database. This is the result of a BugReport task being run.
 ///
 /// Automatic reports may arrived interleaved with manual reports. This may happen when, say a WinQual sync
 /// is happening at the same time as a manual report is requested.
 ///
 /// A Plugin Bug Reference is stored with the Event data in the StackHash database. This can be manually changed
 /// by the StackHash client user. The plug-in can also change the plugin bug reference by returning the desired
 /// bug reference from this call.
 /// Return null if you do NOT want to change the bug reference stored in the StackHash database.
 /// Return any other string (including an empty string) and this value will be used to overwrite the
 /// plugin bug reference in the StackHash database.
 /// Note that there are 2 bug references:
 ///   The BugReference can be set by the StackHash client user manually. This cannot be changed by the plugin.
 ///   The PlugInBugReference can be set by the StackHash client user manually AND/OR set by the plugin.
 ///
 /// </summary>
 /// <param name="reportType">Manual or automatic. If manual identifies what level of report is taking place.</param>
 /// <param name="product">The product to which the file belongs.</param>
 /// <param name="file">The file to which the event belongs.</param>
 /// <param name="theEvent">The event to which the cab belongs.</param>
 /// <param name="cab">The cab to which the note belongs.</param>
 /// <param name="note">The cab note to add.</param>
 /// <returns>Null - if the plugin bug reference in the StackHash database should not be changed, Otherwise the new value for the plugin bug reference.</returns>
 public string CabNoteAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab, BugTrackerNote note)
 {
     return(null);
 }
예제 #14
0
 /// <summary>
 /// If the report type is automatic then this call indicates that a Cab has been updated in the
 /// StackHash database by way of: a Synchronize with the WinQual web site; downloading a cab manually from the
 /// StackHash client; or a script providing further diagnostic information.
 ///
 /// This method is not currently called during a manual BugReport.
 ///
 /// A Cab entry indicates that a cab is available on the WinQual site. The cab has not necessarily been
 /// downloaded yet. Once the cab is downloaded, the CabUpdated method will be called with Cab.CabDownloaded == true.
 ///
 /// Cabs are associated with particular events (identified by EventId, EventTypeName).
 ///
 /// Automatic reports may arrived interleaved with manual reports. This may happen when, say a WinQual sync
 /// is happening at the same time as a manual report is requested.
 ///
 /// A Plugin Bug Reference is stored with the Event data in the StackHash database. This can be manually changed
 /// by the StackHash client user. The plug-in can also change the plugin bug reference by returning the desired
 /// bug reference from this call.
 /// Return null if you do NOT want to change the bug reference stored in the StackHash database.
 /// Return any other string (including an empty string) and this value will be used to overwrite the
 /// plugin bug reference in the StackHash database.
 /// Note that there are 2 bug references:
 ///   The BugReference can be set by the StackHash client user manually. This cannot be changed by the plugin.
 ///   The PlugInBugReference can be set by the StackHash client user manually AND/OR set by the plugin.
 ///
 /// </summary>
 /// <param name="reportType">Manual or automatic. If manual identifies what level of report is taking place.</param>
 /// <param name="product">The product to which the file belongs.</param>
 /// <param name="file">The file to which the event belongs.</param>
 /// <param name="theEvent">The event to which the cab belongs.</param>
 /// <param name="cab">The cab being added.</param>
 /// <returns>Null - if the plugin bug reference in the StackHash database should not be changed, Otherwise the new value for the plugin bug reference.</returns>
 public string CabUpdated(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerCab cab)
 {
     return(null);
 }