Inheritance: System.EventArgs
示例#1
0
 void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (cancelled)
     {
         Debug.Log("Cancelado");
         downloading = false;
         finished    = true;
     }
     else
     {
         if (e.Error == null)
         {
             downloading = false;
             if (onVerify == true)
             {
                 GameObject.Find("DownloaderGestor").GetComponent <TotalProgress> ().NextScript();
                 finished = true;
             }
             else
             {
                 finished = true;
             }
         }
         else
         {
             Debug.Log(e.Error.ToString());
         }
     }
 }
 private void DownloadFileCompleteCb(object sender, System.ComponentModel.AsyncCompletedEventArgs ar)
 {
     try
     {
         if (ar.Error != null)
         {
             DebugUtils.Log("Exception Error: {0}", ar.Error);
             OnResultCallback(AnnounceResult.kExceptionError);
             DebugUtils.Assert(false);
         }
         else
         {
             image_list_.RemoveAt(0);
             if (image_list_.Count > 0)
             {
                 KeyValuePair <string, string> item = image_list_[0];
                 web_client_.DownloadFileAsync(new Uri(item.Key), item.Value);
                 DebugUtils.Log("Download url: {0}", item.Key);
             }
             else
             {
                 DebugUtils.Log("Download file completed.");
                 OnResultCallback(AnnounceResult.kSuccess);
             }
         }
     }
     catch (Exception e)
     {
         DebugUtils.Log("Failure in DownloadFileCompleteCb: {0}", e.ToString());
         OnResultCallback(AnnounceResult.kExceptionError);
     }
 }
 void catalog_DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         MessageBox.Show("加载xap文件错误.\n" + e.Error.Message);
     }
 }
示例#4
0
 static void client_ConnectCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (ConnectFinished != null)
     {
         ConnectFinished(sender, e);
     }
 }
示例#5
0
		public void BeginDownload(RemoteFileInfo fileInfo, string destPath)
		{
			try
			{
				var localFileInfo = new FileInfo(destPath);
				if (localFileInfo.Exists)
				{
					if (Sha1VerifyFile(destPath, fileInfo.Sha1Hash))
					{
						var newEvt = new AsyncCompletedEventArgs(null, false, null);
						DownloadFileCompleted(this, newEvt);
						return; //already have the file with correct contents on disk
					}
				}
			}
			catch (Exception ex)
			{
				var newEvt = new AsyncCompletedEventArgs(ex, false, null);
				DownloadFileCompleted(this, newEvt);
				return; //something failed when trying to hash file
			}

			if (_wc != null)
			{
				_wc.CancelAsync();
				_wc.Dispose();
				_wc = null;
			}

			_wc = new CustomWebClient(Timeout);
			_wc.DownloadProgressChanged += (sender, evt) => { DownloadProgressChanged(sender, evt); };
			_wc.DownloadFileCompleted += (sender, evt) =>
			{
				using (var wc = (WebClient) sender)
				{
					if (evt.Cancelled || evt.Error != null)
					{
						DownloadFileCompleted(sender, evt);
						return;
					}

					try
					{
						if (!Sha1VerifyFile(destPath, fileInfo.Sha1Hash))
							throw new Exception("Hash mismatch after download");
					}
					catch (Exception ex)
					{
						var newEvt = new AsyncCompletedEventArgs(ex, false, evt.UserState);
						DownloadFileCompleted(sender, newEvt);
						return;
					}

					DownloadFileCompleted(sender, evt);
				}
				_wc = null;
			};

			_wc.DownloadFileAsync(new Uri(fileInfo.Url), destPath);
		}
示例#6
0
文件: cccp.cs 项目: Gigawiz/NiVid
 void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     pictureBox3.Width = 515;
     label3.Text = "Installing...";
     label5.Visible = true;
     timer2.Start();
 }
