コード例 #1
0
        /// <summary>
        /// Test Helper : Removes a Property Alias with test assertions.
        /// </summary>
        public void RemovePropertyAlias(int propDef, bool useShorthand = false)
        {
            if (useShorthand)
            {
                this.Settings.UseShorthand = true;
            }

            // Resolve the PropertyDef.
            PropertyDefAdmin pdAdmin = this.V.PropertyDefOperations.GetPropertyDefAdmin(propDef);

            // Format the alias to Remove.
            string aliasToRemove = this.Settings.FormatAlias(pdAdmin);

            // Check for the existence of the alias, removing if found.
            if (!this.V.AliasExists(MFMetadataStructureItem.MFMetadataStructureItemPropertyDef, aliasToRemove))
            {
                this.Tools.Add.PropertyAlias(aliasToRemove, pdAdmin);
            }

            // Verify that the alias exists.
            Assert.IsTrue(
                this.V.AliasExists(MFMetadataStructureItem.MFMetadataStructureItemPropertyDef, aliasToRemove),
                "Verifying that alias exists: " + aliasToRemove);

            // Remove the Alias.
            this.Tools.Remove.PropertyAlias(aliasToRemove, pdAdmin);

            // Verify that the alias does not exist.
            Assert.IsFalse(
                this.V.AliasExists(MFMetadataStructureItem.MFMetadataStructureItemPropertyDef, aliasToRemove),
                "Verifying that alias does not exist: " + aliasToRemove);
        }
コード例 #2
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Clears the Aliases on the <see cref="PropertyDef"/> with the provided id.
			/// </summary>
			/// <param name="propDefAdmin">Pre-resolved PropertyDef Admin</param>
			public void PropertyAlias(PropertyDefAdmin propDefAdmin )
			{
				// Clear the aliases.
				propDefAdmin.SemanticAliases.Value = string.Empty;

				// Save changes.
				this.Vault.PropertyDefOperations.UpdatePropertyDefAdmin( propDefAdmin );
			}
コード例 #3
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Appends the aliases to the PropertyDef.
			/// </summary>
			/// <param name="id">Property ID</param>
			/// <param name="aliases">Aliases to append.</param>
			public void PropertyAliases(int id, string[] aliases)
			{
				// Resolve the API Structure Object.
				PropertyDefAdmin pda = this.Vault.PropertyDefOperations.GetPropertyDefAdmin(id);

				// Add each alias.
				foreach (string alias in aliases)
					PropertyAlias(alias, pda);
			}
コード例 #4
0
        public PropertyDefAdmin AddPropertyDefAdmin(PropertyDefAdmin propertyDefAdmin, TypedValue resetLastUsedValue = null)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: use arguments
            // TODO: error checking
            vault.propertyDefs.Add(propertyDefAdmin);
            return(propertyDefAdmin);
        }
コード例 #5
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Removes an alias from a PropertyDef.
			/// </summary>
			/// <param name="alias">Alias to remove.</param>
			/// <param name="pda">Pre-resolved <see cref="PropertyDefAdmin"/></param>
			public void PropertyAlias(string alias, PropertyDefAdmin pda)
			{
				// Search and Destroy.
				if (removeAlias(pda.SemanticAliases, alias))
				{
					// Save changes.
					this.Vault.PropertyDefOperations.UpdatePropertyDefAdmin( pda );
				}
			}
コード例 #6
0
        /// <summary>
        /// Test Helper : Clears a Property Alias with test assertions.
        /// </summary>
        public void ClearPropertyAlias(int propDef)
        {
            // Resolve the PropertyDef.
            PropertyDefAdmin pdAdmin = this.V.PropertyDefOperations.GetPropertyDefAdmin(propDef);

            // Clear the Alias.
            this.Tools.Clear.PropertyAlias(pdAdmin);

            // Verify that no aliases exist.
            Assert.IsTrue(
                string.IsNullOrWhiteSpace(pdAdmin.SemanticAliases.Value),
                "Verifying that no aliases exist: ");
        }
コード例 #7
0
        public PropertyDef GetPropertyDef(int propertyDef)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: verify functionality
            if (propertyDef < 0)
            {
                throw new IndexOutOfRangeException("ID out of range");
            }
            PropertyDefAdmin pda = vault.propertyDefs.SingleOrDefault(pdef => pdef.PropertyDef.ID == propertyDef);

            return(pda == null ? null : pda.PropertyDef);
        }
コード例 #8
0
        public static void SetSingleSelectFromMultiSelectProperty(this IObjVerEx obj, int singleselect_property, int multiselect_property)
        {
            Vault vault = obj.objVerEx.Vault;

            if (!obj.objVerEx.HasProperty(multiselect_property))
            {
                throw new Exception("Multi-select property not found.");
            }
            if (!obj.objVerEx.HasProperty(singleselect_property))
            {
                throw new Exception("Single-select property not found.");
            }

            PropertyDefAdmin mpd = vault.PropertyDefOperations.GetPropertyDefAdmin(multiselect_property);

            if (mpd == null)
            {
                throw new Exception("Multi-select property not found.");
            }
            if (!mpd.PropertyDef.BasedOnValueList)
            {
                throw new Exception("Invalid multi-select property parameter.");
            }

            PropertyDefAdmin spd = vault.PropertyDefOperations.GetPropertyDefAdmin(singleselect_property);

            if (spd == null)
            {
                throw new Exception("Single-select property not found.");
            }
            if (!spd.PropertyDef.BasedOnValueList)
            {
                throw new Exception("Invalid single-select property parameter.");
            }

            if (spd.PropertyDef.ValueList != mpd.PropertyDef.ValueList)
            {
                throw new Exception("Target property is not  based on the same multi-select value with the Source.");
            }

            Lookups     mvalues      = obj.objVerEx.GetProperty(multiselect_property).TypedValue.GetValueAsLookups();
            IEnumerator m_enumerator = mvalues.GetEnumerator();

            m_enumerator.MoveNext();
            Lookup first_mvalue = m_enumerator.Current as Lookup;

            obj.objVerEx.SetProperty(singleselect_property, MFDataType.MFDatatypeLookup, first_mvalue?.Item);
        }
コード例 #9
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Appends the alias to the object class.
			/// </summary>
			/// <param name="alias">Alias to append.</param>
			/// <param name="propertyDefAdmin"><see cref="PropertyDefAdmin"/></param>
			public void PropertyAlias(string alias, PropertyDefAdmin propertyDefAdmin )
			{
				// Add the alias only if it does not already exist.
				if (!this.Vault.AliasExists(MFMetadataStructureItem.MFMetadataStructureItemPropertyDef, alias))
				{
					// Append a delimiter if needed.
					if (!propertyDefAdmin.SemanticAliases.Value.Trim().EndsWith(";"))
						propertyDefAdmin.SemanticAliases.Value += ';';

					// Append the alias.
					propertyDefAdmin.SemanticAliases.Value += alias;

					// Persist the change.
					this.Vault.PropertyDefOperations.UpdatePropertyDefAdmin(propertyDefAdmin);
				}
			}
        public void KnownPropertyDefReturnsCorrectData()
        {
            // Details about the property.
            int propertyDefId = 1234;

            string[] aliases = new []
            {
                "alias1",
                "alias2"
            };

            // Mock the property definition.
            var mock = this.GetVaultPropertyDefOperationsMock();

            mock
            .Setup(m => m.GetPropertyDefAdmin(propertyDefId))
            .Returns((int id) =>
            {
                var propertyDefAdmin = new PropertyDefAdmin()
                {
                    PropertyDef = new PropertyDef()
                    {
                        ID       = propertyDefId,
                        Name     = "hello world",
                        DataType = MFDataType.MFDatatypeText
                    },
                    SemanticAliases = new SemanticAliases()
                    {
                        Value = string.Join(";", aliases)
                    }
                };
                return(propertyDefAdmin);
            });

            // Run the method and check the output.
            Assert.IsTrue(mock.Object.TryGetPropertyDefAliases(propertyDefId, out string[] output));
            Assert.AreEqual(aliases.Length, output.Length);
            foreach (var alias in aliases)
            {
                Assert.IsTrue(output.Contains(alias));
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: aaron-hardin/TestExample
        static void Main(string[] args)
        {
            MFilesServerApplication server = new MFilesServerApplication();

            server.Connect();
            Vault vault = server.LogInToVault("{82FB2FA4-6FBE-4546-A200-11CEF3DF2169}");

            PropertyDefAdmin ownerChangeElement = vault.PropertyDefOperations.GetPropertyDefAdmin(1213);

            ownerChangeElement.SemanticAliases.Value = "M-Files.Property.OwnerChangeElement";
            ownerChangeElement.PropertyDef.Name      = "Owner (Change Element)";
            vault.PropertyDefOperations.UpdatePropertyDefAdmin(ownerChangeElement);

            PropertyDefAdmin ownerChangeRequest = vault.PropertyDefOperations.GetPropertyDefAdmin(1229);

            ownerChangeRequest.SemanticAliases.Value = "M-Files.Property.OwnerChangeRequest";
            ownerChangeRequest.PropertyDef.Name      = "Owner (Change Request)";
            vault.PropertyDefOperations.UpdatePropertyDefAdmin(ownerChangeRequest);

            Console.Write("Press any key to exit...");
            Console.ReadKey();
        }
コード例 #12
0
        public void Test_003_PropertyDefFormating(string expectedAlias, int id, bool useShorthand = false)
        {
            PropertyDefAdmin propDef = this.V.PropertyDefOperations.GetPropertyDefAdmin(id);

            FormatAlias(propDef, expectedAlias, useShorthand);
        }
コード例 #13
0
        public void UpdatePropertyDefAdmin(PropertyDefAdmin propertyDefAdmin, TypedValue resetLastUsedValue = null)
        {
            vault.MetricGatherer.MethodCalled();

            throw new NotImplementedException();
        }
コード例 #14
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Clears the Aliases on the <see cref="PropertyDef"/> with the provided id.
			/// </summary>
			/// <param name="id">PropertyDef ID</param>
			public void PropertyAlias(int id)
			{
				// Get the PropertyDefAdmin with using the provided id.
				PropertyDefAdmin propDefAdmin = this.Vault.PropertyDefById(id );
				PropertyAlias(propDefAdmin);
			}
コード例 #15
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Appends the alias to the PropertyDef.
			/// </summary>
			/// <param name="id">Property ID</param>
			/// <param name="alias">Alias to append.</param>
			public void PropertyAlias(int id, string alias)
			{
				// Resolve the API Structure Object.
				PropertyDefAdmin pda = this.Vault.PropertyDefOperations.GetPropertyDefAdmin(id);
				PropertyAlias(alias, pda);
			}
コード例 #16
0
        public void UpdatePropertyDefWithAutomaticPermissionsAdmin(PropertyDefAdmin propertyDefAdmin, TypedValue resetLastUsedValue = null, bool automaticPermissionsForcedActive = false)
        {
            vault.MetricGatherer.MethodCalled();

            throw new NotImplementedException();
        }
コード例 #17
0
 public void UpdatePropertyDefWithAutomaticPermissionsAdmin(PropertyDefAdmin PropertyDefAdmin, TypedValue ResetLastUsedValue = null, bool AutomaticPermissionsForcedActive = false)
 {
     throw new NotImplementedException();
 }
コード例 #18
0
 public void UpdatePropertyDefAdmin(PropertyDefAdmin PropertyDefAdmin, TypedValue ResetLastUsedValue = null)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
ファイル: AliasTools.cs プロジェクト: tpayne84/mf-toolbox
			/// <summary>
			/// Removes an alias from a PropertyDef.
			/// </summary>
			/// <param name="id">PropertyDef ID.</param>
			/// <param name="alias">Alias to remove.</param>
			public void PropertyAlias(int id, string alias)
			{
				// Resolve the PropertyDef.
				PropertyDefAdmin pda = this.Vault.PropertyDefById(id );
				PropertyAlias(alias, pda);
			}