locked
WCF - Get lastest records from an entity RRS feed

  • Question

  • Hi,

    How can we via WCF retreive the internal attributes like lastChanged, changedBy, etc. for an entity? And how can we use them in the SearchTerm on the EntityMemberGetCriteria?

    Thanks!

    /Mikkel


    Mikkelsen
    Friday, October 15, 2010 6:51 AM

Answers

  • Hello Mikkelsen

     

    this could help you:

     

     public Metadata GetMetaData(International intl, ref OperationResult or, Identifier ModelId)
      {
       MetadataResultOptions mro = new MetadataResultOptions();
       MetadataSearchCriteria msc = new MetadataSearchCriteria();
       msc.Models = new Collection<Identifier>() { ModelId };
       msc.Versions = new Collection<Identifier>() { new Identifier() };
       msc.Entities = new Collection<Identifier>() { new Identifier() };
       msc.VersionFlags = new Collection<Identifier>() { new Identifier() };
       msc.DerivedHierarchies = new Collection<Identifier>() { new Identifier() };
       msc.AttributeGroups = new Collection<Identifier>() { new Identifier() };
       msc.SearchOption = Common.ServiceReference1.SearchOption.UserDefinedObjectsOnly;
    
    
       mro.Models = ResultType.Identifiers;
       mro.Entities = ResultType.Identifiers;
       mro.DerivedHierarchies = ResultType.Identifiers;
       mro.Versions = ResultType.Identifiers;
       mro.VersionFlags = ResultType.Identifiers;
       mro.AttributeGroups = ResultType.Details;
       Metadata md = new Metadata();
    
    
       using (ServiceClient c = MDS_WSConnect.CreateMdsProxy())
       {
        md = c.MetadataGet(new International(), mro, msc, out or);
        return md;
       }
      }
    

     

    Metadata md returns :

     

    Regards,


    Xavier Averbouch
    Friday, October 15, 2010 8:42 AM

All replies

  • Hello Mikkelsen

     

    this could help you:

     

     public Metadata GetMetaData(International intl, ref OperationResult or, Identifier ModelId)
      {
       MetadataResultOptions mro = new MetadataResultOptions();
       MetadataSearchCriteria msc = new MetadataSearchCriteria();
       msc.Models = new Collection<Identifier>() { ModelId };
       msc.Versions = new Collection<Identifier>() { new Identifier() };
       msc.Entities = new Collection<Identifier>() { new Identifier() };
       msc.VersionFlags = new Collection<Identifier>() { new Identifier() };
       msc.DerivedHierarchies = new Collection<Identifier>() { new Identifier() };
       msc.AttributeGroups = new Collection<Identifier>() { new Identifier() };
       msc.SearchOption = Common.ServiceReference1.SearchOption.UserDefinedObjectsOnly;
    
    
       mro.Models = ResultType.Identifiers;
       mro.Entities = ResultType.Identifiers;
       mro.DerivedHierarchies = ResultType.Identifiers;
       mro.Versions = ResultType.Identifiers;
       mro.VersionFlags = ResultType.Identifiers;
       mro.AttributeGroups = ResultType.Details;
       Metadata md = new Metadata();
    
    
       using (ServiceClient c = MDS_WSConnect.CreateMdsProxy())
       {
        md = c.MetadataGet(new International(), mro, msc, out or);
        return md;
       }
      }
    

     

    Metadata md returns :

     

    Regards,


    Xavier Averbouch
    Friday, October 15, 2010 8:42 AM
  • Hi Xavier,

    That's perfect! Thanks...

    Do you have an example showing how we can use this metadata in a call to the EntityMembersGet method.

    We have a scenario where we would like to retrieve all records for an entity, where the changed-date are larger than a given date. Is this possible?

    Thanks again.


    Mikkelsen
    Friday, October 15, 2010 10:26 AM
  • Hi again Mikkelsen,

    Yes it is possible, and you can do something like this:

     

     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)
     {
      if (m.AuditInfo.UpdatedDateTime < DateTime.Now)
     {
     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 Collection<Member> GetMembers(Identifier modelId, Identifier versionId, CustomEntity entity, string SearchTerm)
        {
          EntityMembersGetCriteria emgc = new EntityMembersGetCriteria();
          emgc.EntityId = entity.entityId;
          emgc.ModelId = modelId;
          emgc.VersionId = versionId;
          emgc.AttributeGroupId = new Identifier();
          emgc.PageSize = 10000;
          emgc.DisplayType = DisplayType.NameCode;
          emgc.MemberReturnOption = MemberReturnOption.DataAndCounts;
          if (!string.IsNullOrEmpty(SearchTerm.Trim()))
            emgc.SearchTerm = SearchTerm;
    
          EntityMembersInformation emi = new EntityMembersInformation();
          
          using (var c = MDS_WSConnect.CreateMdsProxy())
          {
            Metadata md = new Metadata();
            OperationResult or = new OperationResult();
            EntityMembers em = c.EntityMembersGet(new International(), emgc, out emi, out or);
            return em.Members;
          }
        }

    More generally,

    you can find some complete examples to get some data  on my MDSmanager :

    http://social.msdn.microsoft.com/Forums/en-US/sqlmds/thread/837b787a-f55a-4e6a-8e58-6442c6841fc2

     

     


    Note: Please vote/mark the post as answered if it answers your question/helps to solve your problem. _________________________________________________________

    Regards, Xavier Averbouch

    Friday, October 15, 2010 11:26 AM
  • Hi again and thanks again for you answer.

    Your example will work, but is it necessary to load all members first? Is it not possible to add the UpdatedDateTime as a criteria in the search-term, so we only get the members changed since last time?

    I really appreciates your help!

    /Mikkel


    Mikkelsen
    Monday, October 18, 2010 6:24 AM
  • Hi Mikkelsen,

     

    as you can see on this post:

    http://social.msdn.microsoft.com/Forums/en-GB/sqlmds/thread/90ba166f-d791-4e07-8fad-389e3c533c89

    searchterm seems to be restricted.

    I don't think it is possible to add the updateddatetime as a criteria in it.

    But maybe the official MDS Team could tell us more information about that ?

    Regards,

     


    Note: Please vote/mark the post as answered if it answers your question/helps to solve your problem. _________________________________________________________ Regards, Xavier Averbouch, Consultant, Avanade France
    Monday, October 18, 2010 7:57 AM
  • Hi Xavier,

    Thanks for your help!

    We have chosen the SQL-way and will use staging-tables, subscription-views and stored-procedures to integrate with other systems via Biztalk.
    I would have preferred the WCF-way, but the lack of useful documentation and working examples have forced us to chose SQL.

     


    Mikkelsen
    Tuesday, October 19, 2010 6:25 AM
  • Hi Mikkelsen

     

    you can also do it with an ssis package:

    http://social.msdn.microsoft.com/Forums/en-US/sqlmds/thread/3edcde59-374a-4c73-953c-779bc7481163

     

     


    Note: Please vote/mark the post as answered if it answers your question/helps to solve your problem. _________________________________________________________ Regards, Xavier Averbouch, Consultant, Avanade France
    Tuesday, October 19, 2010 6:29 AM