Exemplo n.º 1
0
        private static ObjID SearchObjectByClass(Vault vault, int objType, int objClass)
        {
            var scs = new SearchConditions();

            MFSearchConditionUtils.AddBaseConditions(scs, objType, objClass);

            var res = vault.ObjectSearchOperations.SearchForObjectsByConditions(scs, MFSearchFlags.MFSearchFlagNone,
                                                                                false);

            return(res[1].ObjVer.ObjID);
        }
Exemplo n.º 2
0
        internal static MfContact GetContactByUserId(Vault mfVault, MetadataAliases aliases, int userId)
        {
            var objAlias   = aliases.Objects["ObjContacts"];
            var classAlias = objAlias.ClassDict["ClassContacts"];
            var typeId     = MfAlias.GetObjType(mfVault, objAlias.Alias);
            var classId    = MfAlias.GetObjectClass(mfVault, classAlias.Alias);

            var scs = new SearchConditions();

            MFSearchConditionUtils.AddBaseConditions(scs, typeId, classId);

            var userPropId = MfAlias.GetPropDef(mfVault, classAlias.PropDict["PropAccount"]);

            scs.Add(-1,
                    MFSearchConditionUtils.Property(MFConditionType.MFConditionTypeEqual, userPropId,
                                                    MFDataType.MFDatatypeLookup, userId));

            var res = mfVault.ObjectSearchOperations.SearchForObjectsByConditions(scs, MFSearchFlags.MFSearchFlagNone,
                                                                                  false);

            if (res.Count != 1)
            {
                return(null);
            }
            var obj = res[1];

            var contact = new MfContact
            {
                UserId     = userId,
                InternalId = obj.ObjVer.ID,
                RoleAlias  = classAlias.PropDict["PropProjectRole"]
            };

            var roleId = MfAlias.GetPropDef(mfVault, contact.RoleAlias);//mfVault.UserGroupOperations.GetUserGroupIDByAlias(contact.RoleAlias);

            contact.RoleName = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, roleId).GetValueAsLocalizedText();

            if (!String.IsNullOrEmpty(objAlias.Owner))
            {
                var partTypeId      = MfAlias.GetObjType(mfVault, objAlias.Owner);
                var partType        = mfVault.ObjectTypeOperations.GetObjectType(partTypeId);
                var partOwnerPropId = partType.OwnerPropertyDef;
                var partyTV         = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, partOwnerPropId).Value;
                contact.PartName = partyTV.DisplayValue;
            }


            return(contact);
        }
Exemplo n.º 3
0
        public MFProjectParty GetParty(MFilesVault vault, string partyName, MetadataAliases aliases, int?currentUserId = null)
        {
            var mfVault    = MFServerUtility.GetVault(vault);
            var partyObj   = aliases.Objects["ObjParticipant"];
            var partyClass = partyObj.ClassDict["ClassParticipant"];
            var typeId     = MfAlias.GetObjType(mfVault, partyObj.Alias);
            var classId    = MfAlias.GetObjectClass(mfVault, partyClass.Alias);

            var scs = new SearchConditions();

            MFSearchConditionUtils.AddBaseConditions(scs, typeId, classId);

            var namePropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropParticipantName"]);
            var nameSC     = MFSearchConditionUtils.Property(MFConditionType.MFConditionTypeEqual, namePropId,
                                                             MFDataType.MFDatatypeText, partyName);

            scs.Add(-1, nameSC);

            var res = mfVault.ObjectSearchOperations.SearchForObjectsByConditions(scs, MFSearchFlags.MFSearchFlagNone,
                                                                                  false);

            if (res.Count != 1)
            {
                return(null);
            }

            var party = new MFProjectParty {
                Name = partyName
            };
            var obj = res[1];

            party.InternalId = obj.ObjVer.ID;
            var managerPropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropProjPM"]);
            var managerTV     = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, managerPropId).Value;

            if (!managerTV.IsNULL() && !managerTV.IsUninitialized())
            {
                party.ManagerCount = 1;
                var contactId = managerTV.GetLookupID();
                var userId    = GetContactAccount(mfVault, aliases, contactId);
                if (currentUserId != null && userId == currentUserId.Value)
                {
                    party.IsCurrentManager = true;
                }
            }
            var vmPropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropProjVicePMs"]);
            var vmTV     = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, vmPropId).Value;

            if (!vmTV.IsNULL() && !vmTV.IsUninitialized())
            {
                var lkps = vmTV.GetValueAsLookups();
                party.ViceManagerCount = lkps.Count;
                if (currentUserId != null && !party.IsCurrentManager)
                {
                    for (var i = 1; i <= lkps.Count; i++)
                    {
                        var contactId = lkps[i].Item;
                        var userId    = GetContactAccount(mfVault, aliases, contactId);
                        if (userId == currentUserId.Value)
                        {
                            party.IsCurrentViceManager = true;
                            break;
                        }
                    }
                }
            }
            var mmPropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropMembers"]);
            var mmTV     = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, mmPropId).Value;

            if (!mmTV.IsNULL() && !mmTV.IsUninitialized())
            {
                var lkps = mmTV.GetValueAsLookups();
                party.MemberCount = lkps.Count;
                if (currentUserId != null && !party.IsCurrentViceManager && !party.IsCurrentManager)
                {
                    for (var i = 1; i <= lkps.Count; i++)
                    {
                        var contactId = lkps[i].Item;
                        var userId    = GetContactAccount(mfVault, aliases, contactId);
                        if (userId == currentUserId.Value)
                        {
                            party.IsCurrentMember = true;
                            break;
                        }
                    }
                }
            }

            return(party);
        }