/// <summary> /// データのダウンロード完了後イベントハンドラ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClientDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { try { byte[] bytes = e.Result; Stream stream = new MemoryStream(bytes); var image = new Avalonia.Media.Imaging.Bitmap(stream); var bitmapProperty = (ReactivePropertySlim <Avalonia.Media.Imaging.Bitmap>?)e.UserState; bitmapProperty !.Value = image; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
static void HandleDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { List<string> scoreList = new List<string>(); string jsonString = ""; byte[] data = e.Result; int dataCount = data.Length; for(int byteIndex = 0; byteIndex < dataCount; byteIndex++) { jsonString += (char)data[byteIndex]; } var scores = JSON.Parse(jsonString); for (int index = 0; index < scores.Count; index++) { string scoreText = scores[index]["name"].Value + ":" + scores[index]["score"].AsInt; scoreList.Add(scoreText); } highScores = scoreList; }
private void IPSClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { try { clock.CancelAsync(); this.downloadingLabel.Visible = false; this.applyButton.Text = "APPLY PATCH"; if (!downloadingIPS) { return; } downloadingIPS = false; IPSPatch ips = new IPSPatch(e.Result); if (ips.Verified) { DialogResult result = MessageBox.Show( "Apply this patch to the currently open ROM image?\n\n" + "Note: This will modify the current rom image, and cannot be undone. " + "You may want to save the patched ROM image to disk once done.", "LAZY SHELL", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (ips.ApplyTo(Model.ROM)) { // Needed to reset state for new rom image Model.ClearModel(); State.Instance.PrivateKey = null; // Clear the PrivateKey whenever we load a new rom State.Instance2.PrivateKey = null; // Clear the PrivateKey whenever we load a new rom MessageBox.Show("Patch Applied Succesfully", "LAZY SHELL"); } else { throw new Exception(); } } } else { throw new Exception(); } } catch { MessageBox.Show("There was an error downloading or applying the IPS patch. Please try to download and apply it manually with LunarIPS.", "LAZY SHELL"); return; } }
protected void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { DownloadBundle bundle = e.UserState as DownloadBundle; try { if (!e.Cancelled && e.Error == null) { bundle.bytes = (byte[])e.Result; bundle.success = true; } } finally { bundle.waiter.Set(); } }
private void Request_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e, string fileName) { if (e.Error != null) { WriteToOutput(e.Error.Message); return; } var newFileData = e.Result; using (var fs = new FileStream($@"{SavingPath}\{fileName}", FileMode.Create, FileAccess.Write)) { fs.Write(newFileData, 0, newFileData.Length); } WriteToOutput("Download done."); }
void DownloadCompleted(object sender, DownloadDataCompletedEventArgs e) { var temp = Authentication.Login( Settings.Username, Settings.Password, Settings.HWID); dynamic Results = JsonConvert.DeserializeObject(temp); temp = Results.DecryptionKey.ToString(); Thread InjectionThread = new Thread(() => InjectionHelper.Inject(e.Result, temp)); InjectionThread.Start(); this.Hide(); }
private void DA_MyDownloadCompleted(DownloaderAsync sender, DownloadDataCompletedEventArgs e) { logBuilder.Append("[PROGRESS] Done"); logBuilder.Append(sender.url.ToString() + ":" + Environment.NewLine); logBuilder.Append("[BYTES SIZE] " + sender.totalBytesToReceive.ToString() + Environment.NewLine); logBuilder.Append("[TIME NEEDED] (ms): " + sender.timeNeeded.TotalMilliseconds + Environment.NewLine + Environment.NewLine); try { Directory.CreateDirectory(outputPath); File.Create(Path.Combine(outputPath, filename)).Close(); File.WriteAllBytes(Path.Combine(outputPath, filename), sender.data); } catch (Exception ex) { logBuilder.Append(ex.ToString() + Environment.NewLine + Environment.NewLine); } }
/// <summary> /// Handle finished download, move file from temporary to target location /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Finished(object sender, DownloadDataCompletedEventArgs e) { Logger.Log(LogLevel.Info, "FileDownloadProgressBar", "Download finished!", _url); // Move to the correct location if (File.Exists(_targetlocation)) { File.Delete(_targetlocation); } File.Move(_tmplocation, _targetlocation); DownloadDataCompletedEventHandler handler = DownloadCompleted; if (handler != null) { handler(sender, e); } }
private void MWeb_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { RunOnUiThread(() => { try { string json = Encoding.UTF8.GetString(e.Result); items = JsonConvert.DeserializeObject <List <FilmDTO> >(json); FilmViewAdapter adapter = new FilmViewAdapter(this, items); mView.Adapter = adapter; } catch (Exception) { Android.Widget.Toast.MakeText(this, "Une erreur est survenue lors de la connexion avec le serveur central", Android.Widget.ToastLength.Short).Show(); } }); }
private void Wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { string Html = ""; WebClient Wc = (WebClient)sender; SearchState State = (SearchState)e.UserState; if (e.Error == null) { Html = UncompressResponse(e.Result, Wc.ResponseHeaders); new FileCache().Save(State.CacheKey, Html); ParseMovieHTML(State.Code, State.FullInfo, ref Html, false); } else { OnMovieParsed(null); } }
private static void wcDownLoadDone1(object sender, DownloadDataCompletedEventArgs e) { //if (e.Error != null) // { // //Console.WriteLine("Status Code is {0}", 1); // //Console.WriteLine(" Error Downloading Data Completed Handler - Message - {0}", e.Error.Message); // //Console.WriteLine(e.Error.StackTrace.ToString()); // //Console.WriteLine(e.Error.InnerException.ToString()); // Installer.wslogger.WS_Logger ws = new Installer.wslogger.WS_Logger(); // ws.Logger(sUnid, sCurrentFile + " - " + e.Error.Message, -1, iBatchCl); // //throw new Exception("Downloading Error"); // // throw new Exception(e.Error.Message); // // Console.ReadLine(); // } Console.WriteLine("File Download DoneComplete Complete"); }
void meal_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { RunOnUiThread(() => { string json = Encoding.UTF8.GetString(e.Result); editor = pref.Edit(); editor.PutString("MealDetails", json); editor.Apply(); editor = pref.Edit(); organizeMealData(); var intent = new Intent(this, typeof(login)); StartActivity(intent); }); }
private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvFailed); labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; buttonDownload.Enabled = !Configuration.IsRunningOnLinux(); Cursor = Cursors.Default; return; } string dictionaryFolder = Configuration.DataDirectory; using (var ms = new MemoryStream(e.Result)) using (ZipExtractor zip = ZipExtractor.Open(ms)) { List <ZipExtractor.ZipFileEntry> dir = zip.ReadCentralDir(); foreach (ZipExtractor.ZipFileEntry entry in dir) { if (entry.FilenameInZip.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { string fileName = Path.GetFileName(entry.FilenameInZip); string path = Path.Combine(dictionaryFolder, fileName); if (File.Exists(path)) { path = Path.Combine(dictionaryFolder, fileName + ".new-mpv"); } zip.ExtractFile(entry, path); } } } Cursor = Cursors.Default; labelPleaseWait.Text = string.Empty; buttonOK.Enabled = true; if (!Configuration.IsRunningOnLinux()) { buttonDownload.Enabled = true; } else { buttonDownload.Enabled = false; } MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvOk); }
private void OnPDFDownloadCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null) { Console.WriteLine(e.Error); return; } var pdfBytes = e.Result; File.WriteAllBytes(_pdfFilePath, pdfBytes); if (File.Exists(_pdfFilePath)) { PdfPath = _pdfFilePath; } }
void TrackDownloadClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Cancelled) { TaskbarUtils.SetProgressState(Handle, TaskbarUtils.ProgressState.NoProgress); SetFormEnabled(true); SetDataGridRowColor(Color.LightCoral, null, DownloadData.CurrentTrack.Title); } else if (e.Error != null) { TaskbarUtils.SetProgressState(Handle, TaskbarUtils.ProgressState.Error); TaskbarUtils.Flash(Handle); ShowEx("Failed to download track", e.Error); TaskbarUtils.SetProgressState(Handle, TaskbarUtils.ProgressState.NoProgress); SetFormEnabled(true); } else { if (DownloadData.Step++ == 0) { string page = Encoding.ASCII.GetString(e.Result); var match = TrackUriRegex.Match(page); if (match.Success) { var filepath = match.Groups["file"].Value; var index = filepath.LastIndexOf('/'); if (index >= 0) { DownloadData.Filename = Uri.UnescapeDataString(filepath.Substring(index + 1)); TrackDownloadClient.DownloadDataAsync(new Uri(filepath)); } } } else { // write track to disk File.WriteAllBytes(Path.Combine(DownloadData.FolderPath, DownloadData.Filename), e.Result); // mark track in list as finished SetDataGridRowColor(ProgressTrackProgressBar.ForeColor, null, DownloadData.CurrentTrack.Title); // download next StartDownload(); } } }
private void _wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Cancelled) { Status = WebRequestStatus.Download_Canceled; } else if (e.Error != null) { Status = WebRequestStatus.Download_Failed; _resultString = e.Error.Message; } else { Status = WebRequestStatus.Download_Complete; _resultData = e.Result; } }
private void WebClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { Debug.Assert(this.Status == LoadTileStatus.Loading); lock (this.Observers) { this.ClearObservers(); } if (e.Cancelled) { this.Owner.RemoveDownloadTask(this); this.Status = LoadTileStatus.Canceled; this.CompletionSource.SetCanceled(); } else if (e.Error != null) { this.Owner.RemoveDownloadTask(this); this.Status = LoadTileStatus.Failed; this.CompletionSource.SetException(e.Error); } else { this.Status = LoadTileStatus.Succeed; var buffer = e.Result; var bitmap = new BitmapImage(); using (var stream = new MemoryStream(buffer)) { bitmap.BeginInit(); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.StreamSource = stream; bitmap.EndInit(); bitmap.Freeze(); } this.SaveCache(bitmap); this.CompletionSource.SetResult(bitmap); } }
private void AirDataCompleted(object sender, DownloadDataCompletedEventArgs e) { var data = e.Result; var asString = Encoding.UTF8.GetString(data); var res = JObject.Parse(asString); var dataArray = (JArray)res["acList"]; foreach (var d in dataArray) { var airCraft = new Aircraft { Id = d["Id"] == null ? -1 : (int)d["Id"], Identifier = d["Icao"] == null ? "Unknown" : (string)d["Icao"], Altitude = d["Alt"] == null ? -1 : (int)d["Alt"], Lat = d["Lat"] == null ? -1 : (float)d["Lat"], Lon = d["Long"] == null ? -1f : (float)d["Long"], Time = d["PosTime"] == null ? -1 : (long)d["PosTime"], Speed = d["Spd"] == null ? -1f : (float)d["Spd"], Type = d["Type"] == null ? "Unknown" : (string)d["Type"], Model = d["Mdl"] == null ? "Unknown" : (string)d["Mdl"], Manufacturer = d["Man"] == null ? "Unknown" : (string)d["Man"], Year = d["Year"] == null ? "Unknown" : (string)d["Year"], Operator = d["Op"] == null ? "Unknown" : (string)d["Op"], VerticalSpeed = d["Vsi"] == null ? -1 : (int)d["Vsi"], Turbulence = d["WTC"] == null ? "Unknown" : ParseTurbulence((int)d["WTC"]), Species = d["Species"] == null ? "Unknown" : ParseSpecies((int)d["Species"]), Military = d["Mil"] == null ? false : (bool)d["Mil"], Country = d["Cou"] == null ? "Unknown" : (string)d["Cou"], Call = d["Call"] == null ? "Unknown" : (string)d["Call"], From = d["From"] == null ? "Stockholm-Arlanda, Stockholm, Sweden" : (string)d["From"], To = d["To"] == null ? "Billund, Denmark" : (string)d["To"], }; if (airCraft != null) { // todo: on update (not redraw) check if aircraft is already in the list if (!AircraftList.Any(a => a.Id == airCraft.Id)) { AircraftList.Add(airCraft); } MapController.AddAircraftToMap(airCraft); QueryGeoLocation(airCraft); } } }
private void _client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { try { if (OnDownloadCompleted != null) { OnDownloadCompleted(this, new DownloadCompletedEventArgs(e.Result, e.Result.GetType(), e.Cancelled, e.Error)); } } catch (Exception ex) { MyConsole.AppendLine(string.Format("处理下载完成异常:{0}!时间:{1}", ex.Message, DateTime.Now)); if (OnDownloadErrored != null) { OnDownloadErrored(sender, new DownloadErroredEventArgs(_url, ex)); } } }
protected void DownloadComplete(object sender, DownloadDataCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { string message = string.Format("AsyncWebLoadOperation: Failed to download {0} - {1}", _uri, e.Cancelled ? "Request timed out" : e.Error.Message); if (_ignoredLoggingUriPatterns.Any(pattern => _uri.AbsoluteUri.Contains(pattern))) { ServiceRegistration.Get <ILogger>().Debug(message); } else { ServiceRegistration.Get <ILogger>().Warn(message); } OperationFailed(); return; } OperationCompleted(e.Result); }
private void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { //Debug.Log(e); if (e.Cancelled) { isFinish = true; state = ClientState.fail; } else { if (e.Result != null) { isFinish = true; resultarr = e.Result; state = ClientState.success; } } }
void wcl_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs args) { pbDownload.Value = 100; Text = string.Format("Загрузка завершена"); if (args.Cancelled) { MessageBox.Show("Отменено"); } else if (args.Error != null) { throw args.Error; } else { result = args.Result; } Close(); }
private static void DownCompletePush(object sender, DownloadDataCompletedEventArgs e) { Encoding enc = Encoding.GetEncoding("GB2312"); try { Song song = (Song)e.UserState; Byte[] pageData = e.Result; LrcText = enc.GetString(pageData); string lrcPa = song.FileUrl.Remove(song.FileUrl.LastIndexOf(".")) + ".lrc"; StreamWriter sw = new StreamWriter(lrcPa, false, Encoding.UTF8); sw.Write(LrcText); sw.Flush(); sw.Close(); CompletedNoticeEventHandler(true, lrcPa); } catch { CompletedNoticeEventHandler(false, null); } }
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { //try { // // If the request was not canceled and did not throw // // an exception, display the resource. // if (!e.Cancelled && e.Error == null) { // //File.WriteAllBytes(_tempFilename, (byte[])e.Result); // } //} //finally { //} ////Log.Information($"{this.GetType().Name}: Download complete"); ////Log.Information($"{this.GetType().Name}: Exiting and running installer ({_tempFilename})..."); OnDownloadComplete(_tempFilename); }
private void _client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Cancelled) { //progressBar.Value = 0; OperationResult = "Загрузка отменена"; } else { OperationResult = e.Error != null ? e.Error.Message : "Загрузка закончена!"; } _client.Dispose(); _downloading = false; //DownloadBtn.Text = "Загрузить"; // e.Results содержит все данные FileDownloaded(e.Result); //downloadedData = e.Result; }
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error == null) { byte[] dataArray = e.Result; //ставим правильную кодировку для данных, инчае будут string page = Encoding.UTF8.GetString(dataArray); //корикозябры вместо кириллицы HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(page); //делаем страницу из string DownloaderHtmlPageArgs args = new DownloaderHtmlPageArgs(doc); FinishDownload?.Invoke(this, args); //вызываем событие, аналог if(OnPageDow!=null) } else { Program.statusBarGlobal.Message = "Ошибка подключения при запросе списка торрентов"; } }
// Setup the callback event handler handlers void CompletedHandler(object sender, DownloadDataCompletedEventArgs e) { if (e.UserState == tcs) { if (e.Error != null) { tcs.TrySetException(e.Error); } else if (e.Cancelled) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(e.Result); } } }
private void MClient_DownloadIdDataCompleted(object sender, DownloadDataCompletedEventArgs e) { try { //Assign downloaded data to a string string json = Encoding.UTF8.GetString(e.Result); Log.Debug("GETID", "GETID json = " + json); //Deserialize string from JSON UserId resp = JsonConvert.DeserializeObject <UserId>(json); //Assign downloaded ID to global variable userToken = resp.userID; } //JSON error catch catch (System.Reflection.TargetInvocationException) { Toast.MakeText(this, "There was an error retrieving data from the server. Please close the app and try again later.", ToastLength.Long).Show(); } }
void wcDownloadPrepareHistory_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { MemoryStream ms = new MemoryStream(e.Result); StreamReader reader = new StreamReader(ms); string xml = reader.ReadToEnd(); //Trace.WriteLine(xml); reader.Close(); ms.Close(); int c = PrepareHistory.Load(xml); PromptForm prompt = e.UserState as PromptForm; prompt.Messages[prompt.Messages.Count - 1].Content = string.Format("成功下载{0}条出单记录.", c); prompt.RefreshDisplay(); prompt.OKEnabled = true; }
void ImageDownload_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null && !e.Cancelled) { Image = error_image; } else if (e.Error == null && !e.Cancelled) { using (MemoryStream ms = new MemoryStream(e.Result)) Image = Image.FromStream(ms); } ImageDownload.DownloadProgressChanged -= new DownloadProgressChangedEventHandler(ImageDownload_DownloadProgressChanged); ImageDownload.DownloadDataCompleted -= new DownloadDataCompletedEventHandler(ImageDownload_DownloadDataCompleted); image_download = null; OnLoadCompleted(e); }
/// <summary> /// Occurs when course data has been downloaded from the server. A method is called /// to organize the course data and the user is sent to the login screen. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void course_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { RunOnUiThread(() => { string json = Encoding.UTF8.GetString(e.Result); editor = pref.Edit(); editor.PutString("CourseDetails", json); editor.Apply(); editor = pref.Edit(); organizeCourseData(); mealClient.DownloadDataCompleted += meal_DownloadDataCompleted; mealClient.DownloadDataAsync(mealUri); mealClient.Dispose(); }); }
protected virtual void OnDownloadDataCompleted(DownloadDataCompletedEventArgs args) { if (DownloadDataCompleted != null) DownloadDataCompleted(this, args); }
private void OnDownloadDataCompleted (DownloadDataCompletedEventArgs args) { EventHandler <DownloadDataCompletedEventArgs> handler = DownloadDataCompleted; if (handler != null) { handler (this, args); } }