Exemplo n.º 1
0
        protected override void BeginProcessing()
        {
            string str;

            string[] strArrays = this._computerName;
            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                string str1 = strArrays[i];
                if (str1.Equals("localhost", StringComparison.CurrentCultureIgnoreCase) || str1.Equals(".", StringComparison.OrdinalIgnoreCase))
                {
                    str = "localhost";
                }
                else
                {
                    str = str1;
                }
                string[] strArrays1 = this._logName;
                for (int j = 0; j < (int)strArrays1.Length; j++)
                {
                    string str2 = strArrays1[j];
                    try
                    {
                        if (EventLog.Exists(str2, str1))
                        {
                            if (base.ShouldProcess(StringUtil.Format(EventlogResources.LimitEventLogWarning, str2, str)))
                            {
                                EventLog       eventLog             = new EventLog(str2, str1);
                                int            minimumRetentionDays = eventLog.MinimumRetentionDays;
                                OverflowAction overflowAction       = eventLog.OverflowAction;
                                if (!this.retentionSpecified || !this.overflowSpecified)
                                {
                                    if (!this.retentionSpecified || this.overflowSpecified)
                                    {
                                        if (!this.retentionSpecified && this.overflowSpecified)
                                        {
                                            eventLog.ModifyOverflowPolicy(this._overflowaction, minimumRetentionDays);
                                        }
                                    }
                                    else
                                    {
                                        if (overflowAction.CompareTo(OverflowAction.OverwriteOlder) != 0)
                                        {
                                            ErrorRecord errorRecord = new ErrorRecord(new InvalidOperationException(StringUtil.Format(EventlogResources.InvalidOverflowAction, new object[0])), null, ErrorCategory.InvalidOperation, null);
                                            base.WriteError(errorRecord);
                                            goto Label0;
                                        }
                                        else
                                        {
                                            eventLog.ModifyOverflowPolicy(overflowAction, this._retention);
                                        }
                                    }
                                }
                                else
                                {
                                    if (this._overflowaction.CompareTo(OverflowAction.OverwriteOlder) != 0)
                                    {
                                        ErrorRecord errorRecord1 = new ErrorRecord(new InvalidOperationException(StringUtil.Format(EventlogResources.InvalidOverflowAction, new object[0])), null, ErrorCategory.InvalidOperation, null);
                                        base.WriteError(errorRecord1);
                                        goto Label0;
                                    }
                                    else
                                    {
                                        eventLog.ModifyOverflowPolicy(this._overflowaction, this._retention);
                                    }
                                }
                                if (this.maxkbSpecified)
                                {
                                    int num = 0x400;
                                    this._maximumKilobytes    = this._maximumKilobytes / (long)num;
                                    eventLog.MaximumKilobytes = this._maximumKilobytes;
                                }
                            }
                        }
                        else
                        {
                            ErrorRecord errorRecord2 = new ErrorRecord(new InvalidOperationException(StringUtil.Format(EventlogResources.LogDoesNotExist, str2, str)), null, ErrorCategory.InvalidOperation, null);
                            base.WriteError(errorRecord2);
                        }
                    }
                    catch (InvalidOperationException invalidOperationException1)
                    {
                        InvalidOperationException invalidOperationException = invalidOperationException1;
                        this.WriteNonTerminatingError(invalidOperationException, EventlogResources.PermissionDenied, "PermissionDenied", ErrorCategory.PermissionDenied, str2, str);
                    }
                    catch (IOException oException1)
                    {
                        IOException oException = oException1;
                        this.WriteNonTerminatingError(oException, EventlogResources.PathDoesNotExist, "PathDoesNotExist", ErrorCategory.InvalidOperation, null, str);
                    }
                    catch (ArgumentOutOfRangeException argumentOutOfRangeException1)
                    {
                        ArgumentOutOfRangeException argumentOutOfRangeException = argumentOutOfRangeException1;
                        if (this.retentionSpecified || this.maxkbSpecified)
                        {
                            this.WriteNonTerminatingError(argumentOutOfRangeException, EventlogResources.ValueOutofRange, "ValueOutofRange", ErrorCategory.InvalidData, null, null);
                        }
                        else
                        {
                            this.WriteNonTerminatingError(argumentOutOfRangeException, EventlogResources.InvalidArgument, "InvalidArgument", ErrorCategory.InvalidData, null, null);
                        }
                    }
Label0:
                    continue;
                }
            }
        }