public void LogPrintCycleLogToLocalDb()
 {
     PrintCycleLog obj = null;
     try
     {
         obj = new PrintCycleLog()
         {
             TxnId = this.Transaction.Id,
             ReceiptId = this.Transaction.Id,
             TimePrt = DateTime.Now,
             ReceiptTaken = 1,
             KioskId = long.Parse(this.Transaction.MachineId)
         };
         if (log.IsErrorEnabled) log.Error("PrintCycle logging for TxnId:" + obj.TxnId.ToString() + "KioskId:" + obj.KioskId.ToString());
         DBLogger.AddTxnPrintCycle(obj);
         if (log.IsInfoEnabled) log.Info("Mawaqif - added entry in tbltxnPrintcycle using LogPrintCycleLogToLocalDb." + "TxnId:" + obj.TxnId.ToString());
     }
     catch (Exception ex)
     {
         if (log.IsErrorEnabled) log.Error("Mawaqif - Caught exception in  LogPrintCycleLogToLocalDb method. " + "TxnId:" + obj.TxnId.ToString() + "." + ex.Message);
     }
 }
Esempio n. 2
0
        public static int AddTxnPrintCycle(PrintCycleLog obj)
        {
            int result = 0;
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSelect = new StringBuilder();
            SqlCeDataReader dr;

            strSelect.Append("select TXNID from tblTxnPrintCycle where TXNID='" + obj.TxnId + "'");

            strSql.Append("INSERT INTO tblTxnPrintCycle");
            strSql.Append("(TXNID, TIMEPRT, RECID, RECTAKEN,KioskID) VALUES (");
            strSql.AppendFormat("'{0}','{1}','{2}',{3},{4})", obj.TxnId,
               FormatDateTime(obj.TimePrt), obj.ReceiptId, obj.ReceiptTaken,obj.KioskId);
            //Trace.WriteLine(strSql.ToString());
            if (log.IsInfoEnabled) log.Info(strSql.ToString());
            try
            {
                Open(strConnectionString);

                string readerResult = string.Empty;
                SqlCeCommand commandDr = new SqlCeCommand(strSelect.ToString());
                dr = ExecuteReader(commandDr);

                while (dr.Read())
                {
                    readerResult = Convert.ToString(dr["TxnId"]);
                }
                dr.Close();

                if (string.IsNullOrEmpty(readerResult))
                {
                    SqlCeCommand command = new SqlCeCommand(strSql.ToString());
                    result = ExecuteNonQuery(command);
                }

                if (log.IsErrorEnabled) log.Error("TxnID:"+obj.TxnId.ToString()+"KioskID:"+obj.KioskId  + " is added in tblTxnPrintCycle.And Execution result is:" + result.ToString());
            }
            catch (SqlCeException ex)
            {
                if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddTxnPrintCycle.." + ex.Message);
                Close();
                //System.Environment.Exit(1);  //  exit

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

            return result;
        }
Esempio n. 3
0
 public static void LogPrintCycle(PrintCycleLog objLog, LOGTO enumLog = LOGTO.DATABASE)
 {
     int result = DBLogger.AddTxnPrintCycle(objLog);
 }