Esempio n. 1
0
        internal InternalServerInfo[] ReadCachedWorkspaceInfo()
        {
            string dataDirectory  = TeamFoundationServer.ClientCacheDirectory;
            string configFilePath = Path.Combine(dataDirectory, ConfigFile);

            List <InternalServerInfo> servers = new List <InternalServerInfo>();

            if (!File.Exists(configFilePath))
            {
                return(servers.ToArray());
            }

            using (XmlTextReader reader = new XmlTextReader(configFilePath))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "ServerInfo")
                    {
                        servers.Add(InternalServerInfo.FromXml(reader));
                    }
                }
            }

            return(servers.ToArray());
        }
Esempio n. 2
0
        internal static WorkspaceInfo FromXml(InternalServerInfo server, XmlReader reader)
        {
            string        elementName = reader.Name;
            WorkspaceInfo info        = new WorkspaceInfo(server);

            info.name      = reader.GetAttribute("name");
            info.ownerName = reader.GetAttribute("ownerName");
            info.computer  = reader.GetAttribute("computer");
            info.comment   = reader.GetAttribute("comment");

            List <string> mappedPaths = new List <string>();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
                {
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element && reader.Name == "MappedPath")
                {
                    mappedPaths.Add(reader.GetAttribute("path"));
                }
            }

            info.mappedPaths = mappedPaths.ToArray();
            return(info);
        }
Esempio n. 3
0
        public void UpdateWorkspaceInfoCache(VersionControlServer versionControl,
                                             string ownerName)
        {
            InternalServerInfo[] serverInfos = ReadCachedWorkspaceInfo();
            XmlElement           servers     = InitWorkspaceInfoCache();

            Workspace[]        workspaces    = versionControl.QueryWorkspaces(null, ownerName, Name);
            InternalServerInfo newServerInfo = new InternalServerInfo(versionControl.Uri.ToString(), versionControl.ServerGuid, workspaces);

            bool found = false;

            foreach (InternalServerInfo sInfo in serverInfos)
            {
                InternalServerInfo finalInfo = sInfo;
                if (sInfo.Uri == versionControl.Uri)
                {
                    finalInfo = newServerInfo;
                    found     = true;
                }

                XmlElement serverInfoElement = finalInfo.ToXml(servers.OwnerDocument);
                servers.AppendChild(serverInfoElement);
            }

            if (!found)
            {
                XmlElement serverInfoElement = newServerInfo.ToXml(servers.OwnerDocument);
                servers.AppendChild(serverInfoElement);
            }

            SaveWorkspaceInfoCache(servers.OwnerDocument);
        }
Esempio n. 4
0
        internal WorkspaceInfo(InternalServerInfo server, Workspace workspace)
        {
            this.server = server;
            comment = workspace.Comment;
            computer = workspace.Computer;
            name = workspace.Name;
            ownerName = workspace.OwnerName;

            List<string> paths = new List<string>();
            foreach (WorkingFolder folder in workspace.Folders)
                {
                    paths.Add(folder.LocalItem);
                }

            mappedPaths = paths.ToArray();
        }
Esempio n. 5
0
        internal WorkspaceInfo(InternalServerInfo server, Workspace workspace)
        {
            this.server = server;
            comment     = workspace.Comment;
            computer    = workspace.Computer;
            name        = workspace.Name;
            ownerName   = workspace.OwnerName;

            List <string> paths = new List <string>();

            foreach (WorkingFolder folder in workspace.Folders)
            {
                paths.Add(folder.LocalItem);
            }

            mappedPaths = paths.ToArray();
        }
Esempio n. 6
0
        internal void AddCachedWorkspaceInfo(Guid serverGuid,
                                             Uri serverUri, Workspace workspace)
        {
            InternalServerInfo[] serverInfos = ReadCachedWorkspaceInfo();
            XmlElement           servers     = InitWorkspaceInfoCache();

            bool added = false;

            foreach (InternalServerInfo sInfo in serverInfos)
            {
                if (sInfo.Uri == serverUri)
                {
                    List <WorkspaceInfo> workspaces = new List <WorkspaceInfo>();
                    foreach (WorkspaceInfo info in sInfo.Workspaces)
                    {
                        workspaces.Add(info);
                    }

                    added = true;
                    workspaces.Add(new WorkspaceInfo(sInfo, workspace));
                    sInfo.Workspaces = workspaces.ToArray();
                }

                if (sInfo.Workspaces.Length == 0)
                {
                    continue;
                }

                XmlElement serverInfoElement = sInfo.ToXml(servers.OwnerDocument);
                servers.AppendChild(serverInfoElement);
            }

            if (!added)
            {
                InternalServerInfo sInfo             = new InternalServerInfo(serverUri.ToString(), serverGuid, workspace);
                XmlElement         serverInfoElement = sInfo.ToXml(servers.OwnerDocument);
                servers.AppendChild(serverInfoElement);
            }

            SaveWorkspaceInfoCache(servers.OwnerDocument);
        }
