/// <summary> /// This method creates a word document with the GetWorkItems-Command /// </summary> /// <param name="documentConfiguration">The configuration</param> /// <param name="workItems">The string that identifies the work items that should be imported</param> /// <param name="type">The type of the import operation</param> public void CreateWorkItemDocument(DocumentConfiguration documentConfiguration, string workItems, string type) { try { _documentConfiguration = documentConfiguration; // Initialize the document Initialize(); if (type.Equals("ByID")) { _workItems = GetWorkItemsIdsByString(workItems); } else if (type.Equals("ByQuery")) { _workItems = GetWorkItemsIdsByQueryName(workItems); } if (_workItems == null || _workItems.Count < 1) { SyncServiceTrace.E(Resources.NoWorkItemsFoundInformation); throw new Exception(Resources.NoWorkItemsFoundInformation); } // Get the work items that should be imported / This will come from the query settings 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); } ConsoleExtensionLogging.LogMessage(Resources.WorkItemsImportedInformation, ConsoleExtensionLogging.LogLevel.Both); SyncServiceTrace.D(Resources.WorkItemsImportedInformation); FinalizeDocument(); } catch (Exception e) { // close any open word applications form this method if (_wordApplication != null) { _wordApplication.Quit(); } SyncServiceTrace.LogException(e); // ReSharper disable once PossibleIntendedRethrow throw e; } }
public void CreateDocumentContainingWorkItemsForExistingDocument_OverwriteSwitchedOn_ContentOfDocumentShouldBeReplaced() { var filename = GetTempDocumentNameAndCreateTempFolder(); var newWordApp = new Application(); //Create a document, save it and close it newWordApp.Documents.Add(); var currentDocument = newWordApp.ActiveDocument; currentDocument.SaveAs(filename); currentDocument.Close(); newWordApp.Quit(); Assert.IsTrue(File.Exists(filename)); var documentConfiguration = new DocumentConfiguration(Server, Project, filename, TemplateName, true, CloseOnFinish, null, false, null, TraceLevel.Verbose); var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WorkItemToImport, "ByID"); //Wait for the Importing to finish while (crm.IsImporting) { Thread.CurrentThread.Join(50); } Assert.IsTrue(SearchActiveWordDocumentForString(WorkItemToImport)); //The id should also be in the saved file Assert.IsTrue(SearchSpecificWordDocumentForString(WorkItemToImport, filename)); //File should exist anyway Assert.IsTrue(File.Exists(filename)); }
internal static string Render(DocumentConfiguration config, string view, object model) { var controller = new EmptyController(); controller.ViewData.Model = model; var httpBase = new HttpContextWrapper(HttpContext.Current); var route = new RouteData(); route.Values.Add("controller", "value"); var controllerContext = new ControllerContext(httpBase, route, controller); using (var sw = new StringWriter()) { var viewResult = !string.IsNullOrWhiteSpace(config.MasterName) ? ViewEngines.Engines.FindView(controllerContext, view, config.MasterName) : ViewEngines.Engines.FindPartialView(controllerContext, view); var viewContext = new ViewContext(controllerContext, viewResult.View, controller.ViewData, controller.TempData, sw); viewResult.View.Render(viewContext, sw); viewResult.ViewEngine.ReleaseView(controller.ControllerContext, viewResult.View); var result = sw.GetStringBuilder().ToString(); return(result); } }
public void CreateBasicDocumentWithValidConfigFileAndValidSettings_ShouldReturnException() { //Create Doc conf with arguments and config file, this should fail // ReSharper disable once UnusedVariable var documentConfiguration = new DocumentConfiguration(Server, Project, GetTempDocumentNameAndCreateTempFolder(), TemplateName, Overwrite, CloseOnFinish, "Config/ConfigurationNew1.xml", false, null, TraceLevel.Verbose); Assert.Fail(); }
public void CreateDocumentConfigurationWithConfigFileWithoutTestSpecificationConfiguration_ShouldCreateDocumentConfigurationObjectWithouException() { //Create Doc conf with arguments and config file, this should fail // ReSharper disable once UnusedVariable var documentConfiguration = new DocumentConfiguration(null, null, null, null, false, false, "Config/ConfigurationWithoutTestSpecificationConfiguration.xml", false, null, TraceLevel.Verbose); Assert.IsNotNull(documentConfiguration); }
public void CreateBasicDocumentByQuerydWithStandardOptionsAndWrongQueryName_ShouldFail() { var fileName = GetTempDocumentNameAndCreateTempFolder(); //Create Doc conf var documentConfiguration = new DocumentConfiguration(Server, Project, fileName, TemplateName, Overwrite, CloseOnFinish, null, false, null, TraceLevel.Verbose); var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WrongWorkItemQuery, "ByQuery"); Assert.IsFalse(File.Exists(fileName)); }
/// <summary> /// This method creates a word document with the TestResultReport-Command /// </summary> public void CreateTestResultDocument(DocumentConfiguration documentConfiguration) { try { SyncServiceTrace.D(Resources.CreateTestResultDoc); _documentConfiguration = documentConfiguration; Initialize(); var testResultSettings = _documentConfiguration.TestResultSettings; var testAdapter = SyncServiceFactory.CreateTfsTestAdapter(_documentModel.TfsServer, _documentModel.TfsProject, _documentModel.Configuration); TestCaseSortType testCaseSortType; Enum.TryParse(testResultSettings.SortTestCasesBy, out testCaseSortType); DocumentStructureType documentStructure; Enum.TryParse(testResultSettings.DocumentStructure, out documentStructure); ConfigurationPositionType configurationPositionType; Enum.TryParse(testResultSettings.TestConfigurationsPosition, out configurationPositionType); var testPlan = testAdapter.GetTestPlans(null).Where(plan => plan.Name == testResultSettings.TestPlan).FirstOrDefault(); if (testPlan == null) { SyncServiceTrace.D(Resources.TestSettingsInvalidTestPlan); throw new ArgumentException(Resources.TestSettingsInvalidTestPlan); } var testSuiteSearcher = new TestSuiteSearcher(testPlan); var testSuite = testSuiteSearcher.SearchTestSuiteWithinTestPlan(testResultSettings.TestSuite); var reportModel = new TestResultReportModel(_documentModel, testAdapter, testPlan, testSuite, testResultSettings.CreateDocumentStructure, testResultSettings.SkipLevels, documentStructure, testCaseSortType, testResultSettings.IncludeTestConfigurations, configurationPositionType, testResultSettings.IncludeOnlyMostRecentResults, testResultSettings.MostRecentForAllConfigurations, testResultSettings.Build, testResultSettings.TestConfiguration, new TestReportingProgressCancellationService(false)); reportModel.CreateReport(); FinalizeDocument(); } catch { if (_wordApplication != null) { _wordApplication.Quit(); } // ReSharper disable once PossibleIntendedRethrow throw; } }
public QueuesController( DocumentConfiguration documentConfig, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, IUnitOfWork unitOfWork, ILogger <AccountController> logger) { _documentConfig = documentConfig; _signInManager = signInManager; _userManager = userManager; _unitOfWork = unitOfWork; _logger = logger; }
public DocumentConfiguration CreateDocumentConfig() { try { var documentConfiguration = new DocumentConfiguration(_server, _project, _filename, _templateName, _overwrite, _closeOnFinish, _configFile, _wordHidden, _templateFile, (TraceLevel)_debugLevel); SyncServiceTrace.DebugLevel = new TraceSwitch("DebugLevel", "The Output level of tracing", documentConfiguration.Settings.DebugLevel.ToString()); return(documentConfiguration); } catch (Exception e) { // ReSharper disable once PossibleIntendedRethrow throw e; } }
public void CreateBasicDocumentByIdWithValidSettingsAndMissingTemplate_ShouldNotCreateDocumentAndShoudlRaiseException() { Assert.IsTrue(File.Exists("Configuration\\WordTemplate.dotx")); Assert.IsTrue(File.Exists("Configuration\\ConfigurationNew1.xml")); var fileName = GetTempDocumentNameAndCreateTempFolder(); //Create Doc conf with wrong reference var documentConfiguration = new DocumentConfiguration(Server, Project, fileName, TemplateName, true, CloseOnFinish, null, false, "Configuration/NONExistingWordTemplate.dotx", TraceLevel.Verbose); documentConfiguration.Settings.Filename = fileName; var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WorkItemToImport, "ByID"); Assert.IsFalse(File.Exists(fileName)); }
/// <summary> /// This method creates a word document with the TestSpecReportByQuery-Command /// </summary> /// <param name="documentConfiguration"></param> Document-Configuration /// <param name="workItems"></param> In case of type=ByQuery querypath, else workitem-Ids as string /// <param name="type"></param> {ByQuery, ById} public void CreateTestSpecDocumentByQuery(DocumentConfiguration documentConfiguration, string workItems, string type) { _testSpecByQuery = true; try { CreateWorkItemDocument(documentConfiguration, workItems, type); } catch (Exception e) { if (_wordApplication != null) { _wordApplication.Quit(); } // ReSharper disable once PossibleIntendedRethrow throw e; } }
internal static byte[] GetDocumentFromHtml(DocumentConfiguration config, string htmlString) { byte[] documentBytes = null; using (var memStream = new MemoryStream()) { var document = new Document(config.ITextSharpLayout); var replacements = new Dictionary <string, string>(); if (config.ReplaceCssPaths) { LoadReplacementPaths(htmlString, "link", "href", replacements); } foreach (var originalPath in replacements.Keys) { htmlString = htmlString.Replace(originalPath, replacements[originalPath]); } // si la hoja de estilo ya está en el html, da un error => excluir las repetidas var stylesheetsFilePath = new List <string>(); foreach (var stylesheetPath in config.StyleSheets) { var path = HostingEnvironment.MapPath(stylesheetPath); if (!replacements.ContainsValue(path.ToLower())) { stylesheetsFilePath.Add(path); } } var writer = PdfWriter.GetInstance(document, memStream); writer.CloseStream = false; writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFTRUE); document.Open(); AddHTMLText(writer, document, htmlString, stylesheetsFilePath); document.Close(); documentBytes = memStream.ToArray(); } return(documentBytes); }
public void CreateBasicDocumentByIdWithValidConfigFile_EnsureThatConnectionInformationisSavedInDocumentMode_ShouldCreateDocumentWithValidConnectionInfo() { Assert.IsTrue(File.Exists("Config\\ConfigurationNew1.xml")); CommonConfiguration.ReplaceConfigFileTokens(_testContext); var fileName = GetTempDocumentNameAndCreateTempFolder(); //Create Doc conf var documentConfiguration = new DocumentConfiguration(null, null, null, null, false, false, "Config\\ConfigurationNew1.xml", false, null, TraceLevel.Verbose); documentConfiguration.Settings.Filename = fileName; var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WorkItemToImport, "ByID"); //Wait for the import to finish Assert.IsTrue(File.Exists(fileName)); }
public void CreateBasicDocumentByIdWithStandardOptions_ShouldCreateDocument() { var fileName = GetTempDocumentNameAndCreateTempFolder(); //Create Doc conf var documentConfiguration = new DocumentConfiguration(Server, Project, fileName, TemplateName, Overwrite, CloseOnFinish, null, false, null, TraceLevel.Verbose); var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WorkItemToImport, "ByID"); //Wait for the import to finish while (crm.IsImporting) { Thread.CurrentThread.Join(50); } Assert.IsTrue(File.Exists(fileName)); Assert.IsTrue(SearchActiveWordDocumentForString(WorkItemToImport)); }
public void CreateBasicDocumentByIdWithValidConfigFileWithoutTestConfiguratioNsettings_ShouldCreateDocument() { Assert.IsTrue(File.Exists("Config/ConfigurationWithoutTestConfiguration.xml")); CommonConfiguration.ReplaceConfigFileTokens(_testContext); var fileName = GetTempDocumentNameAndCreateTempFolder(); //Create Doc conf var documentConfiguration = new DocumentConfiguration(null, null, null, null, false, false, "Config/ConfigurationWithoutTestConfiguration.xml", false, null, TraceLevel.Verbose); documentConfiguration.Settings.Filename = fileName; var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WorkItemToImport, "ByID"); //Wait for the import to finish while (crm.IsImporting) { Thread.CurrentThread.Join(50); } Assert.IsTrue(File.Exists(fileName)); }
public void CreateBasicDocumentByIdWithValidSettingsAndTemplate_ShouldCreateDocumentThatContainsWorkItemAndTextFromWordTempalte() { Assert.IsTrue(File.Exists("Configuration/WordTemplate.dotx")); Assert.IsTrue(File.Exists("Configuration/ConfigurationNew1.xml")); var fileName = GetTempDocumentNameAndCreateTempFolder(); //Create Doc conf var documentConfiguration = new DocumentConfiguration(Server, Project, fileName, TemplateName, true, CloseOnFinish, null, false, "Configuration/WordTemplate.dotx", TraceLevel.Verbose); documentConfiguration.Settings.Filename = fileName; var crm = new ConsoleExtensionHelper(new TestReportingProgressCancellationService(false)); crm.CreateWorkItemDocument(documentConfiguration, WorkItemToImport, "ByID"); //Wait for the Importing to finish while (crm.IsImporting) { Thread.CurrentThread.Join(50); } Assert.IsTrue(File.Exists(fileName)); Assert.IsTrue(SearchSpecificWordDocumentForString(WorkItemToImport, fileName)); Assert.IsTrue(SearchSpecificWordDocumentForString("This is a word template file.", fileName)); }
public IServiceProvider ConfigureService(IServiceCollection services) { var config = new CosmosDbTestConfiguration(); var docConfig = new DocumentConfiguration(config.DatabaseEndPoint, config.AuthorizationKey, config.DatabaseId, "Alert"); services.AddScoped <ServiceFactory>(p => p.GetService); services.AddLogging(c => c.AddConsole()); services.AddTransient <ILogger>(p => p.GetRequiredService <ILoggerFactory>().CreateLogger("Console")); services.AddSingleton <ICosmosDbTestConfiguration>(config); //services.AddTransient<IDocumentConfiguration>(p => p.GetRequiredService<ICosmosDbTestConfiguration>().GetDocumentConfiguration("Alert")); services.Scan(scan => { scan .FromAssembliesOf(typeof(IMediator), typeof(ICosmosDbTestConfiguration)) .AddClasses(true) .AsImplementedInterfaces(); }); return(services.BuildServiceProvider()); }
protected BaseDocumentPrinter() { MinimumConfigurationRequirements = new DocumentConfiguration("MinimumConfig", new [] { "PageRectangle", "ContentArea", "PageCountMeasurementReplacerLength", "Landscape" }, new [] { typeof(RectangleF), typeof(RectangleF), typeof(int), typeof(bool) }); renderContext = new RenderContext(() => ContentArea); measurementimage = new Bitmap(5000, 5000); float x = measurementimage.HorizontalResolution; measurementimage.SetResolution(300, 300); measurer = Graphics.FromImage(measurementimage); measurer.PageUnit = GraphicsUnit.Document; measurer.PageScale = 300 / x; }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); MemberConfiguration.Configure(modelBuilder); DocumentConfiguration.Configure(modelBuilder); }
/// <summary> /// Creates Page-Configuration object for a specific page /// </summary> /// <returns>the configuration object containing all possible settings for a specific page</returns> protected abstract DocumentConfiguration GetPageConfiguration(DocumentConfiguration baseConfig);
/// <summary> /// Initializes a new instance of the NewPage event args /// </summary> /// <param name="pageRectangle">the page rectangle that represents the entire page</param> /// <param name="contentRectangle">the rectnagle that represents the content area</param> /// <param name="pageId">the index of the current page</param> /// <param name="pageConfiguration">the configuration for the current page</param> public NewPageEventArgs(int pageId, DocumentConfiguration pageConfiguration) { PageId = pageId; PageConfiguration = pageConfiguration; }