예제 #1
0
        public void ForceUndoCheckout()
        {
            Assembly current = Assembly.GetAssembly(typeof(Tools));
            Stream   stream  = current.GetManifestResourceStream(typeof(Tools), "VaultStructure.json");

            if (stream == null)
            {
                Assert.Fail("Failed to load stream.");
            }

            TestVault vault = TestVault.FromStream(stream);

            PropertyValues pvs = new PropertyValues();
            PropertyValue  pv  = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
            };

            pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0);
            pvs.Add(-1, pv);
            pv.PropertyDef = 0;
            pv.TypedValue.SetValue(MFDataType.MFDatatypeText, "Title");
            pvs.Add(-1, pv);
            ObjectVersionAndProperties ovap = vault.ObjectOperations.CreateNewObject(0, pvs);

            Assert.Throws <Exception>(() => vault.ObjectOperations.ForceUndoCheckout(ovap.ObjVer));

            ObjectVersion ov = vault.ObjectOperations.CheckOut(ovap.ObjVer.ObjID);

            Assert.AreEqual(2, ov.ObjVer.Version);

            ov = vault.ObjectOperations.ForceUndoCheckout(ov.ObjVer);
            Assert.AreEqual(1, ov.ObjVer.Version);
        }
예제 #2
0
        /// <summary>
        /// 生成对象属性
        /// </summary>
        /// <param name="vault">MFiles库对象</param>
        /// <param name="aliasName">对象别名</param>
        /// <param name="properties">属性集合</param>
        /// <returns></returns>
        private static PropertyValues GetMailContentPropertyValues(Vault vault, string aliasName, IEnumerable <MfProperty> properties)
        {
            var oPropValues = new PropertyValues();

            var propValue1 = AecCloud.MFilesCore.MFPropertyUtils.Lookup(
                (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass,
                vault.ClassOperations.GetObjectClassIDByAlias(aliasName));

            oPropValues.Add(-1, propValue1);

            var propValue2 = AecCloud.MFilesCore.MFPropertyUtils.SingleFile(true);

            oPropValues.Add(-1, propValue2);

            foreach (var item in properties)
            {
                var propValue3 = new PropertyValue
                {
                    PropertyDef = vault.PropertyDefOperations.GetPropertyDefIDByAlias(item.PropertyName)
                };
                propValue3.TypedValue.SetValue(item.PropertyType, item.PropertyValue);
                oPropValues.Add(-1, propValue3);
            }

            return(oPropValues);
        }
예제 #3
0
        public void TestEdit()
        {
            Assembly current = Assembly.GetAssembly(typeof(Tools));
            Stream   stream  = current.GetManifestResourceStream(typeof(Tools), "VaultStructure.json");

            if (stream == null)
            {
                Assert.Fail("Failed to load stream.");
            }

            TestVault vault = TestVault.FromStream(stream);

            PropertyValues pvs = new PropertyValues();
            PropertyValue  pv  = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
            };

            pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0);
            pvs.Add(-1, pv);
            ObjectVersionAndProperties ovap = vault.ObjectOperations.CreateNewObject(0, pvs);

            Assert.AreEqual(1, vault.ovaps.Count, "Number of objects != 1");

            PropertyValue sfd = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefSingleFileObject
            };

            sfd.TypedValue.SetValue(MFDataType.MFDatatypeBoolean, true);
            pvs.Add(-1, sfd);

            vault.ObjectPropertyOperations.SetAllProperties(ovap.ObjVer, true, pvs);

            Assert.AreEqual(2, vault.ovaps.Count, "Number of objects/versions != 2");
        }
예제 #4
0
        public void GetObjectInfo()
        {
            Assembly current = Assembly.GetAssembly(typeof(Tools));
            Stream   stream  = current.GetManifestResourceStream(typeof(Tools), "VaultStructure.json");

            if (stream == null)
            {
                Assert.Fail("Failed to load stream.");
            }

            TestVault vault = TestVault.FromStream(stream);

            PropertyValues pvs = new PropertyValues();
            PropertyValue  pv  = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
            };

            pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0);
            pvs.Add(-1, pv);
            pv.PropertyDef = 0;
            pv.TypedValue.SetValue(MFDataType.MFDatatypeText, "Title");
            pvs.Add(-1, pv);
            ObjectVersionAndProperties ovap = vault.ObjectOperations.CreateNewObject(0, pvs);

            ObjectVersion ov = vault.ObjectOperations.GetObjectInfo(ovap.ObjVer, false, true);

            Assert.NotNull(ov);
            Assert.AreEqual("Title", ov.Title);
        }