示例#7
0
        static void client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            if (QueueAddress.Count != 0)
            {
                client = new WebClient();

                string url = QueueAddress.Dequeue();
                Uri    uri = new Uri(url);
                LoadUrl = url;
                client.DownloadFileCompleted   += client_DownloadFileCompleted;
                client.DownloadProgressChanged += client_DownloadProgressChanged;
                client.DownloadFileAsync(uri, QueueSavePath.Dequeue());
                DownLoadID++;
                if (DownLoadNumber != null)
                {
                    DownLoadNumber(DownLoadID);
                }
            }
            else
            {
                if (DownLoadFileFinished != null)
                {
                    DownLoadFileFinished(null, new EventArgs());
                }
                isDownLoading = false;
            }
        }
示例#8
0
 /// <summary>
 /// 异步发信时发完以后的操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void client_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (SendCompleted != null)
     {
         SendCompleted(sender, e);
     }
 }
示例#9
0
 protected virtual void OnDownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (DownCompleted != null)
     {
         DownCompleted(sender, e);
     }
 }
        private static void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            ZipFile.ExtractToDirectory(Path.Combine(Logic.Logic.InstallDirectory, "temp", "LegendaryClient.zip"),
                Logic.Logic.InstallDirectory);

            Logic.Logic.Installed = true;
            Logic.Logic.SwichPage<Finished>();

            Directory.Delete(Path.Combine(Logic.Logic.InstallDirectory, "temp"), true);

            string x = Path.Combine(Logic.Logic.InstallDirectory, "Client", "LC", "Version.Version");
            string l = Path.Combine(Logic.Logic.InstallDirectory, "Client", "LC");
            if (!Directory.Exists(l))
                Directory.CreateDirectory(l);

            if (File.Exists(x))
                return;

            //Write the version to the file
            FileStream y = File.Create(x);
            y.Close();

            var writer = new StreamWriter(x);
            writer.Write(Logic.Logic.Version);
            writer.Close();
        }
示例#11
0
 protected void OnSendCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (SendCompleted != null)
     {
         SendCompleted(sender, e);
     }
 }
示例#12
0
文件: Main.cs 项目: theheroGAC/SHM
        public void Web_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            //throw new NotImplementedException();
            if (e.Cancelled == true)
            {
                //FileSystem.DeleteFile(path + "PKG-h-encore\\xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq.pkg");
                MessageBox.Show("Download canceled.", "Download canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (e.Error != null) // We have an error! Retry a few times, then abort.
            {
                //FileSystem.DeleteFile(path + "PKG-h-encore\\xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq.pkg");
                MessageBox.Show("An error ocurred while trying to download file: " + e.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Downloaded the Homebrew successful", "Sucessfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            ((WebClient)sender).Dispose();

            progressBar1.Visible = false;
            label6.Visible       = false;
            Psvita.Enabled       = true;
            PS3.Enabled          = true;
            PS4.Enabled          = true;
        }
示例#13
0
 void DDownloader_Done(object sender, AsyncCompletedEventArgs e)
 {
     Process x = new Process();
     x.StartInfo = new ProcessStartInfo("T0Updater.exe", "\"" + Path.GetFileName(Application.ExecutablePath) + "\" " + Properties.User.Default.selectedBuilds + " " + Program.Version);
     x.Start();
     Application.Exit();
 }
示例#14
0
 void _wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (FileDownloaded != null)
     {
         FileDownloaded(this, e);
     }
 }
        private void Completed(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.DialogResult = DialogResult.Cancel;
                
                this.pgFile.Value = 0;
                this.lbFile.Text = "Cancelled";

                this.DialogResult = DialogResult.Cancel;
            }
            else if (e.Error != null)
            {
                MessageBox.Show("Error downloading file: " + sUrl + "\n" + e.Error.Message);
                
                this.pgFile.Value = 0;
                this.lbFile.Text = "Error: " + e.Error.Message;

                this.DialogResult = DialogResult.Cancel;
            }
            else
            {
                this.pgFile.Value = 100;

                this.DialogResult = DialogResult.OK;
            }

            this.Close();
        }
示例#16
0
 private async void Smtp_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         //await this.Reporter.Error(this.Properties.Name, "Failed to send Email.", e.Error).ConfigureAwait(false);
     }
 }
示例#17
0
 private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     lbl_status.Text = "Status: Completed";
     Thread.Sleep(500);
     Process.Start("R2_Compiler_conf_gui.exe");
     Application.Exit();
 }
