private static List<TransactionsLog> SelectTransaction(string strSql) { if (log.IsInfoEnabled) log.Info("SelectTransaction started.."); List<TransactionsLog> lstTrans = new List<TransactionsLog>(); try { Open(strConnectionString); SqlCeCommand command = new SqlCeCommand(strSql); SqlCeDataReader reader = ExecuteReader(command); while (reader.Read()) { TransactionsLog objTrLog = new TransactionsLog(); objTrLog.TxnId = Convert.ToInt64(reader["TxnId"]); objTrLog.KioskId = Convert.ToInt64(reader["KioskId"]); objTrLog.TxnTypeId = Convert.ToInt32(reader["TxnTypeId"]); objTrLog.TxnDtTm = Convert.ToDateTime(reader["TxnDtTm"]); objTrLog.KioskTxnDateTime = Convert.ToDateTime(reader["KioskTxnDttm"]); objTrLog.TxnAmount = Convert.ToInt32(reader["TxnAmount"]); objTrLog.KioskTxnrefNum = reader["KioskTxnrefNum"].ToString(); objTrLog.KioskTxnId = Convert.ToInt64(reader["KioskTxnId"]); objTrLog.BillerId = Convert.ToInt32(reader["BillerId"]); objTrLog.BillerTxnrefNum = Convert.ToString(reader["BillerTxnrefNum"]); objTrLog.ConsumerNumber = reader["ConsumerNumber"].ToString(); objTrLog.PaymentModeId = Convert.ToInt32(reader["PaymentModeId"]); objTrLog.ProductDetail = Convert.ToString(reader["ProductDetail"]); objTrLog.LastBalance = Convert.ToDouble(reader["LastBalance"].ToString()); objTrLog.NewBalance = Convert.ToDouble(reader["NewBalance"].ToString()); objTrLog.Repost = Convert.ToBoolean(reader["Repost"].ToString()); objTrLog.Field1 = Convert.ToString(reader["Field1"]); objTrLog.Field2 = Convert.ToString(reader["Field2"]); objTrLog.Field3 = Convert.ToString(reader["Field3"]); objTrLog.Field7 = Convert.ToString(reader["Field7"]); objTrLog.Field8 = Convert.ToString(reader["Field8"]); objTrLog.Field9 = Convert.ToString(reader["Field9"]); objTrLog.Field10 = Convert.ToString(reader["Field10"]); objTrLog.Field11 = Convert.ToString(reader["Field11"]); objTrLog.Field12 = Convert.ToString(reader["Field12"]); objTrLog.Field13 = Convert.ToString(reader["Field13"]); objTrLog.Field14 = Convert.ToString(reader["Field14"]); objTrLog.Field15 = Convert.ToString(reader["Field15"]); objTrLog.Field16 = Convert.ToString(reader["Field16"]); objTrLog.Field17 = Convert.ToString(reader["Field17"]); objTrLog.Field18 = Convert.ToString(reader["Field18"]); objTrLog.Field19 = Convert.ToString(reader["Field19"]); objTrLog.Field20 = Convert.ToString(reader["Field20"]); lstTrans.Add(objTrLog); if (lstTrans.Count() == BatchSize) break; } reader.Close(); } catch (SqlCeException ex) { if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.SelectTransaction.." + ex.Message); Close(); //System.Environment.Exit(1); // exit } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("Generic exception caught in SelectTransaction .." + ex.Message); } if (log.IsInfoEnabled) log.Info("SelectTransaction ended.."); return lstTrans; }
/// <summary> /// Adds the Transaction /// </summary> /// <param name="objTrans"></param> /// <returns>returns 1 on insert</returns> public static int AddTransaction(TransactionsLog objTrans) { ////Set the Connection String //SqlCeConnection Conn = ConnectDb(); int result = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("INSERT INTO [tblTransactions]([KIOSKID],[TxnDttm],[TxnAmount],[KIOSKTxnDttm],[BillerID],[ConsumerNumber],[ProductDetail] ,[LastBalance] ,[NewBalance] ,[TxnTypeId] ,[KioskTxnId] ,[KioskTxnRefNum] ,[PaymentModeId] ,[Status] ,[ResponseCode] ,[Field1] ,[Field2] ,[Field3] ,[Field4] ,[Field5] ,[Field6] ,[BillerTxnRefNum] ,[SystemRespCode] ,[BillerRespCode] ,[Repost],[Field7],[Field8],[Field9],[Field10],[Field11],[Field12],[Field13],[Field14],[Field15],[Field16],[Field17],[Field18],[Field19],[Field20]) Values ("); strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}','{38}')", objTrans.KioskId, FormatDateTime(objTrans.TxnDtTm), objTrans.TxnAmount, FormatDateTime(objTrans.KioskTxnDateTime), objTrans.BillerId, objTrans.ConsumerNumber, objTrans.ProductDetail, objTrans.LastBalance, objTrans.NewBalance, objTrans.TxnTypeId, objTrans.KioskTxnId, objTrans.KioskTxnrefNum, objTrans.PaymentModeId, objTrans.Status, objTrans.ResponseCode, objTrans.Field1, objTrans.Field2, objTrans.Field3, objTrans.Field4, objTrans.Field5, objTrans.Field6, objTrans.BillerTxnrefNum, objTrans.ResponseCode, objTrans.ResponseCode, objTrans.Repost, objTrans.Field7, objTrans.Field8, objTrans.Field9, objTrans.Field10, objTrans.Field11, objTrans.Field12, objTrans.Field13, objTrans.Field14, objTrans.Field15, objTrans.Field16, objTrans.Field17, objTrans.Field18, objTrans.Field19, objTrans.Field20); if (log.IsInfoEnabled) log.Info(" sql query is:" + strSql); try { Open(strConnectionString); SqlCeCommand command = new SqlCeCommand(strSql.ToString()); //Trace.WriteLine(strSql.ToString()); //Trace.WriteLine("Transaction Inserted"); result = ExecuteNonQuery(command); if (result > 0) if (log.IsInfoEnabled) log.Info(" AddTransaction successfull.. for KioskTxnRefNum.." + objTrans.KioskTxnrefNum); } catch (SqlCeException ex) { if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddTransaction.." + ex.Message); Close(); //System.Environment.Exit(1); // exit } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("Generic Exception caught in DBLogger.AddTransaction.." + ex.Message); } return result; }
public static void LogTransaction(TransactionsLog objLog, LOGTO enumLog = LOGTO.DATABASE) { if (log.IsInfoEnabled) log.Info("Logger LogTransaction started.."); int result = DBLogger.AddTransaction(objLog); if (log.IsInfoEnabled) log.Info("Logger LogTransaction ended.."); }