Esempio n. 7
0
        public static InternalServerInfo FromXml(XmlReader reader)
        {
            string             elementName = reader.Name;
            InternalServerInfo info        = new InternalServerInfo();

            info.uri = new Uri(reader.GetAttribute("uri"));
            List <WorkspaceInfo> workspaces = new List <WorkspaceInfo>();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
                {
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element && reader.Name == "WorkspaceInfo")
                {
                    workspaces.Add(WorkspaceInfo.FromXml(info, reader));
                }
            }

            info.Workspaces = workspaces.ToArray();
            return(info);
        }
Esempio n. 8
0
 internal WorkspaceInfo(InternalServerInfo server)
 {
     this.server = server;
 }
Esempio n. 9
0
        internal static WorkspaceInfo FromXml(InternalServerInfo server, XmlReader reader)
        {
            string elementName = reader.Name;
            WorkspaceInfo info = new WorkspaceInfo(server);

            info.name = reader.GetAttribute("name");
            info.ownerName = reader.GetAttribute("ownerName");
            info.computer = reader.GetAttribute("computer");
            info.comment = reader.GetAttribute("comment");

             			List<string> mappedPaths = new List<string>();
            while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
                        break;

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "MappedPath")
                        mappedPaths.Add(reader.GetAttribute("path"));
                }

            info.mappedPaths = mappedPaths.ToArray();
            return info;
        }
Esempio n. 10
0
        public static InternalServerInfo FromXml(XmlReader reader)
        {
            string elementName = reader.Name;
            InternalServerInfo info = new InternalServerInfo();

            info.uri = new Uri(reader.GetAttribute("uri"));
             			List<WorkspaceInfo> workspaces = new List<WorkspaceInfo>();

            while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
                        break;

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "WorkspaceInfo")
                        workspaces.Add(WorkspaceInfo.FromXml(info, reader));
                }

            info.Workspaces = workspaces.ToArray();
            return info;
        }
Esempio n. 11
0
 internal WorkspaceInfo(InternalServerInfo server)
 {
     this.server = server;
 }
Esempio n. 12
0
        internal void AddCachedWorkspaceInfo(Guid serverGuid,
																				 Uri serverUri, Workspace workspace)
        {
            InternalServerInfo[] serverInfos = ReadCachedWorkspaceInfo();
            XmlElement servers = InitWorkspaceInfoCache();

            bool added = false;
            foreach (InternalServerInfo sInfo in serverInfos)
                {
                    if (sInfo.Uri == serverUri)
                        {
                            List<WorkspaceInfo> workspaces = new List<WorkspaceInfo>();
                            foreach (WorkspaceInfo info in sInfo.Workspaces)
                                {
                                    workspaces.Add(info);
                                }

                            added = true;
                            workspaces.Add(new WorkspaceInfo(sInfo, workspace));
                            sInfo.Workspaces = workspaces.ToArray();
                        }

                    if (sInfo.Workspaces.Length == 0) continue;

                    XmlElement serverInfoElement = sInfo.ToXml(servers.OwnerDocument);
                    servers.AppendChild(serverInfoElement);
                }

            if (!added)
                {
                    InternalServerInfo sInfo = new InternalServerInfo(serverUri.ToString(), serverGuid, workspace);
                    XmlElement serverInfoElement = sInfo.ToXml(servers.OwnerDocument);
                    servers.AppendChild(serverInfoElement);
                }

            SaveWorkspaceInfoCache(servers.OwnerDocument);
        }
Esempio n. 13
0
        public void UpdateWorkspaceInfoCache(VersionControlServer versionControl,
																				 string ownerName)
        {
            InternalServerInfo[] serverInfos = ReadCachedWorkspaceInfo();
            XmlElement servers = InitWorkspaceInfoCache();

            Workspace[] workspaces = versionControl.QueryWorkspaces(null, ownerName, Name);
            InternalServerInfo newServerInfo = new InternalServerInfo(versionControl.Uri.ToString(), versionControl.ServerGuid, workspaces);

            bool found = false;
            foreach (InternalServerInfo sInfo in serverInfos)
                {
                    InternalServerInfo finalInfo = sInfo;
                    if (sInfo.Uri == versionControl.Uri)
                        {
                            finalInfo = newServerInfo;
                            found = true;
                        }

                    XmlElement serverInfoElement = finalInfo.ToXml(servers.OwnerDocument);
                    servers.AppendChild(serverInfoElement);
                }

            if (!found)
                {
                    XmlElement serverInfoElement = newServerInfo.ToXml(servers.OwnerDocument);
                    servers.AppendChild(serverInfoElement);
                }

            SaveWorkspaceInfoCache(servers.OwnerDocument);
        }