Пример #1
0
        /// <summary>
        /// Downloads a chuck of the update based on the offset.
        /// </summary>
        /// <param name="request">The request to download the chuck for..</param>
        /// <returns>A chuck of the update starting from the update.</returns>
        public byte[] DownloadUpdateChunk(WindowsServiceUpdateRequest request)
        {
            if (!Directory.Exists(_appDataDirectory))
            {
                throw new Exception("Could not find the directory update.");
            }

            var filePath = _appDataDirectory + "\\" + request.Name;
            var fileInfo = new FileInfo(filePath);
            return !fileInfo.Exists ? new byte[0] : FileChunk(fileInfo, request.Offset);
        }
Пример #2
0
        /// <summary>
        /// Downloads a chuck of the update based on the offset.
        /// </summary>
        /// <param name="request">The request to download the chuck for..</param>
        /// <returns>A chuck of the update starting from the update.</returns>
        public byte[] DownloadUpdateChunk(WindowsServiceUpdateRequest request)
        {
            if (!Directory.Exists(_appDataDirectory))
            {
                throw new Exception("Could not find the directory update.");
            }

            var filePath = _appDataDirectory + "\\" + request.Name;
            var fileInfo = new FileInfo(filePath);

            return(!fileInfo.Exists ? new byte[0] : FileChunk(fileInfo, request.Offset));
        }
Пример #3
0
		private byte[] DownloadUpdate(WindowsServiceUpdate update)
		{
			// Get the file from the deployment service.
			var data = new byte[update.Size];
			var request = new WindowsServiceUpdateRequest { Name = update.Name, Offset = 0 };

			// Read the whole file.
			while (request.Offset < data.Length)
			{
				var chunk = _client.DownloadUpdateChunk(request);
				Array.Copy(chunk, 0, data, request.Offset, chunk.Length);
				request.Offset += chunk.Length;
			}

			// Return the data read.
			return data;
		}
Пример #4
0
        /// <summary>
        /// Downloads a chuck of the update based on the offset.
        /// </summary>
        /// <param name="request">The request to download the chuck for..</param>
        /// <returns>A chuck of the update starting from the update.</returns>
        public byte[] DownloadUpdateChunk(WindowsServiceUpdateRequest request)
        {
            if (_credentials != null)
            {
                Login(_credentials);
            }

            using (var response = _client.Post("DownloadUpdateChunk", request))
            {
                CheckResponse(response);

                using (var content = response.Content)
                {
                    return JsonConvert.DeserializeObject<byte[]>(content.ReadAsStringAsync().Result);
                }
            }
        }
Пример #5
0
        private byte[] DownloadUpdate(WindowsServiceUpdate update)
        {
            // Get the file from the deployment service.
            var data = new byte[update.Size];
            var request = new WindowsServiceUpdateRequest { Name = update.Name, Offset = 0 };

            // Read the whole file.
            while (request.Offset < data.Length)
            {
                var chunk = _client.DownloadUpdateChunk(request);
                Array.Copy(chunk, 0, data, request.Offset, chunk.Length);
                request.Offset += chunk.Length;
            }

            // Return the data read.
            return data;
        }