Click or drag to resize
Dynamic File System
1. Overview

Files in packflow are handled via a specific object named PFFile. It it accessible for the user through a PFFIeldFileHolder control in forms, API, or via an embedded WebDAV server. PFFiles are hosted under a parent PFItem

2. Architecture

Database organisation

Files are stored in an application-dedicated table, ensuring constant performance even with a growing number of applications. See PFFile for further details about persisted metadata.

Database Overview

UI Lifecycle

Files can be created from a template or uploaded using the FileHolder control. This can be made within an Item's form or via inline editing. File has to be confirmed by saving the parent item, otherwise it won't be persisted after form closing.

File Upload 2

Once uploaded, a PFFile can be downloaded, deleted or edited online (MS Office files), even before confirmation.

Templates

PACKflow allows to use predefined FileHolders as template source for file creation.

At modeling level, designer can select a template source fileHolder for another FileHolder. Settings are available to narrow the range of files proposed.

This allows easy runtime management of template files.

URLs

Each file can be accessed through 2 standardized URLs.

  • [PackflowSiteUrl]/Files/[Application Id]/[ContentType Id]/[Item Id]/[File Id]
  • [PackflowSiteUrl]/Files/[Application Id]/[ContentType Id]/[Item Id]/[FileHolder Field Name]/[File Name]

Both URL formats can be used to download files and perform other WebDAV operations.

Permissions

Files are protected by Row Level Security in database.

CRUD permissions are based on parent Item's CRUD. Here is a table showing relations between file and item permissions.

Operation on file

Required permission on parent item

Create

Update

Read

Read

Update

Update

Delete

Update or Delete

Developers information

Relations within PACKflow objects

Here is a description on how the files are related to their parents in PACKflow.

A PFFile always exists under a PFItem instance. It saves metadata about its parent PFApplication, PFContentType and PFFieldFileHolder.

PFFile references are exposed via a PFFieldFileHolderValue on the parent item's FileHolder property.

This value allows to load the files using the Files property on the item.

Objects Overview

Events

Here is a list of events developers can hook on to override default behavior.

Code Examples