示例#18
0
 protected bool HasError(AsyncCompletedEventArgs args)
 {
     var hasError = args.Error != null;
     if (hasError)
         OnNewSystemMessage(args.Error.Message);
     return hasError;
 }
        private void quandoDownloadCompleto(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            indiceLinhaDownload = webList.IndexOf(sender as WebClient);

            dataGridViewAtualizarFirmware.Rows[indiceLinhaDownload].Cells[COLUNA_PERCENTUAL].Value = "100 % Completed";
            if (!String.IsNullOrEmpty(dataGridViewAtualizarFirmware.Rows[indiceLinhaDownload].Cells[COLUNA_DIRETORIO].Value.ToString()))
            {
                Uri uri = new Uri(dataGridViewAtualizarFirmware.Rows[indiceLinhaDownload].Cells[COLUNA_DIRETORIO].Value.ToString());
                if (uri.PathAndQuery.EndsWith(".msi"))
                {
                    string  produto = dataGridViewAtualizarFirmware.Rows[indiceLinhaDownload].Cells[COLUNA_PRODUTO].Value.ToString();
                    Version versao  = new Version(dataGridViewAtualizarFirmware.Rows[indiceLinhaDownload].Cells[COLUNA_VERSAO].Value.ToString());
                    string  sw_fw   = (produto == Application.ProductName) ? "SW" : "FW";
                    string  familia = versao.Major.ToString();

                    string filename = "\\" + produto + "_" + familia + "_" + sw_fw + "_" + versao.ToString().Replace(".", "_");

                    Process.Start(Fachada.diretorio_downloads + "\\" + filename + Path.GetExtension(uri.PathAndQuery));

                    Application.Exit();
                }
                else if (uri.PathAndQuery.EndsWith(".fir"))
                {
                    // Copiar para firmware
                    string[] arquivos = Directory.GetFiles(Fachada.diretorio_downloads, "*.fir");
                    foreach (string arquivo in arquivos)
                    {
                        if (arquivo.Contains("ControladorPontos"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\firmware.fir", true);
                        }
                        else if (arquivo.Contains("PainelMultilinhas"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\multilin.fir", true);
                        }
                        else if (arquivo.Contains("PainelMultplex2vias"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\mux2vias.fir", true);
                        }
                        else if (arquivo.Contains("PainelMultiplex2x13"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\mux_2x13.fir", true);
                        }
                        else if (arquivo.Contains("PainelMultiplex2x8"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\mux_2x8.fir", true);
                        }
                        else if (arquivo.Contains("PainelPontos"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\painel.fir", true);
                        }
                        else if (arquivo.Contains("ControladorTurbus"))
                        {
                            File.Copy(arquivo, Fachada.diretorio_fir + "\\firmware.fir", true);
                        }
                        File.Delete(arquivo);
                    }
                }
            }
        }
示例#20
0
 private void Completed2(object sender, AsyncCompletedEventArgs e)
 {
     File.Copy(savePath + "/cs_bg_champions.png", savePath + "/login.swf", true);
     //MessageBox.Show("Download completed!");
     this.Hide();
     MessageBox.Show("Download completed." + Environment.NewLine + Environment.NewLine + "To enable music, you may need to click on \"Disable Menu Animations\".", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
示例#21
0
 void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (DownloadFileCompleted != null)
     {
         DownloadFileCompleted.Invoke(this, e);
     }
 }
示例#22
0
 void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error != null&&!e.Cancelled)
     {
         //下载出错
         label2.Text = e.Error.Message;
         CancleBtn.Text = "关闭";
         //File.Delete(Application.StartupPath + "/" + DownloadInfo.FileDirectory + "/" + DownloadInfo.FileName);
     }
     else
     {
         if (!e.Cancelled)
         {
             label2.Text = "下载完成";
             CancleBtn.Text = "关闭";
             Process proc = new Process();
             proc.StartInfo.FileName = Application.StartupPath + "/" + DownloadInfo.FileDirectory + "/" + DownloadInfo.FileName;
             proc.StartInfo.Arguments = "";
             proc.Start();
             if (CloseCheckBox.Checked)
             {
                 this.Close();
             }
         }
         else
         {
             //用户取消了下载
             File.Delete(Application.StartupPath + "/" + DownloadInfo.FileDirectory + "/" + DownloadInfo.FileName);
             this.Close();
         }
     }
 }
 protected virtual void OnTransferCompleted(System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (TransferCompleted != null)
     {
         TransferCompleted(this, e);
     }
 }
 private void Completed(object sender, AsyncCompletedEventArgs e)
 {
     progressBar.Visibility = System.Windows.Visibility.Hidden;
     Feedback.Text = "Download completed";
     Feedback.Visibility = System.Windows.Visibility.Visible;
     Process.Start(downloadedFile);
 }
示例#25
0
 protected virtual void OnLoadCompleted(AsyncCompletedEventArgs e)
 {
     if (LoadCompleted != null)
     {
         LoadCompleted(this, e);
     }
 }
示例#26
0
        private void GetChangeLogCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            if (InvokeRequired)
            {
                AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetChangeLogCompleted);
                Invoke(myDelegate, new object[] { sender, e });
                return;
            }

            try
            {
                _appUpdate.GetChangeLogCompletedEvent -= GetChangeLogCompleted;

                if (e.Cancelled)
                {
                    return;
                }
                if (e.Error != null)
                {
                    throw (e.Error);
                }

                txtChangeLog.Text = _appUpdate.ChangeLog;
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateGetChangeLogFailed, ex);
            }
        }
示例#27
0
        /// <summary>
        /// Callback by the web client class when the download finish (completed or cancelled)
        /// </summary>
        void ClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            Thread.Sleep(1500);     // A short pause for a better visual flow

            inProgress.Set();
            isCompleted = !e.Cancelled;
        }
示例#28
0
 /// MONO completely lacks SmtpClient.SendAsync, so this is a copy -----------------------------------------------------------------------------
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tcs"></param>
 /// <param name="e"></param>
 /// <param name="handler"></param>
 /// <param name="client"></param>
 static void HandleCompletion(TaskCompletionSource<object> tcs, AsyncCompletedEventArgs e, SendCompletedEventHandler handler, SmtpClient client)
 {
     if (e.UserState == tcs)
     {
         try
         {
             client.SendCompleted -= handler;
         }
         finally
         {
             if (e.Error != null)
             {
                 tcs.TrySetException(e.Error);
             }
             else if (!e.Cancelled)
             {
                 tcs.TrySetResult(null);
             }
             else
             {
                 tcs.TrySetCanceled();
             }
         }
     }
 }
 public void OnWriting(System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (Writing != null)
     {
         Writing(this, e);
     }
 }
示例#30
0
 private void ClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     m_downloaded = true;
     if (e.Cancelled)
         m_error = true;
     Program.Frm.SetProgress(100);
 }
 public void OnCompleted(System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (Completed != null)
     {
         Completed(this, e);
     }
 }
 public DecisionArgs Build(AsyncCompletedEventArgs eventArgs)
 {
     return new DecisionArgs
     {
         EventArgsOfWebClient = eventArgs
     };
 }
