Skip to main content

Class FileUtil

Provides utility methods for file operations across different storage systems within the Xperiflow ecosystem.

Namespace: Workspace.XBR.Xperiflow.Utilities.File

Assembly: Xperiflow.dll

Declaration
public static class FileUtil

Examples

Checking file existence across different storage types:

// Check if file exists in OneStream file system
bool existsInFS = FileUtil.ValidateFileExists(
sessionInfo,
"Reports/MonthlyReport.xlsx",
null,
FileStorageTypes.OneStreamFileSystem
);

// Check if file exists in Meta file system
bool existsInMFS = FileUtil.ValidateFileExists(
sessionInfo,
"data/processed/customer_data.parquet",
"default-connection",
FileStorageTypes.MetaFileSystem
);

// Check if table exists in database
bool existsInDB = FileUtil.ValidateFileExists(
sessionInfo,
"CustomerData",
"DataWarehouse",
FileStorageTypes.OneStreamSqlDatabase
);

Using with external storage client:

// Create storage client for external system integration
var httpClientManager = new HttpClientManager();
var storageClient = XperiflowClientsEntrypoint.GetXperiflowStorageClient(sessionInfo, httpClientManager);

// Check file existence with external client
bool existsExternal = FileUtil.ValidateFileExists(
sessionInfo,
"external/data/processed_results.json",
"external-storage-connection",
FileStorageTypes.MetaFileSystem,
storageClient
);

if (existsExternal)
{
// Process the external file
var mfsClient = XBRApi.MetaFileSystem.GetMetaFileSystemClient(sessionInfo, "external-storage-connection");
var fileData = mfsClient.ReadFileAsync("external/data/processed_results.json").Result;
}

Remarks

The Workspace.XBR.Xperiflow.Utilities.File.FileUtil class provides static methods for common file operations that work across multiple storage backends supported by the Xperiflow system. This includes OneStream file system, Meta file system, and OneStream SQL database storage. The class abstracts the complexity of working with different storage types behind a unified interface.

Supported Storage Types:

  • OneStream File SystemTraditional OneStream file system storage using OneStream.Shared.Wcf.BRApi.FileSystem

  • Meta File SystemXperiflow Meta file system for enhanced file management capabilities

  • OneStream SQL DatabaseDatabase-backed storage for structured data and file metadata

Usage Guidelines:

All methods require proper configuration of the underlying storage systems and appropriate connection strings or client configurations. Error handling is implemented using OneStream's standard exception patterns with OneStream.Shared.Common.XFException and OneStream.Shared.Common.XFUserMsgException.

Performance Considerations:

File existence checks may involve network operations depending on the storage type. Consider caching results when performing multiple operations on the same files.

Methods

ValidateFileExists(SessionInfo, string, string, FileStorageTypes, IXperiflowStorageClient)

Validates whether a file or data source exists in the specified storage system.

Declaration
public static bool ValidateFileExists(SessionInfo sessionInfo, string sourceName, string connectionName, FileStorageTypes sourceType, IXperiflowStorageClient xperiflowStorageClient = null)
Remarks

This method provides a unified interface for checking file existence across different storage backends supported by the Xperiflow system. The actual implementation varies based on the specified sourceType:

Storage Type Implementations:

Performance Considerations:

Meta file system operations are performed asynchronously and may involve network calls. Database operations may involve SQL queries against system tables. Consider caching results when performing multiple checks on the same resources.

Error Handling:

The method throws an OneStream.Shared.Common.XFUserMsgException for unsupported storage types. Other exceptions from underlying storage systems are propagated to the caller.

Returns

System.Boolean

true if the file or data source exists in the specified storage system; otherwise, false.

Parameters
TypeNameDescription
OneStream.Shared.Common.SessionInfosessionInfoThe session information for the current user context
System.StringsourceNameThe name or path of the file/data source to check. Format depends on storage type:
_ OneStream File System: Relative path within the application database
_ Meta File System: Full path within the Meta file system
* OneStream SQL Database: Table name
System.StringconnectionNameThe connection identifier for the storage system. Required for Meta file system and database operations.
Can be null for OneStream file system operations.
Workspace.XBR.Xperiflow.Utilities.File.FileStorageTypessourceTypeThe type of storage system to check against
Workspace.XBR.Xperiflow.Core.RestApi.Storage.IXperiflowStorageClientxperiflowStorageClientOptional external storage client for Meta file system operations. If null, a default client will be created.
Exceptions

OneStream.Shared.Common.XFUserMsgException Thrown when the specified sourceType is not supported System.ArgumentNullException Thrown when required parameters are null (e.g., connectionName for database operations) System.Exception Various exceptions may be thrown by underlying storage systems:

  • File system exceptions for OneStream file system operations

  • HTTP exceptions for Meta file system network operations

  • SQL exceptions for database operations

Inherited Members

  • System.Object.Equals(System.Object)
  • System.Object.Equals(System.Object,System.Object)
  • System.Object.GetHashCode
  • System.Object.GetType
  • System.Object.MemberwiseClone
  • System.Object.ReferenceEquals(System.Object,System.Object)
  • System.Object.ToString

Was this page helpful?