예제 #5
0
        public static void AddProperties(this ElementCategory cate, PropertyValues pvs, VaultAliases vaultAlias, int modelId)
        {
            if (cate == null)
            {
                return;
            }
            var idPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.Id]
            };

            idPV.Value.SetValue(MFDataType.MFDatatypeInteger, cate.Id);
            pvs.Add(-1, idPV);

            var namePV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.Name]
            };

            namePV.Value.SetValue(MFDataType.MFDatatypeText, cate.Name);
            pvs.Add(-1, namePV);

            var modelPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.OwnedModel]
            };

            modelPV.Value.SetValue(MFDataType.MFDatatypeLookup, modelId);
            pvs.Add(-1, modelPV);
        }
예제 #6
0
        public static void AddProperties(this ViewElement view, PropertyValues pvs, VaultAliases vaultAlias, int levelId, int modeId)
        {
            view.AddBasicProperties(pvs, vaultAlias, modeId);

            var vtPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.ViewType]
            };

            vtPV.Value.SetValue(MFDataType.MFDatatypeInteger, view.ViewType);
            pvs.Add(-1, vtPV);

            if (view.ViewDiscipline != null)
            {
                var vdPV = new PropertyValue {
                    PropertyDef = vaultAlias.PdDict[PD.ViewDisc]
                };
                vdPV.Value.SetValue(MFDataType.MFDatatypeInteger, view.ViewDiscipline.Value);
                pvs.Add(-1, vdPV);
            }
            if (view.GenLevel != null)
            {
                if (levelId <= 0)
                {
                    throw new Exception("必须指定楼层");
                }
                var glPV = new PropertyValue {
                    PropertyDef = vaultAlias.PdDict[PD.Level]
                };
                glPV.Value.SetValue(MFDataType.MFDatatypeLookup, levelId);
                pvs.Add(-1, glPV);
            }
        }
예제 #7
0
        public static void AddBasicProperties(this ElementWithGuid elem, PropertyValues pvs, VaultAliases vaultAlias, int modelId)
        {
            var idPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.Id]
            };

            idPV.Value.SetValue(MFDataType.MFDatatypeInteger, elem.Id);
            pvs.Add(-1, idPV);

            var guidPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.Guid]
            };

            guidPV.Value.SetValue(MFDataType.MFDatatypeText, elem.Guid);
            pvs.Add(-1, guidPV);

            var namePV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.Name]
            };

            namePV.Value.SetValue(MFDataType.MFDatatypeText, elem.Name);
            pvs.Add(-1, namePV);

            var modelPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.OwnedModel]
            };

            modelPV.Value.SetValue(MFDataType.MFDatatypeLookup, modelId);
            pvs.Add(-1, modelPV);
        }
예제 #8
0
        public static void AddProperties(this ElementFamily fam, PropertyValues pvs, VaultAliases vaultAlias, int cateId, int modelId)
        {
            fam.AddBasicProperties(pvs, vaultAlias, modelId);
            var catePV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.PartCategory]
            };

            catePV.Value.SetValue(MFDataType.MFDatatypeLookup, cateId);
            pvs.Add(-1, catePV);
            if (fam.Parameters.Count > 0)
            {
                var pPV = BaseElementExtensions.CreateParameterProp(fam.Parameters, vaultAlias);
                pvs.Add(-1, pPV);
            }
        }
예제 #9
0
        public static ObjectVersionAndProperties CreateNewObject(this Vault vault, int objType, int classId,
                                                                 PropertyValues pvs, SourceObjectFiles files = null)
        {
            var classPV = MFPropertyUtils.Class(classId);

            pvs.Add(0, classPV);

            if (files == null || files.Count != 0)
            {
                var singleFilePV = MFPropertyUtils.SingleFile(false);
                pvs.Add(-1, singleFilePV);
            }

            return(vault.ObjectOperations.CreateNewObject(objType, pvs, files));
        }
