@@ -31,31 +31,31 @@ internal class SQLInteraction
3131 // Store selected and ignored columns from configuration
3232 // private HashSet<string> SelectedColumns { get; set; }
3333 private HashSet < string > IgnoredColumns { get ; set ; }
34- private Dictionary < string , ColumnMapping > ColumnMappings { get ; set ; }
35- private Dictionary < string , ColumnMapping > _columnMappings ;
34+ public Dictionary < string , ColumnMapping > ColumnMappings { get ; set ; }
35+ // private Dictionary<string, ColumnMapping> _columnMappings;
3636
3737 /// <summary>
3838 /// Initializes the SQL table for the specified SharePoint list,
3939 /// creating or updating schema as necessary.
4040 /// </summary>
4141 public void Build ( )
4242 {
43- Logger . Log ( 1 , "[Build]" , $ " Starting SQL build process for list: { this . List ? . Name ?? "null" } " ) ;
43+ Logger . Log ( 1 , "[Build] Starting SQL build process for list: " + ( this . List ? . Name ?? "null" ) ) ;
4444
4545 try
4646 {
4747 // Load selected and ignored columns from configuration
4848 // this.SelectedColumns = ConfigurationReader.GetSelectedColumns();
4949 this . IgnoredColumns = ConfigurationReader . GetIgnoredColumns ( ) ;
5050
51- Logger . Log ( 1 , "[Build]" , $ " Ignored columns from config: { ( this . IgnoredColumns == null ? "None" : string . Join ( ", " , this . IgnoredColumns ) ) } " ) ;
51+ Logger . Log ( 1 , "[Build] Ignored columns from config: " + ( this . IgnoredColumns == null ? "None" : string . Join ( ", " , this . IgnoredColumns ) ) ) ;
5252
5353 this . TableName = this . ToPascalCase ( this . List . Name , false ) ;
5454
5555 try
5656 {
5757 this . Connection = new SqlConnection ( ConfigurationReader . GetSqlConnectionString ( ) ) ;
58- Logger . Log ( 1 , "Build" , " Establishing SQL connection...") ;
58+ Logger . Log ( 1 , "[ Build] Establishing SQL connection..." ) ;
5959 this . Connection . Open ( ) ;
6060 }
6161 catch ( SqlException ex )
@@ -70,7 +70,7 @@ public void Build()
7070
7171 try
7272 {
73- Logger . Log ( 1 , "[Build]" , " Initializing SharePoint list structure...") ;
73+ Logger . Log ( 1 , "[Build] Initializing SharePoint list structure..." ) ;
7474 this . List . Build ( ) ;
7575 }
7676 catch ( Exception ex )
@@ -83,7 +83,7 @@ public void Build()
8383 try
8484 {
8585 this . FNDictionary = new Dictionary < string , Field > ( StringComparer . OrdinalIgnoreCase ) ;
86- Logger . Log ( 1 , "[Build]" , " Building field dictionary...") ;
86+ Logger . Log ( 1 , "[Build] Building field dictionary..." ) ;
8787 this . BuildDictionary ( ) ;
8888 }
8989 catch ( Exception ex )
@@ -97,12 +97,12 @@ public void Build()
9797 {
9898 if ( ! this . TableExists ( this . TableName ) )
9999 {
100- Logger . Log ( 1 , "[Build]" , $ " Creating new table: { this . TableName } " ) ;
100+ Logger . Log ( 1 , "[Build] Creating new table: " + this . TableName ) ;
101101 this . CreateTable ( ) ;
102102 }
103103 else
104104 {
105- Logger . Log ( 1 , "[Build]" , $ " Updating existing table: { this . TableName } " ) ;
105+ Logger . Log ( 1 , "[Build] Updating existing table: " + this . TableName ) ;
106106 this . UpdateTableDesign ( ) ;
107107 }
108108 }
@@ -128,7 +128,7 @@ public void DailyUpdate()
128128 {
129129 try
130130 {
131- Logger . Log ( 2 , "[DailyUpdate]" , $ " Starting daily update for table: { this . TableName } " ) ; // ver isto
131+ Logger . Log ( 2 , "[DailyUpdate] Starting daily update for table " + this . TableName ) ;
132132
133133 try
134134 {
@@ -161,7 +161,7 @@ public void DailyUpdate()
161161 try
162162 {
163163 this . Transaction . Commit ( ) ;
164- Logger . Log ( 2 , "[DailyUpdate]" , " Transaction committed successfully") ;
164+ Logger . Log ( 2 , "[DailyUpdate] Transaction committed successfully" ) ;
165165 }
166166 catch ( Exception ex )
167167 {
@@ -184,7 +184,7 @@ public void CurrentTimeUpdate()
184184 {
185185 try
186186 {
187- Logger . Log ( 2 , "[CurrentTimeUpdate]" , $ " Starting current-time update for: { this . TableName } " ) ; // ver isto
187+ Logger . Log ( 2 , "[CurrentTimeUpdate] Starting current-time update for " + this . TableName ) ;
188188
189189 try
190190 {
@@ -253,19 +253,19 @@ private void BuildDictionary()
253253 if ( mapping . Ignore )
254254 {
255255 ignoredFields ++ ;
256- Logger . Log ( 1 , "[BuildDictionary] Ignored field (by mapping): {columnName}" ) ;
256+ Logger . Log ( 1 , "[BuildDictionary] Ignored field (by mapping) " + columnName ) ;
257257 continue ;
258258 }
259259
260260 string destinationName = mapping . Destination ;
261261 this . FNDictionary . Add ( this . GetKeyName ( destinationName , 1 ) , field ) ;
262262 processedFields ++ ;
263- Logger . Log ( 1 , "[BuildDictionary] Added mapped field: { columnName} -> {destinationName}" ) ;
263+ Logger . Log ( 1 , "[BuildDictionary] Added mapped field " + columnName + " -> " + destinationName ) ;
264264 }
265265 else
266266 {
267267 skippedFields ++ ;
268- Logger . Log ( 1 , "[BuildDictionary] Skipped field (not mapped): {columnName}" ) ;
268+ Logger . Log ( 1 , "[BuildDictionary] Skipped field (not mapped) " + columnName ) ;
269269 }
270270 }
271271 // Se não houver mapeamento, processa todos (comportamento padrão)
@@ -298,7 +298,7 @@ private bool TableExists(string listName)
298298 {
299299 this . Command . CommandText = $ "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{ listName } '";
300300 bool exists = ( int ) this . Command . ExecuteScalar ( ) != 0 ;
301- Logger . Log ( 1 , "[TableExists]" , $ " Table '{ listName } ' exists: { exists } ") ;
301+ Logger . Log ( 1 , $ "[TableExists] Table '{ listName } ' exists: { exists } ") ;
302302 return exists ;
303303 }
304304 catch ( Exception ex )
@@ -456,7 +456,7 @@ private void TransferData(string snapDate)
456456 }
457457 }
458458
459- Logger . Log ( 1 , "[TransferData]" , $ " Transfer completed. Processed: { processedItems } , Failed: { failedItems } ") ;
459+ Logger . Log ( 1 , $ "[TransferData] Transfer completed. Processed: { processedItems } , Failed: { failedItems } ") ;
460460 }
461461
462462 private string SQLFieldType ( Field field )
@@ -495,7 +495,7 @@ private string SQLFieldType(Field field)
495495 ? "[nvarchar](MAX)"
496496 : "[int]" ;
497497 default :
498- Logger . Log ( 1 , "[SQLFieldType]" , $ " Unknown field type encountered - Field: { field . Title } , Type: { field . TypeAsString } ") ;
498+ Logger . Log ( 1 , $ "[SQLFieldType] Unknown field type encountered - Field: { field . Title } , Type: { field . TypeAsString } ") ;
499499 return null ;
500500 }
501501 }
@@ -513,14 +513,14 @@ private string GetSQLColNames()
513513
514514 private void UpdateMetadata ( )
515515 {
516- Logger . Log ( 1 , "[UpdateMetadata]" , $ " Updating metadata for table: { this . TableName } ") ;
516+ Logger . Log ( 1 , $ "[UpdateMetadata] Updating metadata for table: { this . TableName } ") ;
517517 try
518518 {
519519 this . Command . CommandText = $ "DELETE FROM Metadata WHERE TableName = '{ this . TableName } '";
520520 this . Command . ExecuteNonQuery ( ) ;
521521 this . Command . CommandText = $ "INSERT INTO Metadata (TableName, LastRefreshDate) VALUES ('{ this . TableName } ', '{ this . CurrentTime } ')";
522522 this . Command . ExecuteNonQuery ( ) ;
523- Logger . Log ( 1 , "[UpdateMetadata]" , " Metadata updated successfully") ;
523+ Logger . Log ( 1 , $ "[UpdateMetadata] Metadata updated successfully") ;
524524 }
525525 catch ( Exception ex )
526526 {
@@ -612,7 +612,7 @@ private void SafeRollback()
612612
613613 private void LogInfo ( string method , string message )
614614 {
615- Logger . Log ( 1 , $ "SQLInteraction.{ method } " , message ) ;
615+ Logger . Log ( 1 , $ "SQLInteraction.{ method } : { message } " ) ;
616616 }
617617
618618 private void LogError ( string method , string message , Exception ex , bool includeStack = false )
@@ -624,12 +624,12 @@ private void LogError(string method, string message, Exception ex, bool includeS
624624
625625 private void LogWarning ( string method , string message )
626626 {
627- Logger . Log ( 1 , $ "SQLInteraction.{ method } " , message ) ;
627+ Logger . Log ( 1 , $ "SQLInteraction.{ method } : { message } " ) ;
628628 }
629629
630630 private void LogDebug ( string method , string message )
631631 {
632- Logger . Log ( 1 , $ "SQLInteraction.{ method } " , message ) ;
632+ Logger . Log ( 1 , $ "SQLInteraction.{ method } : { message } " ) ;
633633 }
634634
635635 private void LogFatal ( string method , string message , Exception ex )
@@ -640,7 +640,7 @@ private void LogFatal(string method, string message, Exception ex)
640640
641641 private void LogVerbose ( string method , string message )
642642 {
643- Logger . Log ( 1 , $ "SQLInteraction.{ method } " , message ) ;
643+ Logger . Log ( 1 , $ "SQLInteraction.{ method } : { message } " ) ;
644644 }
645645
646646 #endregion
0 commit comments