Exemple #1
0
        private SmartCitizenCard getSmartCitizenCardForPerson(RecordIdentifier personIdentifier)
        {
            SmartCitizenCard      cardForPerson     = new SmartCitizenCard();
            GetCardholderResponse cardHolderDetails = _cmClient.GetCardholder(new GetCardholderData()
            {
                CardholderIdentifier = personIdentifier
            });

            if (cardHolderDetails.Identifier.CardID != null)
            {
                CheckCardResponse cardCheckResponse =
                    _cmClient.CheckCard(new CheckCardData()
                {
                    CardIdentifier = cardHolderDetails.Identifier.CardID
                });
                cardForPerson.IsValid = cardCheckResponse.CardValid;
                cardForPerson.ISRN    = cardHolderDetails.Identifier.CardID;
                DateTime expiryDate;
                DateTime.TryParse(
                    cardHolderDetails.CitizenData.XPathSelectElement("Services/Service/Item[@name='EXPIRY DATE']")
                    .Value, out expiryDate);
                cardForPerson.ExpiryDate = expiryDate;
            }
            return(cardForPerson);
        }
Exemple #2
0
        public XmlDocument UpdateAndRenewPass(int cardHolderId, string ISRN, string title, string forename, string surname,
                                              string dateOfBirth, string gender, string disabilitycategory, string caseId)
        {
            logParams(cardHolderId, ISRN, title, forename, surname, dateOfBirth, gender, disabilitycategory, caseId);
            if (log.IsDebugEnabled)
            {
                log.Debug("Checking pass number against the supplied pass number");
            }
            SmartCitizenCard currentSmartCitizenCard =
                getSmartCitizenCardForPerson(new RecordIdentifier()
            {
                CardholderID = cardHolderId
            });

            if (currentSmartCitizenCard.ISRN != ISRN)
            {
                throw new ScValidationException(ScValidationException.ScValidationReason.CardNotMatched);
            }

            if (!currentSmartCitizenCard.CanBeRenewed)
            {
                throw new ScValidationException(
                          ScValidationException.ScValidationReason.CardOutsideRenewalWindow);
            }

            /*if(!currentSmartCitizenCard.IsValid)
             *  throw new ScValidationException(
             *         ScValidationException.ScValidationReason.CardNotValid);*/

            UpdatePassHolderDetails(cardHolderId, title, forename, surname, dateOfBirth, gender, disabilitycategory);
            return(ReplacePass(cardHolderId, ISRN, 17, caseId));
        }
Exemple #3
0
        private SmartCitizenCard getSmartCitizenCardForPerson(RecordIdentifier personIdentifier)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("Getting Smart Citizen Card for Person");
            }
            logParams(personIdentifier);
            SmartCitizenCard      cardForPerson     = new SmartCitizenCard();
            GetCardholderResponse cardHolderDetails = _cmClient.GetCardholder(new GetCardholderData()
            {
                CardholderIdentifier = personIdentifier
            });

            if (cardHolderDetails.Identifier.CardID != null)
            {
                CheckCardResponse cardCheckResponse =
                    _cmClient.CheckCard(new CheckCardData()
                {
                    CardIdentifier = cardHolderDetails.Identifier.CardID
                });
                EntityDetailsListResponse[] entityDetailsListResponse = _cmClient.GetEntityList(personIdentifier);
                cardForPerson.IsValid = cardCheckResponse.CardValid;

                cardForPerson.ISRN = cardHolderDetails.Identifier.CardID;
                DateTime expiryDate;
                DateTime.TryParse(
                    cardHolderDetails.CitizenData.XPathSelectElement("Services/Service/Item[@name='EXPIRY DATE']")
                    .Value, out expiryDate);
                cardForPerson.ExpiryDate = expiryDate;
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Got Card.");
            }
            return(cardForPerson);
        }
Exemple #4
0
        private XmlDocument ReplacePass(int cardHolderId, string ISRN, int cardStatus, string caseNumber) //, string title, string forename, string dateOfBirth, string gender, string disabilityCategory, string caseId)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("Entering");
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Replacing pass for recordID:" + cardHolderId);
            }
            logParams(cardHolderId, ISRN, cardStatus, caseNumber);//, title, forename, dateOfBirth, gender, disabilityCategory, caseId);


            // code below here for SmartCitizen connection.
            if (log.IsDebugEnabled)
            {
                log.Debug("Loading Response XML file");
            }
            XmlDocument responseDoc = new XmlDocument();

            try
            {
                responseDoc.Load(appDataPath + "CTSelfPassRenewalResponse.xml");
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Could not load Response XML file:" + appDataPath + "CTSelfPassRenewalResponse.xml");
                }
                throw ex;
            }

            if (log.IsDebugEnabled)
            {
                log.Debug("Response Document Loaded.");
            }



            RecordIdentifier cardHolderRecordId = new RecordIdentifier()
            {
                CardholderID = cardHolderId, CardID = ISRN
            };
            //IssuerId is hard-coded to 2 - renew for this service as it is only for renewals.
            // CardLocation is hard-coded to 3: 'unknown' - not sure if this needs to be parameterised.
            UpdateCardData cardDataToUpdate = new UpdateCardData()
            {
                Identifier = cardHolderRecordId, CardLocation = 3, CardStatus = cardStatus, AdditionalInformation = "Renewal requested through CRM. Case Referece Number:" + caseNumber, ReplaceCard = true, IssuerId = 2
            };

            RecordIdentifier responseIdentifier = null;

            try
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("Updating Card.");
                }
                if (log.IsDebugEnabled)
                {
                    log.Debug(SerializeObj(cardDataToUpdate));
                }
                responseIdentifier = _cmClient.UpdateCard(cardDataToUpdate);
                if (log.IsDebugEnabled)
                {
                    log.Debug(SerializeObj(responseIdentifier));
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Error:" + ex.Message);
                }
                var requestStatusNode = responseDoc.SelectSingleNode("PassRenewal/RequestStatus");
                if (requestStatusNode != null)
                {
                    requestStatusNode.InnerText = "Failure";
                }
                return(responseDoc);
            }

            if (responseIdentifier != null)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("Pass Successfully renewed. Getting details of new card");
                }
                SmartCitizenCard cardForPerson = getSmartCitizenCardForPerson(responseIdentifier);
                responseDoc.SelectSingleNode("PassRenewal/CardNumber").InnerText    = cardForPerson.ISRN;
                responseDoc.SelectSingleNode("PassRenewal/ExpiryDate").InnerText    = cardForPerson.ExpiryDateString;
                responseDoc.SelectSingleNode("PassRenewal/RequestStatus").InnerText = "Success";
            }
            else
            {
                responseDoc.SelectSingleNode("PassRenewal/RequestStatus").InnerText = "Failure";
            }


            if (log.IsDebugEnabled)
            {
                log.Debug("Exiting");
            }
            return(responseDoc);
        }