/// <summary>
        /// You need to put this activity in a different agent that write the diagnostics log that you want to change.
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            Thread.Sleep(30000);

            var findAndReplace = context.GetValue(FindAndReplaceStrings);
            _teamProjectUri = context.GetValue(TeamProjectUri);
            _buildUri = context.GetValue(BuildUri);

            var vssCredential = new VssCredentials(true);
            _fcClient = new FileContainerHttpClient(_teamProjectUri, vssCredential);
            var containers = _fcClient.QueryContainersAsync(new List<Uri>() { _buildUri }).Result;

            if (!containers.Any())
                return;

            var agentLogs = GetAgentLogs(containers);

            if (agentLogs == null)
                return;

            using (var handler = new HttpClientHandler() { UseDefaultCredentials = true })
            {
                var reader = DownloadAgentLog(agentLogs, handler);

                using (var ms = new MemoryStream())
                {
                    ReplaceStrings(findAndReplace, reader, ms);
                    var response = UploadDocument(containers, agentLogs, ms);
                }
            }
        }
Example #2
0
        public async Task <Stream> GetFileTask(ContainerItem ticketedItem, CancellationToken cancellationToken)
        {
            ArgUtil.NotNull(ticketedItem, nameof(ticketedItem));

            this._executionContext.Debug(StringUtil.Format("Get file container client for file {0}", ticketedItem.Path));

            VssConnection vssConnection = await GetVssConnection();

            FileContainerHttpClient fileContainer = null;

            try
            {
                fileContainer = vssConnection.GetClient <FileContainerHttpClient>();
            }
            catch (SocketException e)
            {
                ExceptionsUtil.HandleSocketException(e, vssConnection.Uri.ToString(), this._executionContext.Error);
                throw;
            }

            this._executionContext.Debug(StringUtil.Format("Start fetch file stream from filecontainer service for file {0}", ticketedItem.Path));

            Stream stream = await fileContainer.DownloadFileAsync(
                ticketedItem.ContainerId,
                ticketedItem.Path,
                cancellationToken,
                scopeIdentifier : ticketedItem.ScopeIdentifier);

            this._executionContext.Debug(StringUtil.Format("Finished fetch file stream from filecontainer service for file {0}", ticketedItem.Path));

            return(stream);
        }
        public FileContainerServer(
            VssConnection connection,
            Guid projectId,
            long containerId,
            string containerPath)
        {
            ArgUtil.NotNull(connection, nameof(connection));
            this._connection = connection;

            _projectId     = projectId;
            _containerId   = containerId;
            _containerPath = containerPath;

            // default file upload request timeout to 600 seconds
            var fileContainerClientConnectionSetting = connection.Settings.Clone();

            if (fileContainerClientConnectionSetting.SendTimeout < TimeSpan.FromSeconds(600))
            {
                fileContainerClientConnectionSetting.SendTimeout = TimeSpan.FromSeconds(600);
            }

            var fileContainerClientConnection = new VssConnection(connection.Uri, connection.Credentials, fileContainerClientConnectionSetting);

            _fileContainerHttpClient = fileContainerClientConnection.GetClient <FileContainerHttpClient>();
        }
Example #4
0
 protected StorageTreeNode(FileContainerHttpClient service, string fullPath, string icon, bool isLazy)
 {
     this.Service  = service;
     this.FullPath = fullPath;
     this.Icon     = icon;
     this.Name     = GetName(this.FullPath);
     this.children = new ObservableCollection <StorageTreeNode>();
     this.children.CollectionChanged += (sender, e) =>
     {
         this.NonFileChildrenLazy.Clear();
         foreach (var child in this.Children.Where(c => !(c is FileTreeNode)))
         {
             this.NonFileChildrenLazy.Add(child);
         }
     };
     this.NonFileChildrenLazy = new ObservableCollection <StorageTreeNode>();
     if (isLazy)
     {
         this.isLoadNeeded = true;
         this.NonFileChildrenLazy.Add(new PlaceholderTreeNode(service));
     }
     else
     {
         this.isLoadNeeded = false;
     }
 }
        public FileContainerProvider(VssConnection connection, IAppTraceSource tracer)
        {
            BuildHttpClient buildHttpClient = connection.GetClient <BuildHttpClient>();

            connection      = new VssConnection(buildHttpClient.BaseAddress, connection.Credentials);
            containerClient = connection.GetClient <FileContainerHttpClient>();
            this.tracer     = tracer;
        }