예제 #10
0
        public void CloneFrom()
        {
            Assembly current = Assembly.GetAssembly(typeof(Tools));
            Stream   stream  = current.GetManifestResourceStream(typeof(Tools), "VaultStructure.json");

            if (stream == null)
            {
                Assert.Fail("Failed to load stream.");
            }

            TestVault vault = TestVault.FromStream(stream);

            PropertyValues pvs = new PropertyValues();
            PropertyValue  pv  = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
            };

            pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0);
            pvs.Add(-1, pv);
            vault.ObjectOperations.CreateNewObject(0, pvs);

            Assert.AreEqual(1, vault.ovaps.Count, "Number of objects != 1");

            TestVault clone = new TestVault();

            clone.CloneFrom(vault);

            Assert.AreEqual(1, vault.ovaps.Count, "After Clone::Number of objects should be 1.");

            clone.ObjectOperations.CreateNewObject(0, pvs);

            Assert.AreEqual(2, clone.ovaps.Count, "Clone does not have 2 objects");
            Assert.AreEqual(2, vault.ovaps.Count, "Original does not have 2 objects");
        }
예제 #11
0
        /// <summary>
        ///     Given a set of values for the PropertyValue struct, put that in
        /// to the PropertyValueList, overwriting any existing entry.
        /// </summary>
        private void UpdatePropertyValueList(DependencyProperty dp, object value)
        {
            // Check for existing value on dp
            int existingIndex = -1;

            for (int i = 0; i < PropertyValues.Count; i++)
            {
                if (PropertyValues[i].Property == dp)
                {
                    existingIndex = i;
                    break;
                }
            }

            if (existingIndex >= 0)
            {
                // Overwrite existing value for dp
                PropertyValue propertyValue = PropertyValues[existingIndex];
                propertyValue.ValueInternal = value;
                // Put back modified struct
                PropertyValues[existingIndex] = propertyValue;
            }
            else
            {
                // Store original data
                PropertyValue propertyValue = new PropertyValue();
                propertyValue.Property      = dp;
                propertyValue.ValueInternal = value;

                PropertyValues.Add(propertyValue);
            }
        }
예제 #12
0
        public void AddValueToProperty_AddsMultipleValues_Null()
        {
            const int propertyDef = 1024;

            // Set up the instruction to add/update.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.AddValueToProperty,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = propertyDef
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                MFDataType.MFDatatypeMultiSelectLookup,
                new int[] { 4, 5, 6 }
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = propertyDef
                };
                // Set the starting value to null (should end up with one item).
                pv.TypedValue.SetValueToNULL(MFDataType.MFDatatypeMultiSelectLookup);
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(1, propertyValues.Count);
            Assert.AreEqual(propertyDef, propertyValues[1].PropertyDef);
            Assert.AreEqual
            (
                3,
                propertyValues[1].TypedValue.GetValueAsLookups().Count
            );

            // Check they are as expected.
            Assert.AreEqual
            (
                4,
                propertyValues[1].TypedValue.GetValueAsLookups()[1].Item
            );
            Assert.AreEqual
            (
                5,
                propertyValues[1].TypedValue.GetValueAsLookups()[2].Item
            );
            Assert.AreEqual
            (
                6,
                propertyValues[1].TypedValue.GetValueAsLookups()[3].Item
            );
        }
예제 #13
0
        public override void DataBind()
        {
            if (DataSource == null)
            {
                return;
            }

            properties = DataSource.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo property in properties)
            {
                ModulePropertyAttribute attribute = (ModulePropertyAttribute)Attribute.GetCustomAttribute(property, typeof(ModulePropertyAttribute));
                if (attribute == null)
                {
                    continue;
                }

                string value = Context.Request.Form[property.Name];
                if (value == null)
                {
                    continue;
                }

                if (PropertyValues.ContainsKey(property.Name))
                {
                    PropertyValues[property.Name] = value;
                }
                else
                {
                    PropertyValues.Add(property.Name, value);
                }
            }
        }
