/// <summary> /// 下载完成之后更新本地文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpdateLocalFile(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { string zipFilePath = System.IO.Path.Combine(updateFileDir, Constants.ZipFileName); byte[] data = e.Result; BinaryWriter writer = new BinaryWriter(new FileStream(zipFilePath, FileMode.OpenOrCreate)); writer.Write(data); writer.Flush(); writer.Close(); System.Threading.ThreadPool.QueueUserWorkItem((s) => { string tempDir = System.IO.Path.Combine(updateFileDir, "temp"); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } UnZipFile(zipFilePath, tempDir); //移动文件 if (Directory.Exists(System.IO.Path.Combine(tempDir, Constants.UnzipFoldName))) { CopyDirectory(System.IO.Path.Combine(tempDir, Constants.UnzipFoldName), appDir); } }); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Client_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { // System.Diagnostics.Debug.WriteLine("下载完成!"); if (!e.Cancelled && e.Error == null) { verInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <VersionInfo>(Encoding.UTF8.GetString(e.Result)); var lst = from item in verInfo.FileInfos select item.FileRelativePath; var obj = new { FileList = lst }; App.ReInstall = lst.Contains("IM_install.exe"); GetPcIncrementFiles(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); } else { Application.Current.Dispatcher.Invoke(() => this.Description = $"清单文件下载失败,失败原因:{e.Error.Message}"); // System.Diagnostics.Debug.WriteLine($"清单文件下载失败,失败原因:{e.Error.Message}"); System.Threading.Thread.Sleep(2000); Installed = true; } }
void client_DownloadDataCompleted_File(object sender, System.Net.DownloadDataCompletedEventArgs e) { UpdateLocalFile(sender, e); this.txtProcess.Text = "更新完成,是否现在启动程序?"; SetButtonState(); button_Yes.Content = "现在启动"; button_No.Content = "稍后启动"; }
/// <summary> /// 下载完成时执行 /// </summary> /// <param name="clientE"></param> /// <returns></returns> private string DownloadDataCompleted(System.Net.DownloadDataCompletedEventArgs clientE) { string zipFilePath = System.IO.Path.Combine(_info.LocalFilePathTemp, "update.zip"); byte[] data = clientE.Result; BinaryWriter writer = new BinaryWriter(new FileStream(zipFilePath, FileMode.OpenOrCreate)); writer.Write(data); writer.Flush(); writer.Close(); return(zipFilePath); }
void client_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { System.IO.File.WriteAllBytes(e.UserState.ToString(), e.Result); Downloaded.Set(); } if (OnProgress != null) { Target.ProgressPercentage = 100; OnProgress(Target); } }
void wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { if ((e.UserState as string) == "init") { if (e.Error == null) { this.IsInitCompleted = true; if (this.InitCompleted != null) { this.InitCompleted(this, new EventArgs()); } } } }
void TabItemSearchBar_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = new MemoryStream(e.Result); image.EndInit(); SiteImage = image as ImageSource; } catch { SiteImage = null; } }
void FavoriteListItemViewModel_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = new MemoryStream(e.Result); image.EndInit(); SiteImage = image as ImageSource; } catch { _siteImage = null; } }
private void MClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { string json = Encoding.UTF8.GetString(e.Result); mProfile = JsonConvert.DeserializeObject <Profile>(json); if (mProfile == null) { Console.WriteLine("** Error de Carga ( Perfil de Busqueda ) ** : No existe perfil para ese usuario"); Managment.ActivityManager.TakeMeTo(this, typeof(ErrorActivity), true); return; } RunOnUiThread(() => { mSeekBarRange.Progress = mProfile.range - 1; mTextViewRange.Text = "Rango de Búsqueda " + mProfile.range.ToString() + " Km"; mTextPrice.Text = mProfile.maxPrice.ToString(); if (mProfile.GetIs24()) { mIs24Yes.Checked = true; mIs24No.Checked = false; } else { mIs24Yes.Checked = false; mIs24No.Checked = true; } if (mProfile.GetIsCovered()) { mIsCoveredYes.Checked = true; mIsCoveredNo.Checked = false; } else { mIsCoveredYes.Checked = false; mIsCoveredNo.Checked = true; } }); } catch (Exception ex) { Console.WriteLine("** Error de Carga ( Perfil ) ** : " + ex.Message); Managment.ActivityManager.TakeMeTo(this, typeof(ErrorActivity), true); } }
void GetVersionArchive_completed(object sender, System.Net.DownloadDataCompletedEventArgs e) { if (e.Cancelled) { Log.Warning(Log.LogSource.Net, "Updater.GetVersionArchive_completed(): Could not retrieve newest version archive"); return; } if (e.Error != null) { Log.Error(Log.LogSource.Net, "Updater.GetLatestVersion_completed(): Error while retrieving newest version archive"); return; } byte[] data = e.Result; try { string appFile = Assembly.GetEntryAssembly().Location; string appFolder = Path.GetDirectoryName(appFile); MoveOldAssemblies(); using (MemoryStream ms = new MemoryStream(data)) { using (ZipArchive arch = new ZipArchive(ms)) { foreach (var f in arch.Entries) { string destinationPath = Path.GetFullPath(Path.Combine(appFolder, f.FullName)); string destinationDirectory = Path.GetDirectoryName(destinationPath); Directory.CreateDirectory(destinationDirectory); if (f.ToString().Contains('.')) { f.ExtractToFile(destinationPath, true); } } } } _OnGetArchiveSuccess(); } catch (Exception ex) { Log.Error(Log.LogSource.Net, "Updater.GetVersionArchive_completed(): Error while unpacking archive: " + ex.ToString()); _OnGetArchiveFailed?.Invoke(); } }
protected void Wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { BaseItem bi = (BaseItem)e.UserState; if (e.Cancelled || e.Error != null) { bi.Percent = -1; } else { byte[] data = new byte[e.Result.Length]; Array.Copy(e.Result, data, e.Result.Length); bi.ImgData = data; } ((System.Net.WebClient)sender).Dispose(); }
private void Wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { if (null != e.Error) { MessageBox.Show(e.Error.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); _phase.Text = Properties.Resources.MSG12; return; } byte[] buffer = e.Result; _phase.Text = Properties.Resources.MSG13; _setEphemerisWorker.RunWorkerAsync(buffer); return; }
//AUTHENTICATION internal void ProcessAccesTokenCheckResponse(object sender, System.Net.DownloadDataCompletedEventArgs e) //called when facebook responds to checking the users acces token { if (e.Error != null) { Console.WriteLine(e.Error.Message); } else { if (e.Result != null && e.Result.Length > 0) { string downloadedData = Encoding.UTF8.GetString(e.Result); LogInUser(downloadedData); } else { Console.WriteLine("No data was downloaded."); } } }
void OnRunePreviewDownloaded(object sender, System.Net.DownloadDataCompletedEventArgs e) { if (QueuedRunePreviewHashes.Count == 0) { return; } string hash = QueuedRunePreviewHashes.Dequeue(); try { if (!e.Cancelled) { if (e.Error == null) { byte[] data = e.Result; if (!Directory.Exists("images\\runes\\sm")) { Directory.CreateDirectory("images\\runes\\sm"); } using (FileStream fs = new FileStream("images\\runes\\sm\\" + hash + ".png", FileMode.OpenOrCreate, FileAccess.Write)) { fs.Write(data, 0, data.Length); fs.Flush(); } LoadRunePreview(hash); } else { throw e.Error; } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } NewPreviewRequested = true; }
private void LocalClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { string json = Encoding.UTF8.GetString(e.Result); var googleDirection = JsonConvert.DeserializeObject <GoogleDirection>(json); PolylineOptions po = DirectionController.ResolveRoute(googleDirection); RunOnUiThread(() => { mProgressBar.Visibility = ViewStates.Invisible; mMap.AddPolyline(po); }); } catch (Exception ex) { Console.WriteLine("** Error ** : El servidor Google Route no devolvio valores correctos /n " + ex.Message); } }
private void MClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { RunOnUiThread(() => { try { string json = Encoding.UTF8.GetString(e.Result); mVehicles = JsonConvert.DeserializeObject <List <Vehicle> >(json); // Cargo la Listview con los Vehiculos mListAdapter = new VehicleListAdapter(this, mVehicles); mListView.Adapter = mListAdapter; mListView.ItemClick += MListView_ItemClick; mListView.ItemLongClick += MListView_ItemLongClick; } catch (Exception ex) { Managment.ActivityManager.TakeMeTo(this, typeof(ErrorActivity), true); } }); }
private void MClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { RunOnUiThread(() => { try { string json = Encoding.UTF8.GetString(e.Result); mHistoric = JsonConvert.DeserializeObject <List <Historic> >(json); // Cargo la Listview con los Vehiculos mListAdapter = new HistoryListAdapter(this, mHistoric); mListView.Adapter = mListAdapter; mListView.ItemClick += MListView_ItemClick; } catch (Exception ex) { Console.WriteLine("** Error al cargar el Historial **"); //Managment.ActivityManager.TakeMeTo(this, typeof(ErrorActivity), true); } }); }
public static void OnDownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { System.Threading.AutoResetEvent waiter = (System.Threading.AutoResetEvent)e.UserState; try { // If the request was not canceled and did not throw // an exception, display the resource. if (!e.Cancelled && e.Error == null) { byte[] data = (byte[])e.Result; string textData = System.Text.Encoding.UTF8.GetString(data); System.Console.WriteLine(textData); } } finally { // Let the main application thread resume. waiter.Set(); } }
private void OnDownloadFinished(object sender, System.Net.DownloadDataCompletedEventArgs e) { string strPath = Path.Combine(DustUtilityPlugin.DataDirectory, "update.zip"); using (FileStream fs = File.Open(strPath, FileMode.Create)) { fs.Write(e.Result, 0, e.Result.Length); } string strPluginDir = Path.Combine(Hearthstone_Deck_Tracker.Config.AppDataPath, "Plugins"); string[] vOldFiles = Directory.GetFiles(strPluginDir, "*DustUtility*"); for (int i = 0; i < vOldFiles.Length; i++) { File.Delete(vOldFiles[i]); } ZipFile.ExtractToDirectory(strPath, strPluginDir); File.Delete(strPath); }
private void Wclient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { string json = Encoding.UTF8.GetString(e.Result); OperationResult or = JsonConvert.DeserializeObject <OperationResult>(json); if (or.error) { // Ocurrio un error Console.WriteLine("** Error ** : No se pudo eliminar el vehiculo "); } else { getClientVehicles(); } } catch (Exception ex) { Console.WriteLine("** Error ** : No se pudo eliminar el vehiculo "); } }
private void MClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { string json = Encoding.UTF8.GetString(e.Result); mParkinglots = JsonConvert.DeserializeObject <List <Parkinglot> >(json); if (mParkinglots.Count == 0) { RunOnUiThread(() => { // Levanto el mensaje de que no encontro ningun establecimiento mProgressBar.Visibility = ViewStates.Invisible; trans = FragmentManager.BeginTransaction(); dialog = new DialogParkingSearch(); dialog.Show(trans, "Dialog Parking Search"); }); } else { RunOnUiThread(() => { //Levanto el Dialog aca, asi me aseguro que siempre haya mapa donde mostrar los marcadores mProgressBar.Visibility = ViewStates.Invisible; trans = FragmentManager.BeginTransaction(); dialog = new DialogParkingSearch(mParkinglots[mPosition], mPosition); dialog.Show(trans, "Dialog Parking Search"); dialog.mGo += Dialog_mGo; dialog.mNext += Dialog_mNext; }); } } catch (Exception ex) { Managment.ActivityManager.ShowError(this, new Error(errCode, errMsg)); } }
private void WcThumbnail_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { int thumbnailSize = 200; this.Entries[_index - 1].XmlContent = Encoding.UTF8.GetString(e.Result); var tl = ThermalLabel.CreateFromXmlTemplate(this.Entries[_index - 1].XmlContent); var ms = new MemoryStream(); using (var pj = new PrintJob()) { pj.ExportToImage(tl, ms, new ImageSettings() { AntiAlias = true, ImageFormat = ImageFormat.Png, ThumbnailSize = thumbnailSize }, 96); } System.Drawing.Image imgLabel = null; if (ZipUtils.IsPkZipCompressedData(ZipUtils.GetInitBytes(ms, 4))) { using (var zip = new ZipArchive(ms)) { foreach (var entry in zip.Entries) { imgLabel = System.Drawing.Image.FromStream(entry.Open()); } } } else { imgLabel = System.Drawing.Image.FromStream(ms); } var pb = new System.Windows.Forms.PictureBox(); pb.SizeMode = PictureBoxSizeMode.CenterImage; pb.BorderStyle = BorderStyle.FixedSingle; pb.BackColor = System.Drawing.Color.WhiteSmoke; pb.Width = pb.Height = thumbnailSize + 20; pb.Image = imgLabel; var lbl = new Label(); lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.AutoSize = false; lbl.Width = thumbnailSize + 20; lbl.Height = 30; lbl.Text = this.Entries[_index - 1].Name; lbl.ForeColor = System.Drawing.Color.White; var btn = new Button(); btn.Text = "Edit..."; btn.Width = thumbnailSize + 20; btn.Height = 30; btn.BackColor = System.Drawing.SystemColors.ButtonFace; btn.Tag = _index; btn.Click += Btn_Click; var uc = new UserControl(); uc.Controls.Add(lbl); uc.Controls.Add(pb); uc.Controls.Add(btn); pb.Top = lbl.Height; btn.Top = pb.Top + pb.Height; uc.Height = btn.Top + btn.Height; uc.Width = pb.Width; fpnlContainer.Controls.Add(uc); this.pbGallery.Value = _index * this.pbGallery.Step; if (_index == this.Entries.Count) { this.pbGallery.Value = 0; } _index++; }
void wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { downloadperc = -1; }
private void DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { System.IO.File.WriteAllBytes(sUpdatePath, e.Result); MessageBox.Show("Your download is complete. Unzip and double click the install file to update.", "Download Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); }
protected virtual void OnDownloadDataCompleted(System.Net.DownloadDataCompletedEventArgs e) { }
/// <summary> /// Called only when downloading our rule file via webclient /// </summary> private void ParseRules(object sender, System.Net.DownloadDataCompletedEventArgs e) { var data = e.Result; File.WriteAllBytes("/assets/mslrules.txt", data); }
private void _server_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { DownloadState = DownloadStateEnum.Downloaded; }
private static void WebClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { DependencyService.Get <IProgressUpdate>().ProgressCancel(1); }
private void Wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { try { using (var ms = new MemoryStream(e.Result)) { var xmlr = XmlReader.Create(ms); while (xmlr.Read()) { if (xmlr.IsStartElement()) { var name = ""; if (xmlr.MoveToAttribute("name")) { name = xmlr.Value; } var category = ""; if (xmlr.MoveToAttribute("category")) { category = xmlr.Value; } var filename = ""; if (xmlr.MoveToAttribute("filename")) { filename = xmlr.Value; } if (string.IsNullOrWhiteSpace(name) == false) { this.Entries.Add(new GalleryEntry(name, category, filename, "")); } } } } this.pbGallery.Step = (int)(100d / (double)this.Entries.Count); foreach (var entry in this.Entries) { var downloadTemplateUrl = $"{_urlGallery}{entry.Filename}"; if (wcThumbnail == null) { wcThumbnail = new System.Net.WebClient(); wcThumbnail.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); wcThumbnail.DownloadDataCompleted += WcThumbnail_DownloadDataCompleted; } while (wcThumbnail.IsBusy) { //downloading } wcThumbnail.DownloadDataTaskAsync(new Uri(downloadTemplateUrl)); } } catch { //MessageBox.Show("Online Label Gallery is not available.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (wcThumbnail != null) { wcThumbnail.Dispose(); } if (wc != null) { wc.Dispose(); } }
void Wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e) { ((System.Net.WebClient)sender).DownloadDataCompleted -= Wc_DownloadDataCompleted; pictureBox1.Image = System.Drawing.Image.FromStream(new System.IO.MemoryStream(e.Result)); }