async private void DataControl_CurrentItemChanged(object sender, DevExpress.Xpf.Grid.CurrentItemChangedEventArgs e) { var selectedVoucherClient = e.NewItem as VouchersClient; if (selectedVoucherClient != null) { busyIndicator.IsBusy = true; try { if (selectedVoucherClient._Data == null) { await UtilDisplay.GetData(selectedVoucherClient, api); } if (selectedVoucherClient._Fileextension != FileextensionsTypes.DIR) { voucherViewer.HasMultipleVouchers = false; voucherViewer.Vouchers = new VouchersClient[] { selectedVoucherClient }; } else { var dapi = new Uniconta.API.GeneralLedger.DocumentAPI(api); voucherViewer.HasMultipleVouchers = true; voucherViewer.Vouchers = (VouchersClient[])await dapi.GetEnvelopeContent(selectedVoucherClient, true); } } catch (Exception ex) { UnicontaMessageBox.Show(ex); } finally { busyIndicator.IsBusy = false; } } }
private async Task CreateZip(IEnumerable <GLTransClient> glTransLst, Stream outputStream) { var voucherExpLst = new HashSet <int>(); var docApi = new Uniconta.API.GeneralLedger.DocumentAPI(api); using (ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) { // Highest compression rating zipOutputStream.SetLevel(9); zipOutputStream.UseZip64 = UseZip64.Dynamic; foreach (var glTrans in glTransLst) { if (!voucherExpLst.Contains(glTrans._DocumentRef)) { voucherExpLst.Add(glTrans._DocumentRef); var voucher = new VouchersClient() { RowId = glTrans._DocumentRef }; if (await UtilDisplay.GetData(voucher, api) == ErrorCodes.Succes) { if (!voucher._Envelope) { ExportFile(voucher, zipOutputStream); } else { var content = voucher.GetEnvelopeContent(); if (content != null) { foreach (var vou in content) { if (!voucherExpLst.Contains(vou.RowId)) { voucherExpLst.Add(vou.RowId); voucher = new VouchersClient() { RowId = vou.RowId }; if (await UtilDisplay.GetData(voucher, api) == ErrorCodes.Succes) { if (!voucher._Envelope) { ExportFile(voucher, zipOutputStream); } } } } } } } } } zipOutputStream.Finish(); } }