Пример #1
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);
        }
Пример #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Context disposing");
     }
 }
Пример #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);
        }
Пример #4
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);
        }
Пример #5
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());
        }
Пример #6
0
 /// <summary>
 /// A public default constructor must be defined.
 /// </summary>
 public CommandLinePluginControl()
 {
     // You can use the static LogMessage to log a message to the StackHash service log file which is written to
     // c:\ProgramData\StackHash on Vista and Win7 and to c:\Documents and Settings\All Users\Application Data\StackHash
     // on XP systems.
     BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "CommandLinePluginControl Interface created");
 }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
0
        public IBugTrackerV1Context CreateContext()
        {
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Creating new context");
            TestBugTrackerPlugInContext newContext = new TestBugTrackerPlugInContext();

            m_AllContexts.Add(newContext);
            return(newContext);
        }
Пример #10
0
        /// <summary>
        /// Called by the StackHash client to create a context. The StackHash client will not directly
        /// instantiate an instance of the Context class. This gives the plug-in the opportunity to
        /// reject instance creation.
        /// A context will have its own settings.
        /// The context will be created by StackHash when the StackHash profile is activated. This will be
        /// on service startup or may happen when the user manually activates the profile at the StackHash
        /// client.
        /// </summary>
        /// <returns>Reference to the created instance.</returns>
        public IBugTrackerV1Context CreateContext()
        {
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Creating context");

            FaultDatabaseContext newContext = new FaultDatabaseContext(this);

            m_ActiveContexts.Add(newContext);
            return(newContext);
        }
Пример #11
0
        /// <summary>
        /// Called by the StackHash client to create a context. The StackHash client will not directly
        /// instantiate an instance of the Context class. This gives the plug-in the opportunity to
        /// reject instance creation.
        /// A context will have its own settings.
        /// The context will be created by StackHash when the StackHash profile is activated. This will be
        /// on service startup or may happen when the user manually activates the profile at the StackHash
        /// client.
        /// </summary>
        /// <returns>Reference to the created instance.</returns>
        public IBugTrackerV1Context CreateContext()
        {
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Creating CommandLinePluginContext");

            CommandLinePluginContext newContext = new CommandLinePluginContext(this);

            m_ActiveContexts.Add(newContext);
            return(newContext);
        }
Пример #12
0
        /// <summary>
        /// A public default constructor must be defined.
        /// </summary>
        public FaultDatabaseControl()
        {
            m_DefaultProperties[s_LogVerboseProperty]    = "0";     // 0 = Normal logging, 1 = Verbose logging.
            m_DefaultProperties[s_EnableContextProperty] = "1";     // 0 = Enable the plug-in, 1 = Disable plug-in.

            // You can use the static LogMessage to log a message to the StackHash service log file which is written to
            // c:\ProgramData\StackHash on Vista and Win7 and to c:\Documents and Settings\All Users\Application Data\StackHash
            // on XP systems.
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Control Interface created");
        }
Пример #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 (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());
        }
Пример #14
0
        public TestBugTrackerPlugInContext(TestBugTrackerPlugInControl controller)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "context created");
            m_Controller = controller;
            m_Properties = m_Controller.PlugInDefaultProperties;
        }
Пример #15
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);
        }
Пример #16
0
        public void SetSelectPropertyValues(NameValueCollection propertiesToSet)
        {
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Setting properties");
            if (propertiesToSet == null)
            {
                throw new ArgumentNullException("propertiesToSet");
            }

            foreach (String key in propertiesToSet)
            {
                m_Properties[key] = propertiesToSet[key];
            }
        }
