public static GeneratorSpecification Generate(Supplier supplier, int numDocuments = 1, int baseDocumentNumber = 15000) { var gs = new GeneratorSpecification(); gs.Header = new GeneratorHeader { LogoFile = supplier.LogoFile, SupplierFullName = supplier.SupplierFullName, DocumentType = "INVOICE", SupplierKey = supplier.SupplierKey, SupplierName = supplier.SupplierName, BuilderAssembly = supplier.BuilderAssembly, BuilderType = supplier.BuilderType }; gs.Documents = new List <GeneratorDocument>(); for (int d = 0; d < numDocuments; d++) { GeneratorDocument gd = new GeneratorDocument(); gd.DocumentNumber = (baseDocumentNumber + 1 + d).ToString(); gd.DocumentDate = DateTime.Now.Subtract(new TimeSpan(random.Next(1, 180), 0, 0, 0)).ToString("dd/MM/yyyy"); if (random.Next(1, 10) <= 3) { gd.Notes = "Need to do something with this"; } var account = Accounts.GetRandomAccount(); gd.PostalCode = account.PostalCode; gd.SingleName = account.SingleName; gd.Account = account.AccountNumber; gd.AddressLine1 = account.AddressLine1; gd.AddressLine2 = account.AddressLine2; gd.City = account.City; gd.Lines = new List <GeneratorDocumentLineItem>(); var numLines = random.Next(1, supplier.MaxLines); for (int l = 0; l < numLines; l++) { var gdli = new GeneratorDocumentLineItem(); var product = Products.GetRandomProduct(); gdli.Discount = product.Discount; gdli.Isbn = product.Isbn; gdli.ItemNumber = (l + 1).ToString(); gdli.Price = product.Price; gdli.Title = product.Title; gdli.Quantity = random.Next(1, 100); gdli.Taxable = product.Taxable; gd.Lines.Add(gdli); } gs.Documents.Add(gd); } return(gs); }
private void button1_Click_1(object sender, RoutedEventArgs e) { try { GeneratorDocument document = new GeneratorDocument(); string path = document.Save(tvTables.SelectedItem as DatatableItem); if (MessageBox.Show("文件已成功生成,是否打开输出目录?", "完成", MessageBoxButton.OKCancel, MessageBoxImage.Information, MessageBoxResult.OK) == MessageBoxResult.OK) { using (Process p = new Process()) { p.StartInfo.FileName = "explorer.exe"; p.StartInfo.Arguments = @" /select, " + path; p.Start(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public DocumentBuilder(GeneratorHeader header, GeneratorDocument generatorDocument) { this.header = header; this.generatorDocument = generatorDocument; }
public OscorpDocumentBuilder(GeneratorHeader header, GeneratorDocument generatorDocument) : base(header, generatorDocument) { }
public NouryonDocumentBuilder(GeneratorHeader header, GeneratorDocument generatorDocument) : base(header, generatorDocument) { }
public static GeneratorSpecification Generate(Supplier supplier, int numDocuments = 1, int baseDocumentNumber = 20000) { bool save = false; if (saveExpectedResultsToScoreDatabase.ToLower() == "true") { save = true; Console.WriteLine($"Expected results will be saved to scores database"); } else { Console.WriteLine($"Warning!! Expected results are not being saved."); } var gs = new GeneratorSpecification(); gs.Header = new GeneratorHeader { LogoFile = supplier.LogoFile, SupplierFullName = supplier.SupplierFullName, DocumentType = "INVOICE", SupplierKey = supplier.SupplierKey, SupplierName = supplier.SupplierName, BuilderAssembly = supplier.BuilderAssembly, BuilderType = supplier.BuilderType }; gs.Documents = new List <GeneratorDocument>(); for (int d = 0; d < numDocuments; d++) { GeneratorDocument gd = new GeneratorDocument(); gd.DocumentFormat = supplier.SupplierKey; gd.DocumentNumber = (baseDocumentNumber + 1 + d).ToString(); gd.FileName = $"{gs.Header.DocumentType}-{gd.DocumentNumber}.pdf"; gd.DocumentDate = DateTime.Now.Subtract(new TimeSpan(random.Next(1, 180), 0, 0, 0)); if (random.Next(1, 10) <= 3) { gd.Notes = "Need to do something with this"; } var account = Accounts.GetRandomAccount(); gd.PostalCode = account.PostalCode; gd.SingleName = account.SingleName; gd.Account = account.AccountNumber; gd.AddressLine1 = account.AddressLine1; gd.AddressLine2 = account.AddressLine2; gd.City = account.City; gd.Lines = new List <GeneratorDocumentLineItem>(); var numLines = random.Next(1, supplier.MaxLines); for (int l = 0; l < numLines; l++) { var gdli = new GeneratorDocumentLineItem(); var product = Products.GetRandomProduct(); gdli.Discount = product.Discount; gdli.Isbn = product.Isbn; gdli.ItemNumber = (l + 1).ToString(); gdli.Price = product.Price; gdli.Title = product.Title; gdli.Quantity = random.Next(1, 100); gdli.Taxable = product.Taxable; gd.Lines.Add(gdli); } gs.Documents.Add(gd); if (save) { gd.Save(); } } return(gs); }
public static IDocumentBuilder GetBuilder(string assembly, string type, GeneratorHeader header, GeneratorDocument generatorDocument) { string typeToLoad = String.Format(@"{0}.{1}, {0}", assembly, type); Type builderType = Type.GetType(typeToLoad); if ((assembly != null) && (type != null)) { object o = Activator.CreateInstance(builderType, new Object[] { header, generatorDocument }); if (o is IDocumentBuilder) { return((IDocumentBuilder)o); } throw new Exception("Specified Builder does not exist"); } return(null); }