public static void DownloadSolution(string SolutionFolder) { try { SourceControlBase mSourceControl; if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT) { mSourceControl = new GITSourceControl(); } else if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN) { mSourceControl = RepositoryItemHelper.RepositoryItemFactory.GetNewSVnRepo(); } else { mSourceControl = RepositoryItemHelper.RepositoryItemFactory.GetNewSVnRepo(); } 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 + Path.DirectorySeparatorChar + @".git"))) { sol.ExistInLocaly = true; } else { sol.ExistInLocaly = false; } sol.SourceControlLocation = SolutionFolder.Substring(SolutionFolder.LastIndexOf(Path.DirectorySeparatorChar) + 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; RepositoryItemHelper.RepositoryItemFactory.GetLatest(sol.LocalFolder, mSourceControl); } else { getProjectResult = SourceControlIntegration.GetProject(mSourceControl, sol.LocalFolder, ProjectURI); } } catch (Exception e) { Reporter.ToConsole(eLogLevel.INFO, "Error Downloading solution "); Reporter.ToConsole(eLogLevel.INFO, e.Message); Reporter.ToConsole(eLogLevel.INFO, e.Source); } }
public static bool DownloadSolution(string SolutionFolder, bool undoSolutionLocalChanges = false) { try { SourceControlBase mSourceControl; if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT) { if (WorkSpace.Instance != null && WorkSpace.Instance.UserProfile != null && WorkSpace.Instance.UserProfile.SourceControlUseShellClient) { mSourceControl = new GitSourceControlShellWrapper(); } else { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { mSourceControl = new GITSourceControl(); } else { mSourceControl = new GitSourceControlShellWrapper(); } } } else if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN) { if (WorkSpace.Instance != null && WorkSpace.Instance.UserProfile != null && WorkSpace.Instance.UserProfile.SourceControlUseShellClient) { mSourceControl = new SVNSourceControlShellWrapper(); } else { mSourceControl = TargetFrameworkHelper.Helper.GetNewSVnRepo(); } } else { mSourceControl = TargetFrameworkHelper.Helper.GetNewSVnRepo(); } 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.IgnoreCertificate = WorkSpace.Instance.UserProfile.SourceControlIgnoreCertificate; 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; mSourceControl.SourceControlBranch = WorkSpace.Instance.UserProfile.SolutionSourceControlBranch; } 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 + Path.DirectorySeparatorChar + @".svn"))) { sol.ExistInLocaly = true; } else if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && Directory.Exists(PathHelper.GetLongPath(sol.LocalFolder + Path.DirectorySeparatorChar + @".git"))) { sol.ExistInLocaly = true; } else { sol.ExistInLocaly = false; } sol.SourceControlLocation = SolutionFolder.Substring(SolutionFolder.LastIndexOf(Path.DirectorySeparatorChar) + 1); if (sol == null) { Reporter.ToUser(eUserMsgKey.AskToSelectSolution); return(false); } string ProjectURI = string.Empty; if (WorkSpace.Instance.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN && !(mSourceControl is SVNSourceControlShellWrapper)) { if (WorkSpace.Instance.UserProfile.SourceControlURL.StartsWith("SVN", StringComparison.CurrentCultureIgnoreCase)) { ProjectURI = sol.SourceControlLocation; } else { if (WorkSpace.Instance.UserProfile.SourceControlURL.ToUpper().Contains(sol.SourceControlLocation.ToUpper())) { ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL; } else { ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL; if (!ProjectURI.ToUpper().Contains("/SVN") && !ProjectURI.ToUpper().Contains("/SVN/")) { if (!ProjectURI.ToUpper().EndsWith("/")) { ProjectURI += "/"; } ProjectURI += "svn/"; } if (!ProjectURI.ToUpper().EndsWith("/")) { ProjectURI += "/"; } ProjectURI += sol.SourceControlLocation; } //if(WorkSpace.Instance.GingerCLIMode==Amdocs.Ginger.CoreNET.RunLib.CLILib.eGingerCLIMode.run) //{ // ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL; //} //else //{ // ProjectURI= WorkSpace.Instance.UserProfile.SourceControlURL + sol.SourceControlLocation; //} } } else { ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL; } bool getProjectResult = true; getProjectResult = SourceControlIntegration.CreateConfigFile(mSourceControl); if (getProjectResult != true) { return(false); } if (sol.ExistInLocaly == true) { mSourceControl.RepositoryRootFolder = sol.LocalFolder; if (undoSolutionLocalChanges) { Reporter.ToLog(eLogLevel.INFO, "Reverting local Solution changes"); try { TargetFrameworkHelper.Helper.Revert(sol.LocalFolder, mSourceControl); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to revert local Solution changes, error: " + ex.Message); } } return(TargetFrameworkHelper.Helper.GetLatest(sol.LocalFolder, mSourceControl)); } else { return(getProjectResult = SourceControlIntegration.GetProject(mSourceControl, sol.LocalFolder, ProjectURI)); } } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while Downloading/Updating Solution from source control", e); return(false); } }