Exemple #1
0
        protected override async void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.Cursor = Cursors.WaitCursor;

            try
            {
                _docTypes = await DokuFlexService.GetDocumentaryTypesAsync(_ticket);

                cbxDocumentaryTypes.DataSource = new BindingList <Documentary>(_docTypes);

                if (!String.IsNullOrWhiteSpace(_fileId))
                {
                    var docMetadata = await DokuFlexService.GetDocumentMetadadaAsync(_ticket, _fileId);

                    var targetDocType = _docTypes.FirstOrDefault(d => d.id.Equals(docMetadata.docType));

                    if (targetDocType == null)
                    {
                        return;
                    }

                    targetDocType.elements.Clear();
                    targetDocType.elements.AddRange(docMetadata.elements);

                    cbxDocumentaryTypes.SelectedValue = docMetadata.docType;
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemple #2
0
        public async Task <bool> GetDocumentaryTypes()
        {
            try
            {
                _docTypes = await DokuFlexService.GetDocumentaryTypesAsync(Token);
            }
            catch (Exception ex)
            {
                _log.Error($"'GetDocumentaryTypesAsync' call fails", ex);
                return(false);
            }

            return(_docTypes.Count > 0);
        }
Exemple #3
0
        //protected override void OnLoad(EventArgs e)
        //{
        //    base.OnLoad(e);

        //    DisplayScanners();
        //    DisplayFileTypes();

        //    this.Cursor = Cursors.WaitCursor;

        //    try
        //    {
        //        var documentaryList = new List<Documentary>()
        //        {
        //            new Documentary(){id = Guid.NewGuid().ToString("N"), name = "Prueba 1", homologation = 1},
        //            new Documentary(){id = Guid.NewGuid().ToString("N"), name = "Prueba 2", homologation = 0}
        //        };

        //        var certificateList = new List<Certificate>()
        //        {
        //            new Certificate(){id = Guid.NewGuid().ToString("N"), text = "Certificado 1"},
        //            new Certificate(){id = Guid.NewGuid().ToString("N"), text = "Certificado 2"},
        //        };

        //        cbxDocumentaryTypes.DataSource = new BindingList<Documentary>(documentaryList);
        //        cbxCertificates.DataSource = new BindingList<Certificate>(certificateList);
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(string.Format("{0}\n\n{1}", ErrorMessages.AsyncTaskError, ex.Message), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
        //    }
        //    finally
        //    {
        //        this.Cursor = Cursors.Default;
        //    }

        //    bindingSource.ResetBindings(true);
        //}

        protected override async void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            DisplayScanners();
            DisplayFileTypes();

            this.Cursor = Cursors.WaitCursor;

            Task <string> theTask = Session.GetTikectAsync();

            try
            {
                _ticket = await theTask;

                if (String.IsNullOrWhiteSpace(_ticket))
                {
                    this.Close();
                    return;
                }

                var documentaryList = await DokuFlexService.GetDocumentaryTypesAsync(_ticket);

                var certificateList = await DokuFlexService.ListCertificatesAsync(_ticket);

                cbxDocumentaryTypes.DataSource = new BindingList <Documentary>(documentaryList);
                cbxCertificates.DataSource     = new BindingList <Certificate>(certificateList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}\n\n{1}", ErrorMessages.AsyncTaskError, ex.Message), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            bindingSource.ResetBindings(true);
        }
Exemple #4
0
        private async void scanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var scannedImages = new List <ScannedImage>();

            try
            {
                using (var form = new NewScanForm())
                {
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        scannedImages.AddRange(form.ScannedImages);
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(ex.Message, "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            var ticket = String.Empty;

            try
            {
                ticket = await Session.GetTikectAsync();

                if (_documentaryTypes.Count == 0)
                {
                    _documentaryTypes.AddRange(await DokuFlexService.GetDocumentaryTypesAsync(ticket));
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            if (string.IsNullOrWhiteSpace(ticket))
            {
                return;
            }

            using (var form = new ProgressForm())
            {
                if (!form.UploadFiles(ticket, scannedImages))
                {
                    return;
                }
            }

            try
            {
                foreach (var scannedImage in scannedImages)
                {
                    if (!string.IsNullOrWhiteSpace(scannedImage.Routing.Documentary))
                    {
                        await DokuFlexService.UpdateDocumentMetadataAsync(ticket, scannedImage.Routing.Documentary,
                                                                          scannedImage.Routing.FileId, new DokuField[] { });

                        var documentary = _documentaryTypes.FirstOrDefault(d => d.id.Equals(scannedImage.Routing.Documentary));

                        if (documentary != null)
                        {
                            foreach (var element in documentary.elements)
                            {
                                scannedImage.Metadata.Add(DokuField.CreateNew(element));
                            }
                        }
                    }

                    AddToListView(scannedImage);
                }
            }
            catch (Exception ex)
            {
                LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(ex.Message, "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }