Back to Devexpress

StorageCleanerSettings Class

xtrareports-devexpress-dot-xtrareports-dot-web-dot-webdocumentviewer.md

latest7.4 KB
Original Source

StorageCleanerSettings Class

Provides time settings to clean a storage for storing documents and reports.

Namespace : DevExpress.XtraReports.Web.WebDocumentViewer

Assembly : DevExpress.XtraReports.v25.2.Web.dll

NuGet Package : DevExpress.Web.Reporting.Common

Declaration

csharp
public class StorageCleanerSettings :
    StoragesCleanerSettingsBase
vb
Public Class StorageCleanerSettings
    Inherits StoragesCleanerSettingsBase

The following members return StorageCleanerSettings objects:

Remarks

The cleaner service periodically searches the cache and file storage for expired documents/exported documents/reports and deletes them. You can use the CacheCleanerSettings and StorageCleanerSettings to specify check interval and expiration time settings. To prevent expired documents from being deleted, call the UseEmptyStoragesCleaner() method to register an empty storage cleaner.

Settings in a .NET Framework Application

Use the DefaultWebDocumentViewerContainer.Register<T, TImpl> method to register a new instance of the StorageCleanerSettings class with different time settings.

The default WebDocumentViewer storage for documents/exported documents/reports is the memory cache. Call the following methods to enable file storage :

MethodDescription
UseFileDocumentStorageSpecifies a path for the report document’s file storage.
UseFileExportedDocumentStorageSpecifies a path for the exported document’s file storage.
UseFileReportStorageSpecifies the path to the file cache storage used to cache the reports from which the Viewer generates documents.

The code below demonstrates how to register custom settings in a .NET Framework application. The settings force a document, report and exported document to live 30 minutes in a client session. The cleaner performs first check 1 minute after start and checks the storage each 5 minutes. After 30 minutes, the document, report and exported document expire and the viewer cannot display them.

csharp
using DevExpress.XtraReports.Web.WebDocumentViewer;
//... 
  void Application_Start(object sender, EventArgs e) {
    var dueTime = TimeSpan.FromMinutes(1);
    var period = TimeSpan.FromMinutes(5);
    var reportTimeTolive = TimeSpan.FromMinutes(30);
    var documentTimeToLive = TimeSpan.FromMinutes(30);
    var exportedDocumentTimeToLive = TimeSpan.FromMinutes(30);
    DefaultWebDocumentViewerContainer.RegisterSingleton<StorageCleanerSettings>(new StorageCleanerSettings(dueTime, period, reportTimeTolive, documentTimeToLive, exportedDocumentTimeToLive));
  }
//...
vb
Imports DevExpress.XtraReports.Web.WebDocumentViewer
'... 
  Sub Application_Start(sender As Object, e As EventArgs)
    Dim dueTime = TimeSpan.FromMinutes(1)
    Dim period = TimeSpan.FromMinutes(5)
    Dim reportTimeTolive = TimeSpan.FromMinutes(30)
    Dim documentTimeToLive = TimeSpan.FromMinutes(30)
    Dim exportedDocumentTimeToLive = TimeSpan.FromMinutes(30)
    DefaultWebDocumentViewerContainer.RegisterSingleton(Of StorageCleanerSettings)(New StorageCleanerSettings(dueTime, period, reportTimeTolive, documentTimeToLive, exportedDocumentTimeToLive))
  End Sub
'...

Settings in a .NET Application

Use the AddSingleton method to register a new instance of the StorageCleanerSettings class with different time settings.

The default WebDocumentViewer storage for documents/exported documents/reports is the memory cache. If you enable this file-based storage, copies of this resource will then be stored on the hard drive. These copies have their own expiration settings. The CacheCleanerSettings controls the in-memory copy, and the StorageCleanerSettings are applied to the storage copy. Call the following methods to enable file storage :

MethodDescription
UseFileDocumentStorageEnables document file storage and specifies a storage path.
UseFileExportedDocumentStorageEnables exported document file storage and specifies a storage path.
UseFileReportStorageEnables report file storage and specifies a storage path.

The code below demonstrates how to register custom settings in the application startup file. The settings force a document, report, and exported document to live 30 minutes in a client session. The cleaner performs first check 1 minute after start and checks the storage each 5 minutes. After 30 minutes, the document, report, and exported document expire and the viewer cannot display them.

csharp
using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;
using DevExpress.XtraReports.Web.WebDocumentViewer;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDevExpressControls();
builder.Services.AddMvc(); 

var dueTime = TimeSpan.FromMinutes(1);
var period = TimeSpan.FromMinutes(5);
var reportTimeTolive = TimeSpan.FromMinutes(30);
var documentTimeToLive = TimeSpan.FromMinutes(30);
var exportedDocumentTimeToLive = TimeSpan.FromMinutes(30);
builder.Services.AddSingleton<StorageCleanerSettings>(new StorageCleanerSettings(dueTime, period, reportTimeTolive, documentTimeToLive, exportedDocumentTimeToLive));

var app = builder.Build();

Inheritance

Object DevExpress.XtraReports.Web.WebDocumentViewer.Native.Services.StoragesCleanerSettingsBase StorageCleanerSettings

See Also

StorageCleanerSettings Members

DevExpress.XtraReports.Web.WebDocumentViewer Namespace