Exemplo n.º 1
0
        public IProfileSettings GetDefaultProfile(Uri teamProjectUri = null)
        {
            SimpleLogger.Log(SimpleLogLevel.Info, "ProfileProvider.GetDefaultProfile");
            if (Repository.Instance.TfsBridgeProvider.ActiveTeamProject == null)
            {
                return(null);
            }

            if (teamProjectUri == null)
            {
                teamProjectUri = Repository.Instance.TfsBridgeProvider.ActiveTeamProject.ArtifactUri;
            }

            SerializableDictionary <string, ProfileSettings> result = null;

            if (Profiles.TryGetValue(teamProjectUri.ToString(), out result) == false)
            {
                result = new SerializableDictionary <string, ProfileSettings>();
                Profiles.Set(teamProjectUri.ToString(), result);
            }
            ProfileSettings settings = null;

            if (result.TryGetValue("__Default", out settings) == false)
            {
                var teamProjectName = GetTeamProjectName(teamProjectUri);
                settings            = new ProfileSettings(teamProjectUri.ToString(), teamProjectName, "__Default", SetProfileDirty);
                result["__Default"] = settings;
            }
            return(settings);
        }
Exemplo n.º 2
0
        public IProfileSettings GetDefaultProfile(Uri teamProjectUri = null)
        {
            if (Repository.Instance.TfsBridgeProvider.ActiveTeamProject == null)
            {
                return(null);
            }

            if (teamProjectUri == null)
            {
                teamProjectUri = Repository.Instance.TfsBridgeProvider.ActiveTeamProject.ArtifactUri;
            }

            SerializableDictionary <string, ProfileSettings> result = null;

            if (Profiles.TryGetValue(teamProjectUri.ToString(), out result) == false)
            {
                result = new SerializableDictionary <string, ProfileSettings>();
                Profiles[teamProjectUri.ToString()] = result;
            }
            ProfileSettings settings = null;

            if (result.TryGetValue("__Default", out settings) == false)
            {
                var teamProject = Repository.Instance.TfsBridgeProvider.VersionControlServer.GetAllTeamProjects(false).Where(tp => tp.ArtifactUri.Equals(teamProjectUri)).FirstOrDefault();
                settings            = new ProfileSettings(teamProjectUri.ToString(), teamProject.Name, "__Default", SetProfileDirty);
                result["__Default"] = settings;
            }
            return(settings);
        }
Exemplo n.º 3
0
        public bool SaveProfileAs(Uri teamProjectUri, string profileName, bool overwrite)
        {
            SimpleLogger.Log(SimpleLogLevel.Info, "Save Profile: " + profileName);
            if (teamProjectUri == null)
            {
                teamProjectUri = Repository.Instance.TfsBridgeProvider.ActiveTeamProject.ArtifactUri;
            }

            SerializableDictionary <string, ProfileSettings> result = null;

            if (Profiles.TryGetValue(teamProjectUri.ToString(), out result) == false)
            {
                SimpleLogger.Log(SimpleLogLevel.Info, "Create new Profile SerializableDictionary");
                result = new SerializableDictionary <string, ProfileSettings>();
                Profiles.Set(teamProjectUri.ToString(), result);
            }

            if (result.ContainsKey(profileName) && !overwrite)
            {
                return(false);
            }

            var teamProjectName = GetTeamProjectName(teamProjectUri);//Repository.Instance.TfsBridgeProvider.VersionControlServer.GetAllTeamProjects(false).Where(tp => tp.ArtifactUri.Equals(teamProjectUri)).FirstOrDefault();
            var settings        = new ProfileSettings(teamProjectUri.ToString(), teamProjectName, profileName, SetProfileDirty);

            var defaultProfile = GetDefaultProfile(teamProjectUri);

            if (defaultProfile != null)
            {
                (defaultProfile as ProfileSettings).CopyTo(settings);
            }
            result[profileName] = settings;

            if (ActiveProjectProfileListChanged != null &&
                !teamProjectUri.ToString().Equals("http://www.haufe.de/") &&
                teamProjectUri == Repository.Instance.TfsBridgeProvider.ActiveTeamProject.ArtifactUri)
            {
                ActiveProjectProfileListChanged(this, EventArgs.Empty);
            }
            if (ProfilesChanged != null)
            {
                ProfilesChanged(this, EventArgs.Empty);
            }
            _activeProfile = result[profileName];
            SimpleLogger.Log(SimpleLogLevel.Info, "Save Profile finished: " + profileName);
            return(true);
        }
Exemplo n.º 4
0
        public bool SaveProfileAs(Uri teamProjectUri, string profileName, bool overwrite)
        {
            if (teamProjectUri == null)
            {
                teamProjectUri = Repository.Instance.TfsBridgeProvider.ActiveTeamProject.ArtifactUri;
            }

            SerializableDictionary <string, ProfileSettings> result = null;

            if (Profiles.TryGetValue(teamProjectUri.ToString(), out result) == false)
            {
                result = new SerializableDictionary <string, ProfileSettings>();
                Profiles[teamProjectUri.ToString()] = result;
            }

            if (result.ContainsKey(profileName) && !overwrite)
            {
                return(false);
            }

            var teamProject = Repository.Instance.TfsBridgeProvider.VersionControlServer.GetAllTeamProjects(false).Where(tp => tp.ArtifactUri.Equals(teamProjectUri)).FirstOrDefault();
            var settings    = new ProfileSettings(teamProjectUri.ToString(), teamProject.Name, profileName, SetProfileDirty);

            (GetDefaultProfile(teamProjectUri) as ProfileSettings).CopyTo(settings);
            result[profileName] = settings;

            if (ActiveProjectProfileListChanged != null && teamProjectUri == Repository.Instance.TfsBridgeProvider.ActiveTeamProject.ArtifactUri)
            {
                ActiveProjectProfileListChanged(this, EventArgs.Empty);
            }
            if (ProfilesChanged != null)
            {
                ProfilesChanged(this, EventArgs.Empty);
            }
            _activeProfile = result[profileName];
            return(true);
        }