示例#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 EventToString()
        {
            NameValueCollection signature = new NameValueCollection();

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

            BugTrackerEvent theEvent = new BugTrackerEvent("Bug 1234", "Plugin bug ref", 12345678, "CLR20 32-Bit", 10000, signature);

            String result = theEvent.ToString();

            Assert.AreEqual("Event: Id=12345678, EventTypeName=CLR20 32-Bit, BugReference=Bug 1234, TotalHits=10000\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
        public void EventAddedNoEventSignature()
        {
            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());

            context.EventAdded(BugTrackerReportType.Automatic, product, file, theEvent);

            plugInControl.ReleaseContext(context);
            Assert.AreEqual(0, GetNumberOfActiveProfiles(plugInControl));
        }
示例#5
0
        /// <summary>
        /// Process an event note table update. This may indicate a new item or the change to an existing item.
        /// </summary>
        private bool processEventNoteUpdate(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));
            StackHashNoteEntry note     = m_Index.GetEventNote((int)update.ChangedObjectId);

            if ((product == null) || (file == null) || (theEvent == null) || (note == null))
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Event 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);


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

            String newBugId = null;

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

            setPlugInBugReference(product, file, theEvent, newBugId);

            return(true);
        }
示例#6
0
        public void EventNoteAdded()
        {
            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";
            BugTrackerNote note = new BugTrackerNote(DateTime.Now, "Source", "MarkJ", "Hello from me");

            context.EventNoteAdded(BugTrackerReportType.Automatic, product, file, theEvent, note);

            plugInControl.ReleaseContext(context);
            Assert.AreEqual(0, GetNumberOfActiveProfiles(plugInControl));
        }
示例#7
0
        /// <summary>
        /// This method is called when the processing of an Event has completed. Events have associated Cabs, Scripts and notes which
        /// may all be reported during a MANUAL Bug Report. This call effectively delimits the reporting of all
        /// information associated with an event so, if desired, the plug-in can gather all of the information together in one
        /// go for sending to the fault database. This may improve performance for events with large amounts of stored data.
        ///
        /// The plug-in may thus see...
        ///    EventAdded
        ///    EventNoteAdded, EventNoteAdded,...
        ///    CabAdded, CabAdded,...
        ///    CabNoteAdded, CabNoteAdded,...
        ///    ScriptResultAdded, ScriptResultAdded,...
        ///    EventManualUpdateCompleted.
        ///
        /// 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.
        ///
        /// 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.
        /// </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 whose details have now been reported.</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 EventManualUpdateCompleted(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("EmailPluginContext");
            }

            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }

            // Don't change the plugin bug reference. Setting this to any other value will update the plugin bug reference in the
            // StackHash database.
            String pluginBugReference = null;

            return(pluginBugReference);
        }
示例#8
0
        /// <summary>
        /// If the report type is automatic then this call indicates that an Event note has been added to the
        /// StackHash database by a StackHash client.
        ///
        /// If the report type is manual then this call indicates that an Event note already exists in the
        /// StackHash database. This is the result of a BugReport task being run.
        ///
        /// Note that it is possible that the event note existence has already been reported, so the
        /// code here should check, if necessary, that this is not a duplicate before creating new items in
        /// the destination bug tracking system.
        ///
        /// Important Note: AN EVENT IS IDENTIFIED BY ITS ID AND EVENTTYPENAME TOGETHER. Therefore it is possible to
        /// have events with the same ID but different 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 note belongs.</param>
        /// <param name="note">The event 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 EventNoteAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerNote note)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (note == null)
            {
                throw new ArgumentNullException("note");
            }

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

            // Don't change the bug reference.
            return(null);
        }
示例#9
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);
        }
示例#10
0
        public string EventNoteAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent, BugTrackerNote note)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (note == null)
            {
                throw new ArgumentNullException("note");
            }
            m_LastEventNote = note.Note;

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Event 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_EventNoteAddedCount++;
            return(null);
        }
示例#11
0
        public string EventAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            m_EventAddedCount++;
            String bugId = theEvent.BugReference;

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

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Event Added: " + theEvent.ToString());
            return(bugId);
        }
示例#12
0
        public string EventManualUpdateCompleted(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Event Manual Update Completed: " + theEvent.ToString());

            m_EventCompleteCount++;
            return(theEvent.BugReference);
        }
示例#13
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);
 }
示例#14
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);
 }
示例#15
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);
 }
示例#16
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);
        }
示例#17
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);
        }
示例#18
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);
        }
示例#19
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);
        }
示例#20
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);
        }
示例#21
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"]);
        }
