Class RepositoryManager
Class to manage all scripts in the simplic database.
Inheritance
Inherited Members
Namespace: Simplic.Framework.Repository
Assembly: Simplic.Framework.Repository.dll
Syntax
public class RepositoryManager
Properties
| Improve this Doc View SourceIsLocalRepository
Defines wether the current application instance use a local repository
Declaration
public bool IsLocalRepository { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LocalRepositoryPath
Get path to the local repository
Declaration
public string LocalRepositoryPath { get; }
Property Value
Type | Description |
---|---|
System.String |
Singleton
Singleton access to the script repository.
Declaration
public static RepositoryManager Singleton { get; }
Property Value
Type | Description |
---|---|
RepositoryManager |
Methods
| Improve this Doc View SourceCalculatePath(Guid)
Get path of the directory
Declaration
public string CalculatePath(Guid directory)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | directory | Guid of the directory to the path which will should be returned |
Returns
Type | Description |
---|---|
System.String | Path to the directory |
CopyFile(RepositoryFileInfo, String, String, RepositoryManager.HandleOverrideFileOnMove)
Copy one file from one path to another
Declaration
public RepositoryFileInfo CopyFile(RepositoryFileInfo toCopy, string newPath, string newName, RepositoryManager.HandleOverrideFileOnMove overrideHandler = null)
Parameters
Type | Name | Description |
---|---|---|
RepositoryFileInfo | toCopy | File which will be copied |
System.String | newPath | Target path of the move process |
System.String | newName | |
RepositoryManager.HandleOverrideFileOnMove | overrideHandler |
Returns
Type | Description |
---|---|
RepositoryFileInfo |
CreateDirectoryIfNotExists(String)
Create a directory by path if it not exists
Declaration
public IList<RepositoryDirectoryInfo> CreateDirectoryIfNotExists(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the directory |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryDirectoryInfo> | List of created directories, ordered by the creation time |
CreateRepositoryContent(Guid, String)
Create RepositoryContentModel
Declaration
public RepositoryFileInfo CreateRepositoryContent(Guid id, string path)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Id of the script |
System.String | path | Path to the script |
Returns
Type | Description |
---|---|
RepositoryFileInfo | Model instance |
DeleteFromDatabase(RepositoryFileInfo)
Delete repository entry by model instance
Declaration
public void DeleteFromDatabase(RepositoryFileInfo model)
Parameters
Type | Name | Description |
---|---|---|
RepositoryFileInfo | model | Instance of repository model |
DeleteFromDatabase(Guid)
Delete repository entry by id
Declaration
public void DeleteFromDatabase(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
DeleteFromDatabase(String)
Delete repository entry by fullPath
Declaration
public void DeleteFromDatabase(string fullPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | fullPath | FullPath of the entry |
GetAll()
Get all scripts in the repository
Declaration
public IList<RepositoryFileInfo> GetAll()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryFileInfo> | List with repository entries |
GetByContentType(String, Boolean)
Get every thing of a content type in the repository
Declaration
public IList<RepositoryFileInfo> GetByContentType(string contentType, bool ignoreLocalRepository = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentType | ContentType of the document |
System.Boolean | ignoreLocalRepository | Defines whether to ignore local repository or not |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryFileInfo> | List of instances of RepositoryContentModel |
GetByGuidFromDatabase(Guid)
Get an instance of a RepositoryContentModel
Declaration
public RepositoryFileInfo GetByGuidFromDatabase(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Unique id of the script content |
Returns
Type | Description |
---|---|
RepositoryFileInfo | Instance of RepositoryContentModel |
GetByModule(String, String, Boolean)
Get an instance of a RepositoryContentModel
Declaration
public RepositoryFileInfo GetByModule(string module, string contentType, bool ignoreLocalRepository = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | module | Module-Path to the content (File-System-Based) |
System.String | contentType | ContentType of the document |
System.Boolean | ignoreLocalRepository | Defines whether to ignore local repository or not |
Returns
Type | Description |
---|---|
RepositoryFileInfo | Instance of RepositoryContentModel |
GetByPath(String, Boolean)
Get an instance of a RepositoryContentModel
Declaration
public RepositoryFileInfo GetByPath(string path, bool ignoreLocalRepository = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the content (File-System-Based) |
System.Boolean | ignoreLocalRepository | Defines whether to ignore local repository or not |
Returns
Type | Description |
---|---|
RepositoryFileInfo | Instance of RepositoryContentModel |
GetChildDirectories(Guid)
Get all child directories
Declaration
public IList<RepositoryDirectoryInfo> GetChildDirectories(Guid parent)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | parent | id of the directory, from which the children should be returned |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryDirectoryInfo> | List of child directories |
GetDirectory(Guid)
Get repository directory by it's guid
Declaration
public RepositoryDirectoryInfo GetDirectory(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | id of the directory |
Returns
Type | Description |
---|---|
RepositoryDirectoryInfo | Instance of the repository directory |
GetDirectory(String)
Get repository directory by it's path
Declaration
public RepositoryDirectoryInfo GetDirectory(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of the directory |
Returns
Type | Description |
---|---|
RepositoryDirectoryInfo | Instance of the repository directory |
GetDirectoryContent(Guid)
Get the sources in the directory.
Declaration
public IList<RepositoryFileInfo> GetDirectoryContent(Guid directory)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | directory | Guid of the directory. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryFileInfo> | A list of fileinfos of the content in the repository directory. |
GetDirectoryContent(String, Boolean)
Get the sources in the directory by path.
Declaration
public IList<RepositoryFileInfo> GetDirectoryContent(string path, bool recursiv)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of the directory. |
System.Boolean | recursiv |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryFileInfo> | A list of fileinfos of the content in the repository directory. |
GetDirectoryContentByType(Guid, String)
Gets all files of the given type from the directory and all subdirectories.
Declaration
public IList<RepositoryFileInfo> GetDirectoryContentByType(Guid directory, string type)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | directory | Guid of the directory. |
System.String | type | Type of the content. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryFileInfo> | A list of fileinfos of the content in the repository directory. |
GetDirectoryContentByType(String, String)
Gets all files of the given type from the directory and all subdirectories.
Declaration
public IList<RepositoryFileInfo> GetDirectoryContentByType(string path, string type)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path of the directory. |
System.String | type | Allowed file type. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<RepositoryFileInfo> | List of sources in the repository. |
GetFileParent(RepositoryFileInfo)
Gets the directory that a file lies in.
Declaration
public RepositoryDirectoryInfo GetFileParent(RepositoryFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
RepositoryFileInfo | file | Guid of the file |
Returns
Type | Description |
---|---|
RepositoryDirectoryInfo | The directory info of the file |
GetFileParent(Guid)
Gets the directory that a file lies in.
Declaration
public RepositoryDirectoryInfo GetFileParent(Guid file)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | file | Guid of the file |
Returns
Type | Description |
---|---|
RepositoryDirectoryInfo | The directory info of the file |
GetFromLocalRepository(String)
Get a script from the current local repository
Declaration
public RepositoryFileInfo GetFromLocalRepository(string relativePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | relativePath |
Returns
Type | Description |
---|---|
RepositoryFileInfo |
MoveFile(RepositoryFileInfo, String, RepositoryManager.HandleOverrideFileOnMove)
Move one file from one path to another
Declaration
public void MoveFile(RepositoryFileInfo toMove, string newPath, RepositoryManager.HandleOverrideFileOnMove overrideHandler = null)
Parameters
Type | Name | Description |
---|---|---|
RepositoryFileInfo | toMove | File which will be moved |
System.String | newPath | Target path of the move process |
RepositoryManager.HandleOverrideFileOnMove | overrideHandler |
ReadAllBytes(Guid)
Declaration
public byte[] ReadAllBytes(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Returns
Type | Description |
---|---|
System.Byte[] |
ReadAllBytes(String)
Declaration
public byte[] ReadAllBytes(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
System.Byte[] |
ReadAllText(Guid)
Declaration
public string ReadAllText(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Returns
Type | Description |
---|---|
System.String |
ReadAllText(String)
Declaration
public string ReadAllText(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
System.String |
ReadStream(Guid)
Declaration
public Stream ReadStream(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Returns
Type | Description |
---|---|
System.IO.Stream |
ReadStream(String)
Declaration
public Stream ReadStream(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
System.IO.Stream |
RecalculatePathRecursive(Guid)
Recalculate all directories and subdirectorie paths recusivly
Declaration
public void RecalculatePathRecursive(Guid directory)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | directory | Guid of the start directory |
RemoveDirectory(Guid, Boolean)
Remove a directory and all of it's children. The sources in the repository will not be removed
Declaration
public void RemoveDirectory(Guid directory, bool recursive)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | directory | Id of the directory |
System.Boolean | recursive |
RenameDirectory(Guid, String)
Rename a directory and update all child paths (other directories and files)
Declaration
public string RenameDirectory(Guid id, string newName)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Unique id of the directory |
System.String | newName | New name of the directory |
Returns
Type | Description |
---|---|
System.String | New full path |
RenameFile(Guid, String)
Rename a file in the repository
Declaration
public void RenameFile(Guid id, string newName)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Unique id of the file |
System.String | newName | Name of the file |
SaveToDatabase(RepositoryFileInfo, Boolean)
Save repository content (script) in the database.
Declaration
public RepositoryFileInfo SaveToDatabase(RepositoryFileInfo info, bool prepareContentModel = true)
Parameters
Type | Name | Description |
---|---|---|
RepositoryFileInfo | info | Instance of a repository content model (RepositoryContentModel) |
System.Boolean | prepareContentModel | If set to true, the Name, Guid, ModulePath, FilePath and Hash-Value will be proofed |
Returns
Type | Description |
---|---|
RepositoryFileInfo |
SetDiretory(RepositoryDirectoryInfo)
Set a directory direct to the database, no model profing here
Declaration
public void SetDiretory(RepositoryDirectoryInfo model)
Parameters
Type | Name | Description |
---|---|---|
RepositoryDirectoryInfo | model | Instance of a directory model, containing all information |
UseLocalRepository(String)
Use a local repository instead of the database
Declaration
public void UseLocalRepository(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the local repository (absolut) |
WriteAllBytes(Guid, Byte[])
Declaration
public void WriteAllBytes(Guid id, byte[] content)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | |
System.Byte[] | content |
WriteAllBytes(String, Byte[])
Declaration
public void WriteAllBytes(string path, byte[] content)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | |
System.Byte[] | content |
WriteAllText(Guid, String)
Declaration
public void WriteAllText(Guid id, string content)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | |
System.String | content |
WriteAllText(String, String)
Declaration
public void WriteAllText(string path, string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | |
System.String | content |
WriteStream(Guid, Stream)
Declaration
public void WriteStream(Guid id, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | |
System.IO.Stream | content |
WriteStream(String, Stream)
Declaration
public void WriteStream(string path, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | |
System.IO.Stream | content |
WriteToHistory(RepositoryFileInfo, RepositoryFileInfo, Byte[], FileChangeType)
Write some information to the history of a repository file
Declaration
public void WriteToHistory(RepositoryFileInfo oldFileInfo, RepositoryFileInfo newFileInfo, byte[] newContent = null, FileChangeType changeType = FileChangeType.Unknown)
Parameters
Type | Name | Description |
---|---|---|
RepositoryFileInfo | oldFileInfo | Old-Content |
RepositoryFileInfo | newFileInfo | |
System.Byte[] | newContent | New-Content |
FileChangeType | changeType | Change type has the default value for autodetection. If a change-type is set, it will be used. |