Пример #17
0
        /// <summary>
        /// Releases a context that is no longer required.
        /// The context will be released by StackHash when the StackHash profile is deactivated. This will be
        /// on service closedown or may happen when the user manually deactivates the profile at the StackHash
        /// client.
        /// Once a context has been released, StackHash will no longer attempt to invoke it.
        /// </summary>
        /// <param name="context">The context to release.</param>
        public void ReleaseContext(IBugTrackerV1Context context)
        {
            CommandLinePluginContext commandLinePluginContext = context as CommandLinePluginContext;

            if (context != null)
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Releasing CommandLinePluginContext");
                m_ActiveContexts.Remove(commandLinePluginContext);
            }
            else
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Warning, s_PlugInName, "Null or invalid context passed to ReleaseContext");
            }
        }
Пример #18
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++;
        }
Пример #19
0
        /// <summary>
        /// Releases a context that is no longer required.
        /// The context will be released by StackHash when the StackHash profile is deactivated. This will be
        /// on service closedown or may happen when the user manually deactivates the profile at the StackHash
        /// client.
        /// Once a context has been released, StackHash will no longer attempt to invoke it.
        /// </summary>
        /// <param name="context">The context to release.</param>
        public void ReleaseContext(IBugTrackerV1Context context)
        {
            EmailPluginContext emailPluginContext = context as EmailPluginContext;

            if (emailPluginContext != null)
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Releasing EmailPluginContext");
                m_ActiveContexts.Remove(emailPluginContext);
                emailPluginContext.Dispose();
            }
            else
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Warning, s_PlugInName, "Null or invalid context passed to ReleaseContext");
            }
        }
Пример #20
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++;
        }
Пример #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 (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;
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Releases a context that is no longer required.
        /// The context will be released by StackHash when the StackHash profile is deactivated. This will be
        /// on service closedown or may happen when the user manually deactivates the profile at the StackHash
        /// client.
        /// Once a context has been released, StackHash will no longer attempt to invoke it.
        /// </summary>
        /// <param name="context">The context to release.</param>
        public void ReleaseContext(IBugTrackerV1Context context)
        {
            FogBugzPluginContext fogBugzPluginContext = context as FogBugzPluginContext;

            if (context != null)
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Releasing FogBugzPluginContext");
                m_ActiveContexts.Remove(fogBugzPluginContext);

                // logout of FogBugz (if we logged in)
                fogBugzPluginContext.FogBugzApiLogout();
            }
            else
            {
                BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Warning, s_PlugInName, "Null or invalid context passed to ReleaseContext");
            }
        }
Пример #23
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());
        }
Пример #24
0
        public TestBugTrackerPlugInControl()
        {
            s_ThisInstance = this;

            m_Properties["Param1"]  = "1";
            m_Properties["Param2"]  = "2";
            m_Properties["Param3"]  = "3";
            m_Properties["Param4"]  = "4";
            m_Properties["Param5"]  = "5";
            m_Properties["Param6"]  = "6";
            m_Properties["Param7"]  = "7";
            m_Properties["Param8"]  = "8";
            m_Properties["Param9"]  = "9";
            m_Properties["Param10"] = "10";
            m_Properties["Param11"] = "11";
            m_Properties["Param12"] = "12";
            m_Properties["Param13"] = "Much longer parameter value";
            BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Control Interface created");
        }
Пример #25
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);
        }
Пример #26
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);
        }
Пример #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);
        }
Пример #28
0
 public void ReleaseContext(IBugTrackerV1Context context)
 {
     BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Releasing context");
     m_AllContexts.Remove(context as TestBugTrackerPlugInContext);
 }
Пример #29
0
 /// <summary>
 /// Releases a context that is no longer required.
 /// The context will be released by StackHash when the StackHash profile is deactivated. This will be
 /// on service closedown or may happen when the user manually deactivates the profile at the StackHash
 /// client.
 /// Once a context has been released, StackHash will no longer attempt to invoke it.
 /// </summary>
 /// <param name="context">The context to release.</param>
 public void ReleaseContext(IBugTrackerV1Context context)
 {
     BugTrackerTrace.LogMessage(BugTrackerTraceSeverity.Information, s_PlugInName, "Releasing context");
     m_ActiveContexts.Remove(context as FaultDatabaseContext);
 }
Пример #30
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);
        }