Example #1
0
 public AnkhRepository(Uri uri, string repositoryId, IDictionary<string, object> properties)
     : base(PluginConstants.ConnectorName)
 {
     _repositoryId = repositoryId;
     _properties = properties;
     _settings = properties.ToConnectorSettings(uri);
 }
Example #2
0
        public void SaveLocalUserSettings(ConnectorSettings source)
        {
            if (source.LocalAccount)
            {
                if (!Directory.Exists(localAccountFolder))
                {
                    Directory.CreateDirectory(localAccountFolder);
                }

                File.WriteAllText(Path.Combine(localAccountFolder, localAccountSettingsFile),
                                  "user="******"&pass=" + source.Password);
            }
        }
        public static IssueRepositorySettings ToIssueRepositorySettings(this ConnectorSettings src)
        {
            var props = new Dictionary <string, Object>();

            props[PROPERTY_PROJECT]        = src.ProjectId;
            props[PROPERTY_PERPAGE]        = src.IssuesPerPage;
            props[PROPERTY_LOCALACC]       = src.LocalAccount;
            props[PROPERTY_SOAPURI]        = src.WebServicePath;
            props[PROPERTY_FETCHINGMETHOD] = ((int)src.FetchingMethod);
            props[PROPERTY_ISSUEPATTERN]   = src.IssuePattern;
            props[PROPERTY_ADDNOTE]        = src.AddNoteAfterCommit;
            props[PROPERTY_ASSOCIATEDNOTE] = src.AssociatedCommitNoteText;
            props[PROPERTY_CLOSENOTE]      = src.CloseCommitNoteText;

            if (!src.LocalAccount)
            {
                props[PROPERTY_USERNAME] = src.UserName;
                props[PROPERTY_PASSCODE] = src.Password;
            }

            return(new AnkhRepository(src.RepositoryUri, null, props));
        }
Example #4
0
        public void LoadLocalUserSettings(ConnectorSettings destination)
        {
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            string filePath = Path.Combine(localAccountFolder, localAccountSettingsFile);

            if (!File.Exists(filePath))
            {
                return;
            }

            string[] entries = File.ReadAllText(filePath).Split('&');

            foreach (string entry in entries)
            {
                var keyValue = entry.Split(new[] { '=' }, 2);
                if (keyValue.Length != 2)
                {
                    continue;
                }

                switch (keyValue[0])
                {
                case "user":
                    destination.UserName = keyValue[1];

                    break;

                case "pass":
                    destination.Password = keyValue[1];

                    break;
                }
            }
        }
        public static ConnectorSettings ToConnectorSettings(this IDictionary <string, Object> src, Uri repositoryUri)
        {
            var retVal = new ConnectorSettings();

            retVal.RepositoryUri = new Uri(repositoryUri.ToString());

            Object value = null;

            if (src.TryGetValue(PROPERTY_PROJECT, out value))
            {
                retVal.ProjectId = int.Parse(value.ToString());
            }

            if (src.TryGetValue(PROPERTY_LOCALACC, out value))
            {
                retVal.LocalAccount = bool.Parse(value.ToString());
            }

            if (!retVal.LocalAccount)
            {
                if (src.TryGetValue(PROPERTY_USERNAME, out value))
                {
                    retVal.UserName = value.ToString();
                }

                if (src.TryGetValue(PROPERTY_PASSCODE, out value))
                {
                    retVal.Password = value.ToString();
                }
            }

            if (src.TryGetValue(PROPERTY_PERPAGE, out value))
            {
                retVal.IssuesPerPage = int.Parse(value.ToString());
            }

            if (src.TryGetValue(PROPERTY_SOAPURI, out value))
            {
                retVal.WebServicePath = value.ToString();
            }

            if (src.TryGetValue(PROPERTY_FETCHINGMETHOD, out value))
            {
                retVal.FetchingMethod = (FetchingMethod)int.Parse(value.ToString());
            }

            if (src.TryGetValue(PROPERTY_ISSUEPATTERN, out value))
            {
                retVal.IssuePattern = value.ToString();
            }

            if (src.TryGetValue(PROPERTY_ADDNOTE, out value))
            {
                retVal.AddNoteAfterCommit = bool.Parse(value.ToString());
            }

            if (src.TryGetValue(PROPERTY_ASSOCIATEDNOTE, out value))
            {
                retVal.AssociatedCommitNoteText = value.ToString();
            }

            if (src.TryGetValue(PROPERTY_CLOSENOTE, out value))
            {
                retVal.CloseCommitNoteText = value.ToString();
            }

            return(retVal);
        }