コード例 #1
0
        private void NotificationProcessing(VaaaN.MLFF.Libraries.CommonLibrary.CBE.CustomerVehicleCBE customerVehicleInfo, VaaaN.MLFF.Libraries.CommonLibrary.CBE.CustomerAccountCBE customerAccountInfo, VaaaN.MLFF.Libraries.CommonLibrary.CBE.TransactionCBE transaction, Decimal tollToDeduct, Decimal AfterDeduction)
        {
            try
            {
                HelperClass.LogMessage("Trying to push SMS to MSMQ...");

                Message smsMessage = new Message();
                smsMessage.Formatter = new BinaryMessageFormatter();
                VaaaN.MLFF.Libraries.CommonLibrary.Classes.SmsNotification.SMSDetail smsDetail = new Libraries.CommonLibrary.Classes.SmsNotification.SMSDetail();
                CultureInfo culture     = new CultureInfo("id-ID");
                string      RechareDate = transaction.TransactionDateTime.AddDays(4).ToString("dd-MMM-yyyy") + " 23:59:59";
                if (AfterDeduction > 0)
                {
                    smsDetail.SMSMessage = "Pelanggan Yth, telah dilakukan pemotongan senilai Rp " + Decimal.Parse(tollToDeduct.ToString()).ToString("C", culture).Replace("Rp", "") + " terhadap saldo SJBE anda atas transaksi kendaraan " + customerVehicleInfo.VehRegNo + " pada " + transaction.TransactionDateTime.ToString(VaaaN.MLFF.Libraries.CommonLibrary.Constants.DATETIME_FORMAT_WITHOUT_SECONDSForSMS) + " di tempat " + GetPlazaNameById(transaction.PlazaId) + ". Sisa saldo SJBE anda saat ini Rp " + Decimal.Parse(AfterDeduction.ToString()).ToString("C", culture).Replace("Rp", "") + " Ref: [" + transaction.TransactionId.ToString() + "]";
                }
                else
                {
                    smsDetail.SMSMessage = "Pelanggan Yth, Saldo SJBE anda saat ini tidak mencukupi untuk dilakukan pemotongan senilai Rp " + Decimal.Parse(tollToDeduct.ToString()).ToString("C", culture).Replace("Rp", "") + " atas transaksi kendaraan " + customerVehicleInfo.VehRegNo + " pada " + transaction.TransactionDateTime.ToString(VaaaN.MLFF.Libraries.CommonLibrary.Constants.DATETIME_FORMAT_WITHOUT_SECONDSForSMS) + " di Gantry - Medan Merdeka Barat 1. Silahkan melakukan pengisian ulang saldo SJBE anda sebelum " + RechareDate + ". Keterlambatan pengisian ulang saldo akan dikenakan denda sebesar Rp 1.000.000,00. Sisa saldo SJBE anda saat ini Rp " + Decimal.Parse((AfterDeduction + tollToDeduct).ToString()).ToString("C", culture).Replace("Rp", "") + " Ref: [" + transaction.TransactionId.ToString() + "]";
                }

                HelperClass.LogMessage(smsDetail.SMSMessage);
                smsDetail.AccountId          = customerAccountInfo.AccountId;
                smsDetail.CustomerName       = customerAccountInfo.FirstName + " " + customerAccountInfo.LastName;
                smsDetail.SenderMobileNumber = customerAccountInfo.MobileNo;

                smsMessage.Body = smsDetail;

                HelperClass.LogMessage("Detail:" + smsDetail.ToString());
                smsMessageQueue.Send(smsMessage);
                HelperClass.LogMessage("Message pushed successfully to MSMQ.");
            }
            catch (Exception ex)
            {
                HelperClass.LogMessage("Exception in pushing SMS to SMS MSMQ. " + ex.ToString());
            }
        }