示例#22
0
        /// <summary>
        /// This method is called when the processing of an Event has completed. Events have associated Cabs, Scripts and notes which
        /// may all be reported during a MANUAL Bug Report. This call effectively delimits the reporting of all
        /// information associated with an event so, if desired, the plug-in can gather all of the information together in one
        /// go for sending to the fault database. This may improve performance for events with large amounts of stored data.
        ///
        /// The plug-in may thus see...
        ///    EventAdded
        ///    EventNoteAdded, EventNoteAdded,...
        ///    CabAdded, CabAdded,...
        ///    CabNoteAdded, CabNoteAdded,...
        ///    ScriptResultAdded, ScriptResultAdded,...
        ///    EventManualUpdateCompleted.
        ///
        /// 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.
        ///
        /// 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.
        /// </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 whose details have now been reported.</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 EventManualUpdateCompleted(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }

            // Don't change the bug reference. Setting this to any other value will update the bug reference in the
            // StackHash database.
            String plugInBugId = null;

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

            return(plugInBugId);
        }
示例#23
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);
            }
        }
示例#24
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);
        }
示例#25
0
        /// <summary>
        /// If the report type is automatic then this call indicates that an Event has been added to the
        /// StackHash database by way of a Synchronize with the WinQual web site.
        ///
        /// If the report type is manual then this call indicates that an Event already exists in the
        /// StackHash database. This is the result of a BugReport task being run.
        ///
        /// 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.
        ///
        /// Files are mapped to products on the WinQual site. Note that the same file may be mapped to one
        /// or more products and therefore the same event (associated with a file) may "belong" refer to more
        /// than one product.
        ///
        /// Note that it is therefore possible that the event existence has already been reported, so the
        /// code here should check, if necessary, that this is not a duplicate before creating new items in
        /// the destination bug tracking system.
        ///
        /// Important Note: AN EVENT IS IDENTIFIED BY ITS ID AND EVENTTYPENAME TOGETHER. Therefore it is possible to
        /// have events with the same ID but different EventTypeName.
        ///
        /// Note also that event IDs can be negative. This is a consequence of the WinQual site storing event numbers as
        /// 32 bit signed quantities. When the event ID range was exhausted the WinQual events went negative. The StackHash
        /// database stores event IDs as 64 bit signed quantities to future proof against any future changes in the
        /// WinQual values.
        ///
        /// 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.
        /// </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 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 EventAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file, BugTrackerEvent theEvent)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("EmailPluginContext");
            }

            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }

            // do nothing on an automatic report if we're in manaual mode
            if ((reportType == BugTrackerReportType.Automatic) && (m_Settings.IsManualOnly))
            {
                return(null);
            }

            string subjectTemplate = null;
            string messageTemplate = null;

            if (reportType == BugTrackerReportType.Automatic)
            {
                subjectTemplate = StackHash.EmailPlugin.Properties.Resources.EventAdded_SubjectTemplate;
                messageTemplate = StackHash.EmailPlugin.Properties.Resources.EventAdded_MessageTemplate;
            }
            else
            {
                subjectTemplate = StackHash.EmailPlugin.Properties.Resources.EventManualReport_SubjectTemplate;
                messageTemplate = StackHash.EmailPlugin.Properties.Resources.EventManaulReport_MessageTemplate;
            }

            // build a string containing all event signature parameters
            StringBuilder eventSignatureBuilder = new StringBuilder();

            foreach (string key in theEvent.Signature.Keys)
            {
                eventSignatureBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0} = {1}", key, theEvent.Signature[key]);
                eventSignatureBuilder.AppendLine();
                eventSignatureBuilder.AppendLine();
            }

            try
            {
                string subject = string.Format(CultureInfo.CurrentCulture,
                                               subjectTemplate,
                                               product.ProductName,
                                               product.ProductVersion,
                                               theEvent.EventId);

                string message = string.Format(CultureInfo.CurrentCulture,
                                               messageTemplate,
                                               product.ProductName,
                                               product.ProductVersion,
                                               theEvent.EventId,
                                               theEvent.EventTypeName,
                                               theEvent.TotalHits,
                                               eventSignatureBuilder);

                m_Settings.SendEmail(subject, message);
                m_EmailsSent++;
            }
            catch (Exception ex)
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.ComponentFatal,
                                           m_Control.PlugInName,
                                           string.Format(CultureInfo.InvariantCulture,
                                                         "Failed to send event email: {0}",
                                                         ex));

                m_LastException = ex;
                m_FailedEmails++;

                throw;
            }

            // Don't change the plugin bug reference. Setting this to any other value will update the plugin bug reference in the
            // StackHash database.
            string pluginBugReference = null;

            return(pluginBugReference);
        }