public void CreateXlsxWriter_NoHeader() { using (var workbook = new XLWorkbook()) { var worksheet = workbook.Worksheets.Add("sample"); var models = new[] { new Model { Id = 10, Name = "NAME_10", Price = 100, Remarks = "REMARKS_10" }, new Model { Id = 20, Name = "NAME_20", Price = 200, Remarks = null }, new Model { Id = 30, Name = "NAME_30", Price = 300, Remarks = "REMARKS_30" } }; var tableWriter = new TableFactory().CreateXlsxWriter <Model>(worksheet, 1, 1); tableWriter.Write(models); Assert.AreEqual(10D, worksheet.Cell(1, 1).Value); Assert.AreEqual("REMARKS_10", worksheet.Cell(1, 4).Value); } }
private void DomainForm_Shown(object sender, EventArgs e) { // Load the database tables in the current database (excluding all // Backsight system tables) string[] tableNames = new TableFactory().GetUserTables(); // Grab the currently defined domain tables IDomainTable[] currentDomains = EnvironmentContainer.Current.DomainTables; List <string> domains = new List <string>(); domains.Add(String.Empty); // Include only those tables that have the required columns. // Exclude tables that have already been defined as domain tables. foreach (string t in tableNames) { if (!Array.Exists <IDomainTable>(currentDomains, delegate(IDomainTable dt) { return(String.Compare(dt.TableName, t, true) == 0); })) { string[] cols = GetColumnNames(t); if (Array.Exists(cols, delegate(string a) { return(String.Compare(a, "ShortValue", true) == 0); }) && Array.Exists(cols, delegate(string a) { return(String.Compare(a, "LongValue", true) == 0); })) { domains.Add(t); } } } tableNameComboBox.DataSource = domains; }
private void DownloadExcel(HttpResponseBase Response, TableFactory table) { Response.Output.Write(table.ToHtml()); Response.Flush(); Response.Clear(); Response.End(); }
private KeyValuePair <string, TableMetaData> CreateRomRaiderRamTable(string name, int offset, string id, string type) { XElement xel = XElement.Parse(@" <ecu id=""""> <address></address> </ecu> "); xel.Attribute("id").Value = this.parentMod.FinalEcuId; string ts = offset.ToString("X6"); ts = ts.Substring(2, ts.Length - 2); if (ts.Length < 6 && ts.Substring(0, 2) != "FF") { Trace.WriteLine("!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!"); Trace.WriteLine("WARNING! bad ram table: " + name + " with offset: " + offset.ToString("X")); } xel.Element("address").Value = "0x" + ts; int length = Utils.ConvertStorageTypeToIntBytes(type); if (length > 1) { xel.Element("address").SetAttributeValue("length", length.ToString()); } return(new KeyValuePair <string, TableMetaData>(name, TableFactory.CreateRamTable(xel, name, type, this.definition))); }
/// <summary> /// Format summarize expression /// </summary> /// <param name="summarizeExpression">the expression to be formatted</param> /// <returns>the original expression</returns> protected override Expression VisitSummarizeExpression(SummarizeExpression summarizeExpression) { if (summarizeExpression.AllColumns != null && summarizeExpression.AllColumns.Any()) { this.Builder.Append("\tSUMMARIZE(\n"); this.Visit(TableFactory.GetTableExpression(summarizeExpression.MainTable)); if (summarizeExpression.Columns.Any()) { IEnumerable <string> cs = summarizeExpression.Columns.Select(c => ((ColumnExpression)c.Expression).DbName).Distinct(); string columnString = cs.Aggregate((c1, c2) => c1 + ",\n" + c2); this.Builder.Append(","); this.Builder.Append(columnString); } if (summarizeExpression.Measures.Any()) { this.VisitMeasures(summarizeExpression.Measures); this.Builder.Append(")"); } else { this.Builder.Append(")"); } } else { return(this.Visit(summarizeExpression.MainTable)); } return(summarizeExpression); }
public void GetCreateSqlTest() { var table = new AlbumTable(); var expected = $"CREATE TABLE {TableFactory<Album>.GetTable<AlbumTable>().TableName} ({AlbumTable.IdColumnName} INTEGER NOT NULL PRIMARY KEY, {AlbumTable.NameColumnName} TEXT UNIQUE NOT NULL COLLATE NOCASE, {AlbumTable.YearColumnName} INTEGER NOT NULL, {AlbumTable.ArtistIdColumnName} INTEGER NOT NULL, {AlbumTable.GenreIdColumnName} INTEGER NOT NULL, FOREIGN KEY({AlbumTable.ArtistIdColumnName}) REFERENCES {TableFactory<Artist>.GetTable<ArtistTable>().TableName}({ArtistTable.IdColumnName}), FOREIGN KEY({AlbumTable.GenreIdColumnName}) REFERENCES {TableFactory<Genre>.GetTable<GenreTable>().TableName}({GenreTable.IdColumnName})) WITHOUT ROWID;"; Assert.AreEqual(expected, table.GetCreateSql()); }
public void OpenTableReturnsNewTable() { TableFactory factory = new TableFactory(); object obj = factory.OpenTable(""); Assert.IsInstanceOf <ITable>(obj); }
public void GetFetchSqlTest() { var id = HelperObjectFactory.GetRandomInt(0, 100); var value = new IdentifyingInfo { Id = id }; var parameters = new List <SQLiteParameter>(); var table = new GenreTable(); var expected = $"SELECT * FROM {TableFactory<Genre>.GetTable<GenreTable>().TableName} WHERE {GenreTable.IdColumnName} = @{GenreTable.IdColumnName};"; Assert.AreEqual(expected, table.GetFetchSql(value, ref parameters)); Assert.AreEqual(1, parameters.Count); parameters.Clear(); value = new IdentifyingInfo { Name = StringExtensions.GetRandomStringAsync(25).Result }; expected = $"SELECT * FROM {TableFactory<Genre>.GetTable<GenreTable>().TableName} WHERE {GenreTable.NameColumnName} = @{GenreTable.NameColumnName};"; Assert.AreEqual(expected, table.GetFetchSql(value, ref parameters)); Assert.AreEqual(1, parameters.Count); }
public void GetCreateSqlTest() { var table = new GenreTable(); var expected = $"CREATE TABLE {TableFactory<Genre>.GetTable<GenreTable>().TableName} ({GenreTable.IdColumnName} INTEGER NOT NULL PRIMARY KEY, {GenreTable.NameColumnName} TEXT UNIQUE NOT NULL COLLATE NOCASE) WITHOUT ROWID;"; Assert.AreEqual(expected, table.GetCreateSql()); }
static void Main(string[] args) { string basePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "..", "assets"); var files = Directory.GetFiles(basePath, "*.docx"); IList <Model> models = new List <Model>(); string[] fields = new string[] { "name", "sex", "minzu", "jiguan", "birth", "zhengzhimm", "living", "sfzh", "phone", "xueli", "marrige", "date", "health", "company", "area" }; foreach (var file in files) { Console.WriteLine("file: " + file); models.Add(ParseFile(basePath, file, fields)); } // write models to file. using (var workbook = new XLWorkbook(Path.Combine(basePath, "工会会员信息汇总表.xlsx"))) { var worksheet = workbook.Worksheet(1); // parameters is (worksheet, startRowNumber, startColumnNuber) var tableWriter = new TableFactory().CreateXlsxWriter <Model>(worksheet, 2, 1); // parameter is (models, header) tableWriter.Write(models, fields); workbook.Save(); } }
public void CreateExcelWriter() { IWorkbook workbook = new HSSFWorkbook(); var worksheet = workbook.CreateSheet("sample"); var models = new[] { new Model { Id = 10, Name = "NAME_10", Price = 100, Remarks = "REMARKS_10" }, new Model { Id = 20, Name = "NAME_20", Price = 200, Remarks = null }, new Model { Id = 30, Name = "NAME_30", Price = 300, Remarks = "REMARKS_30" } }; var tableWriter = new TableFactory().CreateExcelWriter <Model>(worksheet, 1, 1); tableWriter.Write(models, new[] { "ID", "NAME", "PRICE", "REMARKS" }); Assert.AreEqual("ID", worksheet.GetRow(0).GetCell(0).StringCellValue); Assert.AreEqual("REMARKS", worksheet.GetRow(0).GetCell(3).StringCellValue); Assert.AreEqual(10D, worksheet.GetRow(1).GetCell(0).NumericCellValue); Assert.AreEqual("REMARKS_10", worksheet.GetRow(1).GetCell(3).StringCellValue); Assert.AreEqual("", worksheet.GetRow(2).GetCell(3).StringCellValue); Assert.AreEqual(300D, worksheet.GetRow(3).GetCell(2).NumericCellValue); }
private void DomainForm_Shown(object sender, EventArgs e) { // Load the database tables in the current database (excluding all // Backsight system tables) string[] tableNames = new TableFactory().GetUserTables(); // Grab the currently defined domain tables IDomainTable[] currentDomains = EnvironmentContainer.Current.DomainTables; List<string> domains = new List<string>(); domains.Add(String.Empty); // Include only those tables that have the required columns. // Exclude tables that have already been defined as domain tables. foreach (string t in tableNames) { if (!Array.Exists<IDomainTable>(currentDomains, delegate(IDomainTable dt) { return String.Compare(dt.TableName, t, true) == 0; })) { string[] cols = GetColumnNames(t); if (Array.Exists(cols, delegate(string a) { return String.Compare(a, "ShortValue", true) == 0; }) && Array.Exists(cols, delegate(string a) { return String.Compare(a, "LongValue", true) == 0; })) domains.Add(t); } } tableNameComboBox.DataSource = domains; }
public void OpenTableGenericReturnsGenericTable() { TableFactory factory = new TableFactory(); object obj = factory.OpenTable <DummyDef>(""); Assert.IsInstanceOf <ITable <DummyDef> >(obj); }
public void GenericOpenTableResolvesNameUsingTableCommandRunnerWithZeroForLastTable() { TableFactory factory = new TableFactory(); object table = factory.OpenTable <DummyDef>("DummyPath"); mockcommandrunner.Verify(cmd => cmd.GetName(0)); }
public void CreatePdf <T>(IList <T> listItems, HttpResponseBase Response) { if (listItems == null) { throw new ArgumentNullException("Excel list is Required."); } if (Response == null) { throw new ArgumentNullException("Response is Required."); } var properties = ReportService.GetObjectPropertyInfo <T>(); TableFactory table = new TableFactory(); table.InitTable(); AddPdfTitle <T>(properties.Count(), table); ReportService.AddColumnGroup(properties, table); ReportService.AddTableColumnHeader(properties, table); ReportService.AddTableColumnCell(properties, table, listItems); table.EndTable(); AddResponseHeader(Response); DownloadPdf(Response, new MemoryStream(GeneratePdfBiteArray(table.ToHtml()))); }
void LoadTableList() { IEnvironmentContainer ec = EnvironmentContainer.Current; string[] tableNames = new TableFactory().GetUserTables(); List <string> exclude = new List <string>(); if (excludeDomainTablesCheckBox.Checked) { IDomainTable[] domainTables = ec.DomainTables; foreach (IDomainTable t in domainTables) { exclude.Add(t.TableName); } } if (excludeAlreadyAddedCheckBox.Checked) { ITable[] tables = ec.Tables; foreach (ITable t in tables) { exclude.Add(t.TableName); } } if (exclude.Count > 0) { tableNames = Array.FindAll <string>(tableNames, delegate(string s) { return(!exclude.Contains(s)); }); } tableList.Items.Clear(); tableList.Items.AddRange(tableNames); }
public void ConstructorTest() { var boolNullable = new GenreTable(); Assert.AreEqual("genres", TableFactory <Genre> .GetTable <GenreTable>().TableName); Assert.IsNotNull(boolNullable); }
public STableController() { _factory = new TableFactory(); _Zonefactory = new ZoneFactory(); ViewBag.ListStore = GetListStore(); }
public void GetTableTest() { var t1 = TableFactory <Album> .GetTable <AlbumTable>(); Assert.IsInstanceOf(typeof(AlbumTable), t1); var t2 = TableFactory <Artist> .GetTable <ArtistTable>(); Assert.IsInstanceOf(typeof(ArtistTable), t2); var t3 = TableFactory <Genre> .GetTable <GenreTable>(); Assert.IsInstanceOf(typeof(GenreTable), t3); var s1 = TableFactory <Album> .GetTable <AlbumTable>(); Assert.IsTrue(ReferenceEquals(t1, s1)); var s2 = TableFactory <Artist> .GetTable <ArtistTable>(); Assert.IsTrue(ReferenceEquals(t2, s2)); var s3 = TableFactory <Genre> .GetTable <GenreTable>(); Assert.IsTrue(ReferenceEquals(t3, s3)); }
public void ConstructorTest() { var boolNullable = new ArtistTable(); Assert.AreEqual("artists", TableFactory <Artist> .GetTable <ArtistTable>().TableName); Assert.IsNotNull(boolNullable); }
//----------------------------------------------------------------// public BaseDbOperation(ISession session) { Session = session; TableName = $"public.{TableFactory.GetNameTable<T>()}"; Connection = session.Connection; Transaction = session.Transaction; }
/// <summary> /// Creates the tables in the database. /// </summary> /// <exception cref="ArgumentNullException">The parameter was null.</exception> /// <exception cref="MissingMethodException"> /// In the .NET for Windows Store apps or the Portable Class Library, catch the /// base class exception, <see cref="T:System.MissingMemberException" />, instead. /// The type that is specified does not have a parameterless constructor. /// </exception> private async Task CreateDatabaseTablesAsync() { await DatabaseWrapper.ExecuteSqlWithParametersAsync(TableFactory <Album> .GetTable <AlbumTable>().GetCreateSql(), null); await DatabaseWrapper.ExecuteSqlWithParametersAsync(TableFactory <Artist> .GetTable <ArtistTable>().GetCreateSql(), null); await DatabaseWrapper.ExecuteSqlWithParametersAsync(TableFactory <Genre> .GetTable <GenreTable>().GetCreateSql(), null); }
public ITableFactory BuildTableFactory() { ITableCommandRunner tablerunner = new TableCommandRunner(this.wrapper); IQueryProvider provider = new MapinfoQueryProvider(this.wrapper); ITableFactory tableFactory = new TableFactory(tablerunner, provider); return(tableFactory); }
public Controller() { this.bakedFoods = new List <IBakedFood>(); this.drinks = new List <IDrink>(); this.tables = new List <ITable>(); this.foodFactory = new BakedFoodFactory(); this.drinkFactory = new DrinkFactory(); this.tableFactory = new TableFactory(); }
private void AddPdfTitle <T>(int columnCount, TableFactory table) { if (!string.IsNullOrEmpty(this.PdfTitle)) { table.AddRow(); table.AddReportTitle(this.PdfTitle, columnCount, ReportService.GetTitleStyles <T>()); table.EndRow(); } }
public void OpenTableCallsOpenTableOnCommandRunner() { TableFactory factory = new TableFactory(); object table1 = factory.OpenTable("DummyPath"); object table2 = factory.OpenTable <DummyDef>("DummyPath2"); mockcommandrunner.Verify(cmd => cmd.OpenTable("DummyPath")); mockcommandrunner.Verify(cmd => cmd.OpenTable("DummyPath2")); }
public ResturantController() { this.menu = new List <IFood>(); this.drinks = new List <IDrink>(); this.tables = new List <ITable>(); this.foodFactory = new FoodFactory(); this.drinkFactory = new DrinkFactory(); this.tableFactory = new TableFactory(); }
public static void Main() { IFoodFactory foodFactory = new FoodFactory(); IDrinkFactory drinkFactory = new DrinkFactory(); ITableFactory tableFactory = new TableFactory(); var restaurantController = new RestaurantController(foodFactory, drinkFactory, tableFactory); var engine = new Engine(restaurantController); engine.Run(); }
public void GetUpdateSqlTest() { var id = HelperObjectFactory.GetRandomInt(0, 100); var value = new Genre(id, StringExtensions.GetRandomStringAsync(23).Result); var parameters = new List <SQLiteParameter>(); var table = new GenreTable(); var expected = $"UPDATE {TableFactory<Genre>.GetTable<GenreTable>().TableName} SET {GenreTable.NameColumnName} = @{GenreTable.NameColumnName} WHERE {GenreTable.IdColumnName} = @{GenreTable.IdColumnName};"; Assert.AreEqual(expected, table.GetUpdateSql(value, ref parameters)); Assert.AreEqual(2, parameters.Count); }
public WildMagic OfficialManualRoll(int manualRoll) { // Check if roll is Odd, and add 1 in that case. This is to align with our 1-50 table. if (manualRoll % 2 != 0) { manualRoll++; } int Roll = manualRoll / 2; return(CurrentResult = TableFactory.GetResult(Roll)); }
public void GetInsertSqlTest() { var id = HelperObjectFactory.GetRandomInt(0, 100); var value = new Genre(id, StringExtensions.GetRandomStringAsync(23).Result); var parameters = new List <SQLiteParameter>(); var table = new GenreTable(); var expected = $"INSERT OR IGNORE INTO {TableFactory<Genre>.GetTable<GenreTable>().TableName} ({GenreTable.IdColumnName}, {AlbumTable.NameColumnName}) VALUES(@{GenreTable.IdColumnName}, @{GenreTable.NameColumnName});"; Assert.AreEqual(expected, table.GetInsertSql(value, ref parameters)); Assert.AreEqual(2, parameters.Count); }
internal TemplateForm(IEditTemplate edit) { InitializeComponent(); m_Edit = edit; if (m_Edit == null) { IEnvironmentFactory f = EnvironmentContainer.Factory; m_Edit = f.CreateTemplate(); } m_TableFactory = new TableFactory(); m_Table = null; m_Edit.BeginEdit(); }
public void Setup() { _factory = new TableFactory(new Mock<ITableConventions>().Object); }
string[] GetColumnNames(string tableName) { TableFactory tf = new TableFactory(); Smo.Table t = tf.FindTableByName(tableName); if (t == null) return new string[0]; List<string> result = new List<string>(t.Columns.Count); foreach (Smo.Column c in t.Columns) result.Add(c.Name); return result.ToArray(); }
/// <summary> /// Creates a new <c>CreateTablesForm</c> using the the supplied factory. /// </summary> /// <param name="tf">The factory that can be used to create database tables. /// This should be an instance where its <see cref="DoTablesExist"/> method /// returns <c>false</c>. /// </param> public CreateTablesForm(TableFactory tf) { InitializeComponent(); m_Factory = tf; m_IsCreated = false; }
private void columnsPage_ShowFromNext(object sender, EventArgs e) { columnsGrid.Rows.Clear(); idColumnComboBox.Items.Clear(); TableFactory tf = new TableFactory(); string tableName = m_Edit.TableName; Smo.Table t = tf.FindTableByName(tableName); if (t == null) return; // Get any domains already associated with the table IColumnDomain[] curDomains = m_Edit.ColumnDomains; columnsGrid.RowCount = t.Columns.Count; for (int i=0; i<columnsGrid.RowCount; i++) { Smo.Column c = t.Columns[i]; idColumnComboBox.Items.Add(c.Name); DataGridViewRow row = columnsGrid.Rows[i]; row.Cells["dgcColumnName"].Value = c.Name; Smo.DataType dt = c.DataType; string dataType = dt.SqlDataType.ToString().ToLower(); if (dt.SqlDataType == Smo.SqlDataType.Char || dt.SqlDataType == Smo.SqlDataType.NChar || dt.SqlDataType == Smo.SqlDataType.VarChar || dt.SqlDataType == Smo.SqlDataType.NVarChar) dataType += String.Format("({0})", dt.MaximumLength); if (!c.Nullable) dataType += " not null"; row.Cells["dgcDataType"].Value = dataType; // Display any domain previously associated with the column IColumnDomain cd = Array.Find<IColumnDomain>(curDomains, delegate(IColumnDomain tcd) { return tcd.ColumnName == c.Name; }); if (cd != null) row.Cells["dgcDomain"].Value = cd.Domain; row.Tag = c; } // Nothing initially selected columnsGrid.CurrentCell = null; // If we have a simple primary key, assume it's the feature ID column if (String.IsNullOrEmpty(m_Edit.IdColumnName)) { Smo.Column pk = TableFactory.GetSimplePrimaryKeyColumn(t); if (pk != null) idColumnComboBox.SelectedItem = pk.Name; } else { idColumnComboBox.SelectedItem = m_Edit.IdColumnName; } }
void LoadTableList() { IEnvironmentContainer ec = EnvironmentContainer.Current; string[] tableNames = new TableFactory().GetUserTables(); List<string> exclude = new List<string>(); if (excludeDomainTablesCheckBox.Checked) { IDomainTable[] domainTables = ec.DomainTables; foreach (IDomainTable t in domainTables) exclude.Add(t.TableName); } if (excludeAlreadyAddedCheckBox.Checked) { ITable[] tables = ec.Tables; foreach (ITable t in tables) exclude.Add(t.TableName); } if (exclude.Count > 0) { tableNames = Array.FindAll<string>(tableNames, delegate(string s) { return !exclude.Contains(s); }); } tableList.Items.Clear(); tableList.Items.AddRange(tableNames); }