示例#1
0
        private async Task <byte[]> CreateZip(IEnumerable <VouchersClient> vouchers)
        {
            var zippedMemoryStream = UnistreamReuse.Create();

            using (ZipOutputStream zipOutputStream = new ZipOutputStream(zippedMemoryStream))
            {
                // Highest compression rating
                zipOutputStream.SetLevel(9);
                busyIndicator.IsBusy = true;

                foreach (var voucher in vouchers)
                {
                    zippedMemoryStream.SecureSize();
                    if (voucher._Data == null)
                    {
                        await UtilDisplay.GetData(voucher, api);
                    }
                    byte[] attachment = voucher.Buffer;
                    zippedMemoryStream.SecureSize(attachment.Length);
                    // Write the data to the ZIP file
                    string name = string.Format("{0}_{1}.{2}", voucher.Text, voucher.RowId, Enum.GetName(typeof(FileextensionsTypes), voucher.Fileextension));
                    name = name.Replace("/", "-").Replace(@"\", "-");
                    ZipEntry entry = new ZipEntry(name);
                    zipOutputStream.PutNextEntry(entry);
                    zipOutputStream.Write(attachment, 0, attachment.Length);
                }
                busyIndicator.IsBusy = false;

                zipOutputStream.Finish();
            }
            return(zippedMemoryStream.ToArrayAndRelease());
        }
示例#2
0
        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();
            }
        }
示例#4
0
 async void View(VouchersClient selectedItem)
 {
     if (selectedItem._Data == null)
     {
         busyIndicator.IsBusy = true;
         await UtilDisplay.GetData(selectedItem, api);
     }
     ViewVoucher(TabControls.VouchersPage3, dgAttachedVoucherGrid.syncEntity);
     busyIndicator.IsBusy = false;
 }
 private async Task CreateZip(IEnumerable <VouchersClient> vouchers, Stream outputStream)
 {
     using (ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream))
     {
         // Highest compression rating
         zipOutputStream.SetLevel(9);
         zipOutputStream.UseZip64 = UseZip64.Dynamic;
         foreach (var voucher in vouchers)
         {
             if (!voucher._Envelope)
             {
                 if (voucher._Data == null)
                 {
                     await UtilDisplay.GetData(voucher, api);
                 }
                 ExportFile(voucher, zipOutputStream);
             }
         }
         zipOutputStream.Finish();
     }
 }
示例#6
0
        async void MoveToVoucherAtIndex(int index, bool setFocus = false)
        {
            if (index < 0 || envelopes == null || index > envelopes.Length - 1)
            {
                return;
            }
            btnPrev.IsEnabled = btnNext.IsEnabled = true;
            if (selectedIndex == 0)
            {
                btnPrev.IsEnabled = false;
            }
            if (selectedIndex == envelopes.Length - 1)
            {
                btnNext.IsEnabled = false;
            }
            this.documentViewer.Children.Clear();
            currentBlk.Text = NumberConvert.ToString(index + 1);

            try
            {
                VouchersClient vClient = envelopes[selectedIndex];
                if (vClient._Data != null)
                {
                    VoucherCache.SetGlobalVoucherCache(vClient);
                }
                else
                {
                    await UtilDisplay.GetData(vClient, api);
                }

                this.documentViewer.Children.Add(UtilDisplay.LoadControl(vClient, false, setFocus));
            }
            catch (Exception ex)
            {
                brdMetaInfo.Visibility = System.Windows.Visibility.Visible;
                this.documentViewer.Children.Add((UtilDisplay.LoadDefaultControl(string.Format("{0}. \n{1} : {2}", Uniconta.ClientTools.Localization.lookup("InvalidDocSave"),
                                                                                               Uniconta.ClientTools.Localization.lookup("ViewerFailed"), ex.Message))));
            }
            SetMetaInfo(voucherClient);
        }
示例#7
0
        private void btnAttach_Click(object sender, RoutedEventArgs e)
        {
            CWAttachVouchers attachVouchersDialog = new CWAttachVouchers(api);

            attachVouchersDialog.Closing += async delegate
            {
                if (attachVouchersDialog.DialogResult == true)
                {
                    if (attachVouchersDialog.Voucher != null)
                    {
                        voucherClient = attachVouchersDialog.Voucher;
                        if (voucherClient._Data == null)
                        {
                            await UtilDisplay.GetData(voucherClient, api);
                        }
                        this.txtAttachedFile.Text         = voucherClient.Text;
                        this.txtAttachedFile.TextWrapping = TextWrapping.Wrap;
                    }
                }
            };
            attachVouchersDialog.Show();
        }
示例#8
0
        async private void _LoadInitMaster(UnicontaBaseEntity corasauMaster, VouchersClient voucherClient, int RowId, bool setFocus)
        {
            try
            {
                if (voucherClient == null)
                {
                    if (RowId != 0)
                    {
                        voucherClient = new VouchersClient();
                        voucherClient.SelectRowId(RowId);
                        // we will now enter api.read
                    }
                    else
                    {
                        busyIndicator.IsBusy = true;
                        var voucher = await api.Query <VouchersClient>(corasauMaster);

                        voucherClient = voucher?.FirstOrDefault();
                        if (voucherClient?._Data != null)
                        {
                            VoucherCache.SetGlobalVoucherCache(voucherClient);
                        }
                    }
                }

                if (voucherClient._Data == null)
                {
                    busyIndicator.IsBusy = true;
                    var result = await UtilDisplay.GetData(voucherClient, api);

                    if (result != 0)
                    {
                        busyIndicator.IsBusy = false;
                        UtilDisplay.ShowErrorCode(result);
                        return;
                    }
                }

                this.documentViewer.Children.Clear();

                brdMetaInfo.Visibility = Visibility.Visible;
                if (voucherClient._Envelope)
                {
                    btnPrev.IsEnabled    = false;
                    busyIndicator.IsBusy = true;
                    var dapi = new DocumentAPI(api);
                    envelopes = (VouchersClient[])await dapi.GetEnvelopeContent(voucherClient, true);

                    gridPrevNext.Visibility = Visibility.Visible;
                    if (envelopes != null && envelopes.Length > 0)
                    {
                        totalBlk.Text = NumberConvert.ToString(envelopes.Length);
                        MoveToVoucherAtIndex(selectedIndex, setFocus);

                        /*
                         * currentBlk.Text = NumberConvert.ToString(selectedIndex + 1);
                         * var doc = envelopes[selectedIndex];
                         * this.documentViewer.Children.Add(UtilDisplay.LoadControl(doc.Buffer, doc._Fileextension, false, setFocus));
                         */
                    }
                    else
                    {
                        totalBlk.Text   = "0";
                        currentBlk.Text = "0";
                    }
                    busyIndicator.IsBusy = false;
                }
                else
                {
                    busyIndicator.IsBusy = false;
                    this.documentViewer.Children.Add(UtilDisplay.LoadControl(voucherClient, false, setFocus));
                }
            }
            catch (Exception ex)
            {
                brdMetaInfo.Visibility = Visibility.Visible;
                this.documentViewer.Children.Add((UtilDisplay.LoadDefaultControl(string.Format("{0}. {1} : {2}", Uniconta.ClientTools.Localization.lookup("InvalidDocSave"),
                                                                                               Uniconta.ClientTools.Localization.lookup("ViewerFailed"), ex.Message))));
                busyIndicator.IsBusy = false;
            }
            SetMetaInfo(voucherClient);
        }