示例#33
0
 void catalog_DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         MessageBox.Show("Error occured while loading xap file.\n" + e.Error.Message);
     }
 }
示例#34
0
 void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     var file = filesToDownload[filesDownloaded];
     if (e.Error != null)
     {
         hasError = true;
         if (!cancel)
         {
             Log.ErrorException("Error downloading file: " + file.DownloadInfo.FileName, e.Error);
         }
     }
     else if (file.DownloadInfo.Sha1 != CalculateSha1((Path.Combine(file.TempFolder, file.DownloadInfo.FileName))))
     {
         hasError = true;
         Log.Error("Error downloading file (invalid checksum): " + file.DownloadInfo.FileName);
     }
     else
     {
         filesDownloaded++;
     }
     currentFileProgress = 0;
     currentFileSize = 0;
     DisplayProgress();
     StartNextDownload();
 }
示例#35
0
        public void MyDownloadComplete(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            downloadTimer.Stop();

            if (e.Cancelled)
            {
                DoShowMsg("下载超时");
                playerInfo.IsNotDownloading = true;
                File.Delete(downloadingFilePath);
                return;
            }

            var filename = txtTitle.Text + ".mp3";

            if (File.Exists(downloadingFilePath))
            {
                if (new FileInfo(downloadingFilePath).Length > 0)
                {
                    //添加封面
                    AddCoverToMp3(downloadingFilePath);

                    DoShowMsg($"{txtTitle.Text} 下载完成");
                }
                else
                {
                    DoShowMsg("下载失败");
                    File.Delete(downloadingFilePath);
                }
            }
            else
            {
                DoShowMsg("下载失败");
            }
            playerInfo.IsNotDownloading = true;
        }
示例#36
0
 private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (this.OnDownloadCompleted != null)
     {
         this.OnDownloadCompleted(sender, e);
     }
 }
 void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
   if (e.Error != null || e.Cancelled)
   {
     Trace.TraceError("{0} failed {1}", Name, e.Error);
     Finish(false);
   }
   else
   {
     Trace.TraceInformation("{0} Completed - {1}", Name, Utils.PrintByteLength(Length));
     try
     {
       File.Delete(targetFilePath);
     }
     catch {}
     try
     {
       File.Move(tempFilePath, targetFilePath);
     }
     catch
     {
       Trace.TraceError("Error moving file from {0} to {0}", tempFilePath, targetFilePath);
       Finish(false);
       return;
     }
     Finish(true);
   }
 }
示例#38
0
        public void DownloadFileAsync_should_be_callable_indirectly()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var called = false;
                var notCalled = true;
                var handler = default(AsyncCompletedEventHandler);
                handler = (sender, e) => called = true;
                PULWebClient.AddDownloadFileCompletedAsyncCompletedEventHandler().Body = (@this, value) => handler += value;
                PULWebClient.RemoveDownloadFileCompletedAsyncCompletedEventHandler().Body = (@this, value) => handler -= value;
                PULWebClient.DownloadFileAsyncUri().Body = (@this, address) =>
                {
                    var e = new AsyncCompletedEventArgs(null, false, null);
                    handler(@this, e);
                };

                
                // Act
                var client = new ULWebClient();
                client.DownloadFileAsync(new Uri("http://google.co.jp/"));
                client.DownloadFileCompleted += (sender, e) => notCalled = false;

                
                // Assert
                Assert.IsTrue(called);
                Assert.IsTrue(notCalled);
            }
        }
示例#39
0
文件: Form1.cs 项目: zhh007/CKGen
        private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            string rootDir = Path.GetDirectoryName(this.FilePath);
            string unzipFolder = Path.Combine(rootDir, this.NewVersion);
            if (Directory.Exists(unzipFolder))
            {
                Directory.Delete(unzipFolder, true);
            }
            Directory.CreateDirectory(unzipFolder);
            ZipHelp.UnZip(this.FilePath, unzipFolder);

            string sourceFolder = "";
            var files = Directory.EnumerateFiles(unzipFolder, Config.MainExe, SearchOption.AllDirectories);
            if (files != null && files.Count() == 1)
            {
                var targetFileName = files.FirstOrDefault();
                sourceFolder = Path.GetDirectoryName(targetFileName);
            }

            string targetDir = Environment.CurrentDirectory;
            foreach (var process in Process.GetProcessesByName("CKGen"))
            {
                process.Kill();
            }

            RenameAllFile(targetDir);
            //copy 
            ProcessXcopy(sourceFolder, targetDir);

            Process.Start(Path.Combine(Environment.CurrentDirectory, Config.MainExe));

            this.Close();
        }
