/// <summary>
 /// Refreshes the rich text content controls which are not bound to the Custom XML Parts.
 /// </summary>
 /// <param name="workItemManager">The work item manager that contains the new work items.</param>
 /// <param name="cancellationToken">Used to cancel the refresh.</param>
 private void RefreshRichTextContentControls(WorkItemManager workItemManager, CancellationToken cancellationToken)
 {
     this.logger.Log(TraceEventType.Verbose, "Refreshing rich text content controls");
     foreach (ContentControl c in this.wordDocument.AllContentControls())
     {
         cancellationToken.ThrowIfCancellationRequested();
         if (c.Type == WdContentControlType.wdContentControlRichText)
         {
             Match m = RichTextContentControlTagPattern.Match(c.Tag);
             if (m.Success)
             {
                 string       fieldName = m.Groups["fieldName"].Captures[0].Value;
                 int          id        = int.Parse(m.Groups["id"].Captures[0].Value, CultureInfo.InvariantCulture);
                 ITfsWorkItem workItem  = workItemManager[id];
                 if (workItem != null)
                 {
                     if (workItem.FieldReferenceNames.Contains(fieldName))
                     {
                         this.wordDocument.PopulateRichTextContentControlWithHtml(c, workItem[fieldName].ToString());
                     }
                 }
                 else
                 {
                     this.wordDocument.PopulateRichTextContentControlWithHtml(c, string.Empty);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TeamProjectDocument"/> class.
        /// </summary>
        /// <param name="container">The unity container to use.</param>
        /// <param name="template">The team project template that contains the layout information.</param>
        /// <param name="formatter">The formatter to be used to format work items.</param>
        /// <param name="layoutDefinitionFormatter">The layout definition formatter to be used to show and edit layout definitions in the document.</param>
        /// <param name="verifier">The verifier to be used to verify the document structure.</param>
        /// <param name="factory">The factory used to create other objects.</param>
        /// <remarks>
        /// the code requires the <paramref name="wordDocument"/> parameter to have this exact name because of the way Unity does parameter overrides.
        /// </remarks>
        public TeamProjectDocument(IUnityContainer container, ITeamProjectTemplate template, ITeamProjectDocumentFormatter formatter, ILayoutDefinitionFormatter layoutDefinitionFormatter, ITeamProjectDocumentVerifier verifier, IFactory factory)
        {
            if (template == null)
            {
                throw new ArgumentNullException("template");
            }

            if (formatter == null)
            {
                throw new ArgumentNullException("formatter");
            }

            if (layoutDefinitionFormatter == null)
            {
                throw new ArgumentNullException("layoutDefinitionFormatter");
            }

            if (verifier == null)
            {
                throw new ArgumentNullException("verifier");
            }

            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            this.container = container;
            this.loaded    = false;
            this.template  = template;
            this.formatter = formatter;
            this.layoutDefinitionFormatter = layoutDefinitionFormatter;
            this.verifier = verifier;
            this.factory  = factory;

            XNamespace nsp = Constants.ProjectInformationNamespace;

            this.projectXName       = nsp + "Project";
            this.collectionUriXName = "CollectionUri";
            this.collectionIdXName  = "CollectionId";
            this.projectNameXName   = "ProjectName";

            XNamespace nsq = Constants.QueryNamespace;

            this.queriesAndLayoutsXName = nsq + "QueriesAndLayouts";
            this.queryAndLayoutXName    = nsq + "QueryAndLayout";
            this.queryXName             = nsq + "Query";
            this.layoutNameXName        = nsq + "LayoutName";

            XNamespace nsw = Constants.WorkItemNamespace;

            this.workItemsXName = nsw + "WorkItems";
            this.workItemXName  = nsw + "WorkItem";

            XNamespace nsqw = Constants.QueryWorkItemNamespace;

            this.queryWorkItemAssociationQueryXName = nsqw + "Query";
            this.queryWorkItemAssociationIdXName    = nsqw + "WorkItem";

            this.workItemManager = new WorkItemManager();
            this.queryWorkItems  = new List <QueryWorkItems>();

            ILogger logger = this.container.Resolve <ILogger>();

            logger.Log(TraceEventType.Verbose, "Creating a new Team Project Document");
        }