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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
|
//------------------------------------------------------------------------------
// <copyright file="WebEventCodes.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.Management {
using System.Globalization;
using System.Collections;
using Debug=System.Web.Util.Debug;
using System.Security.Permissions;
// this class is a container for pre-defined event codes
// all APIs will take integers so application defined
// codes or new codes added through servicing are supported
public sealed class WebEventCodes {
private WebEventCodes() {
}
static WebEventCodes()
{
InitEventArrayDimensions();
}
// (not bit flags)
// we're not using an enum for extensibility reasons
public const int InvalidEventCode = -1;
public const int UndefinedEventCode = 0;
public const int UndefinedEventDetailCode = 0;
// ----------------------------------
// Application Codes
// ----------------------------------
public const int ApplicationCodeBase = 1000;
public const int ApplicationStart = ApplicationCodeBase + 1;
public const int ApplicationShutdown = ApplicationCodeBase + 2;
public const int ApplicationCompilationStart = ApplicationCodeBase + 3;
public const int ApplicationCompilationEnd = ApplicationCodeBase + 4;
public const int ApplicationHeartbeat = ApplicationCodeBase + 5;
internal const int ApplicationCodeBaseLast = ApplicationCodeBase + 5;
// ----------------------------------
// Request Codes
// ----------------------------------
public const int RequestCodeBase = 2000;
public const int RequestTransactionComplete = RequestCodeBase+1;
public const int RequestTransactionAbort = RequestCodeBase+2;
internal const int RequestCodeBaseLast = RequestCodeBase+2;
// ----------------------------------
// Error Codes
// ----------------------------------
public const int ErrorCodeBase = 3000;
// Errors during request processing related to client input
// or behavior
public const int RuntimeErrorRequestAbort = ErrorCodeBase + 1;
public const int RuntimeErrorViewStateFailure = ErrorCodeBase + 2;
public const int RuntimeErrorValidationFailure = ErrorCodeBase + 3;
public const int RuntimeErrorPostTooLarge = ErrorCodeBase + 4;
public const int RuntimeErrorUnhandledException = ErrorCodeBase + 5;
// Errors related to configuration or invalid code
public const int WebErrorParserError = ErrorCodeBase + 6;
public const int WebErrorCompilationError = ErrorCodeBase + 7;
public const int WebErrorConfigurationError = ErrorCodeBase + 8;
public const int WebErrorOtherError = ErrorCodeBase + 9;
public const int WebErrorPropertyDeserializationError = ErrorCodeBase + 10;
public const int WebErrorObjectStateFormatterDeserializationError = ErrorCodeBase + 11;
public const int RuntimeErrorWebResourceFailure = ErrorCodeBase + 12;
internal const int ErrorCodeBaseLast = ErrorCodeBase + 12;
// ----------------------------------
// Audit codes
// ----------------------------------
public const int AuditCodeBase = 4000;
// success codes
public const int AuditFormsAuthenticationSuccess = AuditCodeBase + 1;
public const int AuditMembershipAuthenticationSuccess = AuditCodeBase + 2;
public const int AuditUrlAuthorizationSuccess = AuditCodeBase + 3;
public const int AuditFileAuthorizationSuccess = AuditCodeBase + 4;
// failure codes
public const int AuditFormsAuthenticationFailure = AuditCodeBase +5;
public const int AuditMembershipAuthenticationFailure = AuditCodeBase + 6;
public const int AuditUrlAuthorizationFailure = AuditCodeBase + 7;
public const int AuditFileAuthorizationFailure = AuditCodeBase + 8;
public const int AuditInvalidViewStateFailure = AuditCodeBase + 9;
public const int AuditUnhandledSecurityException = AuditCodeBase + 10;
public const int AuditUnhandledAccessException = AuditCodeBase + 11;
internal const int AuditCodeBaseLast = AuditCodeBase + 11;
// Misc events
public const int MiscCodeBase = 6000;
public const int WebEventProviderInformation = MiscCodeBase + 1;
internal const int MiscCodeBaseLast = MiscCodeBase + 1;
// Last code base
internal const int LastCodeBase = 6000;
/////////////////////////////////////////////////////
// Detail Codes
/////////////////////////////////////////////////////
public const int ApplicationDetailCodeBase = 50000;
public const int ApplicationShutdownUnknown = ApplicationDetailCodeBase + 1;
public const int ApplicationShutdownHostingEnvironment = ApplicationDetailCodeBase + 2;
public const int ApplicationShutdownChangeInGlobalAsax = ApplicationDetailCodeBase + 3;
public const int ApplicationShutdownConfigurationChange = ApplicationDetailCodeBase + 4;
public const int ApplicationShutdownUnloadAppDomainCalled = ApplicationDetailCodeBase + 5;
public const int ApplicationShutdownChangeInSecurityPolicyFile = ApplicationDetailCodeBase + 6;
public const int ApplicationShutdownBinDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 7;
public const int ApplicationShutdownBrowsersDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 8;
public const int ApplicationShutdownCodeDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 9;
public const int ApplicationShutdownResourcesDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 10;
public const int ApplicationShutdownIdleTimeout = ApplicationDetailCodeBase + 11;
public const int ApplicationShutdownPhysicalApplicationPathChanged = ApplicationDetailCodeBase + 12;
public const int ApplicationShutdownHttpRuntimeClose = ApplicationDetailCodeBase + 13;
public const int ApplicationShutdownInitializationError = ApplicationDetailCodeBase + 14;
public const int ApplicationShutdownMaxRecompilationsReached = ApplicationDetailCodeBase + 15;
public const int StateServerConnectionError = ApplicationDetailCodeBase + 16;
public const int ApplicationShutdownBuildManagerChange = ApplicationDetailCodeBase + 17;
// Audit detail codes
public const int AuditDetailCodeBase = 50200;
public const int InvalidTicketFailure = AuditDetailCodeBase + 1;
public const int ExpiredTicketFailure = AuditDetailCodeBase + 2;
public const int InvalidViewStateMac = AuditDetailCodeBase + 3;
public const int InvalidViewState = AuditDetailCodeBase + 4;
// Web Event provider detail codes
public const int WebEventDetailCodeBase = 50300;
public const int SqlProviderEventsDropped = WebEventDetailCodeBase + 1;
// Application extensions should start from here
public const int WebExtendedBase = 100000;
internal static string MessageFromEventCode(int eventCode, int eventDetailCode) {
string msg = null;
string detailMsg = null;
if (eventDetailCode != 0) {
switch(eventDetailCode) {
case ApplicationShutdownUnknown:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownUnknown);
break;
case ApplicationShutdownHostingEnvironment:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownHostingEnvironment);
break;
case ApplicationShutdownChangeInGlobalAsax:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownChangeInGlobalAsax);
break;
case ApplicationShutdownConfigurationChange:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownConfigurationChange);
break;
case ApplicationShutdownUnloadAppDomainCalled:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownUnloadAppDomainCalled);
break;
case ApplicationShutdownChangeInSecurityPolicyFile:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownChangeInSecurityPolicyFile);
break;
case ApplicationShutdownBinDirChangeOrDirectoryRename:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownBinDirChangeOrDirectoryRename);
break;
case ApplicationShutdownBrowsersDirChangeOrDirectoryRename:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownBrowsersDirChangeOrDirectoryRename);
break;
case ApplicationShutdownCodeDirChangeOrDirectoryRename:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownCodeDirChangeOrDirectoryRename);
break;
case ApplicationShutdownResourcesDirChangeOrDirectoryRename:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownResourcesDirChangeOrDirectoryRename);
break;
case ApplicationShutdownIdleTimeout:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownIdleTimeout);
break;
case ApplicationShutdownPhysicalApplicationPathChanged:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownPhysicalApplicationPathChanged);
break;
case ApplicationShutdownHttpRuntimeClose:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownHttpRuntimeClose);
break;
case ApplicationShutdownInitializationError:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownInitializationError);
break;
case ApplicationShutdownMaxRecompilationsReached:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownMaxRecompilationsReached);
break;
case ApplicationShutdownBuildManagerChange:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownBuildManagerChange);
break;
case StateServerConnectionError:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_StateServerConnectionError);
break;
case InvalidTicketFailure:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_InvalidTicketFailure);
break;
case ExpiredTicketFailure:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ExpiredTicketFailure);
break;
case InvalidViewStateMac:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_InvalidViewStateMac);
break;
case InvalidViewState:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_InvalidViewState);
break;
case SqlProviderEventsDropped:
detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_SqlProviderEventsDropped);
break;
default:
break;
}
}
switch(eventCode) {
case ApplicationStart:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationStart);
break;
case ApplicationShutdown:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationShutdown);
break;
case ApplicationCompilationStart:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationCompilationStart);
break;
case ApplicationCompilationEnd:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationCompilationEnd);
break;
case ApplicationHeartbeat:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationHeartbeat);
break;
case RequestTransactionComplete:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RequestTransactionComplete);
break;
case RequestTransactionAbort:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RequestTransactionAbort);
break;
case RuntimeErrorRequestAbort:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorRequestAbort);
break;
case RuntimeErrorViewStateFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorViewStateFailure);
break;
case RuntimeErrorValidationFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorValidationFailure);
break;
case RuntimeErrorPostTooLarge:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorPostTooLarge);
break;
case RuntimeErrorUnhandledException:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorUnhandledException);
break;
case WebErrorParserError:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_WebErrorParserError);
break;
case WebErrorCompilationError:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_WebErrorCompilationError);
break;
case WebErrorConfigurationError:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_WebErrorConfigurationError);
break;
case AuditUnhandledSecurityException:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUnhandledSecurityException);
break;
case AuditInvalidViewStateFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditInvalidViewStateFailure);
break;
case AuditFormsAuthenticationSuccess:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFormsAuthenticationSuccess);
break;
case AuditUrlAuthorizationSuccess:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUrlAuthorizationSuccess);
break;
case AuditFileAuthorizationFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFileAuthorizationFailure);
break;
case AuditFormsAuthenticationFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFormsAuthenticationFailure);
break;
case AuditFileAuthorizationSuccess:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFileAuthorizationSuccess);
break;
case AuditMembershipAuthenticationSuccess:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditMembershipAuthenticationSuccess);
break;
case AuditMembershipAuthenticationFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditMembershipAuthenticationFailure);
break;
case AuditUrlAuthorizationFailure:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUrlAuthorizationFailure);
break;
case AuditUnhandledAccessException:
msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUnhandledAccessException);
break;
default:
Debug.Assert(false, "ASP.NET event code " + eventCode.ToString(CultureInfo.InvariantCulture) + " doesn't have message string mapped to it");
return String.Empty;
}
if (detailMsg != null) {
msg += " " + detailMsg;
}
return msg;
}
// Both WebBaseEvents and HealthMonitoringSectionHelper has to store information per {event type, event code}.
// But for system event type, eventCode and event type has a N:1 relationship. Meaning every event
// code can be mapped to one and only one event type. So instead of using {event type, event code} as
// the key, we can use just the event code as the key.
// The simplest way is to use a hashtable. But in order to boost performance, we store those
// information using an array with event code as the key. However, because the event code range is not
// continuous, and has large gap between categories, instead we use an NxM array, when N is number
// of major event code categories (e.g. ApplicationCodeBase and RequestCodeBase), and M is the
// max number of per category event code among all the catogories.
// WebBaseEvents and HealthMonitoringSectionHelper will each maintain its own NxM arrays, and it
// depends on the following functions to calculate the sizes of the array, and to convert an event
// code into a (x,y) coordinate.
internal static int[] s_eventArrayDimensionSizes = new int[2];
internal static int GetEventArrayDimensionSize(int dim) {
Debug.Assert(dim == 0 || dim == 1, "dim == 0 || dim == 1");
return s_eventArrayDimensionSizes[dim];
}
// Convert an event code into a (x,y) coordinate.
internal static void GetEventArrayIndexsFromEventCode(int eventCode, out int index0, out int index1) {
index0 = eventCode/1000 - 1;
index1 = eventCode - (eventCode/1000)*1000 - 1;
Debug.Assert(index0 >= 0 && index0 < GetEventArrayDimensionSize(0), "Index0 of system eventCode out of expected range: " + eventCode);
Debug.Assert(index1 >= 0 && index1 < GetEventArrayDimensionSize(1), "Index1 of system eventCode out of expected range: " + eventCode);
}
static void InitEventArrayDimensions()
{
int sizeOf2ndDim = 0;
int size;
// Below is the manual way to figure out the size of the 2nd dimension.
size = WebEventCodes.ApplicationCodeBaseLast - WebEventCodes.ApplicationCodeBase;
if (size > sizeOf2ndDim) {
sizeOf2ndDim = size;
}
size = WebEventCodes.RequestCodeBaseLast - WebEventCodes.RequestCodeBase;
if (size > sizeOf2ndDim) {
sizeOf2ndDim = size;
}
size = WebEventCodes.ErrorCodeBaseLast - WebEventCodes.ErrorCodeBase;
if (size > sizeOf2ndDim) {
sizeOf2ndDim = size;
}
size = WebEventCodes.AuditCodeBaseLast - WebEventCodes.AuditCodeBase;
if (size > sizeOf2ndDim) {
sizeOf2ndDim = size;
}
size = WebEventCodes.MiscCodeBaseLast - WebEventCodes.MiscCodeBase;
if (size > sizeOf2ndDim) {
sizeOf2ndDim = size;
}
s_eventArrayDimensionSizes[0] = WebEventCodes.LastCodeBase/1000;
s_eventArrayDimensionSizes[1] = sizeOf2ndDim;
}
}
}
|