예제 #14
0
        public void RemoveProperty()
        {
            // Set up the instruction to remove.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.RemovePropertyValue,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                }
            };

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                };
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(0, propertyValues.Count);
        }
 public void AddJsParamerter(string propertyFilter, string getValueJavaScript)
 {
     PropertyValues.Add(propertyFilter, new SimpleJSControl()
     {
         GetValue = () => getValueJavaScript
     });
 }
        void CacheValuesByProvider(SettingsProvider provider)
        {
            SettingsPropertyCollection col = new SettingsPropertyCollection();

            foreach (SettingsProperty p in Properties)
            {
                if (p.Provider == provider)
                {
                    col.Add(p);
                }
            }

            if (col.Count > 0)
            {
                SettingsPropertyValueCollection vals = provider.GetPropertyValues(Context, col);
                foreach (SettingsPropertyValue prop in vals)
                {
                    if (PropertyValues [prop.Name] != null)
                    {
                        PropertyValues [prop.Name].PropertyValue = prop.PropertyValue;
                    }
                    else
                    {
                        PropertyValues.Add(prop);
                    }
                }
            }

            OnSettingsLoaded(this, new SettingsLoadedEventArgs(provider));
        }
예제 #17
0
        public void TestCreate()
        {
            Assembly current = Assembly.GetAssembly(typeof(Tools));
            Stream   stream  = current.GetManifestResourceStream(typeof(Tools), "VaultStructure.json");

            if (stream == null)
            {
                Assert.Fail("Failed to load stream.");
            }

            TestVault vault = TestVault.FromStream(stream);

            PropertyValues pvs = new PropertyValues();
            PropertyValue  pv  = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
            };

            pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 115);
            pvs.Add(-1, pv);
            ObjectVersionAndProperties ovap = vault.ObjectOperations.CreateNewObject(0, pvs);

            Assert.AreEqual(1, vault.ovaps.Count, "Number of objects != 1");

            Assert.AreEqual(115, ovap.VersionData.Class);
        }
예제 #18
0
        /// <summary>
        /// Copies properties and their values from <paramref name="propertyValueCollection"/>
        /// </summary>
        /// <param name="propertyValueCollection">Property value storage to copy data from</param>
        /// <remarks>Existing values are overwritten by values from <paramref name="propertyValueCollection"/></remarks>
        public void Merge(SettingsPropertyValueCollection propertyValueCollection)
        {
            if (propertyValueCollection == null)
            {
                throw new ArgumentNullException("propertyValueCollection");
            }

            foreach (SettingsPropertyValue propertyValue in propertyValueCollection)
            {
                SettingsProperty property = propertyValue.Property;

                if (Properties[property.Name] != null)
                {
                    Properties.Remove(property.Name);
                }

                Properties.Add(property);

                if (PropertyValues[propertyValue.Name] != null)
                {
                    PropertyValues.Remove(propertyValue.Name);
                }

                PropertyValues.Add(propertyValue);
            }
        }
예제 #19
0
        private PropertyValues GetAdditionalPropsForIFC()
        {
            var pvs     = new PropertyValues();
            var modelAt = _aliases.PdDict[PD.ModelUnitAt];
            var floorAt = _aliases.PdDict[PD.FloorAt];
            var discAt  = _aliases.PdDict[PD.DiscAt];
            var props   = _vault.ObjectPropertyOperations.GetProperties(_obj.ObjVer);

            if (modelAt != -1)
            {
                var modelPV = props.SearchForPropertyEx(modelAt, true);
                if (modelPV != null)
                {
                    pvs.Add(-1, modelPV.Clone());
                }
            }
            if (floorAt != -1)
            {
                var floorPV = props.SearchForPropertyEx(floorAt, true);
                if (floorPV != null)
                {
                    pvs.Add(-1, floorPV.Clone());
                }
            }
            if (discAt != -1)
            {
                var discPV = props.SearchForPropertyEx(discAt, true);
                if (discPV != null)
                {
                    pvs.Add(-1, discPV.Clone());
                }
            }

            var modelUrlPD = _aliases.PdDict[PD.ModelUrl];

            if (modelUrlPD != -1)
            {
                var url = GetModelUrl();
                var pv  = new PropertyValue {
                    PropertyDef = modelUrlPD
                };
                pv.TypedValue.SetValue(MFDataType.MFDatatypeMultiLineText, url);
                pvs.Add(-1, pv);
            }

            return(pvs);
        }
