Here's how you can remove parties programatically. It's quite easy.
I. First, you need a reference to the Microsoft.BizTalk.ExplorerOM assembly. You can find this assembly in the Biztalk install folder
II.. Create your code this way
try
{
BtsCatalogExplorer btsExp = new BtsCatalogExplorer();
1. PartyCollection pc = (PartyCollection)btsExp.GetCollection(CollectionType.Party);
2. for (int i=0; i<= pc.Count-1; i++)
{
3. if (bindingFileParties.Contains(pc[i].Name))
{
4. btsExp.RemoveParty(pc[i]);
5. i--;
}
6. btsExp.SaveChanges();
}
}
catch (Exception ex)
{
7. this.btsExp.DiscardChanges();
throw ex;
}
line 1 : Create an instance of the BtsCatalogExplorer and retrieve the partycollection deployed in the Mgmt database
line 2 : loop through all parties
line 3: Here I process only those parties which are declared in a binding file. The bindingFileParties variable here is an Arraylist which contains a list of all “party” values found in a binding file. This is just to make sure that I remove the parties which are mine.
line 4: This is the line where we actually remove the party.
line 5: Bring back the counter one step because we removed a party from the collection
line 6: Commit the changes to the database
line 7: Discard your changes if any exception occured.
You can also use this approach to remove ReceivePorts and Send ports. Just replace PartyCollection with ReceivePortCollection or SendPortCollection and CollectionType.Party with CollectionType.ReceivePort or CollectionType.SendPort
Print | posted on Wednesday, May 03, 2006 7:25 AM