Ejemplo n.º 1
0
        /// <summary>
        /// Execute import work items from TFS to Word process.
        /// </summary>
        public void Import()
        {
            SyncServiceTrace.I(Resources.ImportWorkItems);
            SyncServiceFactory.GetService <IInfoStorageService>().ClearAll();

            // check whether cursor is not inside the table
            if (WordSyncHelper.IsCursorInTable(WordDocument.ActiveWindow.Selection))
            {
                SyncServiceTrace.W(Resources.WordToTFS_Error_TableInsertInTable);
                MessageBox.Show(Resources.WordToTFS_Error_TableInsertInTable, Resources.MessageBox_Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // disable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.ResetBeforeOperation(DocumentModel);
                WordRibbon.DisableAllControls(DocumentModel);
            }

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.GetWorkItems_Title);
            IsImporting = true;

            // start background thread to execute the import
            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork             += DoImport;
            backgroundWorker.RunWorkerCompleted += ImportFinished;
            backgroundWorker.RunWorkerAsync(backgroundWorker);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute find work items process to fill up the Find list box.
        /// </summary>
        public void FindWorkItems()
        {
            SaveQueryConfiguration();
            SyncServiceTrace.I(Resources.FindWorkItems);

            // check whether is at least one link type selected
            if (QueryConfiguration.UseLinkedWorkItems && IsCustomLinkType && QueryConfiguration.LinkTypes.Count == 0)
            {
                MessageBox.Show(Resources.WordToTFS_Error_LinkTypesNotSelected, Resources.MessageBox_Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            // parse IDs
            if (ImportOption == QueryImportOption.IDs && !ParseIDs(QueryConfiguration.ByIDs))
            {
                return;
            }

            if (ImportOption == QueryImportOption.TitleContains)
            {
                QueryConfiguration.ByTitle = ImportTitleContains;
            }

            // disable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.ResetBeforeOperation(DocumentModel);
                WordRibbon.DisableAllControls(DocumentModel);
            }

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.GetWorkItems_Title);
            IsFinding = true;

            TaskScheduler scheduler = null;

            try
            {
                scheduler = TaskScheduler.FromCurrentSynchronizationContext();
            }
            catch (InvalidOperationException)
            {
                scheduler = TaskScheduler.Current;
            }

            Task.Factory.StartNew(DoFind).ContinueWith(FindFinished, scheduler);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Occurs when the background operation has completed, has been canceled, or has raised an exception.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="RunWorkerCompletedEventArgs"/> that contains the event data.</param>
        private void ImportFinished(object sender, RunWorkerCompletedEventArgs e)
        {
            e.Error.NotifyIfException("Failed to import work items.");

            IsImporting = false;
            _importWordAdapter.UndoPreparationsDocumentForLongTermOperation();
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.HideProgress();

            // enable all other functionality
            WordRibbon?.EnableAllControls(DocumentModel);
            SyncServiceTrace.I(Resources.ImportFinished);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Occurs when the background operation has completed, has been canceled, or has raised an exception.
        /// </summary>
        private void FindFinished(Task task)
        {
            IsFinding = false;
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.HideProgress();

            // enable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.EnableAllControls(DocumentModel);
            }

            SyncServiceTrace.I(Resources.FindFinished);
        }
        /// <summary>
        /// Execute find work items process to fill up the Find list box.
        /// </summary>
        public void FindWorkItems()
        {
            SaveQueryConfiguration();
            SyncServiceTrace.I(Resources.FindWorkItems);

            if (SelectedQuery == null)
            {
                QueryConfiguration.ImportOption = QueryImportOption.IDs;

                var wordAdapter = SyncServiceFactory.CreateWord2007TableWorkItemSyncAdapter(DocumentModel.WordDocument, DocumentModel.Configuration);
                wordAdapter.Open(null);

                QueryConfiguration.ByIDs.Clear();

                foreach (var workItem in wordAdapter.WorkItems)
                {
                    if (!workItem.IsNew)
                    {
                        QueryConfiguration.ByIDs.Add(workItem.Id);
                    }
                }
            }

            // check whether is at least one link type selected
            if (QueryConfiguration.UseLinkedWorkItems && IsCustomLinkType && QueryConfiguration.LinkTypes.Count == 0)
            {
                MessageBox.Show(Resources.WordToTFS_Error_LinkTypesNotSelected, Resources.MessageBox_Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            // disable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.ResetBeforeOperation(DocumentModel);
                WordRibbon.DisableAllControls(DocumentModel);
            }

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.QueryWorkItems_Title);
            IsFinding = true;

            Task.Factory.StartNew(DoFind).ContinueWith(FindFinished, TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 6
0
 private void DEssential(object sender, RoutedEventArgs e)
 {
     WordRibbon.DisableEssentialsSimplifyRibbon();
 }
Ejemplo n.º 7
0
 private void DBasic(object sender, RoutedEventArgs e)
 {
     WordRibbon.DisableBasicSimplifyRibbon();
 }