예제 #20
0
        internal static void Create(Vault vault, MFObject obj)
        {
            //  Writelog(string.Format("--11--{0},{1},{2}",obj.Id,obj.Properties.Count,obj));
            var objType = MfAlias.GetObjType(vault, obj.ObjDef.TypeAlias);
            //   Writelog("--22--");
            var objClass = MfAlias.GetObjectClass(vault, obj.ObjDef.ClassAlias);
            //   Writelog("--33--");
            var pvs     = new PropertyValues();
            var classPV = MFPropertyUtils.Class(objClass);

            pvs.Add(-1, classPV);
            //   Writelog("--44--");
            SetProperties(vault, pvs, obj);

            var isSingleFile = false;
            //   Writelog("--55--");
            SourceObjectFiles files = null;

            if (obj.Filepaths != null && obj.Filepaths.Count > 0)
            {
                files = new SourceObjectFiles();
                //todo
                if (obj.Filepaths.Count == 1)
                {
                    isSingleFile = true;
                }
                //    Writelog("--66--");
            }
            var singleFilePV = MFPropertyUtils.SingleFile(isSingleFile);

            pvs.Add(-1, singleFilePV);
            //   Writelog("--77--");
            try
            {
                var objVersion = vault.ObjectOperations.CreateNewObject(objType, pvs, files);
                //     Writelog("--88--");
                var newObjVersion = vault.ObjectOperations.CheckIn(objVersion.ObjVer);

                obj.Id = newObjVersion.ObjVer.ID;
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("CreateNewObject error:{0},{1},{2}", objType, pvs.Count, ex.Message));
            }
        }
예제 #21
0
        public static ObjectVersionAndProperties CreateSingleFileObject(this Vault vault, int objType, int classId,
                                                                        PropertyValues pvs, SourceObjectFile file, bool checkIn)
        {
            var classPV = MFPropertyUtils.Class(classId);

            pvs.Add(0, classPV);

            return(vault.ObjectOperations.CreateNewSFDObject(objType, pvs, file, checkIn));
        }
예제 #22
0
        public static void AddProperties(this ElementType elemType, PropertyValues pvs, VaultAliases vaultAlias, int modelId)
        {
            elemType.AddBasicProperties(pvs, vaultAlias, modelId);

            if (elemType.Parameters.Count > 0)
            {
                var pPV = BaseElementExtensions.CreateParameterProp(elemType.Parameters, vaultAlias);
                pvs.Add(-1, pPV);
            }
        }
예제 #23
0
        public static void AddProperties(this MaterialElement mat, PropertyValues pvs, VaultAliases vaultAlias, int modelId)
        {
            mat.AddBasicProperties(pvs, vaultAlias, modelId);

            if (mat.Parameters.Count > 0)
            {
                var pPV = BaseElementExtensions.CreateParameterProp(mat.Parameters, vaultAlias);
                pvs.Add(-1, pPV);
            }
        }
예제 #24
0
        public static void AddProperties(this LevelElement level, PropertyValues pvs, VaultAliases vaultAlias, int modelId)
        {
            level.AddBasicProperties(pvs, vaultAlias, modelId);
            var elevPV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.Elevation]
            };

            elevPV.Value.SetValue(MFDataType.MFDatatypeText, level.Elevation);
            pvs.Add(-1, elevPV);
        }
        public static void CreateNewDocument()
        {
            LogIntoVault();

            //Prerequisites for creating an object in mfiles;
            //Type of object E.g. 0 is for document
            //PropertyValues
            //Source files if the object's type is document or any other type that can have documents

            var properties = new PropertyValues();

            //Class 0 -> Sınıflandırılmamış Doküman
            var classProperty = new PropertyValue();

            classProperty.PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass; //Simply 100
            classProperty.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0);
            properties.Add(0, classProperty);

            //Name or Title -> İsim veya başlık
            var nameProperty = new PropertyValue();

            nameProperty.PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle; //Simply 0
            nameProperty.TypedValue.SetValue(MFDataType.MFDatatypeText, "Emre");
            properties.Add(0, nameProperty);

            //File from fileSystem
            var sourceObjectFile = new SourceObjectFile();

            sourceObjectFile.Title          = "SampleTextFile";
            sourceObjectFile.SourceFilePath = "SampleTextFile.txt";
            sourceObjectFile.Extension      = "txt";

            //Using Existing ACL
            //ACL with the ID of -10
            var aCL = loggedInVault.NamedACLOperations.GetNamedACL(-10);

            loggedInVault.ObjectOperations.CreateNewSFDObject(
                0
                , properties
                , sourceObjectFile
                , true
                , aCL.AccessControlList);
        }
