private MemoryStream GetStream(string method, FileOutVm vm) { string url = String.Format("{0}/{1}?appGuid={2}", _host, method, vm.AppGuid); using (WebClient webClient = new WebClient()) { webClient.Headers.Add("Authorization", _securityProvider.GetToken()); byte[] response = webClient.DownloadData(url); return(new MemoryStream(response)); } }
private PackageInfo TryGetPackage(Guid appGuid, int count = 0) { var fileOutVm = new FileOutVm { AppGuid = appGuid, }; var result = Execute <FileInVm>(GetFileInfoMethod, fileOutVm); var resultStream = GetStream(GetFileMethod, fileOutVm); if (GetHash(resultStream) == result.Hash) { resultStream.Position = 0; return(new PackageInfo(result.AppName, resultStream)); } if (count < RetryCount) { Thread.Sleep(RetrySleepTime); return(TryGetPackage(appGuid, ++count)); } return(null); }