Exemple #1
0
        /// <summary>
        /// Return values from ENett API
        /// and prepare response to caller
        /// </summary>
        /// <param name="user">user</param>
        /// <param name="vNettresponse">IssueVNettVANResponse</param>
        public void SetValues(UserInfo user, AmendVNettVANResponse vNettResponse, ENettAmendVAN reader)
        {
            if (!vNettResponse.IsSuccessful)
            {
                // The request was not succesfully processed
                // we need to get support log id from ENett
                // start EGE-100347
                if (vNettResponse.SupportLogId == "D")
                {
                    SetVNettTransactionID(vNettResponse.VNettTransactionID);
                    SetPaymentID(reader.PaymentID);
                    vNettResponse.IsSuccessful = false;
                    SetSuccesfull(vNettResponse.IsSuccessful);
                }
                else
                {
                    SetSupportLogId(vNettResponse.SupportLogId);
                    // Return error code and error description from ENett
                    SetException(user, new CEEException(vNettResponse.ErrorCode.ToString()
                                                        , vNettResponse.ErrorDescription).GetCompleteExceptionMessage());
                }

                // No need to go further!
                return;
                // END EGE-100347
            }

            // The response is success
            // Let's extract and return to caller all information
            SetVNettTransactionID(vNettResponse.VNettTransactionID);
            SetPaymentID(reader.PaymentID);
            SetSuccesfull(vNettResponse.IsSuccessful);
        }
        /// <summary>
        /// Log VCard amend in the table
        /// </summary>
        /// <param name="reader">ENettAmendVAN detail</param>
        public void UpdateForAmend(ENettAmendVAN reader, AmendVNettVANResponse result)
        {
            string request = String.Format("UPDATE VCardBooking SET PNR=@pnr, AmendDate =@AmendDate, "
                                           + "RailTicketNumber=@RailTicketNumber, GrossAmount=@GrossAmount, VATAmount=@VATAmount,IsBookingConfirmed=@IsBookingConfirmed, "
                                           + "TripName=@TripName, FreeText1=@FreeText1, FreeText2=@FreeText2, FreeText3=@FreeText3, HotelId=@HotelId, "
                                           + "ExpectedTransactionAmount=@ExpectedTransactionAmount, OriginDate=@OriginDate, OriginAddress=@OriginAddress, "
                                           + "OriginLocationCode=@OriginLocationCode, OriginCountryCode=@OriginCountryCode, EndDate=@EndDate, EndAddress=@EndAddress, "
                                           // --> EGE-85532 update expiration date for cancel van as per date.
                                           + "CardExpirationDate = @CardExpirationDate, "
                                           //<-- EGE-85532
                                           //>>EGE-60949
                                           //+ "EndLocationCode=@EndLocationCode, EndCountryCode=@EndCountryCode, AdultCount=@AdultCount, FundedAmount=@MaxAuthAmount "
                                           + "EndLocationCode=@EndLocationCode, EndCountryCode=@EndCountryCode, AdultCount=@AdultCount, FundedAmount=@MaxAuthAmount, TransAmtVanCurr=@TransAmtVanCurr "
                                           //>>EGE-60949
                                           + "WHERE PaymentId=@PaymentId");

            // objet command
            SqlCommand command = new SqlCommand(request, GetConnection());

            try
            {
                // Send parameters
                command.Parameters.Add("@pnr", SqlDbType.VarChar, 256);
                command.Parameters["@pnr"].Value = Util.Nvl(reader.PNR, DBNull.Value);

                command.Parameters.Add("@AmendDate", SqlDbType.DateTime);
                command.Parameters["@AmendDate"].Value = DateTime.Now;

                command.Parameters.Add("@RailTicketNumber", SqlDbType.VarChar, 200);
                command.Parameters["@RailTicketNumber"].Value = Util.Nvl(reader.RailTicketNumbers, DBNull.Value);

                command.Parameters.Add("@GrossAmount", SqlDbType.Money);
                command.Parameters["@GrossAmount"].Value = Util.TryConvertStringToDouble(reader.GrossAmount, 0.00);

                command.Parameters.Add("@VATAmount", SqlDbType.Money);
                command.Parameters["@VATAmount"].Value = Util.TryConvertStringToDouble(reader.VATAmount, 0.00);

                command.Parameters.Add("@ExpectedTransactionAmount", SqlDbType.Money);
                //--> EGE-61686 : CEE- VNETT - Follow transaction amount in XML
                string amount = reader.TransactionAmount;
                if (String.IsNullOrEmpty(amount) || amount.Equals("0"))
                {
                    amount = reader.TransAmtPosCurr;
                }
                command.Parameters["@ExpectedTransactionAmount"].Value = Util.TryConvertStringToDouble(amount, DBNull.Value);
                //command.Parameters["@ExpectedTransactionAmount"].Value = Util.TryConvertStringToDouble(reader.TransactionAmount, DBNull.Value);
                //<-- EGE-61686 : CEE- VNETT - Follow transaction amount in XML

                command.Parameters.Add("@IsBookingConfirmed", SqlDbType.Bit);
                command.Parameters["@IsBookingConfirmed"].Value = Util.ConvertStringToBool(reader.IsBookingConfirmed)?1:0;
                //Begin EGE-85532
                command.Parameters.Add("@CardExpirationDate", SqlDbType.DateTime);
                command.Parameters["@CardExpirationDate"].Value = Util.ConvertStringToDate(reader.ExpiryDate, Const.ExpirationDateFormat);
                // END EGE-85532
                command.Parameters.Add("@TripName", SqlDbType.VarChar, 256);
                command.Parameters["@TripName"].Value = Util.Nvl(reader.TripName, DBNull.Value);

                command.Parameters.Add("@FreeText1", SqlDbType.VarChar, 1000);
                command.Parameters["@FreeText1"].Value = Util.Nvl(reader.FreeText1, DBNull.Value);

                command.Parameters.Add("@FreeText2", SqlDbType.VarChar, 1000);
                command.Parameters["@FreeText2"].Value = Util.Nvl(reader.FreeText2, DBNull.Value);

                command.Parameters.Add("@FreeText3", SqlDbType.VarChar, 1000);
                command.Parameters["@FreeText3"].Value = Util.Nvl(reader.FreeText3, DBNull.Value);

                command.Parameters.Add("@HotelId", SqlDbType.BigInt);
                command.Parameters["@HotelId"].Value = Util.TryConvertStringToLong(reader.HotelID, 0L);

                command.Parameters.Add("@OriginDate", SqlDbType.DateTime);
                // Origin date is not available in verion 1 of the XML
                if (String.IsNullOrEmpty(reader.OriginDate))
                {
                    command.Parameters["@OriginDate"].Value = DBNull.Value;
                }
                else
                {
                    command.Parameters["@OriginDate"].Value = Util.ConvertStringToDate(reader.OriginDate, Const.ExpirationDateFormat);
                }

                command.Parameters.Add("@OriginAddress", SqlDbType.VarChar, 2000);
                command.Parameters["@OriginAddress"].Value = Util.Nvl(reader.OriginLocationName, DBNull.Value);

                command.Parameters.Add("@OriginLocationCode", SqlDbType.VarChar, 30);
                command.Parameters["@OriginLocationCode"].Value = Util.Nvl(reader.OriginLocationCode, DBNull.Value);

                command.Parameters.Add("@OriginCountryCode", SqlDbType.VarChar, 3);
                command.Parameters["@OriginCountryCode"].Value = Util.Nvl(reader.OriginCountryCode, DBNull.Value);

                command.Parameters.Add("@EndDate", SqlDbType.DateTime);
                // Origin date is not available in verion 1 of the XML
                if (String.IsNullOrEmpty(reader.EndDate))
                {
                    command.Parameters["@EndDate"].Value = DBNull.Value;
                }
                else
                {
                    command.Parameters["@EndDate"].Value = Util.ConvertStringToDate(reader.EndDate, Const.ExpirationDateFormat);
                }

                command.Parameters.Add("@EndAddress", SqlDbType.VarChar, 2000);
                command.Parameters["@EndAddress"].Value = Util.Nvl(reader.EndLocationName, DBNull.Value);

                command.Parameters.Add("@EndLocationCode", SqlDbType.VarChar, 30);
                command.Parameters["@EndLocationCode"].Value = Util.Nvl(reader.EndLocationCode, DBNull.Value);

                command.Parameters.Add("@EndCountryCode", SqlDbType.VarChar, 3);
                command.Parameters["@EndCountryCode"].Value = Util.Nvl(reader.EndCountryCode, DBNull.Value);

                command.Parameters.Add("@AdultCount", SqlDbType.Int);
                command.Parameters["@AdultCount"].Value = Util.TryConvertStringToInt(reader.AdultsCount, DBNull.Value);

                command.Parameters.Add("@MaxAuthAmount", SqlDbType.Money);
                command.Parameters["@MaxAuthAmount"].Value = Util.TryConvertStringToDouble(reader.MaxAuthAmount, DBNull.Value);

                command.Parameters.Add("@PaymentId", SqlDbType.VarChar, 16);
                command.Parameters["@PaymentId"].Value = Util.Nvl(reader.PaymentID, DBNull.Value);

                command.Parameters.Add("@ErrorCode", SqlDbType.VarChar, 50);
                command.Parameters["@ErrorCode"].Value = result.IsSuccessful ? 0 : result.ErrorCode;

                command.Parameters.Add("@ErrorDesc", SqlDbType.VarChar, 256);
                command.Parameters["@ErrorDesc"].Value = Util.Nvl(result.ErrorDescription, DBNull.Value);
                // Technical infos
                command.Parameters.Add("@ModificationDate", SqlDbType.DateTime);
                command.Parameters["@ModificationDate"].Value = DateTime.Now;

                command.Parameters.Add("@ModifiedBy", SqlDbType.VarChar, 128);
                command.Parameters["@ModifiedBy"].Value = Util.Nvl(reader.AgentLogIn, DBNull.Value);

                //>> EGE-60949
                command.Parameters.Add("@TransAmtVanCurr", SqlDbType.Money);
                command.Parameters["@TransAmtVanCurr"].Value = Util.TryConvertStringToDouble(reader.TransAmtVanCurr, DBNull.Value);
                //<< EGE-60949


                // Execute ...
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                // Something wen wrong
                throw new Exception(GetMessages().GetString("VCardLogConnection.Save.Error", reader.PaymentID, e.Message, true));
            }
            finally
            {
                DisposeCommand(command);
            }
        }