-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigaroWebEventProvider.cs
More file actions
139 lines (126 loc) · 5.34 KB
/
FigaroWebEventProvider.cs
File metadata and controls
139 lines (126 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*************************************************************************************************
*
* THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
* PARTICULAR PURPOSE.
*
*************************************************************************************************/
using System;
using System.Configuration.Provider;
using System.Web.Configuration;
using System.Web.Management;
using Figaro.Web.ApplicationServices;
using Figaro.Web.ApplicationServices.Data;
namespace Figaro.Web.ApplicationServices
{
/// <summary>
/// Custom web event provider that exports events into a Figaro XML database.
/// </summary>
public sealed class FigaroWebEventProvider : WebEventProvider
{
private WebEventData data;
/// <summary>
/// Creates a new instance of the FigaroWebProvider class.
/// </summary>
public FigaroWebEventProvider()
{
Init();
}
private void Init()
{
System.Configuration.Configuration cfg = null;
try
{
cfg = WebConfigurationManager.OpenWebConfiguration("~/web.config");
}
catch (Exception ex)
{
var e = ExceptionHandler.HandleException(ex, "FigaroWebEventProvider ctor");
if (e != null) throw e;
}
var section = cfg != null ? cfg.GetSection("system.web/healthMonitoring") as HealthMonitoringSection :
WebConfigurationManager.GetSection("system.web/healthMonitoring") as HealthMonitoringSection;
if (section == null) throw new ProviderException("No membership section found in configuration file.");
var settings = section.Providers["FigaroWebEventProvider"];
if (settings == null) throw new ProviderException("No FigaroWebEventProvider configuration found in healthMonitoring section.");
Initialize(settings.Name, settings.Parameters);
}
/// <summary>
/// Initializes the provider.
/// </summary>
/// <param name="name">The friendly name of the provider.</param>
/// <param name="config">A collection of the
/// name/value pairs representing the provider-specific
/// attributes specified in the configuration for this
/// provider.
/// </param>
/// <exception cref="T:System.ArgumentNullException">The name of the provider is <see langword="null"/>.</exception>
/// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
/// <exception cref="T:System.InvalidOperationException">
/// An attempt is made to call
/// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"/>
/// on a provider after the provider has already been initialized.
/// </exception>
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
if (data != null && data.Initialized) return;
base.Initialize(name, config);
if (null == config["container"])
throw new ArgumentException("container is a required setting for FigaroWebEventProvider.");
data = new WebEventData(config["container"],config["manager"],typeof(WebBaseEvent));
}
/// <summary>
/// Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).
/// </summary>
/// <returns>
/// A brief, friendly description suitable for display in administrative tools or other UIs.
/// </returns>
public override string Description
{
get
{
return "Figaro XML Database Provider for ASP.NET web events and health monitoring.";
}
}
/// <summary>
/// Gets the friendly name used to refer to the provider during configuration.
/// </summary>
/// <returns>
/// The friendly name used to refer to the provider during configuration.
/// </returns>
public override string Name
{
get
{
return "Figaro Web Event Provider";
}
}
/// <summary>
/// Flushes events into the XML database.
/// </summary>
public override void Flush()
{
data.Flush();
}
/// <summary>
/// Processes the event passed to the provider.
/// </summary>
/// <param name="raisedEvent">
/// The <see cref="T:System.Web.Management.WebBaseEvent"/>
/// object to process.</param>
public override void ProcessEvent(WebBaseEvent raisedEvent)
{
if (!data.Initialized) Init();
data.ProcessEvent(raisedEvent);
}
/// <summary>
/// Performs tasks associated with shutting down the provider.
/// </summary>
public override void Shutdown()
{
if (!data.Initialized) return;
data.Shutdown();
}
}
}