示例#40
0
        void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            // install updates
            this.BeginInvoke((MethodInvoker)delegate {
                // Start installer & wait for exit
                statusLabel.Text = "Installing update...";
                progressBar1.Value = 0;
                progressBar1.Style = ProgressBarStyle.Marquee;
                ProcessStartInfo procStart = new ProcessStartInfo("msiexec.exe");
                procStart.Arguments = "/i \""+ InstallerPath + "\" /qr";
                Process p = Process.Start(procStart);
                p.WaitForExit();

                // run installed application & close updater
                statusLabel.Text = "Installation complete!";
                progressBar1.Style = ProgressBarStyle.Blocks;
                progressBar1.Value = 100;

                RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Stijn Raeymaekers\\Weather Wallpaper");
                string installedExe = key.GetValue("installDirectory") + "WeatherWallpaper.exe";
                Process.Start(installedExe);

                Thread.Sleep(1500);
                Environment.Exit(0);
            });
        }
示例#41
0
 void proxy_RestartGameCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         state = TicTacToeState.ServiceNotAvailable;
     }
 }
示例#42
0
 void _webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     Audio audio = e.UserState as Audio;
     string filePath = String.Format("{0}.mp3", audio.ToString());
     TagLib.File tagFile = TagLib.File.Create(filePath);
     string artistName = tagFile.Tag.FirstAlbumArtist == null ? "Unknown artist" : tagFile.Tag.FirstAlbumArtist;
     string albumName = tagFile.Tag.Album == null ? "Unknown album" : tagFile.Tag.Album;
     string title = tagFile.Tag.Title == null ? "Unknown title" : tagFile.Tag.Title;
     var artist = _artists.FirstOrDefault(g => g.Name.ToLower() == artistName.ToLower());
     if (artist == null)
     {
         artist = new Artist(artistName);
         _artists.Add(artist);
     }
     var album = artist.Albums.FirstOrDefault(g => g.Name.ToLower() == albumName.ToLower());
     if (album == null)
     {
         album = new Album(albumName);
         artist.Albums.Add(album);
     }
     var song = album.Songs.FirstOrDefault(g => g.Name.ToLower() == title.ToLower());
     if (song == null)
     {
         song = new Song(title, filePath);
         album.Songs.Add(song);
     }
 }
示例#43
0
 private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (splashScreen.Visible)
     {
         splashScreen.ResetProgress();
     }
 }
示例#44
0
        private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            try
            {
                btnDownload.Enabled  = true;
                prgbDownload.Visible = false;

                if (e.Cancelled)
                {
                    return;
                }
                if (e.Error != null)
                {
                    throw (e.Error);
                }

                if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
                {
                    Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath);
                    return;
                }
                else
                {
                    File.Delete(_appUpdate.CurrentUpdateInfo.UpdateFilePath);
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateDownloadCompleteFailed, ex);
            }
        }
示例#45
0
 //Call completed to run DLR, completed2 for non-DLR pkgs.
 public static void Completed(object sender, AsyncCompletedEventArgs e)
 {
     MessageBox.Show("Download completed!", "File complete");//Tell user
     progressBar.Value = 0;// set back to zero so we know it finished, some ppl are dumb
     table.dlrfinished = true;//dl complete?
     Process.Start((Form1.FilePath1) + (Form1.FilePath2));
 }
        private static void smtpClient_SendCompleted(object sender, AsyncCompletedEventArgs e) {
            // Get the message we sent
            MailMessage mailMessage = (MailMessage)e.UserState;
            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;

            if (e.Cancelled) {
                // prompt user with "send cancelled" message 
                mainWindow.showDialogue("Send Error", "Send Cancelled!");
            }
            if (e.Error != null) {
                // prompt user with error message 
                mainWindow.showDialogue("Send Error", e.Error.Message);
                System.Console.WriteLine(e.Error.Message);
            }
            else {
                // prompt user with message sent!
                // as we have the message object we can also display who the message
                // was sent to etc 
                mainWindow.showDialogue("Send Success", "Message Send Successfully!");
            }

            // finally dispose of the message
            if (mailMessage != null) {
                mailMessage.Dispose();
            }
                
        }
