internal RuleFiringRecord(HealthMonitoringSectionHelper.RuleInfo ruleInfo)
 {
     this._ruleInfo          = ruleInfo;
     this._lastFired         = DateTime.MinValue;
     this._timesRaised       = 0;
     this._updatingLastFired = 0;
 }
Beispiel #2
0
        internal static void RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, int index0, int index1)
        {
            bool flag  = false;
            bool flag2 = false;
            ProcessImpersonationContext context = null;
            HttpContext current = HttpContext.Current;
            object      data    = CallContext.GetData("_WEvtRIP");

            if ((data == null) || !((bool)data))
            {
                eventRaised.IncrementPerfCounters();
                eventRaised.IncrementTotalCounters(index0, index1);
                if (firingRuleInfos == null)
                {
                    firingRuleInfos = HealthMonitoringManager.Manager()._sectionHelper.FindFiringRuleInfos(eventRaised.GetType(), eventRaised.EventCode);
                }
                if (firingRuleInfos.Count != 0)
                {
                    try
                    {
                        bool[] flagArray = null;
                        if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                        {
                            EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_START, current.WorkerRequest, eventRaised.GetType().FullName, eventRaised.EventCode.ToString(CultureInfo.InstalledUICulture), eventRaised.EventDetailCode.ToString(CultureInfo.InstalledUICulture), null);
                        }
                        try
                        {
                            foreach (HealthMonitoringSectionHelper.FiringRuleInfo info in firingRuleInfos)
                            {
                                HealthMonitoringSectionHelper.RuleInfo info2 = info._ruleInfo;
                                if (info2._ruleFiringRecord.CheckAndUpdate(eventRaised) && (info2._referencedProvider != null))
                                {
                                    if (!flag)
                                    {
                                        eventRaised.PreProcessEventInit();
                                        flag = true;
                                    }
                                    if (info._indexOfFirstRuleInfoWithSameProvider != -1)
                                    {
                                        if (flagArray == null)
                                        {
                                            flagArray = new bool[firingRuleInfos.Count];
                                        }
                                        if (flagArray[info._indexOfFirstRuleInfoWithSameProvider])
                                        {
                                            continue;
                                        }
                                        flagArray[info._indexOfFirstRuleInfoWithSameProvider] = true;
                                    }
                                    if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                                    {
                                        EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_START, current.WorkerRequest, info2._ruleSettings.Provider, info2._ruleSettings.Name, info2._ruleSettings.EventName, null);
                                    }
                                    try
                                    {
                                        if (context == null)
                                        {
                                            context = new ProcessImpersonationContext();
                                        }
                                        if (!flag2)
                                        {
                                            CallContext.SetData("_WEvtRIP", true);
                                            flag2 = true;
                                        }
                                        info2._referencedProvider.ProcessEvent(eventRaised);
                                    }
                                    catch (Exception exception)
                                    {
                                        try
                                        {
                                            info2._referencedProvider.LogException(exception);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    finally
                                    {
                                        if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                                        {
                                            EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_END, current.WorkerRequest);
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                            if (context != null)
                            {
                                context.Undo();
                            }
                            if (flag2)
                            {
                                CallContext.FreeNamedDataSlot("_WEvtRIP");
                            }
                            if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                            {
                                EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_END, current.WorkerRequest);
                            }
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
        }