private BlobCommand GetDataBlob(Item item)
        {
            var bytes = new byte[item.ContentLength];
            BlobCommand blob = null;
            try
            {
                var str = item.DownloadFile();
                str.Read(bytes, 0, bytes.Length);
                str.Close();

                var id = _MarkID++;
                blob = BlobCommand.BuildBlob(bytes, id);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine();
                Console.Error.WriteLine("Warning: Unable to fetch file '{0}'{1}{2}", item.ServerItem, Environment.NewLine, ex);
                Console.Error.WriteLine();
            }
            return blob;
        }
Beispiel #2
0
 private Stream GetStreamFromItem(Item item)
 {
     var stream = item.DownloadFile();
     if (!item.ServerItem.EndsWith(".refresh"))
         return stream;
     string path = new StreamReader(stream).ReadToEnd().TrimEnd('\r', '\n');
     return new FileStream(path, FileMode.Open);
 }
        private byte[] Download(Item item1)
        {
            using (var stream = item1.DownloadFile())
            {
                using (var memStream = new MemoryStream())
                {
                    stream.CopyTo(memStream);

                    return memStream.ToArray();
                }
            }
        }
        public void ViewFile(Item theItem)
        {
            if (theItem != null && string.IsNullOrEmpty(theItem.ServerItem))
                return;

            var filename = Path.Combine(Path.GetTempPath(), Path.GetFileName(theItem.ServerItem));

            try
            {
                theItem.DownloadFile(filename);

                Process.Start(filename);
            }
            finally
            {
                File.Delete(filename);
            }
        }
        private static List<string> SearchInFileContent(Item file)
        {
            // results contains the file path and all ocurrences
            List<string> results = new List<string>();
            // ocurrences contains the lines where
            List<string> occurrences = new List<string>();

            StreamReader streamReader = new StreamReader(file.DownloadFile(), Encoding.Default);

            string line = streamReader.ReadLine();
            int lineIndex = 0;

            while (!streamReader.EndOfStream)
            {
                if (searchPatterns.Any(item => line.IndexOf(item, StringComparison.OrdinalIgnoreCase) > 0))
                {
                    occurrences.Add(string.Format("Line {0}: {1}", lineIndex, line.Trim()));
                }

                line = streamReader.ReadLine();
                lineIndex++;
            }

            if (occurrences.Count > 0)
            {
                results.Add(file.ServerItem);
                results.AddRange(occurrences.Select(item => string.Format("\t{0}", item)).ToList());
            }

            return results;
        }
		private BlobCommand GetDataBlob(Item item)
		{
			var bytes = new byte[item.ContentLength];
			var str = item.DownloadFile();
			str.Read(bytes, 0, bytes.Length);
			str.Close();

			var id = _MarkID++;
			var blob = BlobCommand.BuildBlob(bytes, id);
			return blob;
		}
Beispiel #7
0
 private static string GetTfsFile(Item file)
 {
     string result;
     if (_downloadedItems.TryGetValue(file.ItemId, out result))
     {
         return result;
     }
     else
     {
         result = System.IO.Path.GetTempFileName();
         file.DownloadFile(result);
         return result;
     }
 }
        private IEnumerable<PackageDependency> GetPackageDependenciesFromRepositoriesConfig(TeamProject teamProject, Item repository)
        {
            List<PackageDependency> repositoryDependencies = new List<PackageDependency>();

            Stream repoFileStream = repository.DownloadFile();
            XDocument repoXml = XDocument.Load(repoFileStream);
            IEnumerable<string> relativePackageConfigPaths = configInterpreter.GetRelativePackagesConfigPathsFromRepositoriesConfig(repoXml);
            string repositoriesConfigServerPath = repository.ServerItem;
            int repositoriesConfigLength = repositoriesConfigFileName.Length;
            string packageConfigFolderServerPath = repositoriesConfigServerPath.Remove(repositoriesConfigServerPath.Length - repositoriesConfigLength, repositoriesConfigLength);

            foreach (string packageConfigPathRelativeToRepositoriesConfig in relativePackageConfigPaths)
            {
                // navigate to the folder server path for the repositories.config file
                string repositoryNodeServerItem = tfsServerPathTranslator.GetServerPath(packageConfigFolderServerPath, packageConfigPathRelativeToRepositoriesConfig);
                Item packageConfig = teamProject.VersionControlServer.GetItem(repositoryNodeServerItem);
                if (packageConfig != null)
                {
                    Stream packagesConfigStream = packageConfig.DownloadFile();
                    XDocument packagesConfigXml = XDocument.Load(packagesConfigStream);
                    IEnumerable<PackageDependency> packageDependencies = configInterpreter.GetPackageDependenciesFromPackagesConfig(packagesConfigXml);
                    foreach (PackageDependency packageDependency in packageDependencies)
                    {
                        if (repositoryDependencies.Where(dp => dp.Id == packageDependency.Id && dp.VersionSpec == packageDependency.VersionSpec).FirstOrDefault() == null)
                            repositoryDependencies.Add(packageDependency);
                    }
                }
            }
            
            return repositoryDependencies;
        }