Beispiel #1
0
        private TfsPluginProfile Parse(PluginProfile legacyProfile, XmlDocument document)
        {
            var result = new TfsPluginProfile();
            var root   = document.SelectSingleNode("./Settings");

            string server      = GetValueByName(root, "ServerName").TrimEnd('/');
            string projectName = GetValueByName(root, "TeamProjectName");

            result.Uri = string.Concat(server, "/", projectName);

            var syncIntervalValue = GetValueByName(root, "SyncInterval");

            if (!string.IsNullOrEmpty(syncIntervalValue))
            {
                result.SynchronizationInterval = Int32.Parse(syncIntervalValue);
            }

            result.Login    = GetValueByName(root, "Login");
            result.Password = GetValueByName(root, "Password");

            result.StartRevision = GetStartRevision(legacyProfile, root);

            var userMapping = GetValueByName(root, "Maps");
            var parser      = new LegacyMappingParser();

            if (!string.IsNullOrEmpty(userMapping))
            {
                parser.Maps = userMapping;
            }
            foreach (string tfsUser in parser.Users.Keys)
            {
                var tpUser = GetUserBy(parser.Users[tfsUser], x => x.Login);
                if (tpUser != null)
                {
                    result.UserMapping.Add(new MappingElement {
                        Key = tfsUser, Value = Create(tpUser)
                    });
                    continue;
                }

                tpUser = GetUserBy(parser.Users[tfsUser], x => x.Email);
                if (tpUser != null)
                {
                    result.UserMapping.Add(new MappingElement {
                        Key = tfsUser, Value = Create(tpUser)
                    });
                }
            }

            return(result);
        }
		public void UpdateUserMapping(string tfs, string targetprocess)
		{
			var maps = GetLegacyProfileValue("Maps");
			var settings = new LegacyMappingParser();
			if (!string.IsNullOrEmpty(maps))
			{
				settings.Maps = maps.TrimEnd(Environment.NewLine.ToArray());
			}

			settings.Users[tfs] = targetprocess;

			SetLegacyProfileValue("Maps", settings.Maps);
		}