protected bool DoConvertAction(StyleBase style, object value, out OverflowAction action) { OverflowAction?actions; OverflowSplit? splits; if (null == value) { action = OverflowAction.None; return(false); } else if (value is OverflowAction a) { action = a; return(true); } else if (TryParseOverflow(value.ToString(), out splits, out actions) && actions.HasValue) { action = actions.Value; return(true); } else { action = OverflowAction.None; return(false); } }
// // public methods // #region public PDFLayoutPage BeginNewContinuationPage() /// <summary> /// Begins a new page based on the current page's size and content rect. This will then be the current page /// </summary> /// <returns></returns> public PDFLayoutPage BeginNewContinuationPage() { if (CurrentPageIndex < 0) { throw new ArgumentOutOfRangeException("Cannot begin a new page based on previous page if there are no previous pages"); } PDFLayoutPage pg = this.CurrentPage; PDFTraceLog log = this.DocumentComponent.TraceLog; if (log.ShouldLog(TraceLevel.Verbose)) { log.Add(TraceLevel.Verbose, "LAYOUT", "Beginning a new continuation page for '" + pg + "'"); } if (!pg.IsClosed) { pg.Close(); } PDFSize size = pg.Size; Style style = pg.FullStyle; Page owner = pg.Owner as Page; OverflowAction overflow = pg.OverflowAction; PDFLayoutPage newpg = this.BeginNewPage(owner, this.Engine, style, overflow); return(newpg); }
public dtoContainerQuota() { _Overflow = OverflowAction.None; DiskSize = -1; _MaxAvailableSize = 0; _AvailableSize = 0; UsedSize = 0; _MaxUploadFileSize = 0; _UploadOverflow = OverflowAction.None; }
public static void ModifyOverflowPolicy(string logSource, string logName, OverflowAction action, int retentionDays) { try { EventLog eventLog = new EventLog(logName); eventLog.Source = logSource; eventLog.ModifyOverflowPolicy(action, retentionDays); } catch (Exception ex) { OnModifyOverFlowException(ex); } }
public void Initialize(DiskSettings settings, Boolean overrideQuota, long usedSize = 0) { AllowOverrideQuota = overrideQuota; UsedSize = usedSize; _Overflow = settings.RepositoryOverflow; _AvailableSize = settings.AdditionalSpace + settings.AvailableSpace; _MaxAvailableSize = settings.MaxSpace; if (_MaxAvailableSize > DiskSize && DiskSize != -1) { _MaxAvailableSize = DiskSize; } _IsRepository = true; switch (settings.RepositoryOverflow) { case OverflowAction.Allow: case OverflowAction.AllowWithWarning: break; default: if (!overrideQuota) { _MaxAvailableSize = _AvailableSize; } break; } _MaxUploadFileSize = settings.MaxUploadFileSize; _UploadOverflow = settings.UploadOverflow; switch (settings.UploadOverflow) { case OverflowAction.Allow: case OverflowAction.AllowWithWarning: break; default: if (_MaxUploadFileSize > AvailableSize) { _MaxUploadFileSize = AvailableSize; } break; } if (_MaxUploadFileSize > MaxAvailableSize) { _MaxUploadFileSize = MaxAvailableSize; } }
public void Overflow_ActionTest() { OverflowStyle target = new OverflowStyle(); OverflowAction expected = OverflowAction.None; Assert.AreEqual(expected, target.Action); expected = OverflowAction.NewPage; target.Action = expected; Assert.AreEqual(expected, target.Action); expected = OverflowAction.Truncate; target.Action = expected; Assert.AreEqual(expected, target.Action); target.RemoveAction(); expected = OverflowAction.None; Assert.AreEqual(expected, target.Action); }
// Prompt the user for the overflow policy setting. static void GetNewOverflowSetting(ref OverflowAction newOverflow, ref Int32 numDays) { Console.Write("Enter the new overflow policy setting ["); Console.Write(" OverwriteOlder,"); Console.Write(" DoNotOverwrite,"); Console.Write(" OverwriteAsNeeded"); Console.WriteLine("] : "); String input = Console.ReadLine(); if (!String.IsNullOrEmpty(input)) { switch (input.Trim().ToUpper(CultureInfo.InvariantCulture)) { case "OVERWRITEOLDER": newOverflow = OverflowAction.OverwriteOlder; Console.WriteLine("Enter the number of days to retain events: "); input = Console.ReadLine(); if ((!Int32.TryParse(input, out numDays)) || (numDays == 0)) { Console.WriteLine(" Invalid input, defaulting to 7 days."); numDays = 7; } break; case "DONOTOVERWRITE": newOverflow = OverflowAction.DoNotOverwrite; break; case "OVERWRITEASNEEDED": newOverflow = OverflowAction.OverwriteAsNeeded; break; default: Console.WriteLine("Unrecognized overflow policy value."); break; } } Console.WriteLine(); }
// </Snippet2> // <Snippet3> // Display the current event log overflow settings, and // prompt the user to input a new overflow setting. public static void ChangeEventLogOverflowAction(String logName) { if (EventLog.Exists(logName)) { // Display the current overflow setting of the // specified event log. EventLog inputLog = new EventLog(logName); Console.WriteLine(" Event log {0}", inputLog.Log); OverflowAction logOverflow = inputLog.OverflowAction; Int32 numDays = inputLog.MinimumRetentionDays; Console.WriteLine(" Current overflow setting = {0}", logOverflow.ToString()); if (logOverflow == OverflowAction.OverwriteOlder) { Console.WriteLine("\t Entries are retained a minimum of {0} days.", numDays.ToString()); } // Prompt user for a new overflow setting. GetNewOverflowSetting(ref logOverflow, ref numDays); // Change the overflow setting on the event log. if (logOverflow != inputLog.OverflowAction) { inputLog.ModifyOverflowPolicy(logOverflow, numDays); Console.WriteLine("Event log overflow policy was modified successfully!"); } else { Console.WriteLine("Event log overflow policy was not modified."); } } else { Console.WriteLine("Event log {0} was not found.", logName); } }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (LogName.Expression != null) { targetCommand.AddParameter("LogName", LogName.Get(context)); } if (RetentionDays.Expression != null) { targetCommand.AddParameter("RetentionDays", RetentionDays.Get(context)); } if (OverflowAction.Expression != null) { targetCommand.AddParameter("OverflowAction", OverflowAction.Get(context)); } if (MaximumSize.Expression != null) { targetCommand.AddParameter("MaximumSize", MaximumSize.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public void InitializeFromFather(dtoContainerQuota fatherQuota, long usedSize = 0) { _Overflow = fatherQuota.Overflow; _UploadOverflow = fatherQuota.UploadOverflow; DiskSize = fatherQuota.DiskSize; UsedSize = usedSize; _AvailableSize = fatherQuota.AvailableSize - fatherQuota.UsedSize + usedSize; if (_AvailableSize < 0) { _AvailableSize = 0; } if (fatherQuota.IsRepository) { _MaxAvailableSize = (fatherQuota.AllowOverrideQuota) ? fatherQuota.MaxAvailableSize : fatherQuota.AvailableSize; } else { _MaxAvailableSize = fatherQuota.MaxAvailableSize; } _MaxUploadFileSize = fatherQuota.MaxUploadFileSize; }
// // ctor(s) // #region public PDFLayoutPage(PDFLayoutDocument doc, PDFSize size, PDFPage page, PDFStyle full) /// <summary> /// Creates a new instance of the PDFLayoutPage. /// </summary> /// <param name="doc">The document layout this page belongs to</param> /// <param name="page">The page definition this layout is part of </param> /// <param name="full">The full style for the page</param> /// <remarks>The PDFLayout page has one block. The TopBlock. /// This contains all the regions and content for the page.</remarks> public PDFLayoutPage(PDFLayoutDocument doc, PageBase page, IPDFLayoutEngine engine, Style full, OverflowAction overflow) : base(doc, page, engine, full) { this.OverflowAction = overflow; }
public void ModifyOverflowPolicy(OverflowAction action, int retentionDays) { Impl.ModifyOverflowPolicy(action, retentionDays); }
public void ModifyOverflowPolicy(OverflowAction action, int retentionDays) => _inner.ModifyOverflowPolicy(action, retentionDays);
protected virtual PDFLayoutPage CreateNewPageInstance(PageBase owner, IPDFLayoutEngine engine, Style full, OverflowAction action, int pageIndex) { PDFLayoutPage pg = new PDFLayoutPage(this, owner, engine, full, action); pg.PageIndex = pageIndex; return(pg); }
public void ModifyOverflowPolicy(OverflowAction overflowAction, int retentionDays) { OverflowAction = overflowAction; RetentionDays = retentionDays; }
public void ModifyOverflowPolicy(OverflowAction action, int retentionDays) { this.eventLog.ModifyOverflowPolicy(action, retentionDays); }
public void ModifyOverflowPolicy(OverflowAction action, int retentionDays) { }
// // overrides // /// <summary> /// Main overridden method /// </summary> protected override void DoLayoutComponent() { IDisposable record = this.Context.PerformanceMonitor.Record(PerformanceMonitorType.Layout_Pages, "Page " + this.Component.ID); //Take a copy of the style stack for the header and footer this.PageStyleStack = this.Context.StyleStack.Clone(); //Get the page size and position options PageSize pgsize = this.FullStyle.CreatePageSize(); pgsize.Size = this.GetNextPageSize(this.Component, this.FullStyle, pgsize.Size); PDFPositionOptions options = this.FullStyle.CreatePostionOptions(); //Graphics PDFGraphics g = this.Page.CreateGraphics(this.StyleStack, this.Context); this.Context.Graphics = g; //Size, border, margins PDFRect bounds = new PDFRect(PDFPoint.Empty, pgsize.Size); PDFRect contentrect = GetContentRectFromBounds(bounds, options.Margins, options.Padding); //Columns PDFColumnOptions colOpts = this.FullStyle.CreateColumnOptions(); //Overflow OverflowAction action = options.OverflowAction; PDFLayoutPage pg = BuildNewPage(pgsize.Size, options, colOpts, action); //Register page numbering PDFPageNumberOptions numbers = this.GetPageNumbering(this.FullStyle); this.RegisterPageNumbering(pg, numbers); this.LayoutPageContent(); //close the last page PDFLayoutPage last = this.DocumentLayout.CurrentPage; if (last.IsClosed == false) { last.Close(); } //Unregister the page numbers. this.UnRegisterPageNumbering(last, numbers); //release graphics this.Context.Graphics = null; g.Dispose(); record.Dispose(); }
// // support methods // #region protected virtual void BuildNewPage(PDFPageSize pgsize, PDFPositionOptions options ...) /// <summary> /// Creates a new page with the specified options and adds it to the current layout /// </summary> /// <param name="pgsize"></param> /// <param name="options"></param> /// <param name="alley"></param> /// <param name="colcount"></param> /// <param name="action"></param> protected virtual PDFLayoutPage BuildNewPage(PDFSize pgsize, PDFPositionOptions options, PDFColumnOptions colOpts, OverflowAction action) { PDFLayoutDocument doclayout = this.DocumentLayout; PDFLayoutPage pg = doclayout.BeginNewPage(this.Page, this, this.FullStyle, action); pg.InitPage(pgsize, options, colOpts, this.Context); return(pg); }
/// <summary> /// Begins a new page of the requested size and with the specified bounds. This will then be the current page /// </summary> /// <param name="size">The actual size of the page</param> /// <param name="full">The full style of the page</param> /// <returns></returns> public PDFLayoutPage BeginNewPage(PageBase owner, IPDFLayoutEngine engine, Style full, OverflowAction action) { int pgIndex = this.AllPages.Count; PDFLayoutPage pg = CreateNewPageInstance(owner, engine, full, action, pgIndex); this.CurrentPageIndex = pg.PageIndex; this.CurrentPage = pg; this.AllPages.Add(pg); return(pg); }
public override void ModifyOverflowPolicy (OverflowAction action, int retentionDays) { throw new NotSupportedException ("This EventLog implementation does not support modifying overflow policy"); }
/// <summary> /// Initializes a new instance of the <see cref="CachingTargetWrapper"/> class. /// </summary> /// <param name="wrappedTarget">The wrapped target.</param> /// <param name="queueLimit">Maximum number of requests in the queue.</param> /// <param name="overflowAction">The action to be taken when the queue overflows.</param> public CachingTargetWrapper(Target wrappedTarget, int queueLimit, OverflowAction overflowAction) { _eventQueue = new EventQueue(queueLimit, overflowAction); BatchSize = 100; TimeToSleepBetweenBatches = 50; WrappedTarget = wrappedTarget; }
/// <summary> /// Initializes a new instance of the <see cref="EventQueue"/> class. /// </summary> /// <param name="queueLimit">The queue limit.</param> /// <param name="onOverflow">The overflow action.</param> public EventQueue(int queueLimit, OverflowAction onOverflow) { QueueLimit = queueLimit; OnOverflow = onOverflow; _queue = new ConcurrentQueue<AsyncLogEventInfo>(); }
public override void ModifyOverflowPolicy(OverflowAction action, int retentionDays) { throw new NotImplementedException(); }
public void ModifyOverflowPolicy(OverflowAction action, int retentionDays) { string currentMachineName = this.machineName; EventLogPermission permission = new EventLogPermission(EventLogPermissionAccess.Administer, currentMachineName); permission.Demand(); if (action < OverflowAction.DoNotOverwrite || action > OverflowAction.OverwriteOlder) throw new InvalidEnumArgumentException("action", (int)action, typeof(OverflowAction)); // this is a long because in the if statement we may need to store values as // large as UInt32.MaxValue - 1. This would overflow an int. long retentionvalue = (long) action; if (action == OverflowAction.OverwriteOlder) { if (retentionDays < 1 || retentionDays > 365) throw new ArgumentOutOfRangeException(SR.GetString(SR.RentionDaysOutOfRange)); retentionvalue = (long) retentionDays * SecondsPerDay; } PermissionSet permissionSet = EventLog._UnsafeGetAssertPermSet(); permissionSet.Assert(); using (RegistryKey logkey = GetLogRegKey(currentMachineName, true)) logkey.SetValue("Retention", retentionvalue, RegistryValueKind.DWord); }
public void ModifyOverflowPolicy(OverflowAction action, int retentionDays) { m_underlyingEventLog.ModifyOverflowPolicy(action, retentionDays); }
public abstract void ModifyOverflowPolicy (OverflowAction action, int retentionDays);
public DiskSettings() { UploadOverflow = OverflowAction.Allow; RepositoryOverflow = OverflowAction.AllowWithWarning; }
public override void ModifyOverflowPolicy (OverflowAction action, int retentionDays) { throw new NotImplementedException (); }
public abstract void ModifyOverflowPolicy(OverflowAction action, int retentionDays);