public override void ExportDocument(SIEESettings settings, SIEEDocument document, string name, SIEEFieldlist fieldlist) { List <SqlColumn> columns = new List <SqlColumn>(); foreach (ColumnDescription colDes in mySettings.Columns.Where(n => n.SqlTypeName != null)) { SqlColumn col = new SqlColumn() { Name = colDes.Name, SqlType = SqlTypes.GetSqlType(colDes.SqlTypeName), IsDocument = colDes.IsDocument, }; if (colDes.IsDocument) { col.ValueString = document.PDFFileName; } else { SIEEField f = fieldlist.Where(n => n.ExternalId == colDes.Name).FirstOrDefault(); col.ValueString = f == null ? null : f.Value; } columns.Add(col); } try { sqlClient.SetObjectValues(columns); } catch (Exception e) { document.NonRecoverableError = true; throw e; } sqlClient.Insert(columns); }
public List <SqlColumn> GetColumns(string tablename = null) { if (tablename == null) { tablename = DefaultTable; } List <SqlColumn> result = new List <SqlColumn>(); SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM " + tablename, conn); adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; DataTable table = new DataTable(); adapter.Fill(table); foreach (DataColumn dc in table.Columns) { string sqlType = getColumnProperty(tablename, dc, "DATA_TYPE"); bool isNullable = getColumnProperty(tablename, dc, "IS_NULLABLE").ToUpper() == "YES"; result.Add(new SqlColumn() { Name = dc.ColumnName, SqlType = SqlTypes.GetSqlType(sqlType), IsNullable = isNullable, }); } return(result); }
public void T03_GetColumns() { ISqlClient sqlClient = getClient(); List <SqlColumn> columns = sqlClient.GetColumns(testTable); Assert.AreEqual(columnMetadata.Count, columns.Count); foreach (SqlColumn cd in columns) { ColumnMetadata cmd = columnMetadata.Where(n => n.Fieldname == cd.Name).First(); if (cmd.Implemented) { Assert.AreEqual(SqlTypes.GetSqlType(cmd.Typename).SqlDbType, cd.SqlType.SqlDbType); } else { Assert.IsNull(cd.SqlType); } } }