Master Data Services : Getting Errors out of a ModelMembersBulkUpdate/Merge with API

In fact, you can get the error codes on MDS website : in « Integration Management/Staging Batches » clicking on the batch you want and clicking on button « view details for selected batch »
in order to do the same thing with API (get error codes), you’ll need to get back the batch after it is inserted. 

//get information related to a staging batch
public Collection<StagingBatch> StagingGet(Collection<Identifier> stagingBatch, bool ReturnAllCriteria, bool ReturnMembers, bool ReturnAttributes, bool ReturnRelationShips, ref OperationResult or)
Collection<StagingUnbatchedInformation> colUnbatched = new Collection<StagingUnbatchedInformation>();
Collection<StagingBatch> colBatches = new Collection<StagingBatch>();
using (ServiceClient c = MDS_WSConnect.CreateMdsProxy())
or = new OperationResult();
colBatches = c.StagingGet(new International(), true, new StagingResultCriteria() { All = ReturnAllCriteria, Attributes = ReturnAttributes, Members = ReturnMembers, Relationships = ReturnRelationShips },
new StagingSearchCriteria() { StagingBatches = stagingBatch, StagingDataStatus= StagingDataStatus.All }, out or, out colUnbatched);
List<string> lstErr = new List<string>();
// what you need with the error collection
foreach (<strong>StagingBatchError err in colBatches.First().Errors</strong>)
lstErr.Add(err.ErrorCode + " - " + err.TargetCode);

return colBatches;
so, complete process would be:
DateTime dtBefore = DateTime.Now; 
OperationResult or = new OperationResult();
//filling new staging batch with entityMembers
Collection<Identifier> colStaging = ModelMembersBulkMerge(colEntMembers);
//initiating the staging process (not sure I really need that here in fact)
Collection<StagingBatch> colBatches = StagingGet(colStaging, true, true, true, false, ref or);
//triggering staging
ProcessUnbatchedStaging(pModelId, pVersionId);

DateTime dtAfter = DateTime.Now;
TimeSpan ts = dtAfter.Subtract(dtBefore);

MessageBox.Show("members (bulk) inserted : " + colEntMembers.First().Members.Count() + "\r\n" + "time elapsed (seconds):" + ts.TotalSeconds.ToString());
//get back the batch to see if any errors

colBatches = StagingGet(colStaging, true, true, true, false, ref or);
note: StagingDataStatus= StagingDataStatus.All –> get all including Errors
Pour marque-pages : Permaliens.

A propos Xavier

7 years+ .net consulting

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Captcha * Time limit is exhausted. Please reload CAPTCHA.

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.