예제 #26
0
        /// <summary>
        /// 生成对象属性
        /// </summary>
        /// <param name="vault">MFiles库对象</param>
        /// <param name="title">对象名称</param>
        /// <param name="aliasName">对象别名</param>
        /// <returns></returns>
        private static PropertyValues GetAttachmentPropertyValues(Vault vault, string title, string aliasName)
        {
            var oPropValues = new PropertyValues();
            var propValue1  = AecCloud.MFilesCore.MFPropertyUtils.Text(
                (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle, title);

            oPropValues.Add(-1, propValue1);

            var propValue2 = AecCloud.MFilesCore.MFPropertyUtils.Lookup(
                (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass,
                vault.ClassOperations.GetObjectClassIDByAlias(aliasName));

            oPropValues.Add(-1, propValue2);

            var propValue3 = AecCloud.MFilesCore.MFPropertyUtils.SingleFile(true);

            oPropValues.Add(-1, propValue3);

            return(oPropValues);
        }
예제 #27
0
        public void ReturnsNullIfPropertyIsNull()
        {
            // IDs used.
            var propertyDefId = 1234;
            var valueListId   = 123;

            // Mock the property definition operations object.
            var propertyDefinitionsMock = new Mock <VaultPropertyDefOperations>();

            propertyDefinitionsMock.Setup(m => m.GetPropertyDef(It.IsAny <int>()))
            .Returns((int propertyDef) =>
            {
                // Ensure that the property definition Id is correct.
                Assert.AreEqual(propertyDefId, propertyDef);

                // Return a property definition that is not based on a value list.
                return(new PropertyDef()
                {
                    ID = propertyDefId,
                    DataType = MFDataType.MFDatatypeLookup,
                    BasedOnValueList = true,
                    ValueList = valueListId
                });
            })
            .Verifiable();

            // Mock the vault.
            var vaultMock = this.GetVaultMock();

            vaultMock.Setup(m => m.PropertyDefOperations).Returns(propertyDefinitionsMock.Object);

            // Set up the data for the ObjVerEx.
            var objVer = new ObjVer();

            objVer.SetIDs(0, 1, 1);
            var objectVersionMock = new Mock <ObjectVersion>();

            objectVersionMock.SetupGet(m => m.ObjVer)
            .Returns(objVer);
            var properties = new PropertyValues();
            {
                var pv = new PropertyValue();
                pv.PropertyDef = propertyDefId;
                pv.TypedValue.SetValueToNULL(MFDataType.MFDatatypeLookup);
                properties.Add(1, pv);
            }

            // Create the ObjVerEx.
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionMock.Object, properties);

            // Use the method.
            Assert.IsNull(objVerEx.GetPropertyAsValueListItem(propertyDefId));
        }
예제 #28
0
        public void AddValueToProperty_AddsSingleValue_SingleNewValue_NoOverlap()
        {
            const int propertyDef = 1024;

            // Set up the instruction to add/update.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.AddValueToProperty,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = propertyDef
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                MFDataType.MFDatatypeMultiSelectLookup,
                new int[] { 6 }
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = propertyDef
                };
                // Set the starting value to a single item (should end up with two).
                pv.TypedValue.SetValue(MFDataType.MFDatatypeMultiSelectLookup, new int[] { 4 });
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(1, propertyValues.Count);
            Assert.AreEqual(propertyDef, propertyValues[1].PropertyDef);
            Assert.AreEqual
            (
                2,
                propertyValues[1].TypedValue.GetValueAsLookups().Count
            );
            Assert.AreEqual
            (
                4,                 // This is the starting one.
                propertyValues[1].TypedValue.GetValueAsLookups()[1].Item
            );
            Assert.AreEqual
            (
                6,                 // This is the single ID that was added.
                propertyValues[1].TypedValue.GetValueAsLookups()[2].Item
            );
        }
