/// <summary> /// Creates an import template contract and sets mandatory and optional fields. /// /// The name of the import template contract is passed as an argument. /// Calls the CreateImportTemplate method on an instance of the InfoShareService.CommonClient /// class and passes the connection id of the administrator, and the import /// template contract as arguments. /// </summary> /// <param name="connAdminUserID">the connection id of the administrator</param> /// <param name="importTemplateName">the import template name</param> /// <param name="schemaCulture">the schema culture</param> /// <returns>the import template id of the created import template</returns> public string CreateImportTemplate(string connAdminUserID, string importTemplateName, string schemaCulture) { StringGlobalContract strGlobalContract = Utility.ConvertStringToStringGlobalContract(importTemplateName, schemaCulture); ImportTemplateContract importTemplateContract = new ImportTemplateContract { // Sets mandatory field Name = strGlobalContract, // Sets optional fields CanChangeFolders = true, CanChangeInfoStore = true, CanChangeLifeCycle = true, CanChangeLinks = true, CanChangeProcessTemplate = true, CanChangeSignatureProfile = true, CanChangeProtectionDomain = true, CanChangeProperties = true }; string importTemplateID = CommonClient.CreateImportTemplate(connAdminUserID, importTemplateContract); this.RefreshSchemaStore(connAdminUserID); return(importTemplateID); }
/// <summary> /// Creates a document for the specified file id. /// /// Searches for the import template contract with the specified import /// template id and assigns the template to the document contract. It also /// takes over the protection domain and the info store from the import /// template and assigns it to the document contract. It reads out the /// properties passed in the hash map and sets the properties' keys and /// values for the document contract. Furthermore, it sets the name of /// the document. Calls the createDocument method on an instance of the /// InfoShareService class and passes the connection id, the document /// contract, and the file id as arguments. Returns the document contract, /// if the contract is successfully created. /// /// Before creating a document you must call either the uploadFileBytes or /// uploadFileBytesInChunks method on an instance of the File class. These /// methods return the file id you need to create a document. /// /// </summary> /// <param name="documentClient">the document client of the info share WCF service</param> /// <param name="commonClient">the common client of the info share WCF service</param> /// <param name="connectionID">the connection id</param> /// <param name="fileID">the file name</param> /// <param name="documentName">the document name</param> /// <param name="importTemplateID">the import template id</param> /// <param name="schemaCulture">the schema culture</param> /// <param name="dictionaryProperties">the dictionary that contains the properties as key/value pairs</param> /// <returns>the document contract</returns> public DocumentContract CreateDocument(CommonService commonService, string connectionID, string fileID, string documentName, string importTemplateID, string schemaCulture, Dictionary <string, string[]> dictionaryProperties) { DocumentContract documentContract = null; // Gets the import template contract for the specified import template id ImportTemplateContract importTemplateContract = commonService.GetImportTemplateContract(importTemplateID); string propertyPageTemplateID = importTemplateContract.PropertyPageTemplateId; // Gets the property page template contract assigned to the import template contract PropertyPageTemplateContract propertyPageTemplateContract = commonService.GetPropertyPageTemplateContract(propertyPageTemplateID); if (propertyPageTemplateContract != null) { // Gets an array of all property template contracts assigned to the property page template PropertyTemplateContract[] arrayOfPropertyTemplateContract = propertyPageTemplateContract.PropertyTemplates; // Array of property contracts to be set on the document contract further down (see A) IList <PropertyContract> listOfPropertyContract = new List <PropertyContract>(); foreach (PropertyTemplateContract template in arrayOfPropertyTemplateContract) { string propertyTypeID = template.PropertyTypeId; PropertyTypeContract propertyTypeContract = commonService.GetPropertyTypeContract(propertyTypeID); string propertyName = Utility.GetValue(propertyTypeContract.Name, schemaCulture); if (!String.IsNullOrEmpty(propertyName)) { string[] values; dictionaryProperties.TryGetValue(propertyName, out values); // Gets value for key from dictionary PropertyContract propertyContract = new PropertyContract { PropertyTypeId = propertyTypeID, Values = values }; listOfPropertyContract.Add(propertyContract); // Adds property contract } } // Sets mandatory fields documentContract = new DocumentContract { ImportTemplateId = importTemplateID, ProtectionDomainId = importTemplateContract.ProtectionDomainId, InfoStoreId = importTemplateContract.InfoStoreId, Properties = listOfPropertyContract.ToArray(), // Sets all property contracts (A) Name = documentName }; //documentContract = this.DocumentClient.CreateDocument(connectionID, documentContract, fileID, options: null); } return(documentContract); }
/// <summary> /// Gets the import template contract for the specified import template id /// and assigns the protection domain id to the contract. /// /// Calls the UpdateImportTemplate method on an instance of the InfoShareService.CommonClient /// class and passes the connection id of the administrator, and the import /// template contract as arguments. /// </summary> /// <param name="connAdminUserID">the connection id of the administrator</param> /// <param name="importTemplateID">the import template id</param> /// <param name="protectionDomainID">the protection domain id</param> public void AssignProtectionDomainToImportTemplate(string connAdminUserID, string importTemplateID, string protectionDomainID) { ImportTemplateContract importTemplateContract = GetImportTemplateContract(importTemplateID); if (importTemplateContract != null) { importTemplateContract.ProtectionDomainId = protectionDomainID; this.CommonClient.UpdateImportTemplate(connAdminUserID, importTemplateContract); } this.RefreshSchemaStore(connAdminUserID); }
/// <summary> /// Gets the import template contract for the specified import template id /// and assigns the info store id to the contract. /// /// Calls the UpdateImportTemplate method on an instance of the InfoShareService.CommonClient /// class and passes the connection id of the administrator, and the import /// template contract as arguments. /// </summary> /// <param name="connAdminUserID">the connection id of the administrator</param> /// <param name="importTemplateID">the import template id</param> /// <param name="infoStoreID">the info store id</param> public void AssignInfoStoreToImportTemplate(string connAdminUserID, string importTemplateID, string infoStoreID) { ImportTemplateContract importTemplateContract = this.GetImportTemplateContract(importTemplateID); if (importTemplateContract != null) { importTemplateContract.InfoStoreId = infoStoreID; CommonClient.UpdateImportTemplate(connAdminUserID, importTemplateContract); } this.RefreshSchemaStore(connAdminUserID); }
/// <summary> /// Gets the property template contract for the specified import template id. /// /// Gets an array of import template contracts from the schema store contract /// that is passed as an argument and searches for the import template contract /// with the specified import template id. Returns the import template contract, /// if it finds the contract. /// </summary> /// <param name="connectionID">the connection id</param> /// <param name="importTemplateID">the import template id</param> /// <returns>the import template contract</returns> public ImportTemplateContract GetImportTemplateContract(string importTemplateID) { ImportTemplateContract importTemplateContract = null; // Searches for the import template contract with the specified import template id foreach (ImportTemplateContract importTemplate in this.SchemaStore.ImportTemplates) { if (importTemplate.Id == importTemplateID) { // Contract found importTemplateContract = importTemplate; break; } } if (importTemplateContract == null) { throw new NotFoundException("No import template contract found for import template ID <" + importTemplateID + ">."); } return(importTemplateContract); }