Beispiel #1
0
        public static int AddEventLog(EventLogger objTrans)
        {
            //Set the Connection String

            int result = 0;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT INTO tblEventLog");
            strSql.Append("(KIOSKID, EventDttm, EventID, Description, Uploaded) VALUES (");
            strSql.AppendFormat("'{0}','{1}',{2},'{3}','{4}')", objTrans.KioskId, FormatDateTime(objTrans.EventDtTm), objTrans.EventId, objTrans.Desc, objTrans.Uploaded);

            if (log.IsInfoEnabled) log.Info("QUERY FORMED IN AddEventLog IS : " + strSql.ToString());

            //Trace.WriteLine(strSql.ToString());
            try
            {
                Open(strConnectionString);
                SqlCeCommand command = new SqlCeCommand(strSql.ToString());
                result = ExecuteNonQuery(command);
                if (log.IsErrorEnabled) log.Error("KioskId:"+objTrans.KioskId.ToString() +" and EventId:"+ objTrans.EventId.ToString() +" is added in tblEventLog and result is:" + result.ToString());
            }
            catch (SqlCeException ex)
            {
                if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddEventLog.." + ex.Message);
                Close();
                //System.Environment.Exit(1);  //  exit

            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled) log.Error("Generic exception caught in DBLogger.AddEventLog.." + ex.Message);
            }

            return result;
        }
Beispiel #2
0
 public static void LogEvents(EventLogger objLog, LOGTO enumLog = LOGTO.DATABASE)
 {
     int result = DBLogger.AddEventLog(objLog);
 }