Here are some exemples on how to use the PFFile object via API.

  • Subscribe to file events for every file under a ContenType.

    Override the item's OnInitialized method, and hook on the events from there.

    You may also subscribe to events directly on an item instance, but this will have effect on this specific instance only.

    See following handler and event arguments for further details.

    C#
    public partial class ParentItemClass:PFItem{
    
        protected override void OnInitialized()
        {
            base.OnInitialized();
            FileDownloaded += OfficialDocument_FileDownloaded;
            FileOpened += OfficialDocument_FileDownloaded;
            BeforeCreateFile += OfficialDocument_BeforeCreateOrUpdateFile;
            BeforeUpdateFile += OfficialDocument_BeforeCreateOrUpdateFile;
        }
    
        void OfficialDocument_BeforeCreateOrUpdateFile(object sender, PFItem_FileEventArgs e)
        {
            //Your event code here.
            PFFile currentFile = e.File; 
        }
    }
  • Get a file from a FileHolder value

    Items expose FileHolder fields values as properties returning a PFFieldFileHolderValue object.

    C#
    public class MyUtils {
    
        public List<PFFile> LoadFilesUnderItem(MyItemClass myItemInstance)
        {                                        
            PFFieldFileHolderValue fileHolderValue = myItemInstance.__MyFileHolder;
            //PFFIeldFileHolderValue holds metadata about files in the 'References' collection.
            //You may find here the file name, its URl, and parents Ids and Guids.
    
            PFFileReference fileRef = fileHolderValue.References.FirstOrDefault();
            string fileName = fileRef.Name;
            string fileUrl  = fileRef.Url;
    
            //You may load files with all metadata and content by using the Files property on the PFItem.
            List<PFFile> files = myItemInstance.Files.GetByValue(fileHolderValue);
    
            return files;
        }
    }
  • Create a file under an item.

    C#
    public class MyUtils {
    
        public void CreateFileUnderItem(MyItemClass myItemInstance)
        {
            string fileName = "MyNewFileName.pdf";
            byte[] fileContent = File.ReadAllBytes("c:\testFile.pdf");
    
            PFFile newFile = myItemInstance.AttachFile(fileName, fileContent, 
            myItemInstance.ParentContentType.PFField_MyFileHolder);
            newFile.Save();
    
            //Save parent item to confirm file.
            myItemInstance.Save();
        }
    }
  • Do a manual QuickParts dataBinding

    Packflow can feed MSOffice documents with Word QuickParts-compatible data. See MS Office integration for further details. The code below loads a PFFile, creates or updates its QuickParts dataset, then saves it.

    C#
    public class MyUtils {
    
        public void RefreshFilesQuickParts(MyItemClass myItemInstance)
        {
            PFFile fileToFeed = myItemInstance.Files.GetByValue(myItemInstance__MyFileHolder).FirstOrDefault();
    
            if(fileToFeed!=null && MicaSystems.Utils.Utils_File.IsWord2010File(fileToFeed.Name);
            {
                PFQuickPartsBinder binder = new PFQuickPartsBinder(myItemInstance.ParentContentType);
                Stream updatedFileStream = binder.refreshFile(fileToFeed,myItemInstance);
                byte[] updatedFileContent = binder.refreshFile2(fileToFeed,myItemInstance);
                fileToFeed.save();
            }
        }
    }

    See PFQuickPartsBinder for further details.

3. MS Office integration

Online Documents edition

PACKflow has a MS-Office compatible WebDAV module, allowing online edition of hosted files.

Online edition is compatible with Forms Authentication.

See Forms authentication for details.

Note Note
Online edition of documents can only be triggered when browsing forms with Internet Explorer or Firefox.

Extension to Chrome is scheduled but not yet implemented.

QuickParts

PACKflow can databind an Item's properties with a MS Word document. This allows the user to use dataBound placeholders without needing specific add-ins or tools.

QuickParts databinding is set in modeling, with specific settings for each FileHolder.

Note Note
Databinding is one-way only, from item's data to document. There is no mechanism to get the values in a document back to the item.

This may implemented in custom code, by subscribing to AfterUpdateFile.

See the following links for further details about XML and Quick Parts in Office.

Office Quick Parts overview

Basic description of Quick Parts in MS Word.

Well defined Custom XML parts : Content-Types schemas

Information about the XML schemas PACKflow complies with for MS Word integration.

DataBinding triggers

Choosing when QuickParts databinding happens for a FileHolder can be set in modeling. There are 3 cumulable options.

  • Upon File upload / creation

    Databinding takes place when a new file is uploaded, or created from a template.

  • Upon File download / open

    Databinding happens each time a file is downloaded or opened online.

  • Upon user request.

    Databinding is made upon user request. A dedicated button is made available on the FileHolder control.

DataBinding source content-type

At modeling level, it is possible to choose a source content-type which is different than the content-type the FileHolder belongs to.

In this case, the file will be fed with source content-type schema information, but will hold no values.

This feature is interesting in combination with templating. It allows to use a FileHolder as a template source for another content-types's FileHolder, complying with target content-type's schema.

Hence user may design a template document with Quick Parts before any example data exists.

Databinding sequence

Quick Parts Databinding
4. WebDAV module
The WebDAV module is responsible for serving Files exposed through FileHolder fields.

It implements standard WebDAV extensions while being Office and WebDAV MiniRedirector compatible.

PACKflow Site ,Applications , ContentTypes, items and fileHolders are exposed as a WebDAV folder structure.

See links below for further details about the WebDAV standard, and its integration within Office.

Supported operations

HTTP VerbSupported on fileSupported on folder
OPTIONSYesYes
PROPFINDYesNo
PROPPATCHNoNo
GETYesNo
HEADYesYes
LOCKYesNo
UNLOCKYesNo
PUTYesNo
COPYYesNo
DELETEYesNo

Authentication

Transport authentication mechanisms such as Windows ans basic authentication are natively supported by Office.

Forms authentication compatibility is achieved through MS-OFBA compliance.

See Forms Authentication for further details.

Thumbnails

When adding the querystring '?Thumb=true' to a WebDAV query, the server will compute a 200px wide png thumbnail and return it if applicable. See GetThumbnail for further details.

Thumbnails are generated for the following file types:

  • Image files: Bmp, Jpg, Jpeg, Png, Gif
  • Office Files: Docx, Docm

Cache

WebDAV modules maintains a disk cache on the server to avoid overloading the SQL server.

On every request file, the version of the cached file is compared to the version in Database. Hence, only up-to-date files are output by the WebDAV module.

The thumbs are also cached by WebDAV for better performances.

See Also