示例#47
0
        void webClient_DownloadFileCompletedPatch(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"TheLongDrive\Mods");

            downloadbar.Value = 80;
            downloadperc.Text = "Unzipping...";

            sw.Stop();
            //     MessageBox.Show(this, "Download complete!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

            Ionic.Zip.ZipFile zipFile = new Ionic.Zip.ZipFile(path + "/" + "temp/TLDPatcherNEW.zip");
            zipFile.ZipError        += new EventHandler <Ionic.Zip.ZipErrorEventArgs>(zip_Error);
            zipFile.ExtractProgress += new EventHandler <ExtractProgressEventArgs>(zip_Progress);
            try
            {
                zipFile.ExtractAll(path + "/temp/", ExtractExistingFileAction.OverwriteSilently);
                download.Enabled    = true;
                mymods.Enabled      = true;
                downpatcher.Enabled = true;
                downloadperc.Text   = "Complete!";
                downloadbar.Value   = 100;
                zipFile.Dispose();
                webClient.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Close TLDPatcher!");
            }
            System.IO.File.Copy(path + "/temp/patcher/TLDLoader.dll", Application.StartupPath + "/TLDLoader.dll", true);
            Process.Start(path + "/temp/patcher/TLDPatcher.exe", "\"" + path + "/temp/patcher/" + "\"");
        }
 void Completed(AsyncCompletedEventArgs e)
 {
     _notifier.DownloadEnd();
     if (e.Error != null)
         _error = e.Error;
     _locks[(Uri)e.UserState].Set();
 }
示例#49
0
        void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            MessageBox.Show(text: "File downloaded!");
            progressBar1.Value = 0;
            label1.Text        = "";
            string localVersionFile  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "version.ini");
            string ServerVersionFile = "http://your_site/version.ini"; //VERSION URL PATH

            if (File.Exists(localVersionFile))
            {
                string localVersion  = null;
                string ServerVersion = null;
                using (StreamReader sr = File.OpenText(localVersionFile))
                    localVersion = sr.ReadLine();
                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(ServerVersionFile);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    ServerVersion = reader.ReadToEnd();
                if (!string.IsNullOrWhiteSpace(localVersion))
                {
                    using (StreamWriter sw = new StreamWriter(localVersionFile))
                        sw.Write(ServerVersion);
                }
            }
        }
示例#50
0
 /// <summary>
 /// 提供工作完成事件的通知方法,子类及自身在工作完成后,调用这个方法通知外部工作完成了。
 /// </summary>
 /// <param name="args"></param>
 public void OnCompleted(AsyncCompletedEventArgs args)
 {
     if (Completed != null)
     {
         Completed(this, args);
     }
 }
