2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 namespace Sage.
ES.S50.CloudId
9 public static class LogWriterHelper_Obsolete
13 private static string debugFileName1 =
System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().Location),
"SageCloudId.log");
15 private static string debugFileName2 =
System.IO.Path.Combine(
System.IO.Path.GetTempPath(),
"SageCloudId.log");
17 private static string debugFilenameDefinitive = debugFileName1;
19 private static int _logStatus = 1;
21 private static int _logStatus = -1;
24 private static int _retryAttempts = 3;
25 private static int _retryIntervalMs = 100;
27 private static bool writeLog
33 if (
System.IO.File.Exists(debugFileName1))
35 debugFilenameDefinitive = debugFileName1;
38 else if (
System.IO.File.Exists(debugFileName2))
40 debugFilenameDefinitive = debugFileName2;
46 return _logStatus == 1;
50 public static void WriteDebugLine(
string debugText)
56 string cadena2Write = DateTime.Now.ToString() +
" -> " + debugText + Environment.NewLine;
61 System.IO.File.AppendAllText(debugFilenameDefinitive, cadena2Write);
68 if (failedTries < _retryAttempts)
69 System.Threading.Thread.Sleep(_retryIntervalMs);
74 string metaError =
"Se ha producido un error no recuperable al generar trazas de Overdrive por el Sage50cEs App Adapter." + Environment.NewLine +
" - Archivo: " + debugFilenameDefinitive + Environment.NewLine +
" - Último mensaje: " + cadena2Write;
77 System.IO.File.AppendAllText(debugFilenameDefinitive +
".meta", metaError);
84 using (
System.Diagnostics.EventLog eventLog =
new System.Diagnostics.EventLog(
"Application"))
86 eventLog.Source =
"Sage CloudID Exe Helper App";
87 eventLog.WriteEntry(metaError,
System.Diagnostics.EventLogEntryType.Warning);
97 }
while (!success && failedTries < _retryAttempts);
101 public static void ResetLogStatus()
106 public static string ProcessException(Exception ex)
108 string exceptionData =
"**** Datos de excepción no controlada ****" + Environment.NewLine;
109 exceptionData +=
" Mensaje: " + ex.Message + Environment.NewLine;
110 exceptionData +=
" Origen: " + ex.Source + Environment.NewLine;
111 exceptionData +=
" Pila: " + ex.StackTrace + Environment.NewLine;
112 if (ex is AggregateException aex)
116 for (
int index = 0; index < aex.InnerExceptions.Count; index++)
118 Exception exI = aex.InnerExceptions[index];
119 exceptionData +=
" Mensaje excepcion anidada " + (index + 1).ToString() +
" : " + exI.Message + Environment.NewLine;
120 exceptionData +=
" Origen excepcion anidada " + (index + 1).ToString() +
" : " + exI.Source + Environment.NewLine;
121 exceptionData +=
" Pila excepcion anidada " + (index + 1).ToString() +
" : " + exI.StackTrace + Environment.NewLine;
123 if (exI.InnerException != null)
125 exceptionData +=
" Mensaje excepcion anidada " + (index + 1).ToString() +
" Inner : " + exI.InnerException.Message + Environment.NewLine;
126 exceptionData +=
" Origen excepcion anidada " + (index + 1).ToString() +
" Inner : " + exI.InnerException.Source + Environment.NewLine;
127 exceptionData +=
" Pila excepcion anidada " + (index + 1).ToString() +
" Inner : " + exI.InnerException.StackTrace + Environment.NewLine;
132 else if (ex.InnerException != null)
134 exceptionData +=
" Mensaje Inner Exception: " + ex.InnerException.Message + Environment.NewLine;
135 exceptionData +=
" Origen Inner Exception: " + ex.InnerException.Source + Environment.NewLine;
136 exceptionData +=
" Pila Inner Exception: " + ex.InnerException.StackTrace + Environment.NewLine;
139 return exceptionData;