public static void Publish(string fileName, Exception exception, NameValueCollection additionalInfo)
        {
            try
            {

                // Publish the exception based on Configuration Settings and then may be loop thru the config and log for all of them.

                //commenting below line as of now -let log decide where to log the exceptions.
                //if (ConfigManager.Read(EXCEPTIONMANAGEMENT_CONFIG_SECTION) != null) 
                {
                    //Need to do get values from config here
                    if (m_IObjExceptionPublisher == null)
                        m_IObjExceptionPublisher = GetExceptionObject("APPLICATION");

                    m_IObjExceptionPublisher.Publish(fileName, exception, additionalInfo, null);
                }


            }
            catch (Exception exp)
            {
                // Publish the exception thrown within the ExceptionManager.
                //We should be adding additional stuff here so that it will be logged to event viewer
                PublishInternalException(exp, null);
            }
        }
Exemplo n.º 2
0
        }         // End Publish(Exception exception, NameValueCollection AdditionalInfo)

        /// <summary>
        /// Private static helper method to publish the exception information to a custom publisher.
        /// </summary>
        /// <param name="exception">The exception object whose information should be published.</param>
        /// <param name="additionalInfo">A collection of additional data that should be published along with the exception information.</param>
        /// <param name="publisher">The PublisherSettings that contains the values of the publishers configuration.</param>
        private static void PublishToCustomPublisher(Exception exception, NameValueCollection additionalInfo, PublisherSettings publisher)
        {
            try
            {
                // Check if the exception format is "xml".
                if (publisher.ExceptionFormat == PublisherFormat.Xml)
                {
                    // If it is load the IExceptionXmlPublisher interface on the custom publisher.

                    // Instantiate the class
                    IExceptionXmlPublisher XMLPublisher = (IExceptionXmlPublisher)Activate(publisher.AssemblyName, publisher.TypeName);

                    // Publish the exception and any additional information
                    XMLPublisher.Publish(SerializeToXml(exception, additionalInfo), publisher.OtherAttributes);
                }
                // Otherwise load the IExceptionPublisher interface on the custom publisher.
                else
                {
                    // Instantiate the class
                    IExceptionPublisher Publisher = (IExceptionPublisher)Activate(publisher.AssemblyName, publisher.TypeName);

                    // Publish the exception and any additional information
                    Publisher.Publish(exception, additionalInfo, publisher.OtherAttributes);
                }
            }
            catch (Exception e)
            {
                CustomPublisherException publisherException = new CustomPublisherException(resourceManager.GetString("RES_CUSTOM_PUBLISHER_FAILURE_MESSAGE"), publisher.AssemblyName, publisher.TypeName, publisher.ExceptionFormat, e);
                publisherException.AdditionalInformation.Add(publisher.OtherAttributes);

                throw(publisherException);
            }
        }
        public static void Publish(string fileName, Exception exception, NameValueCollection additionalInfo)
        {
            try
            {
                // Publish the exception based on Configuration Settings and then may be loop thru the config and log for all of them.

                //commenting below line as of now -let log decide where to log the exceptions.
                //if (ConfigManager.Read(EXCEPTIONMANAGEMENT_CONFIG_SECTION) != null)
                {
                    //Need to do get values from config here
                    if (m_IObjExceptionPublisher == null)
                    {
                        m_IObjExceptionPublisher = GetExceptionObject("APPLICATION");
                    }

                    m_IObjExceptionPublisher.Publish(fileName, exception, additionalInfo, null);
                }
            }
            catch (Exception exp)
            {
                // Publish the exception thrown within the ExceptionManager.
                //We should be adding additional stuff here so that it will be logged to event viewer
                PublishInternalException(exp, null);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandCoordinator">CommandCoordinator</see>
 /// </summary>
 /// <param name="commandHandlerManager">A <see cref="ICommandHandlerManager"/> for handling commands</param>
 /// <param name="commandContextManager">A <see cref="ICommandContextManager"/> for establishing a <see cref="CommandContext"/></param>
 /// <param name="commandSecurityManager">A <see cref="ICommandSecurityManager"/> for dealing with security and commands</param>
 /// <param name="commandValidators">A <see cref="ICommandValidators"/> for validating a <see cref="ICommand"/> before handling</param>
 /// <param name="localizer">A <see cref="ILocalizer"/> to use for controlling localization of current thread when handling commands</param>
 /// <param name="exceptionPublisher">An <see cref="IExceptionPublisher"/> to send exceptions to</param>
 public CommandCoordinator(
     ICommandHandlerManager commandHandlerManager,
     ICommandContextManager commandContextManager,
     ICommandSecurityManager commandSecurityManager,
     ICommandValidators commandValidators,
     ILocalizer localizer,
     IExceptionPublisher exceptionPublisher)
 {
     _commandHandlerManager    = commandHandlerManager;
     _commandContextManager    = commandContextManager;
     _commandSecurityManager   = commandSecurityManager;
     _commandValidationService = commandValidators;
     _localizer          = localizer;
     _exceptionPublisher = exceptionPublisher;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandCoordinator">CommandCoordinator</see>
 /// </summary>
 /// <param name="commandHandlerManager">A <see cref="ICommandHandlerManager"/> for handling commands</param>
 /// <param name="commandContextManager">A <see cref="ICommandContextManager"/> for establishing a <see cref="CommandContext"/></param>
 /// <param name="commandSecurityManager">A <see cref="ICommandSecurityManager"/> for dealing with security and commands</param>
 /// <param name="commandValidators">A <see cref="ICommandValidators"/> for validating a <see cref="ICommand"/> before handling</param>
 /// <param name="localizer">A <see cref="ILocalizer"/> to use for controlling localization of current thread when handling commands</param>
 /// <param name="exceptionPublisher">An <see cref="IExceptionPublisher"/> to send exceptions to</param>
 public CommandCoordinator(
     ICommandHandlerManager commandHandlerManager,
     ICommandContextManager commandContextManager,
     ICommandSecurityManager commandSecurityManager,
     ICommandValidators commandValidators,
     ILocalizer localizer,
     IExceptionPublisher exceptionPublisher)
 {
     _commandHandlerManager = commandHandlerManager;
     _commandContextManager = commandContextManager;
     _commandSecurityManager = commandSecurityManager;
     _commandValidationService = commandValidators;
     _localizer = localizer;
     _exceptionPublisher = exceptionPublisher;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of <see cref="QueryCoordinator"/>
 /// </summary>
 /// <param name="typeDiscoverer"><see cref="ITypeDiscoverer"/> to use for discovering <see cref="IQueryProviderFor{T}"/> implementations</param>
 /// <param name="container"><see cref="IContainer"/> for getting instances of <see cref="IQueryProviderFor{T}">query providers</see></param>
 /// <param name="fetchingSecurityManager"><see cref="IFetchingSecurityManager"/> to use for securing <see cref="IQuery">queries</see></param>
 /// <param name="validator"><see cref="IQueryValidator"/> to use for validating <see cref="IQuery">queries</see></param>
 /// <param name="filters"><see cref="IReadModelFilters">Filters</see> used to filter any of the read models coming back after a query</param>
 /// <param name="exceptionPublisher">An <see cref="IExceptionPublisher"/> to send exceptions to</param>
 public QueryCoordinator(
     ITypeDiscoverer typeDiscoverer,
     IContainer container,
     IFetchingSecurityManager fetchingSecurityManager,
     IQueryValidator validator,
     IReadModelFilters filters,
     IExceptionPublisher exceptionPublisher)
 {
     _typeDiscoverer          = typeDiscoverer;
     _container               = container;
     _fetchingSecurityManager = fetchingSecurityManager;
     _validator               = validator;
     _filters            = filters;
     _exceptionPublisher = exceptionPublisher;
     DiscoverQueryTypesPerTargetType();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of <see cref="QueryCoordinator"/>
 /// </summary>
 /// <param name="typeDiscoverer"><see cref="ITypeDiscoverer"/> to use for discovering <see cref="IQueryProviderFor{T}"/> implementations</param>
 /// <param name="container"><see cref="IContainer"/> for getting instances of <see cref="IQueryProviderFor{T}">query providers</see></param>
 /// <param name="fetchingSecurityManager"><see cref="IFetchingSecurityManager"/> to use for securing <see cref="IQuery">queries</see></param>
 /// <param name="validator"><see cref="IQueryValidator"/> to use for validating <see cref="IQuery">queries</see></param>
 /// <param name="filters"><see cref="IReadModelFilters">Filters</see> used to filter any of the read models coming back after a query</param>
 /// <param name="exceptionPublisher">An <see cref="IExceptionPublisher"/> to send exceptions to</param>
 public QueryCoordinator(
     ITypeDiscoverer typeDiscoverer,
     IContainer container,
     IFetchingSecurityManager fetchingSecurityManager,
     IQueryValidator validator,
     IReadModelFilters filters,
     IExceptionPublisher exceptionPublisher)
 {
     _typeDiscoverer = typeDiscoverer;
     _container = container;
     _fetchingSecurityManager = fetchingSecurityManager;
     _validator = validator;
     _filters = filters;
     _exceptionPublisher = exceptionPublisher;
     DiscoverQueryTypesPerTargetType();
 }
Exemplo n.º 8
0
 public RestServiceRouteHttpHandler(
     Type type,
     string url,
     IRequestParamsFactory factory,
     IRestServiceMethodInvoker invoker,
     IContainer container,
     ISecurityManager securityManager,
     IExceptionPublisher exceptionPublisher)
 {
     _type               = type;
     _url                = url;
     _factory            = factory;
     _invoker            = invoker;
     _container          = container;
     _securityManager    = securityManager;
     _exceptionPublisher = exceptionPublisher;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Adds the publisher.
        /// </summary>
        /// <param name="publisher">The publisher.</param>
        /// <param name="parameters">The parameters.</param>
        public void AddPublisher(IExceptionPublisher publisher, NameValueCollection parameters)
        {
            lock (_publishers)
            {
                var attributes = new NodeAttributes()
                {
                    NodeName = "publisher"
                };
                attributes.Attributes.Add(parameters);

                _publishers.Add(new PublisherInfo()
                {
                    PublisherAttributes = attributes,
                    Publisher           = publisher
                });
            }
        }
Exemplo n.º 10
0
        public static void AddHandler(bool screenshot, bool showUser, bool kill, IExceptionPublisher publisher)
        {
            _makeScreenshot = screenshot;
            _logToUI        = showUser;

            // track the parent assembly that set up error handling
            // need to call this NOW so we set it appropriately; otherwise
            // we may get the wrong assembly at exception time!
            if (Assembly.GetEntryAssembly() == null)
            {
                _parentAssembly = Assembly.GetCallingAssembly();
            }
            else
            {
                _parentAssembly = Assembly.GetEntryAssembly();
            }

            // Attach handlers
            m_publisher = publisher;

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionHandler);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
        }
        /// <summary>
        /// Method to publish internal exception - to be published to eventviewer
        /// This has been coded as seperate method so that we can have futher enhancements.
        /// </summary>

        internal static void PublishInternalException(Exception exception, NameValueCollection additionalInfo)
        {

            //m_IObjExceptionPublisher.Publish(exception, additionalInfo, null);
            m_IObjInternalExceptionPublisher = GetExceptionObject("INTERNAL");
            m_IObjInternalExceptionPublisher.Publish(exception, additionalInfo, null);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Adds the publisher.
 /// </summary>
 /// <param name="publisher">The publisher.</param>
 public void AddPublisher(IExceptionPublisher publisher)
 {
     AddPublisher(publisher, new NameValueCollection());
 }
        /// <summary>
        /// Method to publish internal exception - to be published to eventviewer
        /// This has been coded as seperate method so that we can have futher enhancements.
        /// </summary>

        internal static void PublishInternalException(Exception exception, NameValueCollection additionalInfo)
        {
            //m_IObjExceptionPublisher.Publish(exception, additionalInfo, null);
            m_IObjInternalExceptionPublisher = GetExceptionObject("INTERNAL");
            m_IObjInternalExceptionPublisher.Publish(exception, additionalInfo, null);
        }