viernes, 13 de septiembre de 2013

CRM 4.0 - Guardar las customizaciones por código

if (contacto_p != null) {

                try {
                    // Create the request.
                    ExportCompressedAllXmlRequest request = new ExportCompressedAllXmlRequest();
                    // Assign the file name for the customizations.
                    request.EmbeddedFileName = "customizations.xml";
                    // Execute the request.
                    ExportCompressedAllXmlResponse response = (ExportCompressedAllXmlResponse)crmService.Execute(request);
                    // Get the compressed data.
                    byte[] compressedXML = response.ExportCompressedXml;
                    // Write the data to disk.
                    using (FileStream fs = new FileStream(@"C:\customs\Customizations.zip", FileMode.Create))
                    {
                    fs.Write(compressedXML, 0, compressedXML.Length);
                    fs.Close();
                    }
                }
                catch (System.Web.Services.Protocols.SoapException ex) {

                    throw new Exception(ex.Message + ". " + ex.Detail.InnerText, ex);

                }

            }

No hay comentarios:

Publicar un comentario