Example #6
0
 public ContainerItemTreeNode(FileContainerHttpClient service, FileContainerItem item, string icon)
     : base(service, item.Path, icon, false)
 {
     this.Item             = item;
     this.DateCreated      = item.DateCreated;
     this.DateLastModified = item.DateLastModified;
     this.Size             = item.FileLength;
 }
Example #7
0
 public ContainerTreeNode(FileContainerHttpClient service, FileContainer container)
     : base(service, container.Name, "Resources/Container.ico", true)
 {
     this.Container        = container;
     this.Description      = container.Description;
     this.DateCreated      = container.DateCreated;
     this.DateLastModified = this.DateCreated;
     this.Size             = container.Size;
 }
Example #8
0
        public FileContainerClientHelper(IClientFactory clientFactory)
        {
            var connection = clientFactory.VssConnection;

            // default file upload request timeout to 600 seconds
            var fileContainerClientConnectionSetting = connection.Settings.Clone();

            if (fileContainerClientConnectionSetting.SendTimeout < TimeSpan.FromSeconds(600))
            {
                fileContainerClientConnectionSetting.SendTimeout = TimeSpan.FromSeconds(600);
            }

            _client = clientFactory.GetClient <FileContainerHttpClient>(fileContainerClientConnectionSetting);

            _client.UploadFileReportProgress += InvokeClientUploadFileReportProgress;
            _client.UploadFileReportTrace    += InvokeClientUploadFileReportTrace;
        }
        public FileContainerServer(
            Uri projectCollectionUrl,
            VssCredentials credential,
            Guid projectId,
            long containerId,
            string containerPath)
        {
            _projectCollectionUrl = projectCollectionUrl;
            _credential = credential;
            _projectId = projectId;
            _containerId = containerId;
            _containerPath = containerPath;

            // default file upload request timeout to 300 seconds
            // TODO: Load from .ini file.
            VssHttpRequestSettings fileUploadRequestSettings = new VssHttpRequestSettings();
            fileUploadRequestSettings.SendTimeout = TimeSpan.FromSeconds(300);
            FileContainerHttpClient = new FileContainerHttpClient(
                _projectCollectionUrl,
                _credential,
                fileUploadRequestSettings,
                new VssHttpRetryMessageHandler(3));
        }
        private async void RefreshContainers(object argument)
        {
            try
            {
                this.StatusText = "Loading...";
                var serverUri = new Uri(this.TeamProjectCollectionUrl);
                this.service = new FileContainerHttpClient(serverUri, new VssClientCredentials());
                var containers = await this.service.QueryContainersAsync(null, Guid.Empty);

                this.Nodes.Clear();
                foreach (var container in containers.OrderBy(c => c.Name))
                {
                    if (!IgnoreBuildLogs || !container.ArtifactUri.ToString().StartsWith("vstfs:///Build/Build/", StringComparison.OrdinalIgnoreCase))
                    {
                        this.Nodes.Add(new ContainerTreeNode(this.service, container));
                    }
                }
                this.StatusText = string.Format(CultureInfo.CurrentCulture, "Loaded {0} container(s) from \"{1}\"", this.Nodes.Count, serverUri.ToString());
            }
            catch (Exception exc)
            {
                HandleException(exc);
            }
        }
Example #11
0
        public FileContainerServer(
            Uri projectCollectionUrl,
            VssCredentials credential,
            Guid projectId,
            long containerId,
            string containerPath)
        {
            _projectCollectionUrl = projectCollectionUrl;
            _credential           = credential;
            _projectId            = projectId;
            _containerId          = containerId;
            _containerPath        = containerPath;

            // default file upload request timeout to 300 seconds
            // TODO: Load from .ini file.
            VssHttpRequestSettings fileUploadRequestSettings = new VssHttpRequestSettings();

            fileUploadRequestSettings.SendTimeout = TimeSpan.FromSeconds(300);
            FileContainerHttpClient = new FileContainerHttpClient(
                _projectCollectionUrl,
                _credential,
                fileUploadRequestSettings,
                new VssHttpRetryMessageHandler(3));
        }
 public FileContainerProvider(VssConnection connection, IAppTraceSource tracer)
 {
     containerClient = connection.GetClient <FileContainerHttpClient>();
     this.tracer     = tracer;
 }
 public FolderTreeNode(FileContainerHttpClient service, FileContainerItem item)
     : base(service, item, "Resources/Folder.ico")
 {
 }
 public FileTreeNode(FileContainerHttpClient service, FileContainerItem item)
     : base(service, item, "Resources/File.png")
 {
 }
Example #15
0
 public PlaceholderTreeNode(FileContainerHttpClient service)
     : base(service, "(Loading...)", null, false)
 {
 }