IFile Interface |
Namespace: PDTec.IceNet.Core.Model.File
public interface IFile : IObject
The IFile type exposes the following members.
Name | Description | |
---|---|---|
ChangedBy |
Gets the name of the user who changed the object last.
(Inherited from IObject.) | |
ChangedOn |
Gets the point of time the object was changed last.
(Inherited from IObject.) | |
CreatedBy |
Gets the name of the user who created the object.
(Inherited from IObject.) | |
CreatedOn |
Gets the point of time the object was created.
(Inherited from IObject.) | |
Description |
Gets or sets the object description. The description can be empty.
(Inherited from IObject.) | |
Extension |
Gets or sets the file extension.
| |
Folder |
Gets the containing folder.
(Inherited from IObject.) | |
Id |
Gets the object ID. The ID is generated by the platform and
cannot be modified.
(Inherited from IObject.) | |
IsLocked |
Indicates if the object is locked.
(Inherited from IObject.) | |
IsValid |
Indicates if the object instance is valid. The object becomes
invalid if the Destroy method has been called.
(Inherited from IObject.) | |
LockedBy |
Gets the name of the user who holds a lock on the object, empty
string if the object is not locked.
(Inherited from IObject.) | |
LockedOn |
Gets the lock timestamp, if object is locked. DateTime.MinValue if not.
(Inherited from IObject.) | |
Name |
Gets or sets the object name. The name cannot be an empty string. It is
modifiable and does not have to be unique.
(Inherited from IObject.) | |
ObjType |
Gets the object type.
(Inherited from IObject.) |
Name | Description | |
---|---|---|
AddKey |
Adds a new key to the object. The key must be unique
within the system context (e.g. unique per database).
(Inherited from IObject.) | |
AppendContent |
Appends content at the end of the most current version. If there is
no version so far, the method fails.
| |
AsT | Obsolete.
Casts to a Business Object interface.
(Inherited from IObject.) | |
CastT |
Casts to a Business Object interface. Throws an exception if the Business Object
interface is not available for this object.
(Inherited from IObject.) | |
ChangeObjType |
Change the object type.
(Inherited from IObject.) | |
ConnectContent |
Connects an existing file content as the most current version to the file object.
| |
CopyTo |
Copies the object. Attributes of the object are copied, relationships not.
(Inherited from IObject.) | |
DeleteKey |
Removes a key from the object.
(Inherited from IObject.) | |
Destroy |
Deletes the object (and its relationships).
(Inherited from IObject.) | |
DestroyContentVersion |
Deletes a specific content version.
| |
GetAttrValue(IAttrDef) |
Retrieves the specified attribute value.
(Inherited from IObject.) | |
GetAttrValue(String, String) |
Retrieves the specified attribute value.
(Inherited from IObject.) | |
GetAttrValue(IAttrDef, Boolean) | Obsolete.
Retrieves the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
GetAttrValue(String, String, Boolean) | Obsolete.
Retrieves the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
GetAttrValues |
Get all attribute values of the object.
(Inherited from IObject.) | |
GetContentSize |
Retrieves the size of the latest version (in bytes).
| |
GetContentSize(Int64) |
Retrieves the size of a specific version (in bytes).
| |
GetContentVersion |
Gets the specific content version.
| |
GetContentVersions |
Retrieves all content versions in the default order (first version comes first,
current version has the index GetContentVersions().Length - 1.
| |
GetFolder |
Retrieves the object's folder.
(Inherited from IObject.) | |
GetKeys |
Retrieves the object's (unique) keys.
(Inherited from IObject.) | |
GetLockInfo |
Retrieves information about the object's lock status.
(Inherited from IObject.) | |
GetObjType |
Retrieve the object type.
(Inherited from IObject.) | |
GetRelationships(RelDirection) |
Retrieves all attached relationships of a specific direction (regardless of their relationship type).
(Inherited from IObject.) | |
GetRelationships(String, RelDirection) |
Retrieves all attached relationships of a specific role (relationship type/direction combination).
(Inherited from IObject.) | |
GetRelationships(IRelType, RelDirection) |
Retrieves all attached relationships of a specific relationship type in a
specific direction.
(Inherited from IObject.) | |
GetSingleRelationship(String, RelDirection) |
Retrieves a single relationship (omit the array overhead).
(Inherited from IObject.) | |
GetSingleRelationship(IRelType, RelDirection) |
Retrieves a single relationship (omit the array overhead).
(Inherited from IObject.) | |
GetTableAttrTemplateRow |
Gets a table attribute template row.
(Inherited from IObject.) | |
GetTableAttrValues |
Gets the table attribute values.
(Inherited from IObject.) | |
IsOf(String) |
Indicates if the object conforms to a specific object type directly
or indirectly (is a subtype of).
(Inherited from IObject.) | |
IsOf(IObjType) |
Indicates if the object conforms to a specific object type directly
or indirectly (is a subtype of).
(Inherited from IObject.) | |
Lock |
Lock the object.
(Inherited from IObject.) | |
MoveTo |
Moves the object to another folder.
(Inherited from IObject.) | |
QueryInterface |
Cast to a Business Object interface.
(Inherited from IObject.) | |
ReadContent(Byte) |
Retrieves the content of the current version.
| |
ReadContent(Int64, Byte) |
Retrieves the content of a specific version.
| |
ReadContentPart(Int64, Int32, Byte) |
Retrieves the binary file content of the latest version.
| |
ReadContentPart(Int64, Int64, Int32, Byte) |
Retrieves the binary file content of a specific version.
| |
Reload |
Refreshes the object data from secondary storage (e.g. database)
if available. Use this method to retrieve up-to-date audit information
(ChangedBy, ChangedOn properties).
(Inherited from IObject.) | |
SetAttrValue(IAttrDef, Object) |
Stores the specified attribute value.
(Inherited from IObject.) | |
SetAttrValue(String, String, Object) |
Stores the specified attribute value.
(Inherited from IObject.) | |
SetAttrValues |
Set multiple attribute values with a single method call.
(Inherited from IObject.) | |
SetRelationshipIndex |
Re-position a relationship within the object/reltype/direction order.
(Inherited from IObject.) | |
SetRelationshipIndices |
Re-order all relationships of a object/reltype/direction context.
(Inherited from IObject.) | |
SetTableAttrValues |
Sets the table attribute values.
(Inherited from IObject.) | |
Touch |
Updates the ChangedBy and ChangedOn information.
(Inherited from IObject.) | |
TryCastT |
Casts to a Business Object interface.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Boolean) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, DateTime) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Double) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Int64) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Object) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, String) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Boolean) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, DateTime) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Double) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Int64) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Object) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, String) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetContentVersion |
Tries the get a specific content version.
| |
TryGetSingleRelationship(String, RelDirection, IRelationship) |
Tries to retrieves a single relationship.
(Inherited from IObject.) | |
TryGetSingleRelationship(IRelType, RelDirection, IRelationship) |
Tries to retrieves a single relationship.
(Inherited from IObject.) | |
UnLock |
Unlock the object.
(Inherited from IObject.) | |
UpdateContentVersion |
Updates the data of a specific version.
| |
WriteContent |
Stores binary file content as the most current version of the file object.
|
Name | Description | |
---|---|---|
GetFolderId |
Gets the folder ID without unneccessarily retrieving the full folder information.
(Defined by ModelExtensions.) | |
GetRepository |
Gets the corresponding repository for an object.
(Defined by ModelExtensions.) | |
IsConnected(String, RelDirection) | Overloaded.
Detects whether an object is connected by at least one relationship of a specific type.
(Defined by ModelExtensions.) | |
IsConnected(IRelType, RelDirection) | Overloaded.
Detects whether an object is connected by at least one relationship of a specific type.
(Defined by ModelExtensions.) |
This example explains how to use the IFile interface to read and write file content.
The following code shows how to create a file object and to store binary content into the built-in vault System.Database:
IObjType pFileObjType = m_pRepository.GetObjTypeByName("Core.File"); byte[] aContent = Encoding.ASCII.GetBytes("FILECONTENT"); Repository.ExecuteTransaction(delegate() { // Create a file object... IFile pFile = pFileObjType.Create<IFile>(m_pRepository.RootFolder, "F1", ""); // Store content (implicitly creates a first content version)...... pFile.WriteContent(true, "", "System.Database", "f1.txt", aContent); });
The following code shows how read binary content from a file:
IFile pFile = Repository.Get<IFile>(objectId); byte[] aContent; // Reads file content from the current (most recent) file version into buffer... pFile.ReadContent(out aContent); // Gets the file size of the current version... long size = pFile.GetContentSize(); // Reads file content with offset and partial size parameters... pFile.ReadContentPart(0, (int)size, out aContent);
The following code shows how to use the AppendContent function to subsequently add content to a file:
IObjType pFileObjType = m_pRepository.GetObjTypeByName("Core.File"); byte[] aContent0 = Encoding.ASCII.GetBytes("F"); byte[] aContent1 = Encoding.ASCII.GetBytes("1"); Repository.ExecuteTransaction(delegate() { // Create a file object... IFile pFile = pFileObjType.Create<IFile>(m_pRepository.RootFolder, "F1", ""); // Store initial content (implicitly creates a first content version)... pFile.WriteContent(true, "description", "System.Database", "f1.txt", aContent0); // Append content to the current version... pFile.AppendContent(aContent1); });
This example explains how to work with vaults and file content directly. This can be useful to implement a transactional safe Web uploading process that enables to upload large files in parts, where the whole uploading process cannot be encapsulated in a single database transaction for HTTP request memory size and timeout reasons:
This procedure ensures that if the upload process fails at one point, the file object does not appear in the database at all. This avoids broken file objects. Unconnected FileContents can be identified and removed easily by a vault utility.
The following code shows how to create a file in several steps and how the individual transactions can be separated from each other.
byte[] aContent = Encoding.ASCII.GetBytes("1234567890"); IVault pVault = Repository.GetVaultByName("System.Database"); string contentUuid = null; // // First step: create a FileContent record in the database... // string hash = FileUtils.CalculateHash(aContent); Repository.ExecuteTransaction(delegate { contentUuid = pVault.CreateFileContent(aContent.Length, hash).Uuid; }); // // Second step: Use the IVaultProtocol of the vault to upload the content... // IVaultProtocol pProtocol = pVault.GetProtocol(); string correlationId = CreateFileContentPartStart(contentUuid); pProtocol.CreateFileContentPartContinue(contentUuid, correlationId, 0, aContent.Take(5).ToArray()); pProtocol.CreateFileContentPartContinue(contentUuid, correlationId, 1, aContent.Skip(5).ToArray()); pProtocol.CreateFileContentPartComplete(contentUuid, correlationId, 2); // // Final step: Create the File object and connect the FileContent as a new content version... // IFile pFile = null; Repository.ExecuteTransaction(delegate { pFile = Repository.GetObjTypeByName("Core.File").Create<IFile>(Repository.RootFolder, "F1", ""); pFile.ConnectContent(true, "", "test.txt", contentUuid); });