Class SoArc2Helper
Helper class containing utility methods (e.g to retrieve data from ForeignKey Table)
Inherited Members
Namespace: SuperOffice.CRM.Documents
Assembly: SoDataBase.dll
Syntax
public static class SoArc2Helper
Methods
CreateReturnInfo(bool, string, string, ReturnType, string, string)
Create a ReturnInfo object
Declaration
public static ReturnInfo CreateReturnInfo(bool success, string externalReference, string versionId, ReturnType type, string value, string additionalInfo)
Parameters
Type | Name | Description |
---|---|---|
bool | success | success/failure status |
string | externalReference | External Reference |
string | versionId | Version Id |
ReturnType | type | Return type |
string | value | Return value |
string | additionalInfo | Additional Info |
Returns
Type | Description |
---|---|
ReturnInfo | ReturnInfo |
EnsureDirectoryExists(DirectoryInfo)
Verify that a directory exists, and if not, create all missing folders
Declaration
public static void EnsureDirectoryExists(DirectoryInfo dirInfo)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | dirInfo |
GetArchivePath()
Path to the main document archive.
Declaration
public static string GetArchivePath()
Returns
Type | Description |
---|---|
string | "\server\so_arc" |
GetArchivePaths()
Path to the document archives, including the main document archive.
Declaration
public static string[] GetArchivePaths()
Returns
Type | Description |
---|---|
string[] | ("\server\so_arc", "\other\so_arc2") |
GetAssociateNameAsync(int, CancellationToken)
Get the associate name for a given associate id
Declaration
public static Task<string> GetAssociateNameAsync(int associateId, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | associateId | Associate Id |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | Associate Name |
GetCurrentVersionFolderPath(IDocumentInfo, string)
This is the folder path where the latest document is in
Declaration
public static string GetCurrentVersionFolderPath(IDocumentInfo documentInfo, string filename = null)
Parameters
Type | Name | Description |
---|---|---|
IDocumentInfo | documentInfo | document id/name/heading |
string | filename | Optional filename override for generated filenames - used if the documentInfo.Name is blank. |
Returns
Type | Description |
---|---|
string | \server\so_arc\user\1999.1 |
GetCurrentVersionFolderPathAsync(DocumentRow, CancellationToken)
This is the folder path where the latest document is located.
Declaration
public static Task<string> GetCurrentVersionFolderPathAsync(DocumentRow documentRow, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
DocumentRow | documentRow | document id, name, heading etc |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | \server\so_arc\user\1999.2 |
GetFullArchivePath(IDocumentInfo, string)
This method will return the physical location of the given document based on the provided IDocumentInfo.
Declaration
public static string GetFullArchivePath(IDocumentInfo documentInfo, string filename = null)
Parameters
Type | Name | Description |
---|---|---|
IDocumentInfo | documentInfo | DocumentInfo object containing the document information |
string | filename | Optional filename override for generated filename - used if the documentInfo.Name is blank. |
Returns
Type | Description |
---|---|
string | Full Archive Path |
GetFullArchivePathAsync(DocumentRow, CancellationToken)
This method will return the physical location of the given document based on the provided IDocumentInfo.
Declaration
public static Task<string> GetFullArchivePathAsync(DocumentRow documentRow, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
DocumentRow | documentRow | DocumentRow object containing the document information |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | Full Archive Path |
GetUniqueFileName(string)
This will get a unique file name in the given path.
Declaration
public static string GetUniqueFileName(string completeFilePath)
Parameters
Type | Name | Description |
---|---|---|
string | completeFilePath | Complete file path including the file name |
Returns
Type | Description |
---|---|
string | A string to a unique filename with no path which is guaranteed not to exist in the path provided. |
Remarks
this will ensure to return an unique file name for the given location If it finds a file(s) with the same name it will create a filename with a suffix with a proper index. e.g It'll create Test[2].docx (if it finds the Test.docx & Test[1].docx in the requested location
GetUniqueFilePath(string)
This will get a unique file name and path in the given path.
Declaration
public static string GetUniqueFilePath(string completeFilePath)
Parameters
Type | Name | Description |
---|---|---|
string | completeFilePath | Complete file path including the file name |
Returns
Type | Description |
---|---|
string | A string to a complete filename and path which is guaranteed not to exist. |
Remarks
this will ensure to return an unique file name for the given location If it finds a file(s) with the same name it will create a filename with a suffix with a proper randomized string. e.g It'll create Test[xyz].docx (if it finds the Test.docx & Test[xyz].docx in the requested location
MakeLegalFileName(string)
Sanitize a file name (no path); this removes backslash and other dangerous characters
Declaration
public static string MakeLegalFileName(string fileNameWithoutPath)
Parameters
Type | Name | Description |
---|---|---|
string | fileNameWithoutPath |
Returns
Type | Description |
---|---|
string |
MakeLegalFileNameAndDirectory(string, bool)
Given a suggested file name (typically derived from a document.header), and make it legal; create directories on the way
Declaration
public static string MakeLegalFileNameAndDirectory(string suggestedFullPathWithExtension, bool skipExistenceCheck = false)
Parameters
Type | Name | Description |
---|---|---|
string | suggestedFullPathWithExtension | |
bool | skipExistenceCheck |
Returns
Type | Description |
---|---|
string |
Remarks
This is in fact rather complicated. There can be a volume designator, such as q: or \?\q: at the beginning of a path - colon is legal there, as is the question mark, but only in these very special places. Elsewhere the illegal-characters set applies. And we also want to guard against upwards navigation using ..\ syntax.
MakeLegalPathName(string)
Sanitize a file name (no path); this removes backslash and other dangerous characters
Declaration
public static string MakeLegalPathName(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path |
Returns
Type | Description |
---|---|
string |