private void Signin_Get_Picture(object sender, LiveDownloadCompletedEventArgs e) { client.DownloadCompleted -= Signin_Get_Picture; if (e.Result != null) { try { ProfilePicture.Visibility = Visibility.Visible; BitmapImage imgSource = new BitmapImage(); imgSource.SetSource(e.Result); ProfilePicture.Source = imgSource; e.Result.Close(); } catch (Exception ex) { MessageBox.Show("Une erreur est survenue."); FlurryWP7SDK.Api.LogError(DateTime.Now.Hour.ToString("00") + "h" + DateTime.Now.Minute.ToString("00") + ": Skydrive Signin_Get_Picture: " + ex.Message.ToString(), ex); FlurryWP7SDK.Api.LogError(ex.StackTrace.ToString(), ex); } } else { MessageBox.Show("Erreur image profil: " + e.Error.ToString()); } }
void Folder_Download_Completed(object sender, LiveDownloadCompletedEventArgs e) { wait_async = false; if (progress_list.Average() == 100) { client.DownloadCompleted -= Folder_Download_Completed; SystemTray.ProgressIndicator.IsVisible = false; //MessageBox.Show("Tous les fichiers ont été téléchargés."); } if (e.Error == null) // enregistre le fichier { using (StreamReader reader = new StreamReader(e.Result)) { string curr_file = list_files_skydrive.ElementAt((int)e.UserState).Name.ToString(); string curr_content = reader.ReadToEnd(); using (IsolatedStorageFileStream fileStream = My_Isolated_Storage.OpenFile("GPX\\" + curr_file, FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter writer = new StreamWriter(fileStream)) { writer.Write(curr_content); writer.Close(); } fileStream.Close(); } } } else { MessageBox.Show("Erreur téléchargement de fichier: " + e.Error.ToString()); } }
private void _clientFolder_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Result == null) { return; } LoadingText = "Decrypting..."; using (IsolatedStorageFile myFile = IsolatedStorageFile.GetUserStoreForApplication()) { if (myFile.FileExists(_selectedWalletFile.FileName)) { myFile.DeleteFile(_selectedWalletFile.FileName); } using (IsolatedStorageFileStream myFileStream = new IsolatedStorageFileStream(_selectedWalletFile.FileName, FileMode.CreateNew, myFile)) { e.Result.CopyTo(myFileStream); myFileStream.Close(); App.MyWallet = CloudWallet.ViewModels.WalletVM.FromFile(_selectedWalletFile.FileName, _password); if (App.MyWallet != null) { App.MyWalletFile = _selectedWalletFile; App.MyWallet.Password = _password; if (OnWalletSelected != null) { OnWalletSelected(this, null); } } } } IsProgressing = false; }
void File_Download_Completed(object sender, LiveDownloadCompletedEventArgs e) { wait_async = false; client.DownloadCompleted -= File_Download_Completed; if (e.Result != null) { using (StreamReader reader = new StreamReader(e.Result)) { string curr_file = e.UserState.ToString(); string curr_content = reader.ReadToEnd(); using (IsolatedStorageFileStream fileStream = My_Isolated_Storage.OpenFile("GPX\\" + curr_file, FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter writer = new StreamWriter(fileStream)) { writer.Write(curr_content); writer.Close(); SystemTray.ProgressIndicator.IsVisible = false; //MessageBox.Show("Le fichier " + curr_file + " à été téléchargé"); } fileStream.Close(); } } } else { MessageBox.Show("Erreur téléchargement de fichier: " + e.Error.ToString()); } }
void merge_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { infoTextBlock3.Text = "Downloading..."; try { using (MemoryStream stream = e.Result as MemoryStream) { // stream = e.Result as MemoryStream; using (StreamReader reader = new StreamReader(stream)) { if (MessageBox.Show(txtnote.Resources.StringLibrary.download_1, "Alert!", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { downloadMerge(reader); } } } if (k != -1 && k == s_number - 1) { //infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2; infoTextBlock3.Text = txtnote.Resources.StringLibrary.download_2; // client.DownloadCompleted -= client_DownloadCompleted; client.DownloadCompleted -= merge_DownloadCompleted; } else { pickMaxMerge(); } } catch (Exception exc) { // MessageBox.Show(exc.Message); MessageBox.Show("Click so frequent!Now restart the Page"); //NavigationService.GoBack(); string uri = String.Format("/txtnote;component/share.xaml"); NavigationService.Navigate(new Uri(uri, UriKind.Relative)); shareManager.SelectedIndex = 2; } } else { MessageBox.Show("Unable to download Backup file.", "Failure", MessageBoxButton.OK); } }
/// <summary> /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#downloading_files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnDownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Result != null) { //imageFrame.Visibility = Visibility.Visible; //BitmapImage imgSource = new BitmapImage(); //imgSource.SetSource(e.Result); //// imageFrame is a user-defined Image control. //imageFrame.Source = imgSource; //e.Result.Close(); StreamReader sr = new StreamReader(e.Result); Debug.WriteLine(sr.ReadToEnd()); } else { Debug.WriteLine("Error downloading image: " + e.Error.ToString()); } }
/// <summary> /// Event handler called when a download operation is completed. /// </summary> /// <param name="sender">The object that fires the event.</param> /// <param name="e">The event arg containing the result of the download operation.</param> private static void OnDownloadOperationCompleted(object sender, LiveDownloadCompletedEventArgs e) { var state = e.UserState as OperationState <Stream>; if (state != null) { UnSubscribe(state.LiveClient, ApiMethod.Download); var tcs = state.Tcs; if (e.Error != null) { tcs.TrySetException(e.Error); } else { tcs.TrySetResult(e.Result); } } }
private void downloadNote_Callback(object sender, LiveDownloadCompletedEventArgs e) { client.DownloadCompleted -= downloadNote_Callback; if (e.Error == null) { // Get the stream with the downloaded file var memoryStream = e.Result as MemoryStream; // Cursor is at the end of the stream so we need to rewind memoryStream.Seek(0, SeekOrigin.Begin); // Read stream into a byte array byte[] bytes = new byte[1000]; int numbytes = memoryStream.Read(bytes, 0, (int)memoryStream.Length); // Prevent loading textbox from firing a text change event notesEditor.TextChanged -= notesEditor_TextChanged; // Load text into the TextBox decoding it as UTF8 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); notesEditor.Text = enc.GetString(bytes, 0, numbytes); // Enable editing note content notesEditor.IsReadOnly = false; // Set Save status to false needToSave = false; deleteNoteBtn.IsEnabled = true; saveBtn.IsEnabled = false; cancelBtn.IsEnabled = false; // Enable detecting changes notesEditor.TextChanged += notesEditor_TextChanged; statusTxt.Text = "Downloaded note (" + numbytes + " bytes)"; } else { statusTxt.Text = e.Error.Message; } }
void downloadClient_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { MemoryStream outputStream = (MemoryStream)e.Result; // Create a filename for JPEG file in isolated storage. String tempJPEG = SelectedPhoto.Title; // Create virtual store and file stream. Check for duplicate tempJPEG files. var myStore = IsolatedStorageFile.GetUserStoreForApplication(); if (myStore.FileExists(tempJPEG)) { myStore.DeleteFile(tempJPEG); } IsolatedStorageFileStream myFileStream = myStore.CreateFile(tempJPEG); myFileStream.Write(outputStream.GetBuffer(), 0, (int)outputStream.Length); myFileStream.Close(); } }
public static void ConnectClient_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null && !e.Cancelled) { var fileName = (string)e.UserState; try { File.WriteAllBytes(fileName, ((MemoryStream)e.Result).ToArray()); } catch (Exception x) { MessageBox.Show(x.Message); } } else { Console.WriteLine(e); } Console.WriteLine("BOOM! Download completed."); }
void client_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { infoTextBlock2.Text = "Downloading..."; try { using (MemoryStream stream = e.Result as MemoryStream) { //stream = e.Result as MemoryStream; using (var reader = new StreamReader(stream)) { txtfile = reader.ReadToEnd(); if (App.ViewModel.displayItem(itemname) == null) { ToDoItem newToDoItem = new ToDoItem { //txtnote需更改 ItemName = itemname, Category = App.ViewModel.CategoriesList.First(), CreatTime = DateTime.Now, EditTime = DateTime.Now, TxtFile = txtfile }; App.ViewModel.AddToDoItem(newToDoItem); } else { ToDoItem toUpdate = App.ViewModel.displayItem(itemname); toUpdate.TxtFile = txtfile; toUpdate.EditTime = DateTime.Now; App.ViewModel.SaveChangesToDB(); } } } //如果有所选中,并且选中的就是当前处理的 if (k != -1 && k == s_number - 1) { //infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2; infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2; // client.DownloadCompleted -= client_DownloadCompleted; client.DownloadCompleted -= client_DownloadCompleted; } else { pickMax(); } } catch (Exception exc) { // MessageBox.Show(exc.Message); MessageBox.Show("Click so frequent!Now restart the Page"); //NavigationService.GoBack(); string uri = String.Format("/txtnote;component/share.xaml"); NavigationService.Navigate(new Uri(uri, UriKind.Relative)); shareManager.SelectedIndex = 1; } } else { MessageBox.Show("Unable to download Backup file.", "Failure", MessageBoxButton.OK); } }
private void ClientOnDownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { ParseFileContent(e.Result); } else { App.ShowMessage("There was an error getting the file"); } }
private void client_DownloadCompletedFile3(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { MemoryStream stream = (MemoryStream)e.Result; stream.Position = 0; XDocument xDoc = XDocument.Load(stream); Dal.File3Dal.PutFile(xDoc); } else { MessageBox.Show("Unable to Restore files", "Error", MessageBoxButton.OK); } }
private void LiveConnector_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { System.Action action = null; System.Action action2 = null; this.LiveConnector.DownloadCompleted -= new System.EventHandler<LiveDownloadCompletedEventArgs>(this.LiveConnector_DownloadCompleted); if (e.Error == null) { if (action == null) { action = delegate { this.datatransferingStep.Success(); this.dataCheckingStep.Start(); }; } this.StatusUpdatingCallBack(action); try { System.IO.MemoryStream result = e.Result as System.IO.MemoryStream; if (result == null) { if (action2 == null) { action2 = delegate { this.OnSyncingFinished(System.EventArgs.Empty); this.dataCheckingStep.Success(); }; } this.StatusUpdatingCallBack(action2); } else { this.ProcessRestoreData(result); } } catch (System.Exception exception) { this.OnReportingStatus(new ReportStatusHandlerEventArgs("RestoreDataFromSkyDriveFailedMessage", exception.Message)); AppUpdater.AddErrorLog("RestoreDataFromSkyDriveFailedMessage", exception.ToString(), new string[0]); } } else { this.StatusUpdatingCallBack(new System.Action(this.datatransferingStep.Failed)); this.OnReportingStatus(new ReportStatusHandlerEventArgs("DownloadDataFromSkyDriveFailedMessage", e.Error.Message)); } this.OnSyncingFinished(System.EventArgs.Empty); }
void OnFileDownloadComplete(object sender, LiveDownloadCompletedEventArgs e) { this.progressIndicator.IsVisible = false; // read in result stream and put string onto page's input if (e.Result != null) { long length = e.Result.Length; byte[] data = new byte[length]; e.Result.Read(data, 0, (int)length); this.content = Encoding.UTF8.GetString(data, 0, (int)length); this.contentInput.Text = this.content; e.Result.Close(); } this.contentInput.IsEnabled = true; }
private void client_DownloadCompleted(object obj, LiveDownloadCompletedEventArgs e) { busyIndicator.IsRunning = false; btnSignIn.IsEnabled = true; btnSave.IsEnabled = true; btnRestore.IsEnabled = true; Stream stream = e.Result; ObservableCollection<Profile> res = Helpers.DataContractDeserialize<ObservableCollection<Profile>>(stream); stream.Flush(); stream.Close(); if (res != null && res.Count != 0) { App.ProfilesManager.Items.Clear(); string[] names = (from p in res select p.Name).ToArray(); log.Add(new LogMessage(Labels.RestoreCompleted, string.Join("\n", names))); foreach (Profile p in res) App.ProfilesManager.Items.Add(p); } else log.Add(new LogMessage(Labels.NoData, Labels.NoProfilesInBackup, true)); }
public static void ConnectClient_GetQuotaCompleted(object sender, LiveDownloadCompletedEventArgs e) { Console.WriteLine(e.ToString()); }
void client_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { infoTextBlock2.Text = "Downloading..."; try { using (MemoryStream stream = e.Result as MemoryStream) { //stream = e.Result as MemoryStream; using (var reader = new StreamReader(stream)) { txtfile = reader.ReadToEnd(); if (App.ViewModel.displayItem(itemname) == null) { ToDoItem newToDoItem = new ToDoItem { //txtnote需更改 ItemName = itemname, Category = App.ViewModel.CategoriesList.First(), CreatTime = DateTime.Now, EditTime = DateTime.Now, TxtFile = txtfile }; App.ViewModel.AddToDoItem(newToDoItem); } else { ToDoItem toUpdate = App.ViewModel.displayItem(itemname); toUpdate.TxtFile = txtfile; toUpdate.EditTime = DateTime.Now; App.ViewModel.SaveChangesToDB(); } } } //如果有所选中,并且选中的就是当前处理的 if (k != -1 && k == s_number - 1) { //infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2; infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2; // client.DownloadCompleted -= client_DownloadCompleted; client.DownloadCompleted -= client_DownloadCompleted; } else pickMax(); } catch (Exception exc) { // MessageBox.Show(exc.Message); MessageBox.Show("Click so frequent!Now restart the Page"); //NavigationService.GoBack(); string uri = String.Format("/txtnote;component/share.xaml"); NavigationService.Navigate(new Uri(uri, UriKind.Relative)); shareManager.SelectedIndex = 1; } } else { MessageBox.Show("Unable to download Backup file.", "Failure", MessageBoxButton.OK); } }
void merge_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { infoTextBlock3.Text = "Downloading..."; try { using (MemoryStream stream = e.Result as MemoryStream) { // stream = e.Result as MemoryStream; using (StreamReader reader = new StreamReader(stream)) { if (MessageBox.Show(txtnote.Resources.StringLibrary.download_1, "Alert!", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { downloadMerge(reader); } } } if (k != -1 && k == s_number - 1) { //infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2; infoTextBlock3.Text = txtnote.Resources.StringLibrary.download_2; // client.DownloadCompleted -= client_DownloadCompleted; client.DownloadCompleted -= merge_DownloadCompleted; } else pickMaxMerge(); } catch (Exception exc) { // MessageBox.Show(exc.Message); MessageBox.Show("Click so frequent!Now restart the Page"); //NavigationService.GoBack(); string uri = String.Format("/txtnote;component/share.xaml"); NavigationService.Navigate(new Uri(uri, UriKind.Relative)); shareManager.SelectedIndex = 2; } } else { MessageBox.Show("Unable to download Backup file.", "Failure", MessageBoxButton.OK); } }
//download completo void client_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Error == null) { try { Stream stream = e.Result; using (isf) { using (IsolatedStorageFileStream filetosave = isf.OpenFile("/shared/transfers/" + fileName, FileMode.Create, FileAccess.ReadWrite)) { stream.CopyTo(filetosave); stream.Flush(); if (isf.FileExists("/shared/transfers/" + fileName)) { stream.Close(); animaProgressBar(false); txtbStatus.Text = "Download completo."; base.NavigationService.RemoveBackEntry(); //volta para a página de atividade string destino = "/atividadePage.xaml?nomeArquivo=" + fileName + "&id=" + idTarefa + "&idCurso=" + idCurso; this.NavigationService.Navigate(new Uri(destino, UriKind.Relative)); } else { animaProgressBar(false); txtbStatus.Text = "Não achamos o arquivo, tente novamente!"; //MessageBox.Show("Arquivo não encontrado no armazenamento interno."); } } } } catch (Exception) { animaProgressBar(false); MessageBox.Show("Não conseguimos realizar o download, tente novamente!"); } } else { animaProgressBar(false); txtbStatus.Text = "Opa, isso não era para ter acontecido, tente novamente!"; } }
void ClientDownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Result != null) { var loadedItems = new List <ListItem>(10); var forDelete = new List <ListItem>(10); var parrentItem = (ListItem)e.UserState; //parrentItem.Items.Clear(); var sr = new StreamReader(e.Result); string text = sr.ReadToEnd(); e.Result.Close(); //parrentItem.Items = new ObservableCollection<ListItem>(); string[] itemsArray = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); bool isMark = true; var numItem = itemsArray.Length > 3 && CommonUtil.IsTrial() ? 3 : itemsArray.Length; for (int index = 0; index < numItem; index++) { var task = itemsArray[index]; bool childMark = false; if (task[0] == '-') { childMark = true; task = task.Substring(1); } else { isMark = false; } var item = parrentItem.FindItem(task) ?? parrentItem.Add(task, true); item.Mark = childMark; item.Deleted = false; loadedItems.Add(item); } forDelete.AddRange(parrentItem.Items.Where(item => !loadedItems.Contains(item) && item.ModifyTime <= item.LastSyncTime)); foreach (var item in forDelete) { parrentItem.Delete(item); } if (parrentItem.Items.Count > 0) { parrentItem.Mark = isMark; } } else if (e.Error != null) { OnError(e.Error.Message); } _downloadCounter--; if (_downloadCounter <= 0) { //Save(); OnDownloadComplited(EventArgs.Empty); } }
private void OnLiveClientDownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { // Sync Step 5. The file has been downloaded as a memory stream. // Write it to its direct location. // (This runs on the emulator and on devices where the background // download method failed.) int filesLeft; string dlFilename; string originalFilename; PreProcessDownload(e, out filesLeft, out dlFilename, out originalFilename); string filepath = GetIsoStorePath(dlFilename); if (e.Result != null) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { // Makes sure the directory exists. isf.CreateDirectory(IsoStoreCartridgesPath); // Creates a file at the right place. using (IsolatedStorageFileStream fs = isf.OpenFile(filepath, FileMode.Create)) { e.Result.CopyTo(fs); } } } PostProcessDownload(filepath, filesLeft); }
void OnDownloadCompleted(object sender, LiveDownloadCompletedEventArgs e) { if (e.Result != null) { //imageFrame.Visibility = Visibility.Visible; //BitmapImage imgSource = new BitmapImage(); //imgSource.SetSource(e.Result); // imageFrame is a user-defined Image control. //imageFrame.Source = imgSource; e.Result.Close(); } else { MessageBox.Show("Error downloading image: " + e.Error.ToString()); } }
private void getUserPicture_Callback(object sender, LiveDownloadCompletedEventArgs e) { this.LiveConnector.DownloadCompleted -= new System.EventHandler<LiveDownloadCompletedEventArgs>(this.getUserPicture_Callback); if (e.Error == null) { System.IO.MemoryStream userState = e.UserState as System.IO.MemoryStream; if (userState != null) { new BitmapImage().SetSource(userState); } else { this.OnLiveConnectorSyncingObjectFailed(new LiveConnectorSyncHandlerEventArgs(LiveConnectorSyncObject.UserPicture, null, "Could not find user's picture")); } } else { this.OnLiveConnectorSyncingObjectFailed(new LiveConnectorSyncHandlerEventArgs(LiveConnectorSyncObject.UserPicture, e.Error, "Could not find user's picture")); } this.getUserName(); }