Esempio n. 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;
            }
        }
Esempio n. 2
0
        private async void btnFind_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(textSearch.Text))
            {
                MessageBox.Show("Debe introducir una palabra o frase de búsqueda",
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            ClearResultsGrid();
            ShowSearchProgress();

            this.Cursor = Cursors.WaitCursor;

            try
            {
                var ticket = await Session.GetTikectAsync();

                var results = await DokuFlexService.SearchAsync(ticket, textSearch.Text, _filterText, "d");

                foreach (var item in results)
                {
                    AddToListView(item);
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                HideSearchProgress();
            }
        }
Esempio n. 3
0
        private async void updateMetadataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            metadataControl.ApplyChanges();

            var scannedImages = new List <ScannedImage>();

            foreach (ListViewItem item in listView.Items)
            {
                scannedImages.Add(item.Tag as ScannedImage);
            }

            listView.Enabled = false;
            this.Cursor      = Cursors.WaitCursor;

            try
            {
                var ticket = await Session.GetTikectAsync();

                foreach (var scannedImage in scannedImages)
                {
                    await DokuFlexService.UpdateDocumentMetadataAsync(ticket, scannedImage.Routing.Documentary,
                                                                      scannedImage.Routing.FileId, scannedImage.Metadata.ToArray());
                }
            }
            finally
            {
                listView.Enabled = true;
                this.Cursor      = Cursors.Default;
            }
        }
Esempio n. 4
0
        public async Task <List <FileFolderInfo> > SyncFilesAsync(string ticket, string syncDir,
                                                                  string groupId, string folderId)
        {
            var fileList = new List <FileFolderInfo>();
            var files    = await DokuFlexService.GetFilesAsync(ticket, groupId, folderId);

            //Files for the current folder
            foreach (var fileItem in files)
            {
                //Create path
                var path = string.Format("{0}\\{1}", syncDir, fileItem.name);

                //Add entry
                fileList.Add(
                    new FileFolderInfo()
                {
                    GroupId    = groupId,
                    FolderId   = folderId,
                    FileFolder = fileItem,
                    Path       = path,
                    SyncFolder = false
                }
                    );
            }

            return(fileList);
        }
Esempio n. 5
0
        private async void dtpStartDate_ValueChanged(object sender, EventArgs e)
        {
            var startDate = dtpStartDate.Value.ToUnixEpoch();

            this.Cursor = Cursors.WaitCursor;

            try
            {
                _ticket = await Session.GetTikectAsync();

                var elements = await DokuFlexService.GetScanHistoryAsync(_ticket, startDate);

                listView.Items.Clear();

                foreach (var element in elements)
                {
                    if (String.IsNullOrWhiteSpace(element.id))
                    {
                        continue;
                    }

                    AddToListView(element);
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 6
0
        public async Task LoadInformation(string inputPdf)
        {
            _inputPdf  = inputPdf;
            _pdfReader = new PdfReader(inputPdf);

            this.Cursor = Cursors.WaitCursor;

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

            try
            {
                _ticket = await theTask;

                var certificates = await DokuFlexService.ListCertificatesAsync(_ticket);

                certificateList.DataSource = new BindingList <Certificate>(certificates);
            }
            catch (Exception ex)
            {
                DokuFlex.Windows.Common.Log.LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(string.Format("{0}\n\n{1}", ErrorMessages.ApplicationError, ex.Message), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 7
0
        public void ShowMetadata()
        {
            TrackingListManager.Reload();

            var trackingItem = TrackingListManager.GetByPath(Globals.ThisAddIn.Application.ActiveDocument.FullName);

            if (trackingItem == null)
            {
                MessageBox.Show(String.Format("El documento no contiene metadatos porque no existe en DokuFlex.\n\n{0}",
                                              "Guarde el documento en DokuFlex y repita la acción"),
                                this.Application.Name, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                var ticket = Session.GetTikect();

                using (var form = new MetadataForm(ticket, trackingItem.FileId, trackingItem.Name))
                {
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        DokuFlexService.UpdateDocumentMetadata(ticket, form.DocumentType,
                                                               trackingItem.FileId, form.Metadata.ToArray());
                    }
                }
            }
        }
Esempio n. 8
0
        public UpdateTaskResponse UpdateTask(string ticket, string communityId, string title,
                                             long startDate, long endDate, string description, string categoryId,
                                             string subCategoryId, string categoryStatusId, string projectId)
        {
            var result = DokuFlexService.UpdateTask(ticket, communityId, title, startDate,
                                                    endDate, description, categoryId, subCategoryId, categoryStatusId, projectId);

            return(result);
        }
Esempio n. 9
0
        private void CreateRootFolderAsyncBegin(TreeNode node)
        {
            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <string> .Factory.StartNew(() => DokuFlexService.CreateFolder(_ticket, _currentGroup.id, string.Empty, node.Text));

            task.ContinueWith(t => CreateFolderAsyncEnd(t.Result, node), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 10
0
        private void DisplayRootsFoldersAsyncBegin()
        {
            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <IList <FileFolder> > .Factory.StartNew(() => DokuFlexService.GetFolders(_ticket, _currentGroup.id, string.Empty));

            task.ContinueWith(t => DisplayRootsFoldersAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 11
0
        protected override async void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _asyncTaskStarted = true;

            try
            {
                foreach (var scannedImage in _scannedImages)
                {
                    if (string.IsNullOrWhiteSpace(scannedImage.Path))
                    {
                        var uploadDir = DFEnvironment.GetSpecialFolder(DFEnvironment.SpecialFolder.UploadDirectory);

                        scannedImage.Path = String.Format("{0}\\{1}", uploadDir, scannedImage.Name + scannedImage.FileType);

                        if (!Directory.Exists(uploadDir))
                        {
                            Directory.CreateDirectory(uploadDir);
                        }

                        try
                        {
                            scannedImage.Image.Save(scannedImage.Path, scannedImage.FileType.ToImageFormat());
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(string.Format("{0}\n\n{1}", ErrorMessages.AsyncTaskError, ex.Message),
                                            this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            this.DialogResult = DialogResult.Cancel;
                            break;
                        }
                    }

                    var result = await DokuFlexService.UploadAsync(_ticket,
                                                                   scannedImage.Routing.Community, string.Empty,
                                                                   scannedImage.Routing.Folder, string.Empty, string.Empty,
                                                                   true, scannedImage.Routing.Certificate, "scan",
                                                                   scannedImage.Routing.ConvertToPdf, new FileInfo(scannedImage.Path));

                    scannedImage.Routing.FileId = result.nodeId;
                }

                if (DialogResult == DialogResult.None)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
            finally
            {
                _asyncTaskStarted = false;
                this.Close();
            }
        }
Esempio n. 12
0
        private void LoginAsyncBegin()
        {
            DisplayLogingInfo();

            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            var task = Task <string> .Factory.StartNew(() => DokuFlexService.Login(_credentials));

            task.ContinueWith(t => LoginAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception), new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted, taskScheduler);
        }
Esempio n. 13
0
        public void SaveDocument()
        {
            var newFile = false;

            if (String.IsNullOrWhiteSpace(this.Application.ActiveDocument.Path))
            {
                if (MessageBox.Show(String.Format("El documento aún no ha sido guardado en disco.\n\n{0}",
                                                  "¿Desea guardar el documento en su PC para continuar?"),
                                    this.Application.Name, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Application.ActiveDocument.Save();

                    newFile = true;

                    if (string.IsNullOrWhiteSpace(this.Application.ActiveDocument.Path))
                    {
                        return;
                    }
                }
            }
            else
            {
                if (!this.Application.ActiveDocument.Saved &&
                    MessageBox.Show(String.Format("¿Desea guardar los cambios en {0} antes continuar?",
                                                  this.Application.ActiveDocument.Name.ToUpperInvariant()),
                                    this.Application.Name, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Application.ActiveDocument.Save();
                }
            }

            var ticket = Session.GetTikect();

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

            var fileId = UploadFile(ticket, this.Application.ActiveDocument.FullName);

            if (newFile && !String.IsNullOrWhiteSpace(fileId))
            {
                using (var form = new MetadataForm(ticket, fileId, this.Application.ActiveDocument.Name))
                {
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        DokuFlexService.UpdateDocumentMetadata(ticket, form.DocumentType,
                                                               fileId, form.Metadata.ToArray());
                    }
                }
            }
        }
Esempio n. 14
0
        private void DisplayChildsFoldersAsyncBegin(TreeNode node)
        {
            var folderId      = (node.Tag as FileFolder).id;
            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <IList <FileFolder> > .Factory.StartNew(() => DokuFlexService.GetFilesFolders(_ticket, _currentGroup.id, folderId));

            task.ContinueWith(t => DisplayChildsFoldersAsyncEnd(t.Result, node), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 15
0
        private void DownloadFileAsyncBegin(string ticket, string fileId, string filePath)
        {
            _taskAsyncStarted = true;

            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <bool> .Factory.StartNew(() => DokuFlexService.Download(ticket, fileId, filePath));

            task.ContinueWith(t => DownloadFileAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 16
0
        private void DisplayProjectsAsyncBegin()
        {
            this.Cursor = Cursors.WaitCursor;

            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <IList <Project> > .Factory.StartNew(() => DokuFlexService.ListProjects(_ticket, _group.id));

            task.ContinueWith(t => DisplayProjectsAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 17
0
        private async void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_currentListViewItem == null)
            {
                return;
            }

            if (MessageBox.Show("¿Desea eliminar el elemento seleccionado?", Text, MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            var scannedImage = _currentListViewItem.Tag as ScannedImage;

            this.Cursor = Cursors.WaitCursor;

            if (!string.IsNullOrWhiteSpace(scannedImage.Path))
            {
                if (File.Exists(scannedImage.Path))
                {
                    try
                    {
#pragma warning disable SG0018 // Path traversal
                        File.Delete(scannedImage.Path);
#pragma warning restore SG0018 // Path traversal
                    }
                    catch (Exception)
                    {
                        //Silent exception
                    }
                }
            }

            try
            {
                var ticket = await Session.GetTikectAsync();

                if (await DokuFlexService.DeleteFileAsync(ticket, scannedImage.Routing.Community, scannedImage.Routing.FileId))
                {
                    metadataControl.BindMetadata(null);
                    textDocumentaryType.Text = string.Empty;
                    listView.Items.Remove(_currentListViewItem);
                    _currentListViewItem = null;
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            RefreshControlsState();
        }
Esempio n. 18
0
        private void DisplayGroupsAsyncBegin()
        {
            //Show loading information.
            lbLoadingGroups.Visible = true;
            lbLoadingGroups.BringToFront();

            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <IList <UserGroup> > .Factory.StartNew(() => DokuFlexService.GetUserGroups(_ticket));

            task.ContinueWith(t => DisplayGroupsAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        private void UploadFileAsyncBegin(string ticket, string groupId, string folderId,
                                          string fileId, string filePath, bool saveAsNewVersion)
        {
            _taskAsyncStarted = true;

            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <UploadResult> .Factory.StartNew(() => DokuFlexService.Upload(ticket,
                                                                                                   groupId, fileId, folderId, String.Empty, String.Empty, saveAsNewVersion,
                                                                                                   String.Empty, "plugin", false, new FileInfo(filePath)));

            task.ContinueWith(t => UploadFileAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }
Esempio n. 21
0
        private async void OnRenamed(object sender, RenamedEventArgs e)
        {
            var item = SyncTableManager.GetByPath(e.OldFullPath);

            if (item != null)
            {
                var command = (Command)null;

                if (item.Type == "F")
                {
                    var folder = new DirectoryInfo(e.FullPath);

                    var ticket = await DokuFlexService.GetTicketAsync();

                    var topLevelPath = ConfigurationManager.GetValue(Resources.SyncDirectoryPathKey);

                    command = new RenameDirectoryCommand(ticket, folder.Name, e.FullPath, e.OldFullPath, topLevelPath);
                }
                else
                {
                    var file = new FileInfo(e.FullPath);

                    //check if file is open by a program
                    if (!file.IsLocked())
                    {
                        var ticket = await DokuFlexService.GetTicketAsync();

                        var topLevelPath = ConfigurationManager.GetValue(Resources.SyncDirectoryPathKey);

                        command = new RenameFileCommand(ticket, file.Name, e.FullPath, e.OldFullPath, topLevelPath);
                    }
                }

                //Attach error event handler
                command.ExecuteError += OnExecuteError;

                //Detect the synchronizer object state
                if (_syncing || _synchronizer.Paused)
                {
                    _synchronizer.Synchronize(command);
                }
                else
                {
                    await _synchronizer.SynchronizeAsync(command);
                }
            }
        }
Esempio n. 22
0
        public void SavePresentation()
        {
            var newFile = false;

            if (String.IsNullOrWhiteSpace(this.Application.ActivePresentation.Path))
            {
                if (MessageBox.Show(String.Format("La presentación aún no ha sido guardada en disco.\n\n{0}",
                                                  "¿Desea guardar la presentación en su equipo para continuar?"),
                                    this.Application.Name, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Application.ActivePresentation.Save();

                    newFile = true;

                    if (string.IsNullOrWhiteSpace(this.Application.ActivePresentation.Path))
                    {
                        return;
                    }
                }
            }
            else
            {
                this.Application.ActivePresentation.Save();
            }

            var ticket = Session.GetTikect();

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

            var fileId = UploadFile(ticket, this.Application.ActivePresentation.FullName);

            if (newFile && !String.IsNullOrWhiteSpace(fileId))
            {
                using (var form = new MetadataForm(ticket, fileId, this.Application.ActivePresentation.Name))
                {
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        DokuFlexService.UpdateDocumentMetadata(ticket, form.DocumentType,
                                                               fileId, form.Metadata.ToArray());
                    }
                }
            }
        }
        protected override async Task <bool> DoExecuteAsync()
        {
            try
            {
                var result = await DokuFlexService.DeleteFolderAsync(_ticket, _item.GroupId, _item.FolderId);

                SyncTableManager.RemoveAllByPath(_item.Path);
                SyncTableManager.Save();

                return(result);
            }
            catch (Exception ex)
            {
                var newMsg = string.Format("Delete online directory, raise an exception with: {0}, Exception: {1}", _item.Path, ex.Message);
                throw new Exception(newMsg);
            }
        }
Esempio n. 24
0
        public static async Task <string> GetTikectAsync()
        {
            var ticket      = String.Empty;
            var credentials = new Credentials();

            credentials.UserName = ConfigurationManager.GetValue(Constants.LoginUserName);

            if (String.IsNullOrWhiteSpace(credentials.UserName))
            {
                using (var form = new LoginView())
                {
                    if (form.ShowLoginDialog())
                    {
                        ticket = form.Ticket;
                    }
                }

                return(ticket);
            }

            credentials.SetEncryptedPassword(ConfigurationManager.GetValue(Constants.LoginPassword));

            try
            {
                ticket = await DokuFlexService.LoginAsync(credentials);
            }
            catch (AggregateException)
            {
                //silent exception
            }

            if (String.IsNullOrWhiteSpace(ticket))
            {
                using (var form = new LoginView())
                {
                    if (form.ShowLoginDialog())
                    {
                        ticket = form.Ticket;
                    }
                }
            }

            return(ticket);
        }
        protected override async Task <bool> DoExecuteAsync()
        {
            var directory = new DirectoryInfo(_path);

            //Add item to SyncTable and set the SyncProgress state
            var item = new SyncTableItem()
            {
                Name          = directory.Name,
                Path          = _path,
                LastWriteTime = directory.LastWriteTimeUtc.ToFileTimeUtc(),
                Type          = "F",
                GroupId       = _groupId,
                FolderId      = String.Empty,
                FileId        = String.Empty,
                ModifiedTime  = 0,
                SyncFolder    = false,
            };

            SyncTableManager.Add(item);
            SyncTableManager.Save();

            try
            {
                var nodeId = await DokuFlexService.CreateFolderAsync(_ticket, _groupId, _parentFolderId, directory.Name);

                //Set nodeId property
                item.FolderId = nodeId;
                SyncTableManager.Save();

                return(!String.IsNullOrWhiteSpace(nodeId));
            }
            catch (Exception ex)
            {
                //Rollback the Add item action
                SyncTableManager.Remove(item);
                SyncTableManager.Save();

                var newMsg = string.Format("Create online directory, raise an exception with: {0}, Exception: {1}", _path, ex.Message);
                throw new Exception(newMsg);
            }
        }
Esempio n. 26
0
        protected override async Task <bool> DoExecuteAsync()
        {
            var item = SyncTableManager.GetByPath(_oldFullPath);

            if (item != null)
            {
                var syncItems = SyncTableManager.GetAllByPath(_oldFullPath);

                if (syncItems != null)
                {
                    foreach (var syncItem in syncItems)
                    {
                        if (syncItem.Type == "F" &&
                            String.Compare(syncItem.FolderId, item.FolderId) == 0)
                        {
                            syncItem.Name = _newName;
                        }

                        syncItem.Path = syncItem.Path.Replace(_oldFullPath, _fullPath);
                    }
                }
                else
                {
                    item.Name = _newName;
                    item.Path = item.Path.Replace(_oldFullPath, _fullPath);
                }

                try
                {
                    return(await DokuFlexService.RenameFileFolderAsync(_ticket, item.GroupId, item.FolderId, _newName));
                }
                catch (Exception ex)
                {
                    var newMsg = string.Format("Rename directory, raise an exception with: {0}, Exception: {1}", item.Path, ex.Message);
                    throw new Exception(newMsg);
                }
            }

            return(false);
        }
Esempio n. 27
0
        public string UploadAttach(string displayName, string ticket, string communityId)
        {
            var attach    = GetAttachments().FirstOrDefault(a => a.DisplayName.Equals(displayName));
            var uploadDir = DFEnvironment.GetSpecialFolder(DFEnvironment.SpecialFolder.UploadDirectory);

            if (!Directory.Exists(uploadDir))
            {
                Directory.CreateDirectory(uploadDir);
            }

            var filePath = String.Format("{0}\\{1}", uploadDir,
                                         _mailItem.Attachments[attach.Index].FileName);

            //Save attach to the uploadDirectory
            _mailItem.Attachments[attach.Index].SaveAsFile(filePath);

            var result = DokuFlexService.Upload(ticket, communityId,
                                                String.Empty, _folder.id, String.Empty, String.Empty,
                                                false, String.Empty, "plugin", false, new FileInfo(filePath));

            return(result.nodeId);
        }
Esempio n. 28
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);
        }
Esempio n. 29
0
        public async Task AddToFavorites()
        {
            var path = Globals.ThisAddIn.Application.ActiveDocument.FullName;

            TrackingListManager.Reload();

            var trackingItem = TrackingListManager.GetByPath(path);

            if (trackingItem == null)
            {
                MessageBox.Show(String.Format("El documento no se puede añadir a los favoritos porque no existe en DokuFlex.\n\n{0}",
                                              "Guarde el documento en DokuFlex y repita la acción"),
                                this.Application.Name, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                var ticket = await Session.GetTikectAsync();

                await DokuFlexService.UpdateFavoriteAsync(ticket, trackingItem.FileId, "A", 1);
            }
        }
Esempio n. 30
0
        private async void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (e.IsSelected)
            {
                _currentListViewItem = e.Item;

                var history = e.Item.Tag as ScanHistory;

                if (String.IsNullOrWhiteSpace(history.path))
                {
                    history.path = String.Format("{0}\\{1}", _downloadDir, history.name);

                    ShowProcessingPane();
                    this.Cursor = Cursors.WaitCursor;

                    try
                    {
                        var docMetadata = await DokuFlexService.GetDocumentMetadadaAsync(_ticket, history.id);

                        metadataControl.BindMetadata(docMetadata.elements);
                        await DokuFlexService.DownloadAsync(_ticket, history.id, history.path);
                    }
                    finally
                    {
                        HideProcessingPane();
                        this.Cursor = Cursors.Default;
                    }
                }

                webBrowser.Navigate(history.path);

                //ShowPreviewNoSupportedPane(history.path);
            }
            else
            {
                _currentListViewItem = null;
            }
        }