Skip to content

IPersistedDocumentStore

Funktionsweise

Mit dem IPersistedDocumentStore können zusätzliche Eigenschaften von Dokumenten abgerufen werden. Dazu gehören beispielsweise Versionen und Renditions.

Voraussetzung

IPersistedDocumentStore wie in Injectables beschrieben als Konstruktor Dependency hinzugefügt.

Beispiel

Der folgende Code lädt die Rendition der neusten Dokumentversion, sofern es sich um ein Word-Dokument handelt.

string extension = "docx";
var dokInfo = ws.DokStore.GetDokumentInfo(dokument.ObjGuid, dokument.TypeDefinition.MainDocumentField.ID);
try
{
    var rendition = documentStore.GetRenditions(dokument.ObjGuid, dokument.TypeDefinition.MainDocumentField.ID)
                .Where(rend => rend.REN_EXTENSION.EndsWith("docx"))
                .OrderByDescending(rend => rend.REN_VERSION)
                .FirstOrDefault();
    var test = documentStore.
    if (rendition == null)
    {
        try
        {
            rendition = documentStore.GetRenditions(dokument.ObjGuid, dokument.TypeDefinition.MainDocumentField.ID)
                    .Where(rend => rend.REN_EXTENSION.EndsWith("xlsx"))
                    .OrderByDescending(rend => rend.REN_VERSION)
                    .FirstOrDefault();
            extension = "xlsx";
        }
        catch { }
    }
    if (rendition != null)
    {
        var fileStream = ws.DokStore.Get(dokument.ObjGuid, dokument.TypeDefinition.MainDocumentField.ID, decimal.ToInt32(rendition.REN_VERSION), Guid.Parse(rendition.REN_CREATORJOB), new CMI.Workspaces.AllowEverythingAccessChecker(), 20);
        if (fileStream != null)
        {
            ws.DokStore.CheckIn(new CheckInRequest
            {
                Content = fileStream,
                Dokumentstatus = Dokumentstatus.Zwischenversion,
                Ext = extension,
                CheckinComment = "Übernahme aus Dokukiosk für Revision",
                FileName = dokInfo.Filename,
                FldId = dokument.TypeDefinition.MainDocumentField.ID,
                ObjGuid = dokumentRevision.ObjGuid,
                SecurityLevel = (DocumentLevel)dokInfo.DokumentSchutzstufe,
                SessionGuid = userSession.SessionGuid,
                TypId = dokument.TypeDefinition.ID,
                CheckInFromIntermediateStorage = false
            }, ws.ObjektDaten);
        }
    }
    else
    {
        ClientActions.DisplayProgressLogEntry(Severity.Warning, "Von diesem Dokument ist keine Word-Version verfügbar. Bitte importieren Sie eine neue Worddatei in die erstellte Dokumenthülle.");

    }
}
catch {

}