private void OnNoteStackedEvent(int denominationStacked, string allowedDenominations) { CashCycleLog obj = null; try { obj = new CashCycleLog() { TxnId = this.Transaction.Id, Accepted = 1, NoteId = 0, NoteVal = denominationStacked, TimeIns = DateTime.Now, Uploaded = 0, KioskId = this.Transaction.MachineId }; DBLogger.AddTxnCashCycle(obj); if (log.IsInfoEnabled) log.Info("mawaqif - added entry in tbltxncashcycle using OnNoteStackedEvent." + "denominationStacked:" + denominationStacked.ToString() + ",allowedDenominations:" + allowedDenominations.ToString() + ",TransactionId:" + this.Transaction.Id); } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("mawaqif - Caught exception in OnNoteStackedEvent method. " + "denominationStacked:" + denominationStacked.ToString() + ",allowedDenominations:" + allowedDenominations.ToString() + ",TransactionId:" + this.Transaction.Id + ",And Exception is:" + ex.Message); } finally { // ViewGrid.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DUpdateUI(UpdateAmountPaidAndDue), denominationStacked, allowedDenominations, false); } }
private void OnNoteReturnedEvent(int denominationReturned) { stackCommandIssued = false; CashCycleLog obj = null; try { if (this.Transaction.CashCycleInProgress) { this.Transaction.CashCycleInProgress = false; } obj = new CashCycleLog() { TxnId = this.Transaction.Id, Accepted = 0, NoteId = 0, NoteVal = denominationReturned, TimeIns = DateTime.Now, Uploaded = 0, KioskId = this.Transaction.MachineId }; //DBLogger.AddTxnCashCycle(obj); if (log.IsInfoEnabled) log.Info("Mawaqif - added entry in tbltxncashcycle using OnNoteReturnedEvent." + "denominationReturned:" + denominationReturned.ToString() + ",TxnId:" + this.Transaction.Id); } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("Mawaqif - Caught exception in OnNoteReturnedEvent method. " + "denominationReturned:" + denominationReturned.ToString() + ",TxnId:" + obj.TxnId.ToString() + "And Exception is:" + ex.Message); } finally { OnStackDelayNotificationTimeOut(null, null); } }
public static int AddTxnCashCycle(CashCycleLog obj) { int result = 0; StringBuilder strSql = new StringBuilder(); //string strTxnIdDataType=string.Empty; //string strKioskIDColumn=string.Empty; //StringBuilder strSelectSql = new StringBuilder(); //StringBuilder strAlterSql = new StringBuilder(); //StringBuilder strFindKioskIDSql = new StringBuilder(); //StringBuilder strAddKioskIDSql = new StringBuilder(); //SqlCeDataReader dr = null; //SqlCeDataReader drKioskID = null; //logic to add KIOSKID column in tblTxnCashCycle // strFindKioskIDSql.Append("SELECT COLUMN_NAME FROM information_schema.columns WHERE table_name = 'tblTxnCashCycle' AND column_name = 'KIOSKID'"); // strAddKioskIDSql.Append("ALTER table tblTxnCashCycle add KIOSKID bigint"); // try // { // Open(strConnectionString); // SqlCeCommand commandKiosk = new SqlCeCommand(strFindKioskIDSql.ToString()); // drKioskID = ExecuteReader(commandKiosk); // while (drKioskID.Read()) // { // strKioskIDColumn = "KIOSKID"; // break; // } // if (drKioskID != null || drKioskID.IsClosed == false) // drKioskID.Close(); // if (strKioskIDColumn != "KIOSKID") // { // SqlCeCommand commandAdd = new SqlCeCommand(strAddKioskIDSql.ToString()); // result = ExecuteNonQuery(commandAdd); // } // } // catch (SqlCeException ex) // { // if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddTxnCashCycle while adding KIOSKID column .." + ex.Message); // Close(); // System.Environment.Exit(1); // exit // } // catch (Exception ex) // { // if (log.IsErrorEnabled) log.Error("Generic exception caught in DBLogger.AddTxnCashCycle while adding KIOSKID column.." + ex.Message); // } // if (log.IsInfoEnabled) log.Info("Altering tblTxnCashCycle to add KIOSKID column is done."); // // end of logic to add KIOSKID column in tblTxnCashCycle ////logic to find datatype of Txnid //strSelectSql.Append("SELECT data_type FROM information_schema.columns WHERE table_name = 'tblTxnCashCycle' AND column_name = 'TxnID'"); //try //{ // Open(strConnectionString); // SqlCeCommand command = new SqlCeCommand(strSelectSql.ToString()); // dr = ExecuteReader(command); // while (dr.Read()) // { // strTxnIdDataType = Convert.ToString(dr["data_type"]); // break; // } //} //catch (SqlCeException ex) //{ // if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddTxnCashCycle while reading TxnID datatype table.." + ex.Message); // Close(); // System.Environment.Exit(1); // exit //} //catch (Exception ex) //{ // if (log.IsErrorEnabled) log.Error("Generic exception caught in DBLogger.AddTxnCashCycle while TxnID datatype table.." + ex.Message); //} //finally //{ // if(dr!=null || dr.IsClosed==false) // dr.Close(); //} // end of logic to find txnid column datatype in tbltxncashcycle //// logic to alter table to change datatype of Txnid in tblTxnCashCycle //if(strTxnIdDataType== "bigint") //{ // strAlterSql.Append("ALTER table tblTxnCashCycle alter column TXNID nvarchar(50)"); // try // { // Open(strConnectionString); // SqlCeCommand commandAlter = new SqlCeCommand(strAlterSql.ToString()); // result = ExecuteNonQuery(commandAlter); // } // catch (SqlCeException ex) // { // if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddTxnCashCycle while altering table.." + ex.Message); // Close(); // System.Environment.Exit(1); // exit // } // catch (Exception ex) // { // if (log.IsErrorEnabled) log.Error("Generic exception caught in DBLogger.AddTxnCashCycle while altering table.." + ex.Message); // } // if (log.IsInfoEnabled) log.Info("Altering tblTxnCashCycle TxnId column datatype is done."); //}// end of logic to alter table to change datatype of Txnid in tblTxnCashCycle strSql.Append("INSERT INTO tblTxnCashCycle"); strSql.Append("(TXNID, TIMEINS, NOTEVAL, NOTEID, ACCEPTED, UPLOADED,KIOSKID) VALUES ("); strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}')", obj.TxnId, FormatDateTime(obj.TimeIns), obj.NoteVal, obj.NoteId, obj.Accepted, obj.Uploaded, obj.KioskId); //Trace.WriteLine(strSql.ToString()); if (log.IsInfoEnabled) log.Info(strSql.ToString()); try { Open(strConnectionString); SqlCeCommand commandInsert = new SqlCeCommand(strSql.ToString()); result = ExecuteNonQuery(commandInsert); if (log.IsErrorEnabled) log.Error(obj.TxnId.ToString()+ " is added in tblTxnCashCycle.And Execution result is:"+result.ToString()); } catch (SqlCeException ex) { if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddTxnCashCycle.." + ex.Message); Close(); //System.Environment.Exit(1); // exit } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("Generic exception caught in DBLogger.AddTxnCashCycle.." + ex.Message); } return result; }
public static void LogCashCycle(CashCycleLog objLog, LOGTO enumLog = LOGTO.DATABASE) { int result = DBLogger.AddTxnCashCycle(objLog); }