/// <summary> /// Method Name: IsCardValid. /// Method Purpose: To check at BackOffice if Card is in valid format. /// Modification Date: April 28, 2011. /// </summary> public bool IsCardValid(string pCardNumber, out string pMsg) { try { pMsg = ""; BackOfficeManager _mngr = new BackOfficeManager(); bool lCardValid = _mngr.IsCardNumberValid(pCardNumber); if (lCardValid == false) { pMsg = Resources.SelfServices.TopupAnonymousCard_CardNoValidate; } if (lCardValid == true) { if (System.Configuration.ConfigurationManager.AppSettings["IsBackOfficeConnected"].ToLower().Equals("true")) { BO_Response lRes = _mngr.CheckCardSerialNumber(pCardNumber); if (lRes != null && (lRes.ResponseCode == _mngr.RES_SUCCESS || lRes.ResponseCode == _mngr.CSN_IS_NOT_ANONYMOUS)) { lCardValid = true; } else { lCardValid = false; if (lRes.ResponseCode == _mngr.RES_ERROR) { pMsg = Resources.CardManagement.BONotConnected; } else { pMsg = Resources.SelfServices.TopupAnonymousCard_CardNoValidate; } } } else { lCardValid = true; } } return(lCardValid); } catch (Exception ex) { if (!ExceptionHandler.IsUserFriendly(ex)) { ex.Data.Add("PageName", "CardRegisteration"); ex.Data.Add("EventName", "IsCardValid"); ExceptionHandler.LogException(ex); } else { throw ex; } pMsg = ""; return(false); } }
/// <summary> /// Method Name: CardRegistrationNavigation. /// Method Purpose: Pulic default constructor. /// Author: Shady Yahia. /// Modification Date: April 28, 2011. /// </summary> public NavCardRegistration(bool pCreateNewNavigationState = false) { _BackOfficeManager = new BackOfficeManager(); _OnlineAccMgr = new OnlineAccountsManager(); if (NavigationState == null) { if (pCreateNewNavigationState == true) { // Try initialize base class. base.InitializeME(); // set new navigation state object. this.SetNavigationState(); } else { // handle session time out. base.HandleSessionTimeOut(); } } if (_NavigationState.LoggedInUserGUID != Guid.Empty && this._NavigationState.Contact == null) { this._NavigationState.NavigationPermitted = this.IsNavigationPermitted(); // set new navigation state object. this.SetNavigationState(); } }
/// <summary> /// Method Name: ProcessCardRegisterationResponse /// Method Description: process the back office response /// </summary> /// <param name="pResponse">Back office response</param> /// <param name="pContact">Contact</param> /// <param name="pCard">Card</param> /// <Author> Mena Armanyous</Author> /// <Modified on>1-Jan-2011</Modified> protected bool ProcessCardRegisterationResponse(BO_CardRegisterationResponse pResponse, out string pMessage) { try { Card pCard = NavigationState.RegisteredCard; Contact pContact = NavigationState.Contact; BackOfficeManager lBOMgr = new BackOfficeManager(); if (pResponse == null) { // other error // Display confirmation message page with explanation message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.BONotConnected; //"CardManagement|BONotConnected"; return(false); // DisplayConfirmationMessage(lMsg, true); } else { if (pResponse.ResponseCode == lBOMgr.RES_APPLICATION_INSERTION_ERROR || pResponse.ResponseCode == lBOMgr.RES_APPLICATION_SELECTION_ERROR || pResponse.ResponseCode == lBOMgr.RES_ERROR) { // Application error // Display confirmation message page with inconvenience error message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.BONotConnected; // "CardManagement|BONotConnected"; return(false); // DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_REGISTERD_CARD) { // card already registered // Display confirmation message page with please register valid card number SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.CardRegisteredErrorMsg;// "CardManagement|CardRegisteredErrorMsg"; return(false); // DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_INPUTS_ARE_BLANK || pResponse.ResponseCode == lBOMgr.RES_INPUT_FORMAT_ERROR) { // card already registered // Display confirmation message page with please register valid card number SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.InputsAreBlankErrorMsg; // "CardManagement|InputsAreBlankErrorMsg"; return(false); // DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_SUCCESS) { // success // Save record to database pCard.CardRegistered.BackEnd_ID = pResponse.BackendID; if (NavigationState.TempCardHolderContact != null) { CloneContact(NavigationState.TempCardHolderContact, NavigationState.Contact); } if (_CardManager.IsCardRegistered(pCard.CardNumber)) { NavigationState.RegistrationResultMsg = "CardManagement|CardRegisteredErrorMsg_Registered"; SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.CardRegisteredErrorMsg_Registered; // "CardManagement|SavingErrorMsg"; return(false); } if (SaveCardRegisteration())//SaveCardRegisteration(pCard)) { //Auditing AuditManagerBase.CommonAuditParams commonAuditParam = new AuditManagerBase.CommonAuditParams(_NavigationState.Contact.Contact_ID, DateTime.Now, (int?)_NavigationState.Contact.Contact_ID, _NavigationState.RegisteredCard.Card_ID, "B/O Registration", "Contact:" + _NavigationState.Contact.Contact_ID); AuditManager.AuditBORegisteration(commonAuditParam, pResponse.ResponseCode, pResponse.ResponseCodePhrase); /////////////////////////////////////////// // Send Notification mail SendCardRegistrationConfirmationMail();// (pCard, pContact); // Saving card succeeded, display success message SessionManager.Set(enumSessionKeys.IsError, false); SessionManager.Set(enumSessionKeys.ConfirmationTitle, Resources.PagesTitles.Confirmation_Title); pMessage = Resources.CardManagement.SuccessMsg; //"CardManagement|SuccessMsg"; return(true); // DisplayConfirmationMessage(lMsg); } else { // saving card failed, display error message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.SavingErrorMsg; // "CardManagement|SavingErrorMsg"; return(false); // DisplayConfirmationMessage(lMsg, true); } } else if (pResponse.ResponseCode == lBOMgr.RES_BLOCKED_CARD_PURSE || pResponse.ResponseCode == lBOMgr.RES_EXPIRED_CARD_PURSE || pResponse.ResponseCode == lBOMgr.RES_CLOSED_OFF_CARD_PURSE || pResponse.ResponseCode == lBOMgr.RES_BLACKLISTED_CARD_PURSE) { // card related error SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.CardErrorMsg + pResponse.ResponseCodePhrase; return(false); //DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_PATRONS_RECORD_NOT_FOUND || pResponse.ResponseCode == lBOMgr.RES_NO_CARD_MASTER) { // card not exists in back office error // Display confirmation message page with explanation message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.RegisterCard_Patrons_Record_Not_Found; // "CardManagement|RegisterCard_Patrons_Record_Not_Found"; return(false); //DisplayConfirmationMessage(lMsg, true); } else { // other error // Display confirmation message page with explanation message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.BONotConnected; // "CardManagement|BONotConnected"; return(false); //DisplayConfirmationMessage(lMsg, true); } } } catch (Exception ex) { if (!ExceptionHandler.IsUserFriendly(ex)) { ex.Data.Add("PageName", "ContactInformation"); ex.Data.Add("EventName", "ProcessCardRegisterationResponse"); ExceptionHandler.handle(ex); } else { throw ex; } SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = HttpContext.GetGlobalResourceObject("CardManagement", "InconvenienceErrorMsg").ToString(); return(false); } }
/// <summary> /// Method Name: RegisterCard /// Method Description: call back office manager to register card /// </summary> /// <param name="pContact">Contact</param> /// <param name="pAddress">Contact Address</param> /// <param name="pCard">Card for registration</param> /// <returns>BO_CardRegisterationResponse</returns> /// <Author>Mena Armanyous</Author> /// <Modified on>7-May-2011</Modified> public bool RegisterCard(out string pMessage) { BackOfficeManager _BackOfficeManager = new BackOfficeManager(); BO_CardRegisterationResponse lBOResponse = null; try { //Register Address lAddress = this.NavigationState.Contact.Addresses.FirstOrDefault(); if (System.Configuration.ConfigurationManager.AppSettings["IsBackOfficeConnected"].ToLower().Equals("false")) { lBOResponse = new BO_CardRegisterationResponse(); lBOResponse.ResponseCode = _BackOfficeManager.RES_SUCCESS; lBOResponse.ResponseCodePhrase = "BORegisteredSuccessfully"; lBOResponse.BackendID = "111114"; //this.NavigationState.BackOfficeResponse = lBOResponse; } else { lBOResponse = _BackOfficeManager.RegisterCard(this.NavigationState.Contact, this.NavigationState.RegisteredCard, lAddress); } StringBuilder strMessage = new StringBuilder(); // Log Event string logTitle = "Card Registration "; strMessage.AppendLine("Response Code:" + lBOResponse.ResponseCode); strMessage.AppendLine("Response Phrase:" + lBOResponse.ResponseCodePhrase); strMessage.AppendLine("Backend ID:" + lBOResponse.BackendID); Logger.LogMessage(logTitle, strMessage.ToString(), LogEntryCategory.Development, System.Diagnostics.TraceEventType.Information, LogEntryPriority.Highest); //process response bool result = ProcessCardRegisterationResponse(lBOResponse, out pMessage); return(result); //else //{ // SessionManager.Set(enumSessionKeys.IsError, true); // SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); // pMessage = HttpContext.GetGlobalResourceObject("CardManagement", "BONotConnected").ToString(); // return false; //} } catch (Exception ex) { if (!ExceptionHandler.IsUserFriendly(ex)) { ex.Data.Add("PageName", "CardRegistration"); ex.Data.Add("EventName", "RegisterCard"); if (lBOResponse != null) { ex.Data.Add("Response Code:", lBOResponse.ResponseCode); ex.Data.Add("Response Desc:", lBOResponse.ResponseCodePhrase); } ExceptionHandler.LogException(ex); } else { throw ex; } SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = HttpContext.GetGlobalResourceObject("CardManagement", "InconvenienceErrorMsg").ToString(); return(false); } }
/// <summary> /// Method Name: ProcessCardRegisterationResponse /// Method Description: process the back office response /// </summary> /// <param name="pResponse">Back office response</param> /// <param name="pContact">Contact</param> /// <param name="pCard">Card</param> /// <Author> Mena Armanyous</Author> /// <Modified on>1-Jan-2011</Modified> protected bool ProcessCardRegisterationResponse(BO_CardRegisterationResponse pResponse,out string pMessage) { try { Card pCard = NavigationState.RegisteredCard; Contact pContact = NavigationState.Contact; BackOfficeManager lBOMgr = new BackOfficeManager(); if (pResponse == null) { // other error // Display confirmation message page with explanation message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.BONotConnected; //"CardManagement|BONotConnected"; return false; // DisplayConfirmationMessage(lMsg, true); } else { if (pResponse.ResponseCode == lBOMgr.RES_APPLICATION_INSERTION_ERROR || pResponse.ResponseCode == lBOMgr.RES_APPLICATION_SELECTION_ERROR || pResponse.ResponseCode == lBOMgr.RES_ERROR) { // Application error // Display confirmation message page with inconvenience error message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.BONotConnected; // "CardManagement|BONotConnected"; return false; // DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_REGISTERD_CARD) { // card already registered // Display confirmation message page with please register valid card number SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.CardRegisteredErrorMsg;// "CardManagement|CardRegisteredErrorMsg"; return false; // DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_INPUTS_ARE_BLANK || pResponse.ResponseCode == lBOMgr.RES_INPUT_FORMAT_ERROR) { // card already registered // Display confirmation message page with please register valid card number SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.InputsAreBlankErrorMsg; // "CardManagement|InputsAreBlankErrorMsg"; return false; // DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_SUCCESS) { // success // Save record to database pCard.CardRegistered.BackEnd_ID = pResponse.BackendID; if (NavigationState.TempCardHolderContact != null) { CloneContact(NavigationState.TempCardHolderContact, NavigationState.Contact); } if (_CardManager.IsCardRegistered(pCard.CardNumber)) { NavigationState.RegistrationResultMsg = "CardManagement|CardRegisteredErrorMsg_Registered"; SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.CardRegisteredErrorMsg_Registered; // "CardManagement|SavingErrorMsg"; return false; } if (SaveCardRegisteration())//SaveCardRegisteration(pCard)) { //Auditing AuditManagerBase.CommonAuditParams commonAuditParam = new AuditManagerBase.CommonAuditParams(_NavigationState.Contact.Contact_ID, DateTime.Now, (int?)_NavigationState.Contact.Contact_ID, _NavigationState.RegisteredCard.Card_ID, "B/O Registration", "Contact:" + _NavigationState.Contact.Contact_ID); AuditManager.AuditBORegisteration(commonAuditParam, pResponse.ResponseCode, pResponse.ResponseCodePhrase); /////////////////////////////////////////// // Send Notification mail SendCardRegistrationConfirmationMail();// (pCard, pContact); // Saving card succeeded, display success message SessionManager.Set(enumSessionKeys.IsError, false); SessionManager.Set(enumSessionKeys.ConfirmationTitle, Resources.PagesTitles.Confirmation_Title); pMessage = Resources.CardManagement.SuccessMsg; //"CardManagement|SuccessMsg"; return true; // DisplayConfirmationMessage(lMsg); } else { // saving card failed, display error message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.SavingErrorMsg; // "CardManagement|SavingErrorMsg"; return false; // DisplayConfirmationMessage(lMsg, true); } } else if (pResponse.ResponseCode == lBOMgr.RES_BLOCKED_CARD_PURSE || pResponse.ResponseCode == lBOMgr.RES_EXPIRED_CARD_PURSE || pResponse.ResponseCode == lBOMgr.RES_CLOSED_OFF_CARD_PURSE || pResponse.ResponseCode == lBOMgr.RES_BLACKLISTED_CARD_PURSE) { // card related error SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.CardErrorMsg + pResponse.ResponseCodePhrase; return false; //DisplayConfirmationMessage(lMsg, true); } else if (pResponse.ResponseCode == lBOMgr.RES_PATRONS_RECORD_NOT_FOUND || pResponse.ResponseCode == lBOMgr.RES_NO_CARD_MASTER) { // card not exists in back office error // Display confirmation message page with explanation message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.RegisterCard_Patrons_Record_Not_Found; // "CardManagement|RegisterCard_Patrons_Record_Not_Found"; return false; //DisplayConfirmationMessage(lMsg, true); } else { // other error // Display confirmation message page with explanation message SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = Resources.CardManagement.BONotConnected; // "CardManagement|BONotConnected"; return false; //DisplayConfirmationMessage(lMsg, true); } } } catch (Exception ex) { if (!ExceptionHandler.IsUserFriendly(ex)) { ex.Data.Add("PageName", "ContactInformation"); ex.Data.Add("EventName", "ProcessCardRegisterationResponse"); ExceptionHandler.handle(ex); } else { throw ex; } SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = HttpContext.GetGlobalResourceObject("CardManagement", "InconvenienceErrorMsg").ToString(); return false; } }
/// <summary> /// Method Name: RegisterCard /// Method Description: call back office manager to register card /// </summary> /// <param name="pContact">Contact</param> /// <param name="pAddress">Contact Address</param> /// <param name="pCard">Card for registration</param> /// <returns>BO_CardRegisterationResponse</returns> /// <Author>Mena Armanyous</Author> /// <Modified on>7-May-2011</Modified> public bool RegisterCard(out string pMessage) { BackOfficeManager _BackOfficeManager = new BackOfficeManager(); BO_CardRegisterationResponse lBOResponse = null; try { //Register Address lAddress = this.NavigationState.Contact.Addresses.FirstOrDefault(); if (System.Configuration.ConfigurationManager.AppSettings["IsBackOfficeConnected"].ToLower().Equals("false")) { lBOResponse = new BO_CardRegisterationResponse(); lBOResponse.ResponseCode = _BackOfficeManager.RES_SUCCESS; lBOResponse.ResponseCodePhrase = "BORegisteredSuccessfully"; lBOResponse.BackendID = "111114"; //this.NavigationState.BackOfficeResponse = lBOResponse; } else { lBOResponse = _BackOfficeManager.RegisterCard(this.NavigationState.Contact, this.NavigationState.RegisteredCard, lAddress); } StringBuilder strMessage = new StringBuilder(); // Log Event string logTitle = "Card Registration "; strMessage.AppendLine("Response Code:" + lBOResponse.ResponseCode); strMessage.AppendLine("Response Phrase:" + lBOResponse.ResponseCodePhrase); strMessage.AppendLine("Backend ID:" + lBOResponse.BackendID); Logger.LogMessage(logTitle, strMessage.ToString(), LogEntryCategory.Development, System.Diagnostics.TraceEventType.Information, LogEntryPriority.Highest); //process response bool result = ProcessCardRegisterationResponse(lBOResponse, out pMessage); return result; //else //{ // SessionManager.Set(enumSessionKeys.IsError, true); // SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); // pMessage = HttpContext.GetGlobalResourceObject("CardManagement", "BONotConnected").ToString(); // return false; //} } catch (Exception ex) { if (!ExceptionHandler.IsUserFriendly(ex)) { ex.Data.Add("PageName", "CardRegistration"); ex.Data.Add("EventName", "RegisterCard"); if (lBOResponse != null) { ex.Data.Add("Response Code:", lBOResponse.ResponseCode); ex.Data.Add("Response Desc:", lBOResponse.ResponseCodePhrase); } ExceptionHandler.LogException(ex); } else { throw ex; } SessionManager.Set(enumSessionKeys.IsError, true); SessionManager.Set(enumSessionKeys.ConfirmationTitle, "Error"); pMessage = HttpContext.GetGlobalResourceObject("CardManagement", "InconvenienceErrorMsg").ToString(); return false; } }
/// <summary> /// Method Name: IsCardValid. /// Method Purpose: To check at BackOffice if Card is in valid format. /// Modification Date: April 28, 2011. /// </summary> public bool IsCardValid(string pCardNumber,out string pMsg) { try { pMsg = ""; BackOfficeManager _mngr = new BackOfficeManager(); bool lCardValid = _mngr.IsCardNumberValid(pCardNumber); if(lCardValid == false) pMsg = Resources.SelfServices.TopupAnonymousCard_CardNoValidate; if (lCardValid == true) { if (System.Configuration.ConfigurationManager.AppSettings["IsBackOfficeConnected"].ToLower().Equals("true")) { BO_Response lRes = _mngr.CheckCardSerialNumber(pCardNumber); if (lRes != null && (lRes.ResponseCode == _mngr.RES_SUCCESS || lRes.ResponseCode == _mngr.CSN_IS_NOT_ANONYMOUS)) { lCardValid = true; } else { lCardValid = false; if (lRes.ResponseCode == _mngr.RES_ERROR) { pMsg = Resources.CardManagement.BONotConnected; } else { pMsg = Resources.SelfServices.TopupAnonymousCard_CardNoValidate; } } } else { lCardValid = true; } } return lCardValid; } catch (Exception ex) { if (!ExceptionHandler.IsUserFriendly(ex)) { ex.Data.Add("PageName", "CardRegisteration"); ex.Data.Add("EventName", "IsCardValid"); ExceptionHandler.LogException(ex); } else throw ex; pMsg = ""; return false; } }