예제 #29
0
        protected virtual Mock <ObjectVersionAndProperties> GetObjectVersionAndPropertiesMock
        (
            Mock <Vault> vaultMock,
            int objectTypeId  = 0,
            int objectId      = 123,
            int version       = 1,
            string externalId = "123ABCDEF123",
            ObjID originalId  = null,
            Guid?objectGuid   = null,
            params Tuple <int, MFDataType, object>[] propertyValues
        )
        {
            var objectVersionAndPropertiesMock = new Mock <ObjectVersionAndProperties>();

            objectVersionAndPropertiesMock
            .Setup(o => o.ObjVer)
            .Returns(() =>
            {
                var objVer = new ObjVer();
                objVer.SetIDs(objectTypeId, objectId, version);
                return(objVer);
            });
            objectVersionAndPropertiesMock
            .Setup(o => o.VersionData)
            .Returns(() =>
            {
                var data = new Mock <ObjectVersion>();
                data.Setup(o => o.DisplayIDAvailable).Returns(!string.IsNullOrWhiteSpace(externalId));
                data.Setup(o => o.DisplayID).Returns(externalId);
                data.Setup(o => o.OriginalObjID).Returns(originalId);
                if (objectGuid.HasValue)
                {
                    data.Setup(o => o.ObjectGUID).Returns(objectGuid.Value.ToString("B"));
                }
                return(data.Object);
            });
            objectVersionAndPropertiesMock
            .Setup(o => o.Properties)
            .Returns(() =>
            {
                var data = new PropertyValues();
                foreach (var tuple in propertyValues ?? new Tuple <int, MFDataType, object> [0])
                {
                    var pv = new PropertyValue {
                        PropertyDef = tuple.Item1
                    };
                    pv.Value.SetValue(tuple.Item2, tuple.Item3);
                    data.Add(-1, pv);
                }
                return(data);
            });
            return(objectVersionAndPropertiesMock);
        }
예제 #30
0
        /// <summary>
        /// Updates the PropertyValues dictionary
        /// </summary>
        internal void UpdatePropertyValues()
        {
            PropertyValues.Clear();

            foreach (string prop in Properties.Keys)
            {
                if (CssBox._properties.ContainsKey(prop))
                {
                    PropertyValues.Add(CssBox._properties[prop], Properties[prop]);
                }
            }
        }
        public void PropertyValuesContainer()
        {
            PropertyValues properties = new PropertyValues();
            properties.Add("key1", "oleg");

            Assert.AreEqual(1, properties.GetCodes().Count);
            Assert.AreEqual(1, properties.GetValues("key1").Count);
            Assert.AreEqual("oleg", properties.GetValues("key1")[0]);
            Assert.AreEqual(0, properties.GetValues("key2").Count);

            properties.Add("key1", "shuruev");
            properties.Add("key2", "hello");

            Assert.AreEqual(2, properties.GetCodes().Count);
            Assert.AreEqual(2, properties.GetValues("key1").Count);
            Assert.AreEqual("oleg", properties.GetValues("key1")[0]);
            Assert.AreEqual("shuruev", properties.GetValues("key1")[1]);
            Assert.AreEqual(1, properties.GetValues("key2").Count);
            Assert.AreEqual("hello", properties.GetValues("key2")[0]);

            properties.Clear("key1");
            properties.Clear("key3");

            Assert.AreEqual(1, properties.GetCodes().Count);
            Assert.AreEqual(1, properties.GetValues("key2").Count);
            Assert.AreEqual("hello", properties.GetValues("key2")[0]);

            foreach (string word in this.emptyWords)
            {
                TestHelper.Throws(delegate
                {
                    properties.Add(word, "hello");
                });

                TestHelper.Throws(delegate
                {
                    properties.Add("key1", word);
                });
            }
        }
