Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Processes a specific product.
        /// </summary>
        private void processProduct(StackHashBugReportData request, StackHashProduct product)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

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

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

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

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

                if (file != null)
                {
                    processFile(request, product, file);
                }
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Process a file table update. This may indicate a new item or the change to an existing item.
        /// </summary>
        private bool processFileUpdate(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);

            if (product == null)
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing File: Inconsistent Update Table Entry = product not found: " + update.ProductId.ToString(CultureInfo.InvariantCulture));
                return(false);
            }
            if (file == null)
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing File: Inconsistent Update Table Entry = file not found: " + update.FileId.ToString(CultureInfo.InvariantCulture));

                return(false);
            }

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

            if (update.TypeOfChange == StackHashChangeType.NewEntry)
            {
                m_TaskParameters.PlugInContext.FileAdded(null, BugTrackerReportType.Automatic, btProduct, btFile);
            }
            else
            {
                m_TaskParameters.PlugInContext.FileUpdated(null, BugTrackerReportType.Automatic, btProduct, btFile);
            }

            return(true);
        }
Ejemplo n.º 10
0
        public void ProductAdded(BugTrackerReportType reportType, BugTrackerProduct product)
        {
            m_ProductAddedCount++;

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

            if (m_Properties["ProductAddedException"] != null)
            {
                throw new ArgumentException("Test exception");
            }

            if (m_Properties["UnhandledException"] != null)
            {
                // Spawn a new thread to cause the exception.
                Thread exceptionThread = new Thread(delegate()
                {
                    throw new ArgumentException("Thread exception");
                });

                exceptionThread.Start();

                Thread.Sleep(2000);
                return;
            }

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Product Added: " + product.ToString());
        }
Ejemplo n.º 11
0
        public void ProductToString()
        {
            BugTrackerProduct product = new BugTrackerProduct("StackHash", "1.2.3.4", 12345678);

            String result = product.ToString();

            Assert.AreEqual("Product: Id=12345678, Name=StackHash, Version=1.2.3.4\r\n", result);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// If the report type is automatic then this call indicates that a Product has been changed in the
        /// StackHash database by way of a Synchronize with the WinQual web site.
        /// The change may include the number of events stored has increased.
        ///
        /// This method is not currently called for manual reports.
        ///
        /// Note that it is possible that an Updated is reported when no Added has been invoked. This can happen if the
        /// plug-in has been installed after the StackHash database has been created. Performing a manual Bug Report of
        /// the entire database when the plug-in is installed will limit the likelihood of this case.
        ///
        /// 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 being updated.</param>
        public void ProductUpdated(BugTrackerReportType reportType, BugTrackerProduct product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            // Note that all of the interface objects have a built in ToString() which formats the fields suitably.
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, m_Control.PlugInName, "Product Updated: " + product.ToString());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// If the report type is automatic then this call indicates that a Product has been changed in the
        /// StackHash database by way of a Synchronize with the WinQual web site.
        /// The change may include the number of events stored has increased.
        ///
        /// This method is not currently called for manual reports.
        ///
        /// Note that it is possible that an Updated is reported when no Added has been invoked. This can happen if the
        /// plug-in has been installed after the StackHash database has been created. Performing a manual Bug Report of
        /// the entire database when the plug-in is installed will limit the likelihood of this case.
        ///
        /// 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 being updated.</param>
        public void ProductUpdated(BugTrackerReportType reportType, BugTrackerProduct product)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("EmailPluginContext");
            }

            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        public void FileAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "File Added: " + file.ToString());

            m_FileAddedCount++;
        }
Ejemplo n.º 17
0
        public void ProductUpdated(BugTrackerReportType reportType, BugTrackerProduct product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Product Updated: " + product.ToString());
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            m_ProductUpdatedCount++;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// If the report type is automatic then this call indicates that a Product 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 a Product already exists in the
        /// StackHash database. This is the result of a BugReport task being run.
        ///
        /// Note that it is therefore possible that the product 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.
        ///
        /// 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 being added.</param>
        public void ProductAdded(BugTrackerReportType reportType, BugTrackerProduct product)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("EmailPluginContext");
            }

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

            // report new products during sync (not during manual reporting) if configured to in settings
            if ((reportType == BugTrackerReportType.Automatic) &&
                (m_Settings.ReportProducts) &&
                (!m_Settings.IsManualOnly))
            {
                try
                {
                    string subject = string.Format(CultureInfo.CurrentCulture,
                                                   StackHash.EmailPlugin.Properties.Resources.ProductAdded_SubjectTemplate,
                                                   product.ProductName,
                                                   product.ProductVersion);

                    string message = string.Format(CultureInfo.CurrentCulture,
                                                   StackHash.EmailPlugin.Properties.Resources.ProductAdded_MessageTemplate,
                                                   product.ProductName,
                                                   product.ProductVersion,
                                                   product.ProductId);

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

                    m_FailedEmails++;
                    m_LastException = ex;

                    throw;
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// If the report type is automatic then this call indicates that a File 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 a File already exists in the
        /// StackHash database. This is the result of a BugReport task being run.
        ///
        /// 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 file 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.
        ///
        /// 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 being added.</param>
        public void FileAdded(BugTrackerReportType reportType, BugTrackerProduct product, BugTrackerFile file)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("EmailPluginContext");
            }

            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
        }
Ejemplo n.º 20
0
        public void ProductUpdated()
        {
            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);

            context.ProductUpdated(BugTrackerReportType.Automatic, product);

            plugInControl.ReleaseContext(context);
            Assert.AreEqual(0, GetNumberOfActiveProfiles(plugInControl));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// If the report type is automatic then this call indicates that a Product 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 a Product already exists in the
        /// StackHash database. This is the result of a BugReport task being run.
        ///
        /// Note that it is therefore possible that the product 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.
        ///
        /// 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 being added.</param>
        public void ProductAdded(BugTrackerReportType reportType, BugTrackerProduct product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            if (reportType == BugTrackerReportType.Automatic)
            {
                // Do automatic processing here. i.e. the result of a WinQualSync Task.
            }
            else
            {
                // Do manual processing here. i.e. the result of a manual BugReport Task.
            }

            // Note that all of the interface objects have a built in ToString() which formats the fields suitably.
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, m_Control.PlugInName, "Product Added: " + product.ToString());
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
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));
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
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));
        }
Ejemplo n.º 27
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);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Process a product table update. This may indicate a new item or the change to an existing item.
        /// </summary>
        private bool processProductUpdate(StackHashBugTrackerUpdate update)
        {
            // Get the associated product information.
            StackHashProduct product = m_Index.GetProduct((int)update.ProductId);

            if (product == null)
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Product: Inconsistent Update Table Entry");
                return(false);
            }

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

            if (update.TypeOfChange == StackHashChangeType.NewEntry)
            {
                m_TaskParameters.PlugInContext.ProductAdded(null, BugTrackerReportType.Automatic, btProduct);
            }
            else
            {
                m_TaskParameters.PlugInContext.ProductUpdated(null, BugTrackerReportType.Automatic, btProduct);
            }

            return(true);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Processes a specific file.
        /// </summary>
        private void processFile(StackHashBugReportData request, StackHashProduct product, StackHashFile file)
        {
            if (this.CurrentTaskState.AbortRequested)
            {
                throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins");
            }

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

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

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

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

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


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

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

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

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

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

                if ((eventPackages != null) && (eventPackages.Count == 1))
                {
                    processEventPackage(request, product, file, eventPackages[0]);
                }
            }
        }
Ejemplo n.º 30
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);
        }