/// <summary> /// Creates a property type contract and sets mandatory and optional fields /// on the contract. /// /// The name of the property type contract is passed as an argument. /// Calls the CreatePropertyType method on an instance of the InfoShareService.CommonClient /// class and passes the connection id of the administrator, and the property /// type contract as arguments. /// </summary> /// <param name="connAdminUserID">the connection id of the administrator</param> /// <param name="propertyName">the property name</param> /// <param name="fieldType">the field type</param> /// <param name="multiKey">make a multikey property or not. If true, the property can have several values.</param> /// <param name="schemaCulture">the schema culture</param> /// <returns>the property type id of the created property type</returns> public string CreatePropertyType(string connAdminUserID, string propertyName, string fieldType, bool multiKey, string schemaCulture) { StringGlobalContract strGlobalContract = Utility.ConvertStringToStringGlobalContract(propertyName, schemaCulture); PropertyTypeConfigurationContract propertyTypeConf = new PropertyTypeConfigurationContract { StringMaximumLength = 100 // mandatory }; PropertyTypeContract propertyTypeContract = new PropertyTypeContract { // Set mandatory fields Name = strGlobalContract, PropertyTypePluginTypeEnum = fieldType, Configuration = propertyTypeConf, Searchable = true, // Makes properties searchable in document search // Sets optional fields Active = true, Multikey = multiKey }; string propertyTypeID = CommonClient.CreatePropertyType(connAdminUserID, propertyTypeContract); this.RefreshSchemaStore(connAdminUserID); return(propertyTypeID); }
/// <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 property type contract for the specified property type id. /// /// Gets an array of property type contracts from the schem store contract that /// is passed as an argument and searches for the property type contract with /// the specified property type id. Returns the property type contract, if it /// finds the contract. /// </summary> /// <param name="propertyTypeID">the property type id</param> /// <returns>the property type contract</returns> public PropertyTypeContract GetPropertyTypeContract(string propertyTypeID) { PropertyTypeContract propertyTypeContract = null; // Gets an array of property type contracts PropertyTypeContract[] arrayOfPropertyTypeContract = this.SchemaStore.PropertyTypes; // Searches for the property type contract with the specified property type id foreach (PropertyTypeContract propertyType in arrayOfPropertyTypeContract) { if (propertyType.Id == propertyTypeID) { // Contract found propertyTypeContract = propertyType; break; } } if (propertyTypeContract == null) { throw new NotFoundException("No property type contract found for property type ID <" + propertyTypeID + ">."); } return(propertyTypeContract); }