示例#51
0
文件: Logic.cs 项目: WELL-E/Toxy-WPF
        public void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            OnExtracting();

            try
            {
                using (ZipFile file = ZipFile.Read(_updateFileName))
                {
                    foreach (ZipEntry entry in file)
                    {
                        // TODO
                        //_dialog.Line3 = entry.FileName;
                        entry.Extract(this.Path, ExtractExistingFileAction.OverwriteSilently);
                        _extractedFiles.Add(entry.FileName);
                    }

                    // TODO
                    //_dialog.Line2 = "Verifying signatures";

                    foreach (ZipEntry entry in file)
                    {
                        if (!entry.FileName.EndsWith(".dll") && !entry.FileName.EndsWith(".exe"))
                            continue;

                        // TODO
                        //_dialog.Line3 = entry.FileName;

                        try
                        {
                            string status;
                            if (!VerifyCertificate(X509Certificate.CreateFromSignedFile(entry.FileName).GetRawCertData(), out status))
                            {
                                OnErrorOccurred(entry.FileName + " does not have a valid signature!\n\n" + status);
                                CleanUp(true);
                                break;
                            }
                        }
                        catch (CryptographicException ex)
                        {

                            OnErrorOccurred(string.Format("A cryptographic exception occurred while trying to verify the signature of: {0}\n{1}\n\nThis probably means that this file doesn't have a valid signature!", entry.FileName, ex.Message));
                            CleanUp(true);
                            break;
                        }
                        catch (Exception ex)
                        {
                            OnErrorOccurred(string.Format("An exception occurred while trying to verify the signature of: {0}\n{1}", entry.FileName, ex.Message));
                            CleanUp(true);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                OnErrorOccurred("Could not extract update:\n" + ex.Message);
            }

            OnFinish();
        }
 void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     this.BeginInvoke((MethodInvoker)delegate
     {
         frmUpdateTool._IsStop = true;
     });
 }
示例#53
0
 public void download_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
     XmlDocument current = new XmlDocument();
        	current.Load(Environment.CurrentDirectory + @"\Info.xml");
        	XmlNodeList pro = current.GetElementsByTagName("ProgramName");
     XmlNodeList update = current.GetElementsByTagName("updatexml");
     string prog = pro[0].InnerText;
        	string updateurl = update[0].InnerText;
        	XmlDocument updater = new XmlDocument();
        	updater.Load(updateurl);
        	XmlNodeList load = updater.GetElementsByTagName("InstallerNAME");
        	string installer = load[0].InnerText;
     if (bytesIn == totalBytes)
     {
         MessageBox.Show("Update has been downloaded sucessfully. Please Close all instances of " + prog + " while update is in session.", "Update Complete");
         System.Diagnostics.Process.Start(path + @"\" + installer);
     }
     else if (bytesIn != totalBytes)
     {
         MessageBox.Show("Update Canceled", "!WARNING!");
         System.IO.File.Delete(path + @"\" + installer);
     }
     Application.Exit();
 }
示例#54
0
 void mSmtpClient_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (OnSendCompelte != null)
     {
         OnSendCompelte(sender, e);
     }
     //throw new NotImplementedException();
 }
示例#55
0
        private void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            // Temporary zip path.
            var tSSZip = Path.Combine(temp, "SSTool.zip");

            // Create a background worker.
            bw = new BackgroundWorker()
            {
                WorkerReportsProgress = true
            };

            // Reset the download progress.
            DownloadProgress.Value = 0;
            // Add the work loop.
            bw.DoWork += UnzipWorker;
            // Add the progress changed listener.
            bw.ProgressChanged += (s, _e) => Dispatcher.Invoke(() => DownloadProgress.Value = _e.ProgressPercentage);

            try
            {
                // Close if it's running.
                var ss = Process.GetProcessesByName("FFXIVTool")[0];
                // Close the mainwindow shutting down the process.
                ss.CloseMainWindow();
                // Try to wait for it to shut down gracefully.
                if (!ss.WaitForExit(10000))
                {
                    // Kill the process.
                    ss.Kill();
                }
            }
            catch (Exception) { }

            // Temporary name.
            var tempName = ".SSTU.old";

            // Rename the updater file to allow for overwrite.
            if (File.Exists(Path.Combine(Environment.CurrentDirectory, tempName)))
            {
                File.Delete(Path.Combine(Environment.CurrentDirectory, tempName));
            }
            File.Move(Path.Combine(Environment.CurrentDirectory, "SSToolUpdater.exe"), Path.Combine(Environment.CurrentDirectory, tempName));

            // Run the worker.
            bw.RunWorkerAsync(tSSZip);

            bw.RunWorkerCompleted += (_, __) =>
            {
                // Start the tool.
                Process.Start(Path.Combine(Environment.CurrentDirectory, "FFXIVTool.exe"));

                // Dispose of the worker.
                bw.Dispose();

                // Shutdown the application we're done here.
                Close();
            };
        }
 void client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     this.IsDownloading = false;
     this.Speed         = 0;
     if (!e.Cancelled)
     {
         this.IsCompleted = true;
     }
 }
 private void Player_LoadCompleted(
     object sender,
     System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (this.Player.IsLoadCompleted)
     {
         this.Player.PlaySync();
     }
 }
示例#58
0
        void webClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            downloadbar.Value = 100;
            downloadperc.Text = "Complete!";

            sw.Stop();
            download.Enabled = true;
            mymods.Enabled   = true;
        }
示例#59
0
        private void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            // System.Diagnostics.Process.Start(FileName);

            //another window comes out : update complete, launch the new version now?
            tB1.Text = "Finished!";

            //enable the OK btn
            okbtn.IsEnabled = true;
        }
示例#60
0
        void m_Web_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            DownloadItem item = (DownloadItem)e.UserState;

            InfoString = "Download beendet: " + item.FileName;

            //m_IsDownloading = false;
            ProcessPercentage = 100;
            NextDownload();
        }