locked
Get member's attributes using EntityMemberAttributesGet RRS feed

  • Question

  • Hi,

    I have a doubt about using EntityMemberAttributesGet operation. I want to get at once the data of multiple entity members and I thought that this method is the appropriate one but I can't get the attribute's values for that members. The attributes collection returned for each member is empty. How can I do this?

    Here is the code:

    			//create the Member collection based on a previous response
    
    			var departmentMembers = new Member[userAtDepResponse.EntityMembersInformation.TotalMemberCount];      
    
          
    
    
    
          //save departments codes
    
          for (int i = 0; i < departmentMembers.Length; i++)
    
          {
    
           departmentMembers[i] = new Member();
    
           departmentMembers[i].MemberId = new MemberIdentifier();
    
           departmentMembers[i].MemberId.Code = userAtDepResponse.EntityMembers.Members[i].MemberId.Code;
    
          }
    
    
    
          //get departments info
    
          var request = new EntityMemberAttributesGetRequest();
    
          request.International = new International();
    
          //set criteria
    
          request.EntityMembers = new EntityMembers();
    
          request.EntityMembers.EntityId = new Identifier();
    
          request.EntityMembers.EntityId.Name = entityName;
    
          request.EntityMembers.ModelId = new Identifier();
    
          request.EntityMembers.ModelId.Name = modelName;
    
          request.EntityMembers.VersionId = new Identifier();
    
          request.EntityMembers.VersionId.Name = GetActualVersion(modelName);
    
    
    
          request.EntityMembers.Members = departmentMembers;
    
          request.EntityMembers.MemberType = MemberType.Leaf;            
    
    
    
          var departmentResponse = service.EntityMemberAttributesGet(departmentsRequest);
    
    

    Thanks in advance.


    Helena Monteiro
    Tuesday, December 7, 2010 2:47 PM

Answers

  • Hello Helena

    please check my winform sample app to see how I get Attributes values on 

    mdsmanager.codeplex.com

     

     

     public void DisplayMembers(Identifier modelId, Identifier versionId, CustomEntity entity, string searchTerm)
        {
    
          CustomMember cm = new CustomMember();
          Collection<Member> colMbr = cm.GetMembers(modelId, versionId, entity, searchTerm);
          lstMembers.Items.Clear();
          (FindForm() as Form1).progressBar1.Maximum = colMbr.Count;
          foreach (Member m in colMbr)
          {
            lstMembers.Items.Add(new CustomMember(m));
            (FindForm() as Form1).progressBar1.PerformStep();
          }
    
          lstMembers.DisplayMember = rbNameCode.Checked ? "NameCode" : "CodeName";
          lblCntMembers.Text = lstMembers.Items.Count.ToString() + " members";
          (FindForm() as Form1).progressBar1.Value = 0;
        }
    
    

     

     

     

     public void DisplayAttributes()
        {
    
          try
          {
    
            Cursor.Current = Cursors.WaitCursor;
            OperationResult or = new OperationResult();
            Common.MDS_WS mds = new MDS_WS();
            Form1 frm = FindForm() as Form1;
            CustomEntity ce = ((ucManageEntities)frm.FindControl("ucManageEntities1")).lstEntities.SelectedItem as CustomEntity;
            Metadata md = null;
            if (ce != null && ce.entityId != null)
            {
              md = mds.GetMetaData(new International(), ref or, (Identifier)frm.lstModels.SelectedItem, (Identifier)frm.lstVersions.SelectedItem, ce.entityId);
    
              var currentItem = lstAttributes.SelectedItem;
              var currentIndex = lstAttributes.SelectedIndex;
              lstAttributes.Items.Clear();
              (FindForm() as Form1).progressBar1.Maximum = md.Attributes.Count;
              foreach (Common.ServiceReference1.MetadataAttribute att in md.Attributes)
              {
                lstAttributes.Items.Add(new CustomMetaDataAttribute(att));
                (FindForm() as Form1).progressBar1.PerformStep();
    
              }
              (FindForm() as Form1).progressBar1.Value = 0;
              lstAttributes.DisplayMember = rbNameType.Checked ? "NameType" : "TypeName";
              lblAttrCount.Text = lstAttributes.Items.Count.ToString() + " attributes";
    
              if (IsAttributeExists(currentItem as CustomMetaDataAttribute, lstAttributes.Items))
              {
                lstAttributes.SelectedIndex = currentIndex;
              }
            }
          }
          catch (Exception ex)
          {
    
            throw ex;
          }
          finally
          {
            Cursor.Current = Cursors.Default;
          }
        }
    
    

     


    Note: Please vote/mark the post as answered if it answers your question/helps to solve your problem. _________________________________________________________ Regards, Xavier Averbouch, Consultant, Avanade France
    Wednesday, December 8, 2010 3:29 PM