Ejemplo n.º 1
0
        public void AutoRefreshGivenQuery(string queryName, Document wordDocument, ISyncServiceDocumentModel documentModel, IConfiguration configuration)
        {
            //RegisterServices();

            _documentModel = documentModel;
            _wordDocument  = documentModel.WordDocument as Document;

            _configuration = configuration;
            _documentModel.Configuration.RefreshMappings();
            _documentModel.Configuration.ActivateMapping(_documentModel.MappingShowName);

            //Get the service
            GetService();

            //Search the workitems
            _workItems = GetWorkItemsIdsByQueryName(queryName);

            Find();

            while (IsFindingWorkItems)
            {
                Thread.CurrentThread.Join(50);
            }

            // Show how many work items were found
            ConsoleExtensionLogging.LogMessage(string.Format("{0}{1}", Resources.WorkItemsCountInformation, FoundWorkItems.Count), ConsoleExtensionLogging.LogLevel.Both);
            SyncServiceTrace.D((string.Format("{0}{1}", Resources.WorkItemsCountInformation, FoundWorkItems.Count)));

            Import();
            while (IsImporting)
            {
                Thread.CurrentThread.Join(50);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestResultReportModel"/> class for the console extension
        /// </summary>
        /// <param name="syncServiceDocumentModel">The <see cref="ISyncServiceDocumentModel"/> to obtain document settings.</param>
        /// <param name="testAdapter"><see cref="ITfsTestAdapter"/> to examine test information.</param>
        /// <param name="testReportingProgressCancellationService">The <see cref="ITestReportingProgressCancellationService"/> indicating that a cancellation is requested.</param>
        protected TestReportModel(ISyncServiceDocumentModel syncServiceDocumentModel, ITfsTestAdapter testAdapter, ITestReportingProgressCancellationService testReportingProgressCancellationService)
        {
            if (syncServiceDocumentModel == null)
            {
                throw new ArgumentNullException("syncServiceDocumentModel");
            }
            if (testAdapter == null)
            {
                throw new ArgumentNullException("testAdapter");
            }
            if (testReportingProgressCancellationService == null)
            {
                throw new ArgumentNullException("testReportingProgressCancellationService");
            }

            SyncServiceDocumentModel = syncServiceDocumentModel;
            TestAdapter = testAdapter;

            Document = syncServiceDocumentModel.WordDocument as Document;

            _modelKey   = GetType().Name;
            _storedData = new Dictionary <string, string>();
            ParseStoredData(SyncServiceDocumentModel.ReadTestReportData(_modelKey));

            _generatingActive = SyncServiceDocumentModel.TestReportRunning;
            _operationActive  = SyncServiceDocumentModel.TestReportRunning;
            TestReportingProgressCancellationService = testReportingProgressCancellationService;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestSpecificationReportByQueryModel" /> class for the console extension.
        /// </summary>
        /// <param name="tfsService">Team foundation service.</param>
        /// <param name="documentModel">Model of word document to work with.</param>
        /// <param name="testAdapter">The test adapter.</param>
        /// <param name="workitems">The work items.</param>
        public TestSpecificationReportByQueryModel(ITfsService tfsService, ISyncServiceDocumentModel documentModel,
                                                   ITfsTestAdapter testAdapter, List <int> workitems)
        {
            if (tfsService == null)
            {
                throw new ArgumentNullException("tfsService");
            }
            if (documentModel == null)
            {
                throw new ArgumentNullException("documentModel");
            }

            TfsService   = tfsService;
            _testAdapter = testAdapter;

            WordDocument  = documentModel.WordDocument as Document;
            DocumentModel = documentModel;
            DocumentModel.PropertyChanged += DocumentModelOnPropertyChanged;

            _queryConfiguration = new QueryConfiguration
            {
                UseLinkedWorkItems = false
            };
            _queryConfiguration.ImportOption = QueryImportOption.IDs;
            _queryConfiguration.ByIDs        = workitems;

            LinkTypes = TfsService.GetLinkTypes().Select(
                x => new DataItemModel <ITFSWorkItemLinkType>(x)
            {
                IsChecked = QueryConfiguration.LinkTypes.Contains(x.ReferenceName)
            }).ToList();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultValuesModel"/> class.
 /// </summary>
 /// <param name="model">Associated model of document to show the default values from.</param>
 public DefaultValuesModel(ISyncServiceDocumentModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     DocumentModel = model;
     RefreshDefaultValues();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Verifies the template mapping.
        /// </summary>
        /// <param name="serviceModel">The service document model.</param>
        /// <param name="syncAdapter">The sync adapter.</param>
        /// <param name="configuration">Configuration with the field to check for existence on the server</param>
        public bool VerifyTemplateMapping(ISyncServiceDocumentModel serviceModel, ITfsService syncAdapter, IConfiguration configuration)
        {
            Guard.ThrowOnArgumentNull(serviceModel, "serviceModel");
            Guard.ThrowOnArgumentNull(syncAdapter, "syncAdapter");
            Guard.ThrowOnArgumentNull(configuration, "configuration");

            _missingFields.Clear();

            // check each mapping field
            foreach (var configurationItem in configuration.GetConfigurationItems())
            {
                if (!configurationItem.RelatedSchema.Equals(serviceModel.MappingShowName))
                {
                    continue;
                }
                foreach (var fieldItem in configurationItem.FieldConfigurations)
                {
                    var fieldExists = syncAdapter.FieldDefinitions.Cast <FieldDefinition>().Any(field => fieldItem.ReferenceFieldName.Equals(field.ReferenceName));

                    if (!fieldExists)
                    {
                        // add missing fields to collection if it is not based on variable type
                        fieldItem.SourceMappingName = configurationItem.WorkItemTypeMapping;

                        if (!fieldItem.FieldValueType.IsVariable())
                        {
                            _missingFields.Add(fieldItem);
                        }
                    }
                    //Field Exists, check if the defintions are right
                    else
                    {
                        //If the field on Word is handeled as HTML, check the counterpart on the tfs
                        if (fieldItem.FieldValueType == FieldValueType.HTML)
                        {
                            //Get the TFS Item
                            var tfsFieldItem = syncAdapter.FieldDefinitions[fieldItem.ReferenceFieldName];

                            if (tfsFieldItem.FieldType != FieldType.Html)
                            {
                                fieldItem.SourceMappingName = configurationItem.WorkItemTypeMapping;
                                _wrongMappedFields.Add(fieldItem);
                            }
                        }
                    }
                }
            }

            // return true if there were no missing fields or no wrong mapped field, else false.
            if (_missingFields.Count == 0 && _wrongMappedFields.Count == 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestSpecificationReportModel"/> class for the console extension
 /// </summary>
 /// <param name="syncServiceDocumentModel">The <see cref="ISyncServiceModel"/> to obtain document settings.</param>
 /// <param name="testAdapter"><see cref="ITfsTestAdapter"/> to examine test information.</param>
 /// <param name="sort"></param>
 /// <param name="testReportingProgressCancellationService">The progess cancellation service used to check at certain points if a cancellation has been triggered and further steps should be skipped.</param>
 /// <param name="plan">The selected <see cref="ITfsTestPlan"/> used for the report generation.</param>
 /// <param name="suite">The selected <see cref="ITfsTestSuite"/> used for the report generation.</param>
 /// <param name="documentStructure">The information if a document structure should be created.</param>
 /// <param name="skipLevels">The level count to ignore generation.</param>
 /// <param name="structureType"></param>
 public TestSpecificationReportModel(ISyncServiceDocumentModel syncServiceDocumentModel, ITfsTestAdapter testAdapter, ITfsTestPlan plan, ITfsTestSuite suite, bool documentStructure, int skipLevels, DocumentStructureType structureType, TestCaseSortType sort, ITestReportingProgressCancellationService testReportingProgressCancellationService)
     : base(syncServiceDocumentModel, testAdapter, testReportingProgressCancellationService)
 {
     SelectedTestPlan        = plan;
     SelectedTestSuite       = suite;
     CreateDocumentStructure = documentStructure;
     SkipLevels = skipLevels;
     SelectedDocumentStructureType = structureType;
     SelectedTestCaseSortType      = sort;
     CreateReportCommand           = new ViewCommand(ExecuteCreateReportCommand, CanExecuteCreateReportCommand);
     WordDocument = syncServiceDocumentModel.WordDocument as Document;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultValuesControl"/> class.
 /// </summary>
 /// <param name="documentModel">Model for associated document to show the default values from.</param>
 public DefaultValuesControl(ISyncServiceDocumentModel documentModel)
 {
     if (documentModel == null)
     {
         throw new ArgumentNullException("documentModel");
     }
     InitializeComponent();
     WordDocument  = documentModel.WordDocument as Document;
     DocumentModel = documentModel;
     _model        = new DefaultValuesModel(DocumentModel);
     DataContext   = _model;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestSpecificationReportModel"/> class.
        /// </summary>
        /// <param name="syncServiceDocumentModel">The <see cref="ISyncServiceModel"/> to obtain document settings.</param>
        /// <param name="dispatcher">Dispatcher of associated view.</param>
        /// <param name="testAdapter"><see cref="ITfsTestAdapter"/> to examine test information.</param>
        /// <param name="wordRibbon">Interface to the word ribbon</param>
        /// <param name="testReportingProgressCancellationService">The progess cancellation service used to check at certain points if a cancellation has been triggered and further steps should be skipped.</param>
        public TestSpecificationReportModel(ISyncServiceDocumentModel syncServiceDocumentModel, IViewDispatcher dispatcher,
                                            ITfsTestAdapter testAdapter, IWordRibbon wordRibbon, ITestReportingProgressCancellationService testReportingProgressCancellationService)
            : base(syncServiceDocumentModel, dispatcher, testAdapter, wordRibbon, testReportingProgressCancellationService)
        {
            CreateDocumentStructure = StoredCreateDocumentStructure;
            SkipLevels = StoredSkipLevels;
            SelectedDocumentStructureType = StoredSelectedDocumentStructureType;
            SelectedTestCaseSortType      = StoredSelectedTestCaseSortType;
            CreateReportCommand           = new ViewCommand(ExecuteCreateReportCommand, CanExecuteCreateReportCommand);
            SetTestReportDefaults(syncServiceDocumentModel.Configuration.ConfigurationTest.ConfigurationTestSpecification.DefaultValues);

            WordDocument = syncServiceDocumentModel.WordDocument as Document;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Create the model of the document and bind the project to the server
        /// </summary>
        private void CreateModel()
        {
            SyncServiceTrace.D(Resources.CreateModelInfo);
            // Create a word appliaction and set it to visible
            if (!_documentConfiguration.Settings.Overwrite && File.Exists(_fileName))
            {
                throw new Exception(Resources.FileExistsError);
            }
            SyncServiceTrace.D(Resources.FileIsOverwrittenOrNotExists);

            string wordTemplateFile = null;

            if (!string.IsNullOrEmpty(_documentConfiguration.Settings.DotxTemplate))
            {
                wordTemplateFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _documentConfiguration.Settings.DotxTemplate);

                // if the path is absolute, use it
                if (Path.IsPathRooted(_documentConfiguration.Settings.DotxTemplate))
                {
                    wordTemplateFile = _documentConfiguration.Settings.DotxTemplate;
                }
            }

            if (!string.IsNullOrEmpty(wordTemplateFile) && !File.Exists(wordTemplateFile))
            {
                throw new Exception(string.Format(Resources.Error_TemplateDoesNotExist, wordTemplateFile));
            }

            _wordApplication         = new Application();
            _wordApplication.Visible = !_documentConfiguration.Settings.WordHidden;

            if (!string.IsNullOrEmpty(wordTemplateFile))
            {
                _wordApplication.Documents.Add(wordTemplateFile);
            }
            else
            {
                _wordApplication.Documents.Add();
            }


            _wordDocument = _wordApplication.ActiveDocument;
            PrepareDocumentForReportGeneration();
            _documentModel = new SyncServiceDocumentModel(_wordDocument);

            _documentModel.MappingShowName = _documentConfiguration.Settings.Template;
            _documentModel.BindProject(_documentConfiguration.Settings.Server, _documentConfiguration.Settings.Project);
            SaveDocument();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateManagerControl"/> class.
 /// </summary>
 /// <param name="documentModel">Associated document model contains word document.</param>
 /// <param name="templateManager">Template manager contains the currently available template bundles.</param>
 public TemplateManagerControl(ISyncServiceDocumentModel documentModel, Model.TemplateManagement.TemplateManager templateManager)
 {
     InitializeComponent();
     if (documentModel == null)
     {
         throw new ArgumentNullException("documentModel");
     }
     if (templateManager == null)
     {
         throw new ArgumentNullException("templateManager");
     }
     AttachedDocument = documentModel.WordDocument as Document;
     _templateManager = templateManager;
     DataContext      = new TemplateManagerModel(_templateManager);
 }
        /// <summary>
        /// Creates a new instance of this class.
        /// </summary>
        /// <param name="tfsWorkItem">The TFS version of this work item.</param>
        /// <param name="wordWorkItem">The Word version of this work item.</param>
        /// <param name="wordAdapter">The Word adapter from which to load.</param>
        /// <param name="documentModel">The model of the current document for which to monitor sync state.</param>
        /// <param name="cancellationToken">Token used to cancel synchronization state query.</param>
        public SynchronizedWorkItemViewModel(IWorkItem tfsWorkItem, IWorkItem wordWorkItem, IWorkItemSyncAdapter wordAdapter, ISyncServiceDocumentModel documentModel, CancellationToken?cancellationToken)
        {
            if (cancellationToken.HasValue)
            {
                _cancellationToken = cancellationToken.Value;
            }

            _wordAdapter   = wordAdapter;
            _documentModel = documentModel;

            TfsItem  = tfsWorkItem;
            WordItem = wordWorkItem;

            SynchronizationState = SynchronizationState.Unknown;

            Task.Factory.StartNew(Load, _cancellationToken).ContinueWith(CheckIfCancelled);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetWorkItemsPanelViewModel"/> class.
        /// </summary>
        /// <param name="tfsService">Team foundation service.</param>
        /// <param name="documentModel">Model of word document to work with.</param>
        /// <param name="wordRibbon">Word ribbon.</param>
        public GetWorkItemsPanelViewModel(ITfsService tfsService, ISyncServiceDocumentModel documentModel, IWordRibbon wordRibbon)
        {
            if (tfsService == null)
            {
                throw new ArgumentNullException("tfsService");
            }
            if (documentModel == null)
            {
                throw new ArgumentNullException("documentModel");
            }
            if (wordRibbon == null)
            {
                throw new ArgumentNullException("wordRibbon");
            }
            TfsService = tfsService;
            WordRibbon = wordRibbon;

            WordDocument                   = documentModel.WordDocument as Document;
            DocumentModel                  = documentModel;
            _isDirectLinkOnlyMode          = DocumentModel.Configuration.GetDirectLinksOnly;
            DocumentModel.PropertyChanged += DocumentModelOnPropertyChanged;

            _queryConfiguration = new QueryConfiguration
            {
                UseLinkedWorkItems = false
            };

            DocumentModel.ReadQueryConfiguration(_queryConfiguration);
            SelectedQuery = FindQueryInHierarchy(QueryHierarchy, _queryConfiguration.QueryPath);

            var resultOfGetLinkTypes = TfsService.GetLinkTypes();

            if (resultOfGetLinkTypes != null)
            {
                LinkTypes = resultOfGetLinkTypes.Select(
                    x => new DataItemModel <ITFSWorkItemLinkType>(x)
                {
                    IsChecked = QueryConfiguration.LinkTypes.Contains(x.ReferenceName)
                }).ToList();
            }

            CollapseQueryTree        = DocumentModel.Configuration.CollapsQueryTree;
            IsExistNotShownWorkItems = false;
            SynchronizationState     = SynchronizationState.Unknown;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestSpecificationReportByQueryModel" /> class.
        /// </summary>
        /// <param name="tfsService">Team foundation service.</param>
        /// <param name="documentModel">Model of word document to work with.</param>
        /// <param name="wordRibbon">Word ribbon.</param>
        /// <param name="testAdapter">The test adapter.</param>
        public TestSpecificationReportByQueryModel(ITfsService tfsService, ISyncServiceDocumentModel documentModel, IWordRibbon wordRibbon,
                                                   ITfsTestAdapter testAdapter)
        {
            if (tfsService == null)
            {
                throw new ArgumentNullException("tfsService");
            }
            if (documentModel == null)
            {
                throw new ArgumentNullException("documentModel");
            }
            if (wordRibbon == null)
            {
                throw new ArgumentNullException("wordRibbon");
            }

            TfsService = tfsService;
            WordRibbon = wordRibbon;

            _testAdapter = testAdapter;

            WordDocument  = documentModel.WordDocument as Document;
            DocumentModel = documentModel;
            DocumentModel.PropertyChanged += DocumentModelOnPropertyChanged;

            _queryConfiguration = new QueryConfiguration
            {
                UseLinkedWorkItems = false
            };
            DocumentModel.ReadQueryConfiguration(_queryConfiguration);
            SelectedQuery = FindQueryInHierarchy(QueryHierarchy, _queryConfiguration.QueryPath);

            LinkTypes = TfsService.GetLinkTypes().Select(
                x => new DataItemModel <ITFSWorkItemLinkType>(x)
            {
                IsChecked = QueryConfiguration.LinkTypes.Contains(x.ReferenceName)
            }).ToList();

            CollapseQueryTree = DocumentModel.Configuration.CollapsQueryTree;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetWorkItemsPanelViewModel"/> class.
        /// </summary>
        /// <param name="tfsService">Team foundation service.</param>
        /// <param name="documentModel">Model of word document to work with.</param>
        /// <param name="wordRibbon">Word ribbon.</param>
        public WorkItemOverviewPanelViewModel(ITfsService tfsService, ISyncServiceDocumentModel documentModel, IWordRibbon wordRibbon)
        {
            if (tfsService == null)
            {
                throw new ArgumentNullException("tfsService");
            }
            if (documentModel == null)
            {
                throw new ArgumentNullException("documentModel");
            }
            if (wordRibbon == null)
            {
                throw new ArgumentNullException("wordRibbon");
            }

            TfsService = tfsService;
            WordRibbon = wordRibbon;

            WordDocument  = documentModel.WordDocument as Document;
            DocumentModel = documentModel;
            DocumentModel.PropertyChanged += DocumentModelOnPropertyChanged;

            _queryConfiguration = new QueryConfiguration
            {
                UseLinkedWorkItems   = false,
                IsDirectLinkOnlyMode = false
            };
            DocumentModel.ReadQueryConfiguration(_queryConfiguration);
            SelectedQuery = FindQueryInHierarchy(QueryHierarchy, _queryConfiguration.QueryPath);

            LinkTypes = TfsService.GetLinkTypes().Select(
                x => new DataItemModel <ITFSWorkItemLinkType>(x)
            {
                IsChecked = QueryConfiguration.LinkTypes.Contains(x.ReferenceName)
            }).ToList();
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AreaIterationPathViewModel"/> class.
 /// </summary>
 /// <param name="tfsService">Team foundation server service.</param>
 /// <param name="model">Associated model of word document.</param>
 public AreaIterationPathViewModel(ITfsService tfsService, ISyncServiceDocumentModel model)
 {
     TfsService    = tfsService;
     DocumentModel = model;
 }