Exemple #1
0
        private void writeLog()
        {
            try
            {
                const string tag = "|";
                string       log = Environment.NewLine + this.date + tag + this.starttime + tag + this.function +
                                   tag + (string.IsNullOrEmpty(this.sql) ? "" : this.sql.Replace(Environment.NewLine, " ")) +
                                   tag + this.vars + tag + this.endtime + tag + this.user +
                                   tag + (string.IsNullOrEmpty(this.error) ? "" : this.error.Replace(Environment.NewLine, " ")) +
                                   tag + this.info;

                archivos f    = new archivos();
                string   file = f.checkCarpeta(this.LogFolder) + this.LogFile;
                if (f.existeFichero(file))
                {
                    //append to actual log
                    using System.IO.StreamWriter z_varocioStreamWriter = new System.IO.StreamWriter(file, true, System.Text.Encoding.UTF8);
                    z_varocioStreamWriter.Write(log);
                    z_varocioStreamWriter.Close();
                }
                else
                {
                    log = "DATE" + tag + "Start Time" + tag + "Function" + tag + "SQL" +
                          tag + "Variables" + tag + "End Time" + tag + "USER" +
                          tag + "Error Trace" + tag + "Info" + tag + log;
                    f.guardaDato(this.LogFile, log, this.LogFolder);
                }
                f = null;
            }
            catch
            {
                return;
            }
        }
Exemple #2
0
 public defLog(string Folder)
 {
     this.date      = DateTime.Today.ToShortDateString();
     this.starttime = DateTime.Now.ToShortTimeString();
     this.endtime   = DateTime.Now.ToShortTimeString();
     this.sql       = string.Empty;
     this.function  = string.Empty;
     this.vars      = string.Empty;
     this.result    = false;
     this.error     = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Folder))
         {
             archivos a = new archivos();
             this.folder = a.checkCarpeta(Folder);
             a           = null;
         }
         else
         {
             this.folder = string.Empty;
         }
     }
     catch
     {
         this.folder = string.Empty;
     }
 }