public void BtnProductList_Click(object sender, EventArgs e) { DocumentCreator dc = new DocumentCreator(); dc.AddList <Vendor>(vendors, "vendor"); dc.AddList <Product>(products, "prod"); //Totals per vendor dc.AddInt32("avail", 0); dc.AddInt32("unavail", 0); dc.AddInt32("tot", 0); //Final totals dc.AddInt32("available", 0); dc.AddInt32("unavailable", 0); dc.AddInt32("total", 0); dc.ScanStart += new ScanStartEventHandler(Dc_ScanStart); dc.AfterScanRecord += new AfterScanRecordEventHandler(Dc_AfterScanRecord1); dc.ScanEnded += new ScanEndedEventHandler(Dc_ScanEnded1); dc.CreateDocument(_inputPath, _outputPath); if (!_unitTest) { Process.Start(_outputPath); } }
private Lucene.Net.Store.Directory CreateLuceneIndex(IEnumerable <PackageVersion> packages, string luceneDirectory) { Lucene.Net.Store.Directory directory; if (luceneDirectory != null) { var directoryInfo = new DirectoryInfo(luceneDirectory); directoryInfo.Create(); directory = new SimpleFSDirectory(directoryInfo); } else { directory = new RAMDirectoryWrapper(); } using (var indexWriter = DocumentCreator.CreateIndexWriter(directory, true)) { foreach (var version in packages) { var metadata = GetPackageMetadata(version); var document = DocumentCreator.CreateDocument(metadata); indexWriter.AddDocument(document); } indexWriter.Commit(); } return(directory); }
public void NestedTest6() { var docCreator = new DocumentCreator(delimiter: "~", preprocessText: false); var testList = new List <TestClass> { new TestClass() { Go = true, Go2 = true }, new TestClass() { Go = false, Go2 = true }, new TestClass() { Go = true, Go2 = false }, new TestClass() { Go = false, Go2 = false }, }; docCreator.AddList(testList, "S"); docCreator.CreateDocument(inputTemplatePath[5], outputPath[5]); FileAssert.AreEqual(outputPath[5], comparisonPath[5]); }
public void BtnProductList_Click(object sender, EventArgs e) { DocumentCreator dc = new DocumentCreator(); dc.AddList <Product>(products, "P"); //Group Totals dc.AddInt32("avail", 0); dc.AddInt32("unavail", 0); dc.AddInt32("tot", 0); //Final totals dc.AddInt32("available", 0); dc.AddInt32("unavailable", 0); dc.AddInt32("total", 0); dc.AddInt32("showVendor", 0); dc.AddBoolean("groupEnd", false); currentVendor = "-none-"; dc.BeforeScanRecord += new BeforeScanRecordEventHandler(Dc_BeforeScanRecord); dc.AfterScanRecord += new AfterScanRecordEventHandler(Dc_AfterScanRecord1); dc.ScanEnded += new ScanEndedEventHandler(Dc_ScanEnded1); dc.CreateDocument(_inputPath, _outputPath); if (!_isUnitTest) { Process.Start(_outputPath); } }
static void ProcessPackageDetails(IndexWriter indexWriter, JObject catalogItem) { Trace.TraceInformation("ProcessPackageDetails"); indexWriter.DeleteDocuments(CreateDeleteQuery(catalogItem)); var package = CatalogPackageMetadataExtraction.MakePackageMetadata(catalogItem); var document = DocumentCreator.CreateDocument(package); indexWriter.AddDocument(document); }
public void GenerateDocument(string path, string keyID, string username) { DocumentCreator dc = new DocumentCreator(); dc.AddString("Date", DateTime.Now.ToShortDateString()); dc.AddString("keyID", keyID); var outputPath = $"{path}//Oswiadczenie.rtf"; dc.CreateDocument(inputPath, outputPath); Process.Start(outputPath); }
private void ProcessPackageDetails(IndexWriter indexWriter, JObject catalogItem) { _logger.LogDebug("ProcessPackageDetails"); indexWriter.DeleteDocuments(CreateDeleteQuery(catalogItem)); var package = CatalogPackageMetadataExtraction.MakePackageMetadata(catalogItem); var document = DocumentCreator.CreateDocument(package); indexWriter.AddDocument(document); }
public void HasExpectedFieldNamesAndValues() { // Arrange var package = GetPackage(); var expected = new[] { new KeyValuePair <string, string>(LuceneConstants.IdPropertyName, "DotNetZip"), new KeyValuePair <string, string>(LuceneConstants.IdAutocompletePropertyName, "DotNetZip"), new KeyValuePair <string, string>(LuceneConstants.TokenizedIdPropertyName, "DotNetZip"), new KeyValuePair <string, string>(LuceneConstants.ShingledIdPropertyName, "DotNetZip"), new KeyValuePair <string, string>(LuceneConstants.VerbatimVersionPropertyName, "1.00.000"), new KeyValuePair <string, string>(LuceneConstants.NormalizedVersionPropertyName, "1.0.0"), new KeyValuePair <string, string>(LuceneConstants.FullVersionPropertyName, "1.0.0"), new KeyValuePair <string, string>(LuceneConstants.TitlePropertyName, "The Famous DotNetZip"), new KeyValuePair <string, string>(LuceneConstants.DescriptionPropertyName, "The description."), new KeyValuePair <string, string>(LuceneConstants.SummaryPropertyName, "The summary."), new KeyValuePair <string, string>(LuceneConstants.TagsPropertyName, "dot net zip"), new KeyValuePair <string, string>(LuceneConstants.AuthorsPropertyName, "Justin Bieber, Nick Jonas"), new KeyValuePair <string, string>(LuceneConstants.SemVerLevelPropertyName, ""), new KeyValuePair <string, string>(LuceneConstants.ListedPropertyName, "true"), new KeyValuePair <string, string>(LuceneConstants.OriginalCreatedPropertyName, "2001-01-01T00:00:00.0000000Z"), new KeyValuePair <string, string>(LuceneConstants.OriginalPublishedPropertyName, "2002-02-02T00:00:00.0000000Z"), new KeyValuePair <string, string>(LuceneConstants.PublishedDatePropertyName, "20020202"), new KeyValuePair <string, string>(LuceneConstants.OriginalLastEditedPropertyName, "2003-03-03T00:00:00.0000000Z"), new KeyValuePair <string, string>(LuceneConstants.LastEditedDatePropertyName, "20030303"), new KeyValuePair <string, string>(LuceneConstants.SortableTitlePropertyName, "the famous dotnetzip"), new KeyValuePair <string, string>(LuceneConstants.IconUrlPropertyName, "http://example/icon.png"), new KeyValuePair <string, string>(LuceneConstants.ProjectUrlPropertyName, "http://example/"), new KeyValuePair <string, string>(LuceneConstants.MinClientVersionPropertyName, "2.0.0"), new KeyValuePair <string, string>(LuceneConstants.ReleaseNotesPropertyName, "The release notes."), new KeyValuePair <string, string>(LuceneConstants.CopyrightPropertyName, "The copyright."), new KeyValuePair <string, string>(LuceneConstants.LanguagePropertyName, "English"), new KeyValuePair <string, string>(LuceneConstants.LicenseUrlPropertyName, "http://example/license.txt"), new KeyValuePair <string, string>(LuceneConstants.PackageHashPropertyName, "0123456789ABCDEF"), new KeyValuePair <string, string>(LuceneConstants.PackageHashAlgorithmPropertyName, "SHA1"), new KeyValuePair <string, string>(LuceneConstants.PackageSizePropertyName, "1200"), new KeyValuePair <string, string>(LuceneConstants.RequiresLicenseAcceptancePropertyName, "true"), new KeyValuePair <string, string>(LuceneConstants.FlattenedDependenciesPropertyName, "Lucene.Net:2.9.4.1|WindowsAzure.Storage:1.6"), new KeyValuePair <string, string>(LuceneConstants.DependenciesPropertyName, "[{\"Id\":\"Lucene.Net\",\"VersionSpec\":\"2.9.4.1\"},{\"Id\":\"WindowsAzure.Storage\",\"VersionSpec\":\"1.6\"}]"), new KeyValuePair <string, string>(LuceneConstants.SupportedFrameworksPropertyName, "[\"net40\",\"aspnet99\"]") }; // Act var document = DocumentCreator.CreateDocument(package); // Assert var actual = document.GetFields().Select(f => new KeyValuePair <string, string>(f.Name, f.StringValue)).ToArray(); Assert.Equal(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.Equal(expected[i], actual[i]); } }
public void VerifiesRequiredPropertiesAreProvided(string key, string expected) { // Arrange var package = GetPackage(); package.Remove(key); // Act, Assert var exception = Assert.Throws <Exception>(() => DocumentCreator.CreateDocument(package)); Assert.Equal(expected, exception.Message); }
public void ValidatesPropertiesThatAreNotStrings(string key, string expected) { // Arrange var package = GetPackage(); package[key] = "bad"; // Act, Assert var exception = Assert.Throws <Exception>(() => DocumentCreator.CreateDocument(package)); Assert.Equal(expected, exception.Message); }
public void RejectsMissingVersionAndOriginalVersion() { // Arrange var package = GetPackage(); package.Remove(MetadataConstants.NormalizedVersionPropertyName); package.Remove(MetadataConstants.VerbatimVersionPropertyName); // Act, Assert var exception = Assert.Throws <Exception>(() => DocumentCreator.CreateDocument(package)); Assert.Equal($"Required property '{MetadataConstants.VerbatimVersionPropertyName}' not found.\r\n", exception.Message); }
public void RejectsInvalidOriginalVersionWhenVersionIsNotProvided() { // Arrange var package = GetPackage(); package.Remove(MetadataConstants.NormalizedVersionPropertyName); package[MetadataConstants.VerbatimVersionPropertyName] = "bad"; // Act, Assert var exception = Assert.Throws <Exception>(() => DocumentCreator.CreateDocument(package)); Assert.Equal($"Unable to parse '{MetadataConstants.VerbatimVersionPropertyName}' as NuGetVersion.\r\n", exception.Message); }
public void DefaultsEmptyTitleToValueOfId() { // Arrange var package = GetPackage(); package[MetadataConstants.TitlePropertyName] = string.Empty; // Act var document = DocumentCreator.CreateDocument(package); // Assert Assert.Equal("DotNetZip", document.GetFieldable(LuceneConstants.TitlePropertyName).StringValue); Assert.Equal("dotnetzip", document.GetFieldable(LuceneConstants.SortableTitlePropertyName).StringValue); }
public void AllFieldsAreStoredAndIndexed() { // Arrange var package = GetPackage(); // Act var document = DocumentCreator.CreateDocument(package); // Assert foreach (var field in document.GetFields()) { Assert.True(field.IsStored, $"{field.Name} should be stored."); Assert.True(field.IsIndexed, $"{field.Name} should be indexed."); } }
public void DefaultsMissingVersionToParsedOriginalVersion() { // Arrange var package = GetPackage(); package.Remove(MetadataConstants.NormalizedVersionPropertyName); package[MetadataConstants.VerbatimVersionPropertyName] = "1.02.003"; // Act var document = DocumentCreator.CreateDocument(package); // Assert Assert.Equal("1.02.003", document.GetFieldable(LuceneConstants.VerbatimVersionPropertyName).StringValue); Assert.Equal("1.2.3", document.GetFieldable(LuceneConstants.NormalizedVersionPropertyName).StringValue); }
public void Button1_Click(object sender, EventArgs e) { try { //Create a Dataset containing the required tables. DataSet MyData = LoadData(); //DocumentCreator represents the API to the NTemplates engine, so we need to instantiate it dc = new DocumentCreator(); //We need to make the DocumentCreator instance aware of the tables by ccalling the AddDataTable method //for each need table. foreach (DataTable dt in MyData.Tables) { dc.AddDataTable(dt); } //We'are handling some events, so we need to define some event handlers dc.BeforeScanRecord += new BeforeScanRecordEventHandler(Dc_BeforeScanRecord); dc.ScanEnded += new ScanEndedEventHandler(Dc_ScanEnded); //By calling the Add<Type> methods of DocumentCreator, we add variables to the //document creator memory space. We can use those for showing values in the report //itself or, we can use them for internal calculations. dc.AddDateTime("invDate", DateTime.Parse(_invoiceDate)); //Invoice date dc.AddDouble(_extprice, 0); //Line total (price * units) dc.AddDouble(_subtotal, 0); //Sum of all extPrices dc.AddDouble(_taxes, 0); //Asume this is a calculated result dc.AddDouble(_total, 0); // subtotal + taxes dc.AddString("title", "Powered by NTemplates"); dc.AddString("address", "http://ntemplates.codeplex.com"); //Finally, we command to create the document using one of the CreateDocument method overloads. //In this case, we are picking a template from a physical file on disc and generating the report //to a physical file too. dc.CreateDocument(_inputPath, _outputPath); if (!_unitTest) { System.Diagnostics.Process.Start(_outputPath); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Button1_Click(object sender, EventArgs e) { DataTable Parent = new DataTable("P"); Parent.Columns.Add(new DataColumn("id", typeof(int))); Parent.Columns.Add(new DataColumn("description", typeof(string))); DataTable Child = new DataTable("C"); //TableName is mandatory Child.Columns.Add(new DataColumn("id", typeof(int))); Child.Columns.Add(new DataColumn("parentID", typeof(int))); Child.Columns.Add(new DataColumn("description", typeof(string))); DataTable GrandChild = new DataTable("GRCH"); //TableName is mandatory GrandChild.Columns.Add(new DataColumn("id", typeof(int))); GrandChild.Columns.Add(new DataColumn("parentID", typeof(int))); GrandChild.Columns.Add(new DataColumn("description", typeof(string))); Parent.Rows.Add(new object[] { "1", "Parent 1" }); Parent.Rows.Add(new object[] { "2", "Parent 2" }); Parent.Rows.Add(new object[] { "3", "Parent 3" }); Child.Rows.Add(new object[] { "1", "1", "Parent 1 Child 1" }); Child.Rows.Add(new object[] { "2", "1", "Parent 1 Child 2" }); Child.Rows.Add(new object[] { "3", "1", "Parent 1 Child 3" }); Child.Rows.Add(new object[] { "4", "2", "Parent 2 Child 1" }); Child.Rows.Add(new object[] { "5", "2", "Parent 2 Child 2" }); Child.Rows.Add(new object[] { "6", "2", "Parent 2 Child 3" }); GrandChild.Rows.Add(new object[] { "1", "1", "Parent 1 Child 1 Grand Child 1" }); GrandChild.Rows.Add(new object[] { "2", "1", "Parent 1 Child 1 Grand Child 2" }); GrandChild.Rows.Add(new object[] { "3", "1", "Parent 1 Child 1 Grand Child 3" }); DocumentCreator dc = new DocumentCreator(); dc.ScanStart += new ScanStartEventHandler(Dc_ScanStart); dc.AddDataTable(Parent); dc.AddDataTable(Child); dc.AddDataTable(GrandChild); dc.CreateDocument(_inputPath, _outputPath); if (!_unitTest) { Process.Start(_outputPath); } }
public void DefaultsMissingLastEditedToValueOfPublished() { // Arrange var package = GetPackage(); package.Remove(MetadataConstants.LastEditedPropertyName); // Act var document = DocumentCreator.CreateDocument(package); // Assert Assert.Equal("2002-02-02T00:00:00.0000000Z", document.GetField(LuceneConstants.OriginalPublishedPropertyName).StringValue); Assert.Null(document.GetField(LuceneConstants.OriginalLastEditedPropertyName)); Assert.Equal("20020202", document.GetFieldable(LuceneConstants.PublishedDatePropertyName).StringValue); Assert.Equal("20020202", document.GetFieldable(LuceneConstants.LastEditedDatePropertyName).StringValue); }
public void AllAnalyzedFieldsHasPositionsAndOffsetsStored() { // Arrange var package = GetPackage(); // Act var document = DocumentCreator.CreateDocument(package); // Assert foreach (var fieldable in document.GetFields().Where(f => f.IsTokenized && !(f is NumericField))) { Assert.True(fieldable.IsTermVectorStored, $"{fieldable.Name} should have its term vector stored."); Assert.True(fieldable.IsStoreOffsetWithTermVector, $"{fieldable.Name} should store offsets with its term vector."); Assert.True(fieldable.IsStorePositionWithTermVector, $"{fieldable.Name} should store positions with its term vector."); } }
public void BtnGenerateLetter_Click(object sender, EventArgs e) { //First, we need an instance of the DocumentCreator class. DocumentCreator dc = new DocumentCreator(); //Now, we need to pass the data we want in the report, to the document creator instance. //We are going to "query" and bind the data in a single method, for simplicity. AddDataForReport(dc); //Finally, we will create a report, based on our template and save it to a location. //I encourage you to explore other overloads of the function CreateDocument dc.CreateDocument(_inputPath, _outputPath); if (!_unitTest) { Process.Start(_outputPath); } }
public void BtnProductList_Click(object sender, EventArgs e) { DocumentCreator dc = new DocumentCreator(); dc.AddList <Product>(products, "P"); dc.AddInt32("available", 0); dc.AddInt32("unavailable", 0); dc.AddInt32("total", 0); dc.AfterScanRecord += new AfterScanRecordEventHandler(Dc_AfterScanRecord1); dc.ScanEnded += new ScanEndedEventHandler(Dc_ScanEnded1); dc.CreateDocument(_inputPath, _outputPath); if (!_isUnitTest) { Process.Start(_outputPath); } }
protected void OnGenerateCode(object parameter) { switch (CurrentTool.Language) { case "javascript": //Check for source files string fileStatus = DocumentCreator.AddFile(@"D:\Zkit\SourceFiles", @"Output\Scripts", "CommonObjects.js"); //Create CSS CSSGenerator css = new CSSGenerator(CurrentTool); string cssStatus = DocumentCreator.CreateDocument(@"Output\Styles", (CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project") + "Styles", "css", css.GenerateDoc(), true); PHPGenerator php = new PHPGenerator(CurrentTool); //set php info here php.DB = "zkit"; php.Pass = "******"; php.Server = "localhost"; php.User = "******"; //Create PHP Scripts string phpStatus = DocumentCreator.CreateDocument(@"Output\PHP", "connect", "php", php.GenerateConnectDoc(), true); if (!String.IsNullOrWhiteSpace(phpStatus)) { MessageBox.Show(phpStatus); } phpStatus = DocumentCreator.CreateDocument(@"Output\PHP", "save_" + (CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project"), "php", php.GenerateSaveDoc(), true); if (!String.IsNullOrWhiteSpace(phpStatus)) { MessageBox.Show(phpStatus); } phpStatus = DocumentCreator.CreateDocument(@"Output\PHP", "load_" + (CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project"), "php", php.GenerateLoadDoc(), true); if (!String.IsNullOrWhiteSpace(phpStatus)) { MessageBox.Show(phpStatus); } //Create Javascript files JavascriptGenerator js = new JavascriptGenerator(CurrentTool); js.ProjectName = CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project"; //Needs to be the name of the objecst string jsStatus = DocumentCreator.CreateDocument(@"Output\Scripts", js.ProjectName, "js", js.GenerateDoc(), true); if (!String.IsNullOrWhiteSpace(jsStatus)) { MessageBox.Show(jsStatus); } jsStatus = DocumentCreator.CreateDocument(@"Output\Scripts", js.ProjectName + "_functions", "js", js.GenerateFunctionsDoc(), true); if (!String.IsNullOrWhiteSpace(jsStatus)) { MessageBox.Show(jsStatus); } HTMLGenerator g = CurrentTool.HTML; g.ProjectName = CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project"; g.ToolRef = CurrentTool; g.ScriptIncludes.Add("CommonObjects.js"); g.ScriptIncludes.Add(js.ProjectName + ".js"); g.ScriptIncludes.Add("https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"); g.ScriptIncludes.Add(g.ProjectName + "_functions.js"); g.GenerateDoc(); //Creates begining point of doc //Load js objects var htmlTag = g.Tags.Where(x => x.TagName == "html").FirstOrDefault(); if (htmlTag != null && htmlTag.GetType() == typeof(HTMLTagBase)) { var headTag = ((HTMLTagBase)htmlTag).Children.Where(x => x.TagName == "head").FirstOrDefault(); if (headTag != null) { var scriptTag = ((HTMLTagBase)headTag).Children.Where(x => x.TagName == "script").FirstOrDefault(); HTMLTagBase script = null; if (scriptTag != null) { script = (HTMLTagBase)scriptTag; } else //create a script tag { script = new HTMLTagBase(); script.TagName = "script"; headTag.Children.Add(script); } List <string> names = new List <string>(); foreach (var o in CurrentTool.Objects) { names.Add(o.Name); } script.InnerHTML = JavascriptGenerator.GenerateInitFunction(names); } var bodyTag = ((HTMLTagBase)htmlTag).Children.Where(x => x.TagName == "body").FirstOrDefault(); if (bodyTag != null) { bodyTag.Elements.Add("onload", "initObjs();"); } } else //no html tag found. Something is wrong. { } string htmlDoc = g.ReOutputDoc(); string status = DocumentCreator.CreateDocument("Output", CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project", "html", htmlDoc, true); if (!String.IsNullOrWhiteSpace(status)) { MessageBox.Show(status); } //TODO: Finish adding all report elements - tags in reports.html, additional scripts //***** Create Report Document HTMLTagBase reportDoc = g.CreateReportPage(); var reportHeadTag = ((HTMLTagBase)reportDoc).Children.Where(x => x.TagName == "head").FirstOrDefault(); if (reportHeadTag != null) { var scriptTag = ((HTMLTagBase)reportHeadTag).Children.Where(x => x.TagName == "script").FirstOrDefault(); HTMLTagBase script = null; if (scriptTag != null) { script = (HTMLTagBase)scriptTag; } else //create a script tag { script = new HTMLTagBase(); script.TagName = "script"; reportHeadTag.Children.Add(script); } List <string> names = new List <string>(); foreach (var o in CurrentTool.Objects) { names.Add(o.Name); } script.InnerHTML = JavascriptGenerator.GenerateReportInitFunction(names, CurrentTool.Objects.ElementAt(0)); } var reportBodyTag = ((HTMLTagBase)reportDoc).Children.Where(x => x.TagName == "body").FirstOrDefault(); if (reportBodyTag != null) { reportBodyTag.Elements["onload"] += "initObjs();"; } status = DocumentCreator.CreateDocument("Output", "Reports", "html", reportDoc.GenerateTag(), true); if (!String.IsNullOrWhiteSpace(status)) { MessageBox.Show(status); } //***** Create SQL Scripts SQLGenerator sql = new SQLGenerator(CurrentTool); string sqlStatus = DocumentCreator.CreateDocument("Output", "CREATE_TABLES", "sql", sql.GenerateDoc(), true); MessageBox.Show("Files Created!"); break; } }