Example #1
0
        public override bool TestConnection(ref string error)
        {
            try
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                    delegate
                {
                    return(true);
                }
                    );
                WebResponse response = null;
                bool        result   = false;
                if (SourceControlURL.ToUpper().Trim().StartsWith("HTTP"))
                {
                    if (!SourceControlURL.EndsWith("/"))
                    {
                        SourceControlURL = SourceControlURL + "/";
                    }
                    WebRequest request = WebRequest.Create(SourceControlURL);
                    request.Timeout     = 15000;
                    request.Credentials = new System.Net.NetworkCredential(SourceControlUser, SourceControlPass);
                    response            = (WebResponse)request.GetResponse();
                }
                else if (SourceControlURL.ToUpper().Trim().StartsWith("SVN"))
                {
                    using (SvnClient sc = new SvnClient())
                    {
                        sc.Authentication.DefaultCredentials = new System.Net.NetworkCredential(SourceControlUser, SourceControlPass);
                        Uri targetUri = new Uri(SourceControlURL);
                        var target    = SvnTarget.FromUri(targetUri);
                        Collection <SvnInfoEventArgs> info;
                        result = sc.GetInfo(target, new SvnInfoArgs {
                            ThrowOnError = false
                        }, out info);
                    }
                }

                if (response != null || result)
                {
                    return(true);
                }
                else
                {
                    error = "No Details";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Example #2
0
        public override ObservableList <SolutionInfo> GetProjectsList()
        {
            ObservableList <SolutionInfo> SourceControlSolutions = new ObservableList <SolutionInfo>();

            try
            {
                string repositoryName = SourceControlURL.Substring(SourceControlURL.LastIndexOf("/") + 1);
                if (repositoryName == string.Empty)
                {
                    string SourceControlURLExcludeSlash = SourceControlURL.Substring(0, SourceControlURL.LastIndexOf("/"));
                    repositoryName = SourceControlURLExcludeSlash.Substring(SourceControlURLExcludeSlash.LastIndexOf("/") + 1);
                }
                AddSolution(SourceControlSolutions, SourceControlLocalFolder + @"\" + repositoryName, repositoryName);
            }
            catch (Exception ex)
            { Console.WriteLine(ex.StackTrace); }
            return(SourceControlSolutions);
        }
Example #3
0
        public override ObservableList <SolutionInfo> GetProjectsList()
        {
            ObservableList <SolutionInfo> SourceControlSolutions = new ObservableList <SolutionInfo>();

            try
            {
                string repositoryName = SourceControlURL.Substring(SourceControlURL.LastIndexOf("/") + 1);
                if (repositoryName == string.Empty)
                {
                    string SourceControlURLExcludeSlash = SourceControlURL.Substring(0, SourceControlURL.LastIndexOf("/"));
                    repositoryName = SourceControlURLExcludeSlash.Substring(SourceControlURLExcludeSlash.LastIndexOf("/") + 1);
                }
                //check which path to show to download
                string localPath = SourceControlLocalFolder;
                if (IsImportSolution)
                {
                    localPath = SourceControlLocalFolderForGlobalSolution;
                }
                AddSolution(SourceControlSolutions, localPath + @"\" + repositoryName, repositoryName);
            }
            catch (Exception ex)
            { Console.WriteLine(ex.StackTrace); }
            return(SourceControlSolutions);
        }
Example #4
0
        public override ObservableList <SolutionInfo> GetProjectsList()
        {
            ObservableList <SolutionInfo> SourceControlSolutions = new ObservableList <SolutionInfo>();

            if (SourceControlURL.ToUpper().Trim().StartsWith("HTTP"))
            {
                WebRequest request = WebRequest.Create(SourceControlURL);
                request.Timeout     = 60000;
                request.Credentials = new System.Net.NetworkCredential(SourceControlUser, SourceControlPass);
                SourceControlSolutions.Clear();
                Stream objStream;

                objStream = request.GetResponse().GetResponseStream();
                StreamReader objReader = new StreamReader(objStream);

                //quick and dirty way to get the folder instead of messing with XML
                string sLine = "";
                while (!objReader.EndOfStream)
                {
                    sLine = objReader.ReadLine();
                    if (sLine.Contains("dir name"))
                    {
                        int    i1           = sLine.IndexOf("dir name=");
                        int    len          = sLine.IndexOf(" href") - i1 - 11;
                        string SolutionName = sLine.Substring(i1 + 10, len);

                        AddSolution(SourceControlSolutions, SourceControlLocalFolder + @"\" + SolutionName, SolutionName);
                    }
                    else if (sLine.StartsWith("  <li><a href=\""))
                    {
                        int start = sLine.IndexOf("\"");
                        sLine = sLine.Substring(start + 1);
                        int    end          = sLine.IndexOf("\"");
                        string SolutionName = sLine.Substring(0, end - 1);

                        if (!SolutionName.Contains("."))
                        {
                            AddSolution(SourceControlSolutions, SourceControlLocalFolder + @"\" + SolutionName, SolutionName);
                        }
                    }
                }
            }
            else if (SourceControlURL.ToUpper().Trim().StartsWith("SVN"))
            {
                using (SvnClient sc = new SvnClient())
                {
                    sc.Authentication.DefaultCredentials = new System.Net.NetworkCredential(SourceControlUser, SourceControlPass);
                    Uri targetUri = new Uri(SourceControlURL);
                    var target    = SvnTarget.FromUri(targetUri);
                    Collection <SvnInfoEventArgs> info;
                    bool result = sc.GetInfo(target, new SvnInfoArgs {
                        ThrowOnError = false
                    }, out info);
                    SourceControlSolutions.Clear();
                    if (result)
                    {
                        foreach (var f in info)
                        {
                            AddSolution(SourceControlSolutions, SourceControlLocalFolder + @"\" + f.Path, f.Uri.OriginalString);
                        }
                    }
                }
            }
            return(SourceControlSolutions);
        }