Text Search
The search for files/folders known from the controls can be called with the following command:
var containerIds = await dms.Container.SearchContainersByString(searchString);This searches the text properties of the file base object. This means that no topic-specific fields are searched, only AzInter, AzGericht, Description, Client, Opponent, etc.
The search result is sorted in ascending order by internal file number and limited to a maximum of 1000 entries.
If you want to change this, there is an overload with more parameters:
var containerIds = await dms.Container.SearchContainersByString(
searchString,
OrderField.Mandant, false,
null, 2000);Now it is sorted in descending order (false) by Client and the first 2000 files are delivered.
The query can be further expanded with additional filters:
var containerIds = await dms.Container.SearchContainersByString(
searchString,
OrderField.Mandant, false,
null, 2000,
ContainerStatus.Inactive,
"insolvency");This will only return the inactive insolvency files. The two additional parameters statusFilter and topicFilter are optional.
Filter Search
This method can be called with a simple and a complex filter. Filters are used to search containers based on the metadata stored in the database. A complex filter is a combination of several (including hierarchical) simple filters.
Simple Filters
var filter = new SimpleExpression(
SimpleOperator.Equals,
STP.Ecm.ApiCore.Fieldname.Dossier.Filenumber,
"01/2021");
var dossierIds = await dms.Container.FilterContainerIds(filter);Simple filters allow searches for values from exactly one field. If multiple fields or multiple values of a field need to be considered, complex filters must be used.
Complex Filters
This allows multiple SimpleExpression elements to be combined with And/Or. A ComplexExpression element can contain a list of simple expressions (SimpleExpression) and/or a list of complex expressions, allowing for a tree structure.
Example of searching for files where a name is entered as a client or as an opponent:
var clientFilter = new ComplexExpression(ComplexOperator.Or);
categoryFilter.SimpleExpressions.Add(new SimpleExpression(
SimpleOperator.Equals,
STP.Ecm.ApiCore.Fieldname.Dossier.Client,
"Markus Meier"));
categoryFilter.SimpleExpressions.Add(new SimpleExpression(
SimpleOperator.Equals,
STP.Ecm.ApiCore.Fieldname.Dossier.Opponent,
"Markus Meier"));Restriction by Topics
A filter can also be limited to one or more topics. For this, a list of topic names (internal names, not display names) is specified as the second parameter.
For example, to search for folders in the knowledge base whose name starts with "Secret", you would use the following:
var filter = new SimpleExpression(
SimpleOperator.Like,
STP.Ecm.ApiCore.Fieldname.Folder.Name,
"Secret%");
var folderIds = await dms.Container.FilterContainerIds(
filter,
new [] { "Jurathek" });Sorting
If you already have a list of container IDs and want to reorder them, you can do so with the following call (here, sorting is done by client).
var orders = new List<OrderDefinition>();
orders.Add(new OrderDefinition()
{
Fieldname = STP.Ecm.ApiCore.Fieldname.Dossier.Client,
Direction = OrderDirection.Ascending
});
var sortedIds = await dms.Container.SortIds(unsortedIds, orders);Loading Data
var containerDatas = await dms.Container.LoadContainers(listOfIds);With this command, you can load the corresponding data for a list of IDs. The result list can include files and/or folders. The data objects contain all metadata, as well as the structure of the registers.
To load the documents contained in the file/folder, use the following call:
var documentIds = await dms.Container.GetDocumentIdsForContainer(containerId);This returns the IDs of all documents in the file (regardless of the section) that the user has at least read access to.
To get the contents of a section, use this:
var documentIds = await dms.Container.GetDocumentIdsForContainerTray(containerId, trayId, true);This returns the IDs of all documents directly in the specified section or in one of its subsections (true). With false, only documents directly from the section are returned.
Filter (from DMS Server 7.6.316)
Additionally, filters can be specified in the above calls to narrow down the results.
var documentIds = await dms.Container.GetDocumentIdsForContainer(containerId, filter);Modify Data
Separate methods must be called for files and folders. However, the procedure is always the same. A list of field data to be changed must be created and then the update command is called with the container ID.
Create change list:
var changes = new List<FieldUpdateInfo>();
changes.Add(new FieldUpdateInfo() {
FieldKey = STP.Ecm.ApiCore.Fieldname.Dossier.Description,
Value = "New File Name"
}This allows a change to be made to the file. Here, the file name is changed.
var dossierId = await dms.Container.UpdateDossier(dossierId, changes);Create Folder
var name = "New Folder";
var folderId = await dms.Container.CreateFolder(name, "Jurathek");A new folder named “New Folder” is created under the topic “Jurathek.” Note: Folder names must be unique across the entire DMS.
Create File
Similar to folders, files can also be created. A file number and a description are required for this.
var azIntern = "01/2021";
var bezeichnung = "First File of the Year";
var folderId = await dms.Container.CreateDossier(azIntern, bezeichnung, "STPAkte");When creating, a register structure can be directly provided, which will be set on the new file:
var registers = new[] {
new FilingTrayDto() {
Id = 1,
TrayId = 1,
ParentId = 0,
Text = "An example register",
Number = 1
}
};
var folderId = await dms.Container.CreateDossier(azIntern, bezeichnung,
"STPFile", registers.ToArray());To create a file with a register structure template, use the following method. The filingSystemTemplateId you need to provide here can be obtained by querying the templates (see Query Filing Plans).
var filingSystemTemplateId = ...
var containerId = await dms.Container.CreateDossier("01/2021", "Example File", "STPFile", filingSystemTemplateId);Register
Create Register
To add a new register to a container, call the following:
var registerName = "New Register";
var parentTrayId = 0; // 0 is the top level, directly under the file/folder
var tray = await dms.Container.CreateFilingTray(containerId, registerName, parentTrayId);Rename Register
var newRegisterName = "Updated Register";
var trayId = 1; // the Id can be obtained from the container's FilingTrays list
var tray = await dms.Container.UpdateFilingTray(containerId, trayId, newRegisterName);Delete Register
var trayId = 1; // the Id can be obtained from the container's FilingTrays list
var success = await dms.Container.DeleteFilingTray(containerId, trayId);Query Filing Plans
In DMS, there are templates for the register structure of files/folders. These templates must be approved for a topic (file/folder type). The following function can be used to query the approved templates for a topic.
var templates = await dms.Container.GetFilingSystemTemplates("Insolvency");In the example, the templates for the insolvency topic are queried.
Starting from DMS Server 7.5.258, the information queried here also includes the register structure of the template.
Related to