private async Task <bool> ZFetchToStream(cUID pUID, cSection pSection, eDecodingRequired pDecoding, string pTitle, Stream pStream) { frmProgress lProgress = null; try { lProgress = new frmProgress(pTitle); ZChildAdd(lProgress); await mClient.SelectedMailbox.UIDFetchAsync(pUID, pSection, pDecoding, pStream, new cBodyFetchConfiguration(lProgress.CancellationToken, lProgress.Increment)); return(true); } catch (OperationCanceledException) { } catch (Exception ex) { if (!IsDisposed) { MessageBox.Show(this, $"problem when fetching\n{ex}"); } } finally { if (lProgress != null) { lProgress.Complete(); } } return(false); }
private async void dgv_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { var lData = dgv.Rows[e.RowIndex].DataBoundItem as cGridRowData; if (lData == null) { return; } cAttachment lAttachment = lData.Attachment; var lSaveFileDialog = new SaveFileDialog(); lSaveFileDialog.FileName = lAttachment.FileName ?? lAttachment.Part.Section.Part + "." + lAttachment.Part.SubType; if (lSaveFileDialog.ShowDialog() != DialogResult.OK) { return; } frmProgress lProgress = null; try { int lSize = lAttachment.SaveSizeInBytes(); lProgress = new frmProgress("saving " + lSaveFileDialog.FileName, lSize); ZDownloadAdd(lProgress); await lAttachment.SaveAsAsync(lSaveFileDialog.FileName, new cBodyFetchConfiguration(lProgress.CancellationToken, lProgress.Increment)); } catch (OperationCanceledException) { } catch (Exception ex) { if (!IsDisposed) { MessageBox.Show(this, $"problem when saving '{lSaveFileDialog.FileName}'\n{ex}"); } } finally { if (lProgress != null) { lProgress.Complete(); } } }
private async void ZDownloadRaw(cSection pSection, int pSize) { var lSaveFileDialog = new SaveFileDialog(); lSaveFileDialog.FileName = ZDownloadFileName(pSection) + ".txt"; if (lSaveFileDialog.ShowDialog() != DialogResult.OK) { return; } frmProgress lProgress = null; try { lProgress = new frmProgress("saving " + lSaveFileDialog.FileName, pSize); ZDownloadAdd(lProgress); using (FileStream lStream = new FileStream(lSaveFileDialog.FileName, FileMode.Create)) { await mMessage.FetchAsync(pSection, eDecodingRequired.none, lStream, new cBodyFetchConfiguration(lProgress.CancellationToken, lProgress.Increment)); } } catch (OperationCanceledException) { } catch (Exception ex) { if (!IsDisposed) { MessageBox.Show(this, $"problem when saving '{lSaveFileDialog.FileName}'\n{ex}"); } } finally { if (lProgress != null) { lProgress.Complete(); } } }