Example #1
0
        /// <summary>
        /// Method merges solution components into Master solution and exports along with unzip file
        /// </summary>
        /// <param name="serviceProxy">organization service proxy</param>
        /// <param name="solutionFile">solution file info</param>
        private void ExportMasterSolution(OrganizationServiceProxy serviceProxy, SolutionFileInfo solutionFile)
        {
            this.MergeSolutions(solutionFile, serviceProxy);

            solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueueExportStatus;
            solutionFile.Solution.Attributes["syed_webjobs"] = Singleton.SolutionFileInfoInstance.WebJobs();
            solutionFile.Update();

            this.ExportSolution(serviceProxy, solutionFile, solutionFile.SolutionUniqueName, "Downloading Master Solution: ", solutionFile.ExportAsManaged);
            solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueueExportSuccessful;
            solutionFile.Solution.Attributes["syed_webjobs"] = Singleton.SolutionFileInfoInstance.WebJobs();
            solutionFile.Update();

            this.ImportSolutionToTargetInstance(serviceProxy, solutionFile);

            if (solutionFile.CheckInSolution)
            {
                if (string.IsNullOrEmpty(solutionFile.GitRepoUrl))
                {
                    solutionFile.Solution[Constants.SourceControlQueueAttributeNameForRepositoryUrl] = this.RepositoryUrl;
                }

                if (string.IsNullOrEmpty(solutionFile.BranchName))
                {
                    solutionFile.Solution[Constants.SourceControlQueueAttributeNameForBranch] = this.Branch;
                }

                if (string.IsNullOrEmpty(solutionFile.RemoteName))
                {
                    solutionFile.Solution[Constants.SourceControlQueueAttributeNameForRemote] = this.RemoteName;
                }

                solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueueExportStatus;
                solutionFile.Solution.Attributes["syed_webjobs"] = Singleton.SolutionFileInfoInstance.WebJobs();
                solutionFile.Update();

                this.ExportSolution(serviceProxy, solutionFile, solutionFile.SolutionUniqueName, "Downloading Unmanaged Master Solution: ", false);
                this.ExportSolution(serviceProxy, solutionFile, solutionFile.SolutionUniqueName, "Downloading Managed Master Solution: ", true);

                solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueueExportSuccessful;
                solutionFile.Solution.Attributes["syed_webjobs"] = Singleton.SolutionFileInfoInstance.WebJobs();
                solutionFile.Update();

                solutionFile.ProcessSolutionZipFile(this.SolutionPackagerPath);
            }
        }
Example #2
0
        /// <summary>
        /// Method exports solution
        /// </summary>
        /// <param name="serviceProxy">organization service proxy</param>
        /// <param name="solutionFile">solution file info</param>
        private void ExportSolution(OrganizationServiceProxy serviceProxy, SolutionFileInfo solutionFile)
        {
            if (solutionFile.SolutionsToBeMerged.Count > 0)
            {
                this.MergeSolutions(solutionFile, serviceProxy);
            }

            if (!solutionFile.CheckInSolution)
            {
                return;
            }

            solutionFile.Solution[Constants.SourceControlQueueAttributeNameForRepositoryUrl] = this.RepositoryUrl;
            solutionFile.Solution[Constants.SourceControlQueueAttributeNameForBranch]        = this.Branch;
            solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus]        = Constants.SourceControlQueueExportStatus;
            solutionFile.Update();

            ExportSolutionRequest exportRequest = new ExportSolutionRequest
            {
                Managed      = false,
                SolutionName = solutionFile.SolutionUniqueName
            };

            Console.WriteLine("Downloading Solution " + solutionFile.SolutionUniqueName);
            ExportSolutionResponse exportResponse = (ExportSolutionResponse)serviceProxy.Execute(exportRequest);

            // Handles the response
            byte[] downloadedSolutionFile = exportResponse.ExportSolutionFile;
            solutionFile.SolutionFilePath = Path.GetTempFileName();
            File.WriteAllBytes(solutionFile.SolutionFilePath, downloadedSolutionFile);

            string solutionExport = string.Format("Solution Successfully Exported to {0}", solutionFile.SolutionUniqueName);

            Console.WriteLine(solutionExport);

            solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueueExportSuccessful;
            solutionFile.Update();
            solutionFile.ProcessSolutionZipFile(this.SolutionPackagerPath);
        }