Пример #1
0
        public void DownloadSolution(string SolutionFolder)
        {
            SourceControlBase mSourceControl;

            if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT)
            {
                mSourceControl = new GITSourceControl();
            }
            else if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN)
            {
                mSourceControl = new SVNSourceControl();
            }
            else
            {
                mSourceControl = new SVNSourceControl();
            }

            if (mSourceControl != null)
            {
                WorkSpace.Instance.UserProfile.SourceControlType = mSourceControl.GetSourceControlType;
                mSourceControl.SourceControlURL         = WorkSpace.Instance.UserProfile.SourceControlURL;
                mSourceControl.SourceControlUser        = WorkSpace.Instance.UserProfile.SourceControlUser;
                mSourceControl.SourceControlPass        = WorkSpace.Instance.UserProfile.SourceControlPass;
                mSourceControl.SourceControlLocalFolder = WorkSpace.Instance.UserProfile.SourceControlLocalFolder;
                mSourceControl.SolutionFolder           = SolutionFolder;

                mSourceControl.SourceControlConfigureProxy = WorkSpace.Instance.UserProfile.SolutionSourceControlConfigureProxy;
                mSourceControl.SourceControlProxyAddress   = WorkSpace.Instance.UserProfile.SolutionSourceControlProxyAddress;
                mSourceControl.SourceControlProxyPort      = WorkSpace.Instance.UserProfile.SolutionSourceControlProxyPort;
                mSourceControl.SourceControlTimeout        = WorkSpace.Instance.UserProfile.SolutionSourceControlTimeout;
                mSourceControl.supressMessage = true;
            }

            if (WorkSpace.Instance.UserProfile.SourceControlLocalFolder == string.Empty)
            {
                Reporter.ToUser(eUserMsgKey.SourceControlConnMissingLocalFolderInput);
            }
            if (SolutionFolder.EndsWith("\\"))
            {
                SolutionFolder = SolutionFolder.Substring(0, SolutionFolder.Length - 1);
            }

            SolutionInfo sol = new SolutionInfo();

            sol.LocalFolder = SolutionFolder;
            if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN && Directory.Exists(PathHelper.GetLongPath(sol.LocalFolder)))
            {
                sol.ExistInLocaly = true;
            }
            else if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && Directory.Exists(PathHelper.GetLongPath(sol.LocalFolder + @"\.git")))
            {
                sol.ExistInLocaly = true;
            }
            else
            {
                sol.ExistInLocaly = false;
            }

            sol.SourceControlLocation = SolutionFolder.Substring(SolutionFolder.LastIndexOf("\\") + 1);

            if (sol == null)
            {
                Reporter.ToUser(eUserMsgKey.AskToSelectSolution);
                return;
            }

            string ProjectURI = string.Empty;

            if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN)
            {
                ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL.StartsWith("SVN", StringComparison.CurrentCultureIgnoreCase) ?
                             sol.SourceControlLocation : WorkSpace.Instance.UserProfile.SourceControlURL + sol.SourceControlLocation;
            }
            else
            {
                ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL;
            }
            bool getProjectResult = true;

            getProjectResult = SourceControlIntegration.CreateConfigFile(mSourceControl);
            if (getProjectResult != true)
            {
                return;
            }

            if (sol.ExistInLocaly == true)
            {
                mSourceControl.RepositoryRootFolder = sol.LocalFolder;
                SourceControlIntegration.GetLatest(sol.LocalFolder, mSourceControl);
            }
            else
            {
                getProjectResult = SourceControlIntegration.GetProject(mSourceControl, sol.LocalFolder, ProjectURI);
            }
        }