How to get a file attribute value for an entity member using MDM -WCF service?
-
1 августа 2011 г. 14:24
I am using following code to get the Entity Member Attributes. This code results in following two problems
1. Attribute type is changed to "String" after giving call to
getResponse = MDSProxy.MDSClient.EntityMemberAttributesGet(getRequest);
2. Does not return Content in case of File Attributes
public MDS.EntityMembers ExecuteReaderWithFileAttribute(string searchTerm, string sortColumn, MDS.DisplayType displayType, int StartPage, intPageSize)
{
MDS.
EntityMembersGetRequestgetRequest;
MDS.
EntityMembersGetResponsegetResponse;
MDS.
EntityMembersmembers;
getRequest = GetRequest(searchTerm, sortColumn, displayType, StartPage, PageSize);
getResponse = MDSProxy.MDSClient.EntityMembersGet(getRequest);
_Reader = getResponse;
_CRUDResult = getResponse.OperationResult;
_EntityMembersInformation = getResponse.EntityMembersInformation;
members = ReadFileAttributeForMember(getResponse.EntityMembers);
returnmembers;
}
public MDS.EntityMembers ReadFileAttributeForMember(MDS.EntityMembersm)
{
MDS.
EntityMemberAttributesGetRequest getRequest = new MDS.EntityMemberAttributesGetRequest();
MDS.
EntityMemberAttributesGetResponsegetResponse;
getRequest.EntityMembers = m;
getRequest.International =
new MDS.International() { Locale = "en-US"};
getResponse = MDSProxy.MDSClient.EntityMemberAttributesGet(getRequest);
returngetResponse.EntityMembers;
}
private MDS.EntityMembersGetRequest GetRequest(string searchTerm, string sortColumn, MDS.DisplayType displayType, int StartPage, intPageSize)
{
MDS.
EntityMembersGetRequestgetRequest;
getRequest =
new MDS.EntityMembersGetRequest();
//Represents a request complex type that defines the EntityMember criteria for the operations result set.
MDS.
EntityMembersGetCriteria memberGetCriteria = new MDS.EntityMembersGetCriteria();
//Sets GUID or the exact name of the model.
memberGetCriteria.ModelId =
new MDS.Identifier() { Name = ModelName };
//Sets a GUID or the exact name of the entity.
memberGetCriteria.EntityId =
new MDS.Identifier() { Name = EntityName };
//Sets the GUID or the exact name of the version.
memberGetCriteria.VersionId =
new MDS.Identifier() { Name = Version };
// memberGetCriteria.AttributeGroupId = new MDS.Identifier() { Name = AttributeGroupName };
if(StartPage <= 0) StartPage = 1;
memberGetCriteria.PageNumber = StartPage ;
if(PageSize <= 0) PageSize = 10;
memberGetCriteria.PageSize = PageSize;
memberGetCriteria.MemberReturnOption = MDS.
MemberReturnOption.DataAndCounts;
memberGetCriteria.AttributeGroupId =
new MDS.Identifier{ Name = AttributeGroup };
//Sets a WHERE clause search criteria to filter records.
memberGetCriteria.SearchTerm = searchTerm;
// Set display type for domain fields
memberGetCriteria.DisplayType = displayType;
// Set a Sort Column ID
if (sortColumn.ToUpper().Contains("ASC")) memberGetCriteria.SortDirection = MDS.SortDirection.Asc; else memberGetCriteria.SortDirection = MDS.SortDirection.Desc;
if (!string.IsNullOrEmpty(sortColumn)) sortColumn = sortColumn.Replace(" ASC", "").Replace(" DESC", "").Trim();
memberGetCriteria.SortColumnId =
new MDS.Identifier() { Name = sortColumn };
// Created Request Object
MDS.
International international = new MDS.International() { Locale = "en-US"};
getRequest.International = international;
getRequest.MembersGetCriteria = memberGetCriteria;
returngetRequest;
}
How do i overcome above two error
Все ответы
-
31 декабря 2011 г. 7:15
Hi Try below codes to get File attribute.
[TestMethod()] public void EntityMemberAttributesGet2Test() { EntityMembersGetRequest getRequest = new EntityMembersGetRequest(); EntityMembersGetResponse getResponse = new EntityMembersGetResponse(); Microsoft.MasterDataServices.Services.Service target = new Microsoft.MasterDataServices.Services.Service(); //Represents a request complex type that defines the EntityMember criteria for the operations result set. EntityMembersGetCriteria memberGetCriteria = new EntityMembersGetCriteria(); //Sets GUID or the exact name of the model. memberGetCriteria.ModelId = new Identifier() { Name = "Vehicle" }; //Sets a GUID or the exact name of the entity. memberGetCriteria.EntityId = new Identifier() { Name = "Vehicle" }; //Sets the GUID or the exact name of the version. memberGetCriteria.VersionId = new Identifier() { Name = "VERSION_1" }; memberGetCriteria.SearchTerm = String.Format(" [Code] = '{0}' ", "0"); memberGetCriteria.PageSize = 200; getRequest.MembersGetCriteria = memberGetCriteria; getResponse = target.EntityMembersGet(getRequest); string fileName = (getResponse.EntityMembers.Members[0].Attributes[6].Value as FileAttribute).Name; Console.Read(); }In UI, we have model: Vehicle, a membr with code="0";
In my test, I can get the correct file name.
BTW, I use the EntityMembersGet method instead.
Hope this helps.
----------------------------------------------------------------------
胡以谦