예제 #32
0
        public void PropertyOperations()
        {
            PropertyValues properties = new PropertyValues();
            properties.Add("Package", "zip");
            properties.Add("Keywords", "production");
            properties.Add("Keywords", "application");
            database.SetProperties(EntityType.Project, 10, properties);

            properties = database.GetProperties(EntityType.Project, 10);
            Assert.AreEqual(2, properties.GetCodes().Count);
            Assert.AreEqual(1, properties.GetValues("Package").Count);
            Assert.AreEqual("zip", properties.GetValues("Package")[0]);
            Assert.AreEqual(2, properties.GetValues("Keywords").Count);
            Assert.AreEqual("application", properties.GetValues("Keywords")[0]);
            Assert.AreEqual("production", properties.GetValues("Keywords")[1]);

            properties = new PropertyValues();
            properties.Add("Package", "zip");
            properties.Add("Package", "msi");
            properties.Add("Keywords", "service");
            properties.Add("Status", "beta");
            database.SetProperties(EntityType.Project, 10, properties);

            properties = database.GetProperties(EntityType.Project, 10);
            Assert.AreEqual(3, properties.GetCodes().Count);
            Assert.AreEqual(2, properties.GetValues("Package").Count);
            Assert.AreEqual("msi", properties.GetValues("Package")[0]);
            Assert.AreEqual("zip", properties.GetValues("Package")[1]);
            Assert.AreEqual(1, properties.GetValues("Keywords").Count);
            Assert.AreEqual("service", properties.GetValues("Keywords")[0]);
            Assert.AreEqual(1, properties.GetValues("Status").Count);
            Assert.AreEqual("beta", properties.GetValues("Status")[0]);

            properties = new PropertyValues();
            database.SetProperties(EntityType.Project, 10, properties);

            properties = database.GetProperties(EntityType.Project, 10);
            Assert.AreEqual(0, properties.GetCodes().Count);
        }
        private PropertyValues QueryPropertyValues(string propertyName) {
            var res = new PropertyValues();
            var assetType = connector.MetaModel.GetAssetType(propertyName);
            IAttributeDefinition nameDef = null;
            if (propertyName == "Member")
            {
                nameDef = assetType.GetAttributeDefinition("Nickname");
            }
            else {
                nameDef = assetType.GetAttributeDefinition("Name");
            }

            IAttributeDefinition inactiveDef;
            assetType.TryGetAttributeDefinition("Inactive", out inactiveDef);
           
            var query = new Query(assetType);
            query.Selection.Add(nameDef);

            if (inactiveDef != null) {
                query.Selection.Add(inactiveDef);
            }
            
            /*
            if(assetType.TryGetAttributeDefinition("Inactive", out inactiveDef)) {
                var filter = new FilterTerm(inactiveDef);
                filter.Equal("False");
                query.Filter = filter;
            }
            */
            
            query.OrderBy.MajorSort(assetType.DefaultOrderBy, OrderBy.Order.Ascending);

            res.Add(new ValueId()); // which is the aim of this? having a blank item at the begining of the combo?
            
            foreach(var asset in connector.Services.Retrieve(query).Assets) {
                var name = asset.GetAttribute(nameDef).Value as string;
                var inactive = false;
                if (inactiveDef != null)
                {
                    inactive = (bool)asset.GetAttribute(inactiveDef).Value;
                }
                res.Add(new ValueId(asset.Oid, name, inactive));
            }

            return res;
        }
        public PropertyValues QueryPropertyValues(string propertyName)
        {
            var res = new PropertyValues();
            IAttributeDefinition nameDef;
            var query = GetPropertyValuesQuery(propertyName, out nameDef);

            foreach (var asset in services.Retrieve(query).Assets) {
                var name = asset.GetAttribute(nameDef).Value as string;
                res.Add(new ValueId(asset.Oid, name));
            }

            return res;
        }
        private PropertyValues QueryPropertyValues(string propertyName) {
            var res = new PropertyValues();
            var assetType = connector.MetaModel.GetAssetType(propertyName);
            var nameDef = assetType.GetAttributeDefinition(Entity.NameProperty);
            IAttributeDefinition inactiveDef;

            var query = new Query(assetType);
            query.Selection.Add(nameDef);
            
            if(assetType.TryGetAttributeDefinition("Inactive", out inactiveDef)) {
                var filter = new FilterTerm(inactiveDef);
                filter.Equal("False");
                query.Filter = filter;
            }

            query.OrderBy.MajorSort(assetType.DefaultOrderBy, OrderBy.Order.Ascending);

            res.Add(new ValueId());
            
            foreach(var asset in connector.Services.Retrieve(query).Assets) {
                var name = asset.GetAttribute(nameDef).Value as string;
                res.Add(new ValueId(asset.Oid, name));
            }

            return res;
        }