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 void T04_Insert() { ISqlClient sqlClient = getClient(); sqlClient.ClearTable(testTable); // Get column definitions (from data base) List <SqlColumn> columns = sqlClient.GetColumns(testTable); // Add some information from test meta data definition foreach (ColumnMetadata cmd in columnMetadata) { SqlColumn col = columns.Where(n => n.Name == cmd.Fieldname).First(); col.ValueString = cmd.TestValue; col.IsDocument = cmd.IsDocument; } // Remove unsupported columns List <SqlColumn> toBeRemoved = columns.Where(n => n.SqlType == null).ToList(); foreach (SqlColumn col in toBeRemoved) { columns.Remove(col); } // Convert strings to objects and insert row sqlClient.SetObjectValues(columns); sqlClient.Insert(columns); // Read back row from data base List <SqlColumn> result = new List <SqlColumn>(); foreach (SqlColumn col in columns) { result.Add(new SqlColumn() { Name = col.Name, SqlType = col.SqlType }); } sqlClient.GetOneRow(result); // Verify that input values and output values match foreach (SqlColumn col in columns) { compareSqlColumn(col, result.Where(n => n.Name == col.Name).First()); } // Verify that docuoment has been stored properly as blob string resultDocument = Path.Combine(Path.GetTempPath(), "Document1.pdf"); File.WriteAllBytes(resultDocument, columns.Where(n => n.Name == "MyDocument").First().ValueObject as Byte[]); Assert.IsTrue(SIEEUtils.CompareFiles(testDocument, resultDocument)); File.Delete(resultDocument); // Clear table sqlClient.ClearTable(testTable); }
public void T05_CultureInfo() { ISqlClient sqlClient = getClient(); foreach (SqlColumn col in sqlClient.GetColumns(testTable).Where(n => n.SqlType != null)) { List <SqlColumn> lc = new List <SqlColumn>(); lc.Add(col); switch (col.SqlType.DotNetType.ToString()) { case SqlTypes.DateTime_TypeName: col.ValueString = "03.04.2016"; sqlClient.SetCulture(new CultureInfo("de-DE")); sqlClient.SetObjectValues(lc); Assert.AreEqual(4, ((DateTime)col.ValueObject).Month); sqlClient.SetCulture(new CultureInfo("en-US")); sqlClient.SetObjectValues(lc); Assert.AreEqual(3, ((DateTime)col.ValueObject).Month); break; case SqlTypes.Decimal_TypeName: col.ValueString = "1.234,56"; sqlClient.SetCulture(new CultureInfo("de-DE")); sqlClient.SetObjectValues(lc); Assert.AreEqual((decimal)1234.56, col.ValueObject); col.ValueString = "1,234.56"; sqlClient.SetCulture(new CultureInfo("en-US")); sqlClient.SetObjectValues(lc); Assert.AreEqual((decimal)1234.56, col.ValueObject); break; case SqlTypes.Double_TypeName: col.ValueString = "1.234,5678"; sqlClient.SetCulture(new CultureInfo("de-DE")); sqlClient.SetObjectValues(lc); Assert.AreEqual(1234.5678, col.ValueObject); col.ValueString = "1,234.5678"; sqlClient.SetCulture(new CultureInfo("en-US")); sqlClient.SetObjectValues(lc); Assert.AreEqual(1234.5678, col.ValueObject); break; default: break; } } }