Пример #1
0
        /// <summary>
        /// Method tries to update repository
        /// </summary>
        /// <param name="solutionUniqueName">unique solution name</param>
        /// <param name="committerName">committer name</param>
        /// <param name="committerEmail">committer email</param>
        /// <param name="authorEmail">author email</param>
        public static void TryUpdateToRepository(string solutionUniqueName, string committerName, string committerEmail, string authorEmail)
        {
            ICrmSolutionHelper crmSolutionHelper = new CrmSolutionHelper(
                RepositoryConfigurationConstants.RepositoryUrl,
                RepositoryConfigurationConstants.BranchName,
                CrmConstants.OrgServiceUrl,
                CrmConstants.DynamicsUserName,
                CrmConstants.DynamicsPassword,
                CrmConstants.SolutionPackagerPath);

            int timeOut = Convert.ToInt32(CrmConstants.SleepTimeoutInMillis);

            // while (true)
            {
                HashSet <string> hashSet = new HashSet <string>();

                try
                {
                    var solutionFiles = crmSolutionHelper.DownloadSolutionFile(solutionUniqueName);

                    if (!crmSolutionHelper.CanPush)
                    {
                        System.Threading.Thread.Sleep(timeOut);

                        // continue;
                    }

                    ////if (!Directory.Exists(ConfigurationManager.AppSettings["RepositoryLocalDirectory"]))
                    ////{
                    ////    Console.WriteLine("Repository local directory doesnt exists " + ConfigurationManager.AppSettings["RepositoryLocalDirectory"]);
                    ////}
                    ////else
                    {
                        string solutionFilePath = RepositoryConfigurationConstants.LocalDirectory + "solutions.txt";

                        // todo: enable solutions file clear from crm portal
                        PopulateHashset(solutionFilePath, new HashSet <string>());
                        foreach (var solutionFile in solutionFiles)
                        {
                            if (solutionFile.CheckInSolution)
                            {
                                TryPushToRepository(committerName, committerEmail, authorEmail, solutionFile, solutionFilePath, hashSet);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex);
                    System.Threading.Thread.Sleep(timeOut);
                }

                System.Threading.Thread.Sleep(timeOut);
            }
        }
Пример #2
0
        /// <summary>
        /// Method tries to update repository
        /// </summary>
        /// <param name="solutionUniqueName">unique solution name</param>
        /// <param name="committerName">committer name</param>
        /// <param name="committerEmail">committer email</param>
        /// <param name="authorEmail">author email</param>
        public void TryUpdateToRepository(string solutionUniqueName, string committerName, string committerEmail, string authorEmail, string mode)
        {
            try
            {
                string             solutionFilePath  = string.Empty;
                ICrmSolutionHelper crmSolutionHelper = new CrmSolutionHelper(
                    Singleton.RepositoryConfigurationConstantsInstance.RepositoryUrl,
                    Singleton.RepositoryConfigurationConstantsInstance.BranchName,
                    Singleton.RepositoryConfigurationConstantsInstance.RepositoryRemoteName,
                    Singleton.CrmConstantsInstance.OrgServiceUrl,
                    Singleton.CrmConstantsInstance.DynamicsUserName,
                    Singleton.CrmConstantsInstance.DynamicsPassword,
                    Singleton.CrmConstantsInstance.SolutionPackagerPath);

                int timeOut       = Convert.ToInt32(Singleton.CrmConstantsInstance.SleepTimeoutInMillis);
                var solutionFiles = crmSolutionHelper.DownloadSolutionFile(solutionUniqueName, mode);
                if (!crmSolutionHelper.CanPush)
                {
                    System.Threading.Thread.Sleep(timeOut);
                    //// continue;
                }

                if (solutionFiles.Count > 0)
                {
                    solutionFilePath = Singleton.RepositoryConfigurationConstantsInstance.LocalDirectory + "solutions.txt";
                    GitDeploy.GitRepositoryManager gitRepositoryManager = this.ConfigureRepository(solutionFiles[0], committerName, committerEmail, authorEmail, solutionFilePath);
                    this.PushRepository(solutionFiles, committerName, committerEmail, authorEmail, solutionFilePath, gitRepositoryManager);
                    System.Threading.Thread.Sleep(timeOut);
                }
            }
            catch (Exception ex)
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(ex.Message);
                Console.WriteLine(ex.Message);
            }
        }