public override void Dump(
            StringBuilder stringBuilder,
            Dictionary <string, object> parameters,
            ConnectionManager connectionManager,
            WordTemplateFolderManager wordTemplateFolderManager,
            string teamProjectName)
        {
            WorkItemManger workItemManger = PrepareWorkItemManager(connectionManager, teamProjectName);

            parameters = parameters.ToDictionary(k => k.Key, v => v.Value); //clone
            //If we do not have query parameters we have a single query or we can have parametrized query with iterationPath
            var queries = PrepareQueries(parameters);

            foreach (var query in queries)
            {
                var workItems = workItemManger.ExecuteQuery(query).Take(Limit);
                foreach (var workItem in workItems.Where(ShouldExport))
                {
                    var values = workItem.CreateDictionaryFromWorkItem();
                    foreach (var value in values)
                    {
                        stringBuilder.AppendLine($"{value.Key.PadRight(50, ' ')}={value.Value}");
                    }
                }
            }
        }
示例#2
0
        public override void Assemble(
            WordManipulator manipulator,
            Dictionary <string, object> parameters,
            ConnectionManager connectionManager,
            WordTemplateFolderManager wordTemplateFolderManager,
            string teamProjectName)
        {
            parameters = parameters.ToDictionary(k => k.Key, v => v.Value); //clone
            //If we do not have query parameters we have a single query or we can have parametrized query with iterationPath
            var            queries        = PrepareQueries(parameters);
            WorkItemManger workItemManger = new WorkItemManger(connectionManager);

            workItemManger.SetTeamProject(teamProjectName);

            foreach (var query in queries)
            {
                var workItems = workItemManger.ExecuteQuery(query).Take(Limit);

                if (String.IsNullOrEmpty(TableTemplate))
                {
                    foreach (var workItem in workItems)
                    {
                        if (!SpecificTemplates.TryGetValue(workItem.Type.Name, out var templateName))
                        {
                            templateName = wordTemplateFolderManager.GetTemplateFor(workItem.Type.Name);
                        }
                        else
                        {
                            templateName = wordTemplateFolderManager.GenerateFullFileName(templateName);
                        }

                        manipulator.InsertWorkItem(workItem, templateName, true, parameters);
                    }
                }
                else
                {
                    //We have a table template, we want to export work item as a list
                    var tableFile = wordTemplateFolderManager.GenerateFullFileName(TableTemplate);
                    var tempFile  = wordTemplateFolderManager.CopyFileInTempDirectory(tableFile);
                    using (var tableManipulator = new WordManipulator(tempFile, false))
                    {
                        tableManipulator.SubstituteTokens(parameters);
                        tableManipulator.FillTableWithCompositeWorkItems(true, workItems);
                    }
                    manipulator.AppendOtherWordFile(tempFile);
                }
            }

            base.Assemble(manipulator, parameters, connectionManager, wordTemplateFolderManager, teamProjectName);
        }