Class SynchronizedRepository
- Namespace
- combit.Reporting.ProjectConverter
- Assembly
- combit.ListLabel31.ProjectConverter.dll
Provides seamless synchronization between a classic List & Label repository and a cross-platform repository. This class acts as a bridge, ensuring that all operations performed on your classic repository are automatically mirrored to the cross-platform repository, enabling a straightforward way to design projects in the Web Report Designer and then use List & Label Cross Platform for printing.
public class SynchronizedRepository : IRepository, IDisposable
- Inheritance
-
SynchronizedRepository
- Implements
- Inherited Members
Constructors
SynchronizedRepository(IRepository, IRepository, InitialSynchronization?, string, int, bool)
Creates a new synchronized repository that keeps a classic repository and cross-platform repository in sync.
public SynchronizedRepository(IRepository repositoryClassic, IRepository repositoryCrossPlatform, InitialSynchronization? initialSynchronization = InitialSynchronization.IfCrossPlatformRepositoryIsEmpty, string importData = "SynchronizedRepository", int threadCount = 1, bool writeIndented = false)
Parameters
repositoryClassicIRepositoryYour existing classic List & Label repository containing your current projects and resources.
repositoryCrossPlatformIRepositoryThe target cross-platform repository that will receive converted projects and synchronized content.
initialSynchronizationInitialSynchronization?Determines whether to synchronize existing items from classic to cross-platform repository on startup. Defaults to IfCrossPlatformRepositoryIsEmpty for a balance between startup performance and ease of use.
importDatastringCustom metadata to associate with imported items.
threadCountintNumber of parallel threads to use during project conversion operations. Higher values can improve performance for large repositories.
writeIndentedboolWhether to format the output JSON with indentation for better readability during debugging or manual inspection.
Examples
var classicRepo = new FileSystemRepository(@"C:\Reports\Classic");
var crossPlatformRepo = new FileSystemRepository(@"C:\Reports\CrossPlatform");
var syncRepo = new SynchronizedRepository(classicRepo, crossPlatformRepo, InitialSynchronization.IfCrossPlatformRepositoryIsEmpty);
// Use syncRepo instead of classicRepo for all repository operations
Exceptions
- ArgumentNullException
Thrown when required repository parameters are null.
Methods
ContainsItem(string)
Checks whether a specific report, project, or resource exists in your repository. This method queries the classic repository to determine item availability.
public bool ContainsItem(string id)
Parameters
idstringThe unique identifier (in the format "repository://{guid}") of the repository item you want to check.
Returns
- bool
trueif the item exists and can be accessed; otherwise,false.
CreateOrUpdateItem(RepositoryItem, string?, Stream?)
Adds a new item or updates an existing item in both the classic and cross-platform repositories.
public void CreateOrUpdateItem(RepositoryItem item, string? importData, Stream? sourceStream)
Parameters
itemRepositoryItemThe repository item containing metadata such as name, type, and folder information.
importDatastringCustom metadata to associate with imported item.
sourceStreamStreamThe actual content of the item (report file, image, etc.). If null, only metadata will be updated.
Remarks
For List & Label project files the item will be automatically converted to cross-platform format during synchronization.
For other resources (images, includes, shapefiles), the content is copied directly to both repositories.
If the item already exists, it will be overwritten with the new content and metadata.
DeleteItem(string)
Permanently removes an item from both the classic and cross-platform repositories.
public void DeleteItem(string id)
Parameters
idstringThe unique identifier (in the format "repository://{guid}") of the item to delete.
Remarks
Warning: This operation cannot be undone. The item will be permanently removed from both repositories.
Before deleting project files, ensure they are not referenced by other projects to avoid broken dependencies.
Consider backing up important items before deletion.
Dispose()
Releases all resources used by the synchronized repository. Call this method when you're finished using the repository to ensure proper cleanup of conversion resources.
public void Dispose()
Dispose(bool)
Releases managed resources used by the synchronized repository, including the project converter.
protected virtual void Dispose(bool disposing)
Parameters
disposingboolTrue if disposing managed resources; false if called from finalizer.
GetAllItems()
Retrieves a complete list of all reports, projects, and resources available in your classic repository. This provides an overview of your entire List & Label content library.
public IEnumerable<RepositoryItem> GetAllItems()
Returns
- IEnumerable<RepositoryItem>
A collection of repository items, each containing metadata about available content including names, types, and modification dates.
Remarks
The returned items include all types of repository content: report projects, drilldown reports, images, includes, shapefiles, and custom resources.
Use this method to build content browsers, perform bulk operations, or create backup routines.
GetItem(string)
Retrieves detailed information from the classic repository about a specific repository item without loading its content. Use this to access metadata such as display name, type, modification date, and folder location.
public RepositoryItem? GetItem(string id)
Parameters
idstringThe unique identifier (in the format "repository://{guid}") of the item you want to examine.
Returns
- RepositoryItem
A RepositoryItem object containing the item's metadata, or
nullif the item doesn't exist.
Remarks
This method is efficient for retrieving item information without the overhead of loading file content. Perfect for displaying item properties in user interfaces or validating item attributes before processing.
LoadItem(string, Stream, CancellationToken)
Loads the actual content of a repository item (report file, image, etc.) from the classic repository into a stream for processing or display. This method retrieves the file data from the classic repository.
public void LoadItem(string id, Stream destinationStream, CancellationToken cancelToken)
Parameters
idstringThe unique identifier (in the format "repository://{guid}") of the item whose content you want to load.
destinationStreamStreamThe stream where the item's content will be written. This could be a file stream, memory stream, or network stream.
cancelTokenCancellationTokenA token that allows you to cancel the loading operation if needed (useful for large files or network operations).
Remarks
The destination stream must be writable and will receive the complete file content of the specified repository item.
For large files or slow storage, use the cancellation token to provide responsive user interfaces.
Ensure the destination stream has sufficient capacity or is expandable to accommodate the item content.
LockItem(string)
Acquires an exclusive lock on a repository item to prevent concurrent modifications by other users or processes.
public bool LockItem(string id)
Parameters
idstringThe unique identifier (in the format "repository://{guid}") of the item you want to lock for editing.
Returns
- bool
trueif the lock was successfully acquired and you can safely edit the item;falseif the item is already locked by another user.
Remarks
Remember to call UnlockItem(string) when you're finished editing to release the lock for other users.
SynchronizeAllItems()
Performs a complete synchronization of all content from your classic repository to the cross-platform repository. This ensures both repositories contain identical content and your projects are available across all supported platforms.
public void SynchronizeAllItems()
Remarks
This operation performs the following steps:
- Removes items from the cross-platform repository that no longer exist in the classic repository
- Copies and converts all resources (images, includes, etc.) from classic to cross-platform repository
- Converts all List & Label projects to cross-platform format and saves them to the cross-platform repository
Use this method when setting up cross-platform support for existing repositories or when you need to ensure both repositories are completely in sync.
UnlockItem(string)
Releases an exclusive lock that was previously acquired on a repository item, allowing other users to edit the item.
public void UnlockItem(string id)
Parameters
idstringThe unique identifier (in the format "repository://{guid}") of the item whose lock you want to release.