[chore:] logging for DataImport.cs
This commit is contained in:
+29
-2
@@ -19,6 +19,8 @@ public class DataImport
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<(bool, KasAddressList)> ImportKasAddressListWithoutPatch(Uri pathToCsv, char separator)
|
private static async Task<(bool, KasAddressList)> ImportKasAddressListWithoutPatch(Uri pathToCsv, char separator)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(pathToCsv.LocalPath))
|
if (!File.Exists(pathToCsv.LocalPath))
|
||||||
{
|
{
|
||||||
@@ -83,7 +85,7 @@ public class DataImport
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error while parsing line: {line} - {ex.Message}");
|
Logger.Log($"Error while creating new kas person (import): {ex.Message}",Logger.LogType.Error);
|
||||||
Console.WriteLine(ex.StackTrace);
|
Console.WriteLine(ex.StackTrace);
|
||||||
return (false, null);
|
return (false, null);
|
||||||
}
|
}
|
||||||
@@ -91,9 +93,18 @@ public class DataImport
|
|||||||
|
|
||||||
return (true, imported);
|
return (true, imported);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log($"Error while importing kas address list without patch: {ex.Message}",Logger.LogType.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (false, null);
|
||||||
|
}
|
||||||
|
|
||||||
private static async Task<(bool, KasAddressList)> ImportKasAddressListWithPatch(Uri pathToCsv, AddressPatch patch,
|
private static async Task<(bool, KasAddressList)> ImportKasAddressListWithPatch(Uri pathToCsv, AddressPatch patch,
|
||||||
char separator)
|
char separator)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(pathToCsv.LocalPath))
|
if (!File.Exists(pathToCsv.LocalPath))
|
||||||
{
|
{
|
||||||
@@ -217,13 +228,19 @@ public class DataImport
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error while parsing line: {line} - {ex.Message}");
|
Logger.Log($"Error while creating kas person (import, patch): {ex.Message}",Logger.LogType.Error);
|
||||||
Console.WriteLine(ex.StackTrace);
|
Console.WriteLine(ex.StackTrace);
|
||||||
return (false, null);
|
return (false, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (true, imported);
|
return (true, imported);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log($"Error while importing kas address list with patch: {ex.Message}",Logger.LogType.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// int GenerateNewRefsid()
|
// int GenerateNewRefsid()
|
||||||
// {
|
// {
|
||||||
@@ -236,6 +253,7 @@ public class DataImport
|
|||||||
// last_refsid = biggest + 1;
|
// last_refsid = biggest + 1;
|
||||||
// return last_refsid;
|
// return last_refsid;
|
||||||
// }
|
// }
|
||||||
|
return (false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,6 +263,8 @@ public class DataImport
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static string[] ParseCsvLine(string line, char separator)
|
private static string[] ParseCsvLine(string line, char separator)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var fields = new List<string>();
|
var fields = new List<string>();
|
||||||
var current = new StringBuilder();
|
var current = new StringBuilder();
|
||||||
@@ -280,4 +300,11 @@ public class DataImport
|
|||||||
fields.Add(current.ToString().Trim());
|
fields.Add(current.ToString().Trim());
|
||||||
return fields.ToArray();
|
return fields.ToArray();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log($"Error while persing csv line: {ex.Message}",Logger.LogType.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user