public static void InsertExpiryDateReminder(VaaaN.TollMax.Library.TollMaxLibrary.CBE.PrepaidCardCBE prepaidCard) { CBE.CustomerSmsNotificationCBE smsNotification = new CBE.CustomerSmsNotificationCBE(); try { smsNotification.TmsId = prepaidCard.TmsId; smsNotification.PlazaId = prepaidCard.PlazaId; smsNotification.TellerId = 0; smsNotification.CreationDate = DateTime.Now; smsNotification.DeliveryDate = DateTime.MaxValue; smsNotification.DeliveryStatus = "0"; // Delivered = 1 and Un Delivered = 0 smsNotification.SentStatus = "0"; // Sent = 1 Unsent = 0 smsNotification.SentDate = DateTime.Now; CBE.AccountCBE account = new CBE.AccountCBE(); account.PlazaId = prepaidCard.PlazaId; account.TmsId = prepaidCard.TmsId; account.AccountId = prepaidCard.AccountId; account = BLL.AccountBLL.GetAccountById(account); smsNotification.AccountId = prepaidCard.AccountId; smsNotification.SerialNo = prepaidCard.SerialNo; smsNotification.EmailId = account.EmailId; smsNotification.ContactNumber = account.MobNumber; smsNotification.CustomerName = account.FirstName; smsNotification.AttemptCount = 0; smsNotification.MessageCategory = "expiryreminder"; smsNotification.MediaType = Convert.ToString((int)Constants.CustomerNotificationMedia.SMS); smsNotification.ModuleName = "POS"; smsNotification.Message = CreateMessageForSMS(smsNotification, prepaidCard, null); // Send only one reminder to customer in a month VaaaN.TollMax.Library.TollMaxLibrary.CBE.CustomerSmsNotificationCollection notifications = VaaaN.TollMax.Library.TollMaxLibrary.BLL.CustomerSmsNotificationBLL.GetBySerialNo(smsNotification.TmsId, smsNotification.PlazaId, smsNotification.SerialNo); bool createReminder = true; foreach (VaaaN.TollMax.Library.TollMaxLibrary.CBE.CustomerSmsNotificationCBE notification in notifications) { if ((DateTime.Now - notification.CreationDate).TotalDays <= 20 && notification.MessageCategory.ToLower() == smsNotification.MessageCategory.ToLower()) { createReminder = false; break; } } if (createReminder) { VaaaN.TollMax.Library.TollMaxLibrary.BLL.CustomerSmsNotificationBLL.Insert(smsNotification); } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Reminder not required." + smsNotification.ToString(), logModule); } } catch (Exception ex) { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Failed to insert customer notification." + smsNotification.ToString(), logModule); throw ex; } }
private static string CreateMessageForSMS(VaaaN.TollMax.Library.TollMaxLibrary.CBE.CustomerSmsNotificationCBE smsNotification, VaaaN.TollMax.Library.TollMaxLibrary.CBE.PrepaidCardCBE prepaidCard, VaaaN.TollMax.Library.TollMaxLibrary.CBE.PrepaidTransactionCBE prepaidTransaction) { #region Message format samples /* * //Expiry and Balance Notification Message: * Dear Customer, Your <Vehicle Class>, <Vehicle Regn #>, Balance trips are <No. of trips>and Validity is <Expiry date> at <Toll Plaza Name>. Please recharge your Pass. Regards, <Name of Company> * * * //Expiry Notification Message for unlimited trip pass: * Dear Customer, Your Pass of <Vehicle Class>, <Vehicle Regn #>, Expiring on <Expiry date> at <Toll Plaza Name>. Please recharge your Pass. Regards, <Name of Company> * * * // Sale * Dear Customer, Thanks for purchasing new pass of Rs. <Amount> for <Vehicle Class>, <Vehicle Regn #> on <Sale Date> at <Toll Plaza>. Regards, <Name of Company> * * * // Recharge * Dear Customer, Thanks for recharging your pass of Rs. <Recharge Amount> for <Vehicle Class>, <Vehicle Regn #> on <Recharge Date> at <Toll Plaza>. Regards, <Name of Company> */ /* * //Expiry and Balance Notification Message: * Dear Customer, Your <Vehicle Class>, <Vehicle Regn #>, Balance trips are <No. of trips>and Validity is <Expiry date> at <Toll Plaza Name>. Please recharge your Smart card. Regards, PS Toll Roads * * // Sale * Dear Customer, Thanks for purchasing new pass of Rs. <Amount> for <Vehicle Class>, <Vehicle Regn #> on <Sale Date> at <Toll Plaza>. Regards, PS Toll Roads * * // Recharge * Dear Customer, Thanks for recharging your pass of Rs. <Recharge Amount> for <Vehicle Class>, <Vehicle Regn #> on <Recharge Date> at <Toll Plaza>. Regards, PS Toll Roads * */ #endregion #region Variables string message = ""; string plazaName = ""; string companyName = ""; string vehicleClassName = ""; string vehRegNo = ""; string currencySymbol = "Rs."; try { if (plazaConfiguration == null) { if (prepaidTransaction != null) { VaaaN.TollMax.Library.TollMaxLibrary.CBE.PlazaConfigurationCollection plazaConfigurations = VaaaN.TollMax.Library.TollMaxLibrary.BLL.PlazaConfigurationBLL.GetAll(prepaidTransaction.TmsId, prepaidTransaction.PlazaId); if (plazaConfigurations != null && plazaConfigurations.Count > 0) { plazaConfiguration = plazaConfigurations[0]; currencySymbol = plazaConfiguration.CurrencySymbol; } else { plazaConfiguration = null; VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Plaza configuration record nofound.", logModule); } } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("prepaidTransaction found null.", logModule); } } else { currencySymbol = plazaConfiguration.CurrencySymbol; } } catch (Exception ex) { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Failed to get plaza configurations." + ex.Message, logModule); plazaConfiguration = null; } #endregion #region Get plaza name/ company name VaaaN.TollMax.Library.TollMaxLibrary.CBE.PlazaCollection plazas = BLL.PlazaBLL.GetAll(smsNotification.TmsId); foreach (CBE.PlazaCBE plaza in plazas) { if (plaza.PlazaId == smsNotification.PlazaId) { plazaName = plaza.PlazaName; companyName = plaza.CompanyName; break; } } #endregion if (masterConfig == null) { masterConfig = (VaaaN.TollMax.Library.TollMaxLibrary.ConfigurationClasses.MasterConfigProperties) VaaaN.TollMax.Library.SharedLibrary.Serialization.Serialization.Deserialize( typeof(VaaaN.TollMax.Library.TollMaxLibrary.ConfigurationClasses.MasterConfigProperties), VaaaN.TollMax.Library.TollMaxLibrary.Constants.plazaConfigDirectory + "MasterConfig.xml"); } #region Reliance if (masterConfig.SMSFormatName.ToLower().Equals(VaaaN.TollMax.Library.TollMaxLibrary.Constants.SMSFormatName[(int)VaaaN.TollMax.Library.TollMaxLibrary.Constants.SMSFormat.Reliance - 1].ToLower())) { if (smsNotification.MessageCategory.ToLower() == "sale") { #region Sale if (prepaidTransaction != null) { vehicleClassName = GetVehicleClassNameById(prepaidTransaction.TmsId, prepaidTransaction.PlazaId, prepaidTransaction.VehicleClassId).ToUpper(); vehRegNo = prepaidTransaction.VehRegNum.ToUpper(); message = "Dear Customer, Thanks for purchasing new pass of " + currencySymbol + " " + String.Format("{0:0.00}", prepaidTransaction.PaidAmount) + " for " + vehicleClassName + ", " + vehRegNo + " on " + prepaidTransaction.DateTime.ToString(VaaaN.TollMax.Library.TollMaxLibrary.Constants.dateTimeFormat) + " at " + plazaName + ". Regards, " + companyName; } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Prepaid card transaction found null.", VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.ErrorLogModule.SMS); } #endregion } else if (smsNotification.MessageCategory.ToLower() == "recharge") { #region Recharge if (prepaidTransaction != null) { vehicleClassName = GetVehicleClassNameById(prepaidTransaction.TmsId, prepaidTransaction.PlazaId, prepaidTransaction.VehicleClassId).ToUpper(); vehRegNo = prepaidTransaction.VehRegNum.ToUpper(); message = "Dear Customer, Thanks for recharging your pass of " + currencySymbol + " " + String.Format("{0:0.00}", prepaidTransaction.PaidAmount) + " for " + vehicleClassName + ", " + vehRegNo + " on " + prepaidTransaction.DateTime.ToString(VaaaN.TollMax.Library.TollMaxLibrary.Constants.dateTimeFormat) + " at " + plazaName + ". Regards, " + companyName; } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Prepaid card transaction found null.", VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.ErrorLogModule.SMS); } #endregion } else if (smsNotification.MessageCategory.ToLower() == "expiryreminder") { #region Expiry date and trip notification vehicleClassName = GetVehicleClassNameById(prepaidCard.TmsId, prepaidCard.PlazaId, prepaidCard.VehicleClassId).ToUpper(); vehRegNo = prepaidCard.VehRegNum.ToUpper(); if (prepaidCard != null) { //Expiry and Balance Notification Message: if (prepaidCard != null && prepaidCard.CardType == (int)VaaaN.TollMax.Library.TollMaxLibrary.Constants.CardType.Trip) { message = "Dear Customer, Your " + vehicleClassName + ", " + vehRegNo + ", Balance trips are " + prepaidCard.Balance + " and Validity is " + prepaidCard.ExpiryDate.ToString("dd-MMM-yyyy") + " at " + plazaName + ". Please recharge your Pass. Regards, " + companyName; } //Expiry Notification Message for unlimited trip pass: if (prepaidCard != null && prepaidCard.CardType == (int)VaaaN.TollMax.Library.TollMaxLibrary.Constants.CardType.Time) { message = "Dear Customer, Your " + vehicleClassName + ", " + vehRegNo + ", Balance trips are " + "" + " and Validity is " + prepaidCard.ExpiryDate.ToString("dd-MMM-yyyy") + " at " + plazaName + ". Please recharge your Pass. Regards, " + companyName; } } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Prepaid card found null.", VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.ErrorLogModule.SMS); } #endregion } // Blacklist // Refund } #endregion #region Bangladesh Regnum //Purchasing: //Dear Customer,Thanks for purchasing new Smart Card of Tk...... for Truck/Lorry............ on Date & Time at Sitakunda Axle Load Control Station. O&M: Regnum //Recharging: //Dear Customer,Thanks for recharging new Smart Card of Tk...... for Truck/Lorry............ on Date & Time at Sitakunda Axle Load Control Station. O&M: Regnum if (masterConfig.SMSFormatName.ToLower().Equals(VaaaN.TollMax.Library.TollMaxLibrary.Constants.SMSFormatName[(int)VaaaN.TollMax.Library.TollMaxLibrary.Constants.SMSFormat.RegnumBangladesh - 1].ToLower())) { if (smsNotification.MessageCategory.ToLower() == "sale") { #region Sale if (prepaidTransaction != null) { vehicleClassName = GetVehicleClassNameById(prepaidTransaction.TmsId, prepaidTransaction.PlazaId, prepaidTransaction.VehicleClassId).ToUpper(); vehRegNo = prepaidTransaction.VehRegNum.ToUpper(); message = "Dear Customer,Thanks for purchasing new Smartcard of " + currencySymbol + String.Format("{0:0.00}", prepaidTransaction.PaidAmount) + " for " + vehicleClassName + " on " + prepaidTransaction.DateTime.ToString(VaaaN.TollMax.Library.TollMaxLibrary.Constants.dateTimeFormat) + " at Sitakunda Axle Load Control Station. O and M:Regnum"; } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Prepaid card transaction found null.", VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.ErrorLogModule.SMS); } #endregion } else if (smsNotification.MessageCategory.ToLower() == "recharge") { #region Recharge if (prepaidTransaction != null) { vehicleClassName = GetVehicleClassNameById(prepaidTransaction.TmsId, prepaidTransaction.PlazaId, prepaidTransaction.VehicleClassId).ToUpper(); vehRegNo = prepaidTransaction.VehRegNum.ToUpper(); message = "Dear Customer,Thanks for recharging new Smartcard of " + currencySymbol + String.Format("{0:0.00}", prepaidTransaction.PaidAmount) + " for " + vehicleClassName + " on " + prepaidTransaction.DateTime.ToString(VaaaN.TollMax.Library.TollMaxLibrary.Constants.dateTimeFormat) + " at Sitakunda Axle Load Control Station. O and M:Regnum"; } else { VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.Write("Prepaid card transaction found null.", VaaaN.TollMax.Library.SharedLibrary.FileIO.Log.ErrorLogModule.SMS); } #endregion } // Expiry Reminder // Blacklist // Refund } #endregion return(message); }