示例#1
0
        /// <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: 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;
            }
        }
示例#3
0
        /// <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: 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;
            }
        }