Nov 26, 2010

Export Import & Publish Programmatically

1. Export Customization

ExportXmlRequest request = new ExportXmlRequest(); 
request.ParameterXml = @"<importexportxml><entities></entities> <nodes> <node></node>
</nodes> <securityroles></securityroles> <settings></settings> <workflows></workflows>
// Execute the request.
ExportXmlResponse response = (ExportXmlResponse)service.Execute(request);
// Create an instance of StreamWriter to write text to a file.
// The using statement also closes the StreamWriter.
using (StreamWriter sw = new StreamWriter(Path.Combine(strLocation, "Customizations_Backup.xml")))
// Write the customization XML to the file

2. Modify the customization file.
3. Create the import request.

ImportXmlRequest importRequest = new ImportXmlRequest();            
// Define the location of the customization XML.
string customizationPath = Path.Combine(path, "Customizations_Backup.xml");
// Pass the stream of customization XML to the import request.
using (StreamReader sr = new StreamReader(customizationPath))
string customizationXml = sr.ReadToEnd();
importRequest.CustomizationXml = customizationXml;
// Execute the import.
ImportXmlResponse importResponse = (ImportXmlResponse)service.Execute(importRequest);

4. Publish Customization

// Create the request.            
PublishXmlRequest publishRequest = new PublishXmlRequest();
publishRequest.ParameterXml = @"<importexportxml>
// Execute the request.
PublishXmlResponse publishResponse = (PublishXmlResponse)service.Execute(publishRequest);

Refer this link as well


No comments: