コード例 #1
0
ファイル: Config.cs プロジェクト: solutema/ultralight
 /// <summary>
 /// Escribe un evento en la tabla sys_log. Se utiliza para registrar operaciones de datos (altas, bajas, ingresos, egresos, etc.)
 /// </summary>
 public static void ActionLog(Lfx.Data.Connection conn, Log.Acciones action, IElementoDeDatos elemento, string extra1)
 {
         try {
                 qGen.Insert Comando = new qGen.Insert(conn, "sys_log");
                 Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                 Comando.Fields.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
                 if (Lbl.Sys.Config.Actual == null || Lbl.Sys.Config.Actual.UsuarioConectado == null || Lbl.Sys.Config.Actual.UsuarioConectado.Id == 0)
                         Comando.Fields.AddWithValue("usuario", null);
                 else
                         Comando.Fields.AddWithValue("usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                 Comando.Fields.AddWithValue("comando", action.ToString());
                 if (elemento == null) {
                         Comando.Fields.AddWithValue("tabla", null);
                         Comando.Fields.AddWithValue("item_id", null);
                 } else {
                         if (action == Log.Acciones.LogOn || action == Log.Acciones.LogOnFail)
                                 Comando.Fields.AddWithValue("tabla", null);
                         else
                                 Comando.Fields.AddWithValue("tabla", elemento.TablaDatos);
                         Comando.Fields.AddWithValue("item_id", elemento.Id);
                 }
                 Comando.Fields.AddWithValue("extra1", extra1);
                 conn.Execute(Comando);
         } catch (System.Exception ex) {
                 System.Console.WriteLine(ex.ToString());
         }
 }