Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added same msg into the Logger as there is sent to the LogManager plu… #28

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.10</Version>
<Version>10.0.11</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>SQL Provider</Title>
<Description>SQL Provider</Description>
Expand Down
11 changes: 7 additions & 4 deletions src/SQLDestinationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public int RowsToWriteCount
protected DuplicateRowsHandler duplicateRowsHandler;
protected readonly bool removeMissingAfterImportDestinationTablesOnly;
protected readonly bool SkipFailingRows;
private readonly ColumnMappingCollection _columnMappings;

/// <summary>
/// Initializes a new instance of the SqlDestinationWriter class.
Expand Down Expand Up @@ -90,6 +91,7 @@ public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool remo
public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool removeMissingAfterImport, ILogger logger, string tempTablePrefix, bool discardDuplicates)
{
Mapping = mapping;
_columnMappings = Mapping.GetColumnMappings();
SqlCommand = connection.CreateCommand();
SqlCommand.CommandTimeout = 1200;
this.removeMissingAfterImport = removeMissingAfterImport;
Expand All @@ -116,6 +118,7 @@ public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool remo
public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool removeMissingAfterImport, ILogger logger, bool discardDuplicates)
{
Mapping = mapping;
_columnMappings = Mapping.GetColumnMappings();
SqlCommand = connection.CreateCommand();
SqlCommand.CommandTimeout = 1200;
this.removeMissingAfterImport = removeMissingAfterImport;
Expand All @@ -142,6 +145,7 @@ public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool remo
public SqlDestinationWriter(Mapping mapping, SqlCommand mockSqlCommand, bool removeMissingAfterImport, ILogger logger, string tempTablePrefix, bool discardDuplicates)
{
Mapping = mapping;
_columnMappings = Mapping.GetColumnMappings();
SqlCommand = mockSqlCommand;
this.removeMissingAfterImport = removeMissingAfterImport;
this.logger = logger;
Expand All @@ -153,14 +157,13 @@ public SqlDestinationWriter(Mapping mapping, SqlCommand mockSqlCommand, bool rem
protected new virtual void Initialize()
{
List<SqlColumn> destColumns = new List<SqlColumn>();
var columnMappings = Mapping.GetColumnMappings();
foreach (ColumnMapping columnMapping in columnMappings.DistinctBy(obj => obj.DestinationColumn.Name))
foreach (ColumnMapping columnMapping in _columnMappings.DistinctBy(obj => obj.DestinationColumn.Name))
{
destColumns.Add((SqlColumn)columnMapping.DestinationColumn);
}
if (Mapping.DestinationTable != null && Mapping.DestinationTable.Name == "EcomAssortmentPermissions")
{
if (columnMappings.Find(m => string.Compare(m.DestinationColumn.Name, "AssortmentPermissionAccessUserID", true) == 0) == null)
if (_columnMappings.Find(m => string.Compare(m.DestinationColumn.Name, "AssortmentPermissionAccessUserID", true) == 0) == null)
destColumns.Add(new SqlColumn("AssortmentPermissionAccessUserID", typeof(string), SqlDbType.Int, null, -1, false, true, false));
}
SQLTable.CreateTempTable(SqlCommand, Mapping.DestinationTable.SqlSchema, Mapping.DestinationTable.Name, tempTablePrefix, destColumns, logger);
Expand Down Expand Up @@ -189,7 +192,7 @@ public SqlDestinationWriter(Mapping mapping, SqlCommand mockSqlCommand, bool rem

DataRow dataRow = TableToWrite.NewRow();

var columnMappings = Mapping.GetColumnMappings().Where(cm => cm.Active);
var columnMappings = _columnMappings.Where(cm => cm.Active);
foreach (ColumnMapping columnMapping in columnMappings)
{
object rowValue = null;
Expand Down
5 changes: 4 additions & 1 deletion src/SQLProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,10 @@ public override bool RunJob(Job job)
catch (Exception ex)
{
string msg = ex.Message;
LogManager.System.GetLogger(LogCategory.Application, "Dataintegration").Error($"{GetType().Name} error: {ex.Message} Stack: {ex.StackTrace}", ex);
string stackTrace = ex.StackTrace;

Logger?.Error($"Error: {msg.Replace(System.Environment.NewLine, " ")} Stack: {stackTrace.Replace(System.Environment.NewLine, " ")}", ex);
LogManager.System.GetLogger(LogCategory.Application, "Dataintegration").Error($"{GetType().Name} error: {msg} Stack: {stackTrace}", ex);

if (ex.Message.Contains("Subquery returned more than 1 value"))
msg += System.Environment.NewLine + "This error usually indicates duplicates on column that is used as primary key or identity.";
Expand Down
Loading