Changes

DocumentProxy

605 bytes added, 15:56, 24 June 2024
/* BatchDocumentProxyCreator */
{{Attention|This page is under construction.}}
 
== Basics ==
A Document Proxy object contains the logic of a basic [[Proxy]] object combined with the capability to handle file documents from an interface.
One Document Proxy object can handle both import and export of the same Ubik FileDocument instance via one interface.
{{Hint|A Document Proxy object '''MUST HAVE''' Proxies are instances of PX_DOCUMENT or a derivative of it defined as its [[MetaClass]]!}}The TargetType for DocumentMetaProxy has to should be a FileDocument MetaClass.
[[Category:Document|DocumentProxy]][[Category:Interfacing|DocumentProxy]] == DocumentMetaProxy Setup ==
UBIK provides a DocumentMetaProxy called '''PX_DOCUMENT''' (UID: 58c1a444-3867-41e7-84a2-bd655fb04755) that is derived from PROXYROOT.
The TargetType of DocumentMetaProxies needs to be set to a FileDocumentMetaClass (e.g. a MetaClass derived from FILEDOCUMENT).
The following methods need to be overridden for the InterfaceAdministration MetaClasses that are related to DocumentMetaProxies via their SYSREL_INTERFACE_ADMIN_METAPROXY relation:
* GetExternalDataReader()
Here it is necessary to return an object of a class that implements the abstract class ''DocumentReadFromExternalExecutionBase''.
 
<source lang="csharp">
namespace protected override UBIK.Interface.IInterfaceExecutor GetExternalDataReader()
{
public struct FileDetails { public string FileName; public string FullPath; public string ContentType; public DateTime CreationTime; }  public abstract class DocumentReadFromExternalExecutionBase : InterfaceExecutionBase { return new UBIK.Interface.FileDocumentReadFromExternalExecutor(this. public abstract Stream GetFilestream(DocumentProxy proxy);  public abstract bool TryGetFileDetails(DocumentProxy proxy, out FileDetails detailsEnvironment); }
}
</source>
* GetExternalDataWriter()
<source lang="csharp">
protected override UBIK.Interface.IInterfaceExecutor GetExternalDataWriter()
{
return new UBIK.Interface.FileDocumentWriteToExternalExecutor(this.Environment);
}
</source>
[[Category:Document|DocumentProxy]]
[[Category:Interfacing|DocumentProxy]]
== Properties ==
! Property!! Description
|-
| Key|| External primary key. Can be the The '''file path ''' to the external document or a byte stream(ubik needs to have access to it). External primary key.
|-
| File name|| The name of the external file (including its extension).
== DocumentBatchProxyCreator BatchDocumentProxyCreator ==The DocumentBatchProxyCreator BatchDocumentProxyCreator class provides the possibility to create multiple Document Proxies with the import status set to QuedForReadFromExternal.
The following two methods can be executed by e.g. using Who-Bert:
'''Example: Asking a DocumentBatchProxyCreator BatchDocumentProxyCreator to create Document Proxies for all documents in a folder. The import status will be set to QuedForReadFromExternal for all of them(top level only) without filters.'''
<source lang="csharp">
MetaProxy myMetaProxy = obj.Environment.UBIKDataFactory().ContentObject(new Guid("put UID of your MetaProxy here")) as MetaProxy;
// Creating a DocumentBatchProxyCreator BatchDocumentProxyCreator instanceUBIK.Interface.DocumentBatchProxyCreator BatchDocumentProxyCreator creator = new UBIK.Interface.DocumentBatchProxyCreatorBatchDocumentProxyCreator();
// Defining string for folder pathstring folderPath = @"C:\Documents"; // calling ImportBatchOfDocumentsCreateProxies() without filtering options
// Parameter 1: the path to the folder that contains the documents.
// Parameter 2: the MataProxy
creator.ImportBatchOfDocumentsCreateProxies("put path folderPath, myMetaProxy);</source> '''Example: Asking a BatchDocumentProxyCreator to create Document Proxies for all documents in a folder here(top and sub levels) with filters.''' <source lang=", csharp">// Getting your required MetaProxyMetaProxy myMetaProxy= obj.Environment.UBIKDataFactory().ContentObject(new Guid("put UID of your MetaProxy here")) as MetaProxy; // Creating a BatchDocumentProxyCreator instanceUBIK.Interface.BatchDocumentProxyCreator creator = new UBIK.Interface.BatchDocumentProxyCreator(); // Defining string for folder pathstring folderPath = @"C:\Documents"; //Define string for search patternstring searchPattern = "*.pdf";
// calling ImportBatchOfDocumentsCreateProxies() with filtering options
// Parameter 1: string of the path to the folder that contains the documents.
// Parameter 2: the MataProxy
// Parameter 3: string of the search pattern
// Parameter 4: System.IO.SearchOption
creator.ImportBatchOfDocumentsCreateProxies("put path to folder here"folderPath, myMetaProxy, "*mySearchPattern*"searchPattern, SearchOption.AllDirectories);
</source>
[[Category:Document|DocumentProxy]]
[[Category:Interfacing|DocumentProxy]]
==See also==
* [[ProxyMetaProperty]]
* [[Proxy]]
* [[ProxyScanner]]
* [[HowTo:Configure_Proxies]]
 
[[Category:Document|DocumentProxy]]
[[Category:Interfacing|DocumentProxy]]
322
edits

Help improve this page!