public void Deploy(bool publish, bool force, List <string> explicitExtensions)
        {
            if (File.Exists(Path.Combine(this.source, "package.crmpkg")))
            {
                Load();
                string currentDirectory = Directory.GetCurrentDirectory();
                Directory.SetCurrentDirectory(this.source);
                List <Guid> source = Deploy(solution.Files, force, explicitExtensions);
                Directory.SetCurrentDirectory(currentDirectory);

                Log.Information("Saving Post Deploy Package Changes... ");
                solution.Save();

                if (!publish || source == null || source.Count() <= 0 || !Connect())
                {
                    return;
                }

                try
                {
                    Log.Information("Publishing changes, {0} to update... ", source.Count());

                    var sources = string.Join(Environment.NewLine, source.Select(s => $"<webresource>{s.ToString("B")}</webresource>"));

                    PublishXmlRequest publishXmlRequest = new PublishXmlRequest()
                    {
                        ParameterXml = $"<importexportxml><webresources>{sources}</webresources></importexportxml>"
                    };

                    if (connection.IsReady)
                    {
                        PublishXmlResponse publishXmlResponse = (PublishXmlResponse)connection.Execute(publishXmlRequest);
                    }
                    else
                    {
                        Log.Error(connection.LastCrmError);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Failed");
                }
            }
            else
            {
                Log.Information("The package definition does not exist. Please create a deployment package before continuing.");
            }
        }
Exemplo n.º 2
0
        public bool Run()
        {
            try
            {
                // Set up the CRM Service.
                CrmService service = new CrmService();
                service.Credentials = System.Net.CredentialCache.DefaultCredentials;

                CrmAuthenticationToken token = new CrmAuthenticationToken();
                // TODO Replace 'AdventureWorksCycle' with your Microsoft CRM organization name.
                token.OrganizationName = "AdventureWorksCycle";

                service.CrmAuthenticationTokenValue = token;
                // TODO Replace 'localhost:5555' with your CRM server information.
                service.Url = @"http://*****:*****@"	<importexportxml>
													<entities>
														<entity>new_bankaccount</entity>
														<entity>new_safedepositbox</entity>
													</entities>
													<nodes/>
                                                    <securityroles/>
                                                    <settings/>
                                                    <workflows/>
												</importexportxml>"                                                ;

                // Execute the import.
                ImportXmlResponse importResponse = (ImportXmlResponse)service.Execute(importRequest);

                #endregion

                #region Publish new entities

                // Create the request.
                PublishXmlRequest publishRequest = new PublishXmlRequest();

                // Supply the request that is being published with the Bank Account and Safe Deposit Box.
                publishRequest.ParameterXml = @"<importexportxml>
												<entities>
														<entity>new_bankaccount</entity>
														<entity>new_safedepositbox</entity>
												</entities>
												<nodes/>
                                                <securityroles/>
                                                <settings/>
                                                <workflows/>
											</importexportxml>"                                            ;

                // Execute the request.
                PublishXmlResponse publishResponse = (PublishXmlResponse)service.Execute(publishRequest);

                #endregion
            }
            catch (System.Web.Services.Protocols.SoapException)
            {
                // Add your error handling code here.
            }

            return(true);
        }
Exemplo n.º 3
0
        public bool Run()
        {
            try
            {
                string          configFileName = "demo.ini";
                IniConfigSource configSource   = new IniConfigSource(configFileName);

                IConfig demoConfigSection = configSource.Configs["Demo"];
                string  extractPath       = demoConfigSection.Get("extractPath", string.Empty);

                // Set up the CRM Service.
                CrmService service = new CrmService();
                service.Credentials = System.Net.CredentialCache.DefaultCredentials;

                CrmAuthenticationToken token = new CrmAuthenticationToken();
                // TODO Replace 'AdventureWorksCycle' with your Microsoft CRM organization name.
                token.OrganizationName = "IBMRational";

                service.CrmAuthenticationTokenValue = token;
                // TODO Replace 'localhost:5555' with your CRM server information.
                service.Url = @"http://*****:*****@"C:\Users\rsdiasoliveira\Downloads\sdk4\sdk\server\fullsample\importexportpublish\cs\bin\Debug\";
                //const string customizationPath = @"C:\AppProject\Smart\ExternalSmartStaff\site\document";
                Console.WriteLine(customizationPath);
                foreach (var file in Directory.GetFiles(customizationPath))
                {
                    File.Copy(file, Path.Combine(sourceDir, Path.GetFileName(file)), true);
                }


                // Pass the stream of customization XML to the import request.
                using (StreamReader sr = new StreamReader(Path.Combine(customizationPath + "customizations.xml")))
                {
                    string customizationXml = sr.ReadToEnd();
                    importRequest.CustomizationXml = customizationXml;
                }

                // Supply the request that is being imported with the Bank Accounts and Safe Deposit Boxes.

                // Supply the request that is being imported with the Bank Accounts and Safe Deposit Boxes.
                importRequest.ParameterXml = @"	<importexportxml>
													<entities>
                                                        <entity>contact</entity>
														<entity>incident</entity>
														<entity>credifin_campanhapromo</entity>
													</entities>
													<nodes/>
                                                    <securityroles/>
                                                    <settings/>
                                                    <workflows/>
												</importexportxml>"                                                ;

                // Execute the import.
                ImportXmlResponse importResponse = (ImportXmlResponse)service.Execute(importRequest);

                #endregion

                #region Publish new entities

                // Create the request.
                PublishXmlRequest publishRequest = new PublishXmlRequest();

                // Supply the request that is being published with the Bank Account and Safe Deposit Box.

                publishRequest.ParameterXml = @"<importexportxml>
													<entities>
                                                        <entity>contact</entity>
														<entity>incident</entity>
														<entity>credifin_campanhapromo</entity>
													</entities>
													<nodes/>
                                                    <securityroles/>
                                                    <settings/>
                                                    <workflows/>
												</importexportxml>"                                                ;

                // Execute the request.
                PublishXmlResponse publishResponse = (PublishXmlResponse)service.Execute(publishRequest);

                #endregion
            }
            catch (System.Web.Services.Protocols.SoapException)
            {
                // Add your error handling code here.
            }

            return(true);
        }