Click or drag to resize

clsImportDocument Class

Inheritance Hierarchy
SystemObject
  MARIInterfaceclsImportBase
    MARIInterfaceclsImportDocument

Namespace:  MARIInterface
Assembly:  MARIInterface (in MARIInterface.dll) Version: 8.0.0.100
Syntax
public class clsImportDocument : clsImportBase

The clsImportDocument type exposes the following members.

Constructors
  NameDescription
Public methodclsImportDocument
Initializes a new instance of the clsImportDocument class
Top
Properties
  NameDescription
Public propertyByteData
To upload a file as a byte array without physical file path
Public propertyByteDataMIMEType
The mime type will be set automatically, by extension from FileNameAndPath. Please set this field, when data is delivered as byte array in ByteData.
  • application/msg
  • application/msword
  • application/octet-stream
  • ...
Public propertyDataClassID
Type of the data (internal ClassID) See clsImportBase.eCoreDataClassID. Not for all dimensions document can be linked. See Folder definition in the settings of MARIProejct.
Public propertyDataKey
Key of the data (Projectnumber,ContractID etc.)
Public propertyDateTime
(readonly) Date of primary creation
Public propertyDMSDocumentID
DMSDocumentID Internal Key in the DMS System
Public propertyDocumentID
(readonly) Internal Document of the picture or document in the Sub Tables
Public propertyDocumentType
Picture or document: eDocumentType.
Public propertyFileNameAndPath
Path of the file, where MARIIntercace can directly access the source file.
Public propertyFolderID
FolderId of the folder definition for the given dimension DataClassID . SELECT GroupID FROM MARIFolderDocumentsGroups

This property can be used instead of the property FolderName

Public propertyFolderName
FolderName in the dimension. If no Folder Name given, the first tab in the folders is used. SELECT [Description] AS FolderName, ClassID, GroupID FROM MARIFolderDocumentsGroups

This property can be used instead of the property FolderID

Public propertyLinkToUploadedDocument
ID of the existing document: Load as reference to the access ID. In Memory, the real ID from the table will be used.
Public propertyLinkType
Mandatory selection for the file handling: eLinkType
Public propertyMemo
Memo of the document. Also Text for the Note variant
Public propertyTitle
Title of the document
Top
Remarks
For each dimension first, the folders has to be defined.

Store the Folder Names (tabs) by dimension. View: MARIFolderDocumentsGroups: :Table: MPSammelmappeGruppen

Locical Link between a master data and a document: View: MARIFolderDocuments: :Table: MPSammelmappe

Store binary data in the database for files: View: MARIDocuments: :Table: MPDokumente

Store binary data for images: View: MARIPictures: :Table: MPBilder

Examples
Upload a file into the folder mechanism
/// <summary>
/// Example to upload a file into the file mechanism and attach it to a dimension
/// </summary>
/// <param name="sFileName">Full file+path name</param>
/// <param name="sDocTitle">Text in the list of files</param>
/// <param name="nClassID">Dimension 40=project</param>
/// <param name="sClassKey">Project number or employee number...</param>
/// <param name="sFolderName">The folder mechanism has folders for each dimension. The correct folder is found by its name</param>
/// <returns></returns>
private int bImportFileToDatabase(string sFileName, string sDocTitle, clsImportBase.eCoreDataClassID nClassID, string sClassKey, string sFolderName) {

    string sErrordetails;
    try {

        //The import tool has to have access to the file
        System.IO.FileInfo fi = new System.IO.FileInfo(sFileName);
        if (fi.Exists) {

            clsImportDocument NewDocument = new clsImportDocument();
            NewDocument.DocumentType = clsImportDocument.eDocumentType.Document; // or Picture
            NewDocument.DateTime = fi.LastAccessTime;
            NewDocument.DataClassID = nClassID;
            NewDocument.FileNameAndPath = sFileName;
            NewDocument.LinkType = clsImportDocument.eLinkType.UploadDocument;
            NewDocument.Title = sDocTitle;
            NewDocument.DataKey = sClassKey;
            NewDocument.FolderName = sFolderName;
            if (MPInterface.bImportDocument(NewDocument, clsImportBase.eImportMode.ValidateAndImport)) {
                return NewDocument.DocumentID; // ID in MARIPictures/MARIDocuments
            } else {
                throw new NotImplementedException(MPInterface.sPrintErrors());
            }
        }
    } catch (Exception ex) {
        sErrordetails = ex.Message;
        Assert.False(true, sErrordetails);
    }
    return 0;
}
Examples
Link a filed already uploaded to another location
/// <summary>
/// Link a filed already uploaded to another location. Serveral links, but only one file in the database.
/// </summary>
/// <param name="lFileID"></param>
/// <param name="sFileName"></param>
/// <param name="sDocTitle"></param>
/// <param name="nClassID"></param>
/// <param name="sClassKey"></param>
/// <param name="sFolderName"></param>
/// <returns></returns>
private bool bLinkExistingFileToObject(int lFileID, string sFileName, string sDocTitle, clsImportBase.eCoreDataClassID nClassID, string sClassKey, string sFolderName) {
    try {

        //The import tool has to have access to the file
        System.IO.FileInfo fi = new System.IO.FileInfo(sFileName);
        if (fi.Exists) {

            clsImportDocument NewDocument = new clsImportDocument();
            NewDocument.DocumentType = clsImportDocument.eDocumentType.Document; // or Picture
            NewDocument.DateTime = fi.LastAccessTime;
            NewDocument.DataClassID = nClassID;
            NewDocument.FileNameAndPath = sFileName;
            NewDocument.LinkType = clsImportDocument.eLinkType.LinkToUploadedDocument;
            NewDocument.LinkToUploadedDocument = lFileID;
            NewDocument.Title = sDocTitle;
            NewDocument.DataKey = sClassKey;
            NewDocument.FolderName = sFolderName;
            if (MPInterface.bImportDocument(NewDocument, clsImportBase.eImportMode.ValidateAndImport)) {
                return true;
            } else {
                throw new NotImplementedException(MPInterface.sPrintErrors());
            }
        }
    } catch (Exception) {

        throw;
    }

    return false;
}
Examples
Link a simple note to the folder mechanism
private bool bAddNoteToFolder(string sNoteContent, string sNoteTitle, clsImportBase.eCoreDataClassID nClassID, string sClassKey) {

    clsImportDocument NewDocument = new clsImportDocument();
    NewDocument.DocumentType = clsImportDocument.eDocumentType.Document; // This property is not relevant for a note
    NewDocument.DateTime = DateTime.Now;
    NewDocument.DataClassID = nClassID;
    NewDocument.LinkType = clsImportDocument.eLinkType.Notice; // Link Type for a note
    NewDocument.Title = sNoteTitle;
    NewDocument.DataKey = sClassKey;
    NewDocument.Memo = sNoteContent;
    if (MPInterface.bImportDocument(NewDocument, clsImportBase.eImportMode.ValidateAndImport)) {
        return true;
    } else {
        throw new NotImplementedException(MPInterface.sPrintErrors());
    }
}
See Also