locked
Regarding Audit trail for entity members in MDS RRS feed

  • Question

  • Hi All,

    My question is related to the way audit trail is maintained in MDS. When we enable audit tracking for attributes, we can see audit data being entered in the table named as 'tblTransaction' in the MDS database. Now if I am entering data using MDS API and specify audit info for the member like below:

    <span style="white-space:pre">	</span>  EntityMembersCreateRequest request = new EntityMembersCreateRequest();
          EntityMembersCreateResponse response = new EntityMembersCreateResponse();
    
          request.Members = new EntityMembers();
          request.Members.ModelId = new Identifier { Name = "Test" };
          request.Members.EntityId = new Identifier { Name = "Study" };
          request.Members.VersionId = new Identifier { Name = "VERSION_1" };
    
    
          Member member = new Member { MemberId = new MemberIdentifier { Code = "04", Name = "Study04" } };
          member.AuditInfo = new AuditInfo();
          member.AuditInfo.CreatedDateTime = DateTime.Now;
          member.AuditInfo.CreatedUserId = new Identifier { InternalId = 3 };
    

    Where would this information go in MDS database. I created 3 members specifying this information but I could not see these details in 'tblTransaction' table. The table only had audit trail for the attributes I enabled audit trail while creating the entity.

     

     

     


    Thanks, Himanshu.
    Friday, January 28, 2011 9:04 AM

Answers

  • Hi Himanshu

     

    it looks like you forgot something in the request parameters

    please take a look at my mds winform application source code.

    when I use the add button to add a member, it is well logged in transactions table.

    you can find the full source code on http://mdsmanager.codeplex.com/

     

     public void ManageMember(MemberAction action)
      {
       try
       {
        Cursor.Current = Cursors.WaitCursor;
        if (!string.IsNullOrEmpty(txtAttributeValue.Text.Trim()) && ucManageEntities1.lstEntities.SelectedItem != null && lstModels.SelectedItem != null && lstVersions.SelectedItem != null)
        {
         EntityMembers em = new EntityMembers();
         em.EntityId = ((CustomEntity)ucManageEntities1.lstEntities.SelectedItem).entityId;
         em.ModelId = (Identifier)lstModels.SelectedItem;
         em.VersionId = ((CustomVersion)lstVersions.SelectedItem).Identifier;
         em.MemberType = new MemberType();
         em.MemberType = MemberType.Leaf;
         em.Members = new Collection<Member>();
         Member m = new Member();
         if (action == MemberAction.UpdateMember)
         {
          m.MemberId = ucManageMembers1.lstMembers.SelectedItem != null ? ((CustomMember)ucManageMembers1.lstMembers.SelectedItem).MemberId : new MemberIdentifier();
          // m.SecurityPermission = SecurityPermission.Update;
         }
         else
         {
          m.MemberId = new MemberIdentifier();
         }
         m.MemberId.Name = txtAttributeName.Text.Trim();
         m.MemberId.Code = txtAttributeValue.Text.Trim();
         if (action == MemberAction.UpdateMember)
         {
          m.Attributes = new Collection<Common.ServiceReference1.Attribute>();
          Common.ServiceReference1.Attribute attr1 = new Common.ServiceReference1.Attribute();
          attr1.Identifier = new Identifier();
          attr1.Identifier.Name = "Code";
          attr1.Value = new char();
          attr1.Value = m.MemberId.Code;
          m.Attributes.Add(attr1);
    
          Common.ServiceReference1.Attribute attr2 = new Common.ServiceReference1.Attribute();
          attr2.Identifier = new Identifier();
          attr2.Identifier.Name = "Name";
          attr2.Value = new char();
          attr2.Value = m.MemberId.Name;
          m.Attributes.Add(attr2);
         }
    
         em.Members.Add(m);
         OperationResult or = new OperationResult();
    
         using (ServiceClient c = MDS_WSConnect.CreateMdsProxy())
         {
          if (action == MemberAction.AddMember)
           or = c.EntityMembersCreate(new International(), em);
    
          if (action == MemberAction.UpdateMember)
          {
           c.EntityMembersUpdate(new International(), em);
          }
          if (action == MemberAction.DeleteMember)
           or = c.EntityMembersDelete(new International(), em);
    
         }
         StringBuilder sb = new StringBuilder();
         if (or.Errors != null && or.Errors.Count > 0)
         {
          foreach (Error err in or.Errors)
          {
           sb.AppendLine(em.Members[0].MemberId.Code + " - " + err.Code + " - " + err.Description);
          }
          MessageBox.Show(sb.ToString(), "Errors");
    
    
         }
         RefreshLstMembersAttributes((Identifier)lstModels.SelectedItem, (CustomEntity)ucManageEntities1.lstEntities.SelectedItem, (CustomVersion)lstVersions.SelectedItem);
        }
        else
         lblError.Text = "Member Code cannot be empty!";
       }
       catch (Exception ex)
       {
        lblError.Text = ex.Message;
        //throw ex;
       }
       finally
       {
        Cursor.Current = Cursors.Default;
       }
    
      }
    

     



    Xavier Averbouch - Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, February 2, 2011 5:14 PM