コード例 #2
0
        private void FinancialProcessing(VaaaN.MLFF.Libraries.CommonLibrary.CBE.CustomerVehicleCBE customerVehicleInfo, VaaaN.MLFF.Libraries.CommonLibrary.CBE.CustomerAccountCBE customerAccountInfo, VaaaN.MLFF.Libraries.CommonLibrary.CBE.TransactionCBE transaction)
        {
            #region LaneType and TollRate Section
            decimal tollToDeduct = -1;
            try
            {
                HelperClass.LogMessage("Finding out LaneType and toll rate to deduct...");
                int laneTypeId = GetLaneTypeByLaneId(transaction.LaneId);
                HelperClass.LogMessage("LaneType is: " + laneTypeId);
                tollToDeduct = GetTollRate(Libraries.CommonLibrary.Constants.GetCurrentPlazaId(), laneTypeId, transaction.TransactionDateTime, customerVehicleInfo.VehicleClassId);
                HelperClass.LogMessage("Toll to deduct is (for motorcycle it may be 0.00): " + tollToDeduct);
            }
            catch (Exception ex)
            {
                HelperClass.LogMessage("Exception in finding out lane type and toll to deduct. " + ex.ToString());
                tollToDeduct = -1;
            }
            #endregion

            if (tollToDeduct > -1)
            {
                Decimal CurrentAccountBalance = customerAccountInfo.AccountBalance;
                Decimal AfterDeduction        = CurrentAccountBalance - tollToDeduct;
                if (AfterDeduction > 0)
                {
                    #region Account History Section
                    try
                    {
                        HelperClass.LogMessage("Trying to record in account history table...");
                        VaaaN.MLFF.Libraries.CommonLibrary.CBE.AccountHistoryCBE accountHistory = new Libraries.CommonLibrary.CBE.AccountHistoryCBE();
                        accountHistory.TMSId = transaction.TMSId;
                        //accountHistory.EntryId = 0;//this  is the auto incremented and primery key of table
                        accountHistory.AccountId = customerAccountInfo.AccountId;
                        accountHistory.CustomerVehicleEntryId = customerVehicleInfo.EntryId; //<=============================
                        accountHistory.TransactionTypeId      = (int)VaaaN.MLFF.Libraries.CommonLibrary.Constants.TransactionType.LaneDebit;
                        accountHistory.TransactionId          = transaction.TransactionId;
                        accountHistory.Amount      = tollToDeduct;
                        accountHistory.IsSMSSent   = (int)VaaaN.MLFF.Libraries.CommonLibrary.Constants.SMSSentStatus.Unsent;    //will be updated later on
                        accountHistory.IsEmailSent = (int)VaaaN.MLFF.Libraries.CommonLibrary.Constants.EmailSentStatus.Unsent;; //will be updated later on
                                                                                                                                //accountHistory.ModifierId = 1;//will be updated later on
                        accountHistory.CreationDate     = DateTime.Now;
                        accountHistory.ModificationDate = DateTime.Now;
                        accountHistory.TransferStatus   = (int)VaaaN.MLFF.Libraries.CommonLibrary.Constants.TransferStatus.NotTransferred;
                        VaaaN.MLFF.Libraries.CommonLibrary.BLL.AccountHistoryBLL.Insert(accountHistory);
                        HelperClass.LogMessage("Recorded in account history table successfully.");
                    }
                    catch (Exception ex)
                    {
                        HelperClass.LogMessage("Exception in recording in the Account History table. " + ex.ToString());
                    }
                    #endregion

                    #region Update Balance Section
                    try
                    {
                        HelperClass.LogMessage("Trying to update balance in customer account table...");
                        //should be by by trigger defined in TBL_ACCOUNT_HISTORY
                        VaaaN.MLFF.Libraries.CommonLibrary.BLL.CustomerAccountBLL.UpdateBalance(customerAccountInfo, (-1 * tollToDeduct));
                        HelperClass.LogMessage("Balance updated successfully in the customer account.");
                    }
                    catch (Exception ex)
                    {
                        HelperClass.LogMessage("Exception in updating customer's account balance. " + ex.ToString());
                    }
                    #endregion

                    #region Mark transaction as balance updated
                    try
                    {
                        HelperClass.LogMessage("Trying to update isBalanceUpdated field in transaction table...");
                        VaaaN.MLFF.Libraries.CommonLibrary.BLL.TransactionBLL.MarkAsBalanceUpdated(transaction);
                        HelperClass.LogMessage("Transaction is marked as balance updated.");
                    }
                    catch (Exception ex)
                    {
                        HelperClass.LogMessage("Exception in marking the transaction as balance updated. " + ex.ToString());
                    }
                    #endregion
                }
                else
                {
                    HelperClass.LogMessage("Due to insufficient balance.");
                    NotificationProcessing(customerVehicleInfo, customerAccountInfo, transaction, tollToDeduct, AfterDeduction);
                }
            }
            else
            {
                HelperClass.LogMessage("Toll to deduct is -1.00. There is some error somewhere.");
            }
        }