Exemple #1
0
        /// <summary>
        /// Updates the deals in the reference numbers to the credit status specified.
        /// </summary>
        /// <param name="referenceNumbers">
        /// The list of reference numbers of the deals to update.
        /// </param>
        /// <param name="creditStatus">
        /// The credit status to which to set the redeemed deals.
        /// </param>
        /// <param name="redeemedDealOperations">
        /// The object to use to perform redeemed deal operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <param name="threadId">
        /// The ID of the thread attempting to perform this action.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// * Parameter redeemedDealOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        public void UpdateDealStatus(Collection <int> referenceNumbers,
                                     CreditStatus creditStatus,
                                     IRedeemedDealOperations redeemedDealOperations,
                                     CommerceContext context,
                                     int threadId)
        {
            if (redeemedDealOperations == null)
            {
                throw new ArgumentNullException("redeemedDealOperations",
                                                "Parameter redeemedDealOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            if (threadId == AuthorizedThreadId)
            {
                context.Log.Verbose("Updating specified redeemed deals to credit status {0}.", creditStatus);
                context[Key.ReferenceNumbers] = referenceNumbers;
                context[Key.CreditStatus]     = creditStatus;
                redeemedDealOperations.UpdateRedeemedDeals();

                //// Add analytics info.
                //Collection<SettledDealInfo> settledDealInfoList = redeemedDealOperations.RetrieveSettlementAnalyticsInfo();
                //foreach (SettledDealInfo settledDealInfo in settledDealInfoList)
                //{
                //    Analytics.AddSettlementEvent(settledDealInfo.UserId, settledDealInfo.EventId, settledDealInfo.CorrelationId,
                //                                 settledDealInfo.ParentDealId, settledDealInfo.Currency,
                //                                 settledDealInfo.SettlementAmount, settledDealInfo.DiscountAmount,
                //                                 settledDealInfo.DealId, settledDealInfo.PartnerMerchantId);
                //}
            }
        }
        /// <summary>
        /// Updates the data store to reflect the reversal of the redeemed deal.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        public ResultCode ProcessRedemptionTimeout()
        {
            ResultCode result;

            Context.Log.Verbose("Attempting to update the data store to reflect the reversal of the timed out redemption.");
            IRedeemedDealOperations redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            result = redeemedDealOperations.ProcessRedemptionTimeout();
            Context.Log.Verbose("ResultCode after reversing the timed out redemption in the data store: {0}", result);

            return(result);
        }
        /// <summary>
        /// Updates the data store to reflect the reversal of the redeemed deal.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        public ResultCode ReverseRedeemedDeal()
        {
            ResultCode result;

            Context.Log.Verbose("Attempting to update the data store to reflect the reversal of the redeemed deal.");
            IRedeemedDealOperations redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            result = redeemedDealOperations.ReverseRedeemedDeal();
            Context.Log.Verbose("ResultCode after reversing the redeemed deal in the data store: {0}", result);

            return(result);
        }
        /// <summary>
        /// Adds the redeemed deal to the data store and logs accordingly.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        private ResultCode AddRedeemedDeal()
        {
            ResultCode result = ResultCode.Success;

            // Add the redemption event info to the data store.
            Context.Log.Verbose("Attempting to add the redeemed deal to the data store.");
            IRedeemedDealOperations redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            result = redeemedDealOperations.AddRedeemedDeal();
            Context.Log.Verbose("ResultCode after adding the redeemed deal to the data store: {0}", result);

            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Updates the pending MasterCard redeemed deals in the record list to the credit status specified.
        /// </summary>
        /// <param name="records">
        /// The list of records whose redeemed deals to update.
        /// </param>
        /// <param name="redeemedDealOperations">
        /// The object to use to perform redeemed deal operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// * Parameter redeemedDealOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        public static void MarkSettledAsRedeemed(Collection <OutstandingRedeemedDealInfo> records,
                                                 IRedeemedDealOperations redeemedDealOperations,
                                                 CommerceContext context)
        {
            if (redeemedDealOperations == null)
            {
                throw new ArgumentNullException("redeemedDealOperations", "Parameter redeemedDealOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            context.Log.Verbose("Updating specified redeemed deals as SettledAsRedeemed.");
            context[Key.OutstandingRedeemedDeals] = records;
            redeemedDealOperations.MarkSettledAsRedeemed();
        }
Exemple #6
0
        /// <summary>
        /// Updates the pending redeemed deals in the merchant record list to the credit status specified.
        /// </summary>
        /// <param name="records">
        /// The list of merchant records whose redeemed deals to update.
        /// </param>
        /// <param name="creditStatus">
        /// The credit status to which to set the redeemed deals.
        /// </param>
        /// <param name="redeemedDealOperations">
        /// The object to use to perform redeemed deal operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// * Parameter redeemedDealOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        public static void UpdatePendingRedeemedDeals(Collection <OutstandingRedeemedDealInfo> records,
                                                      CreditStatus creditStatus,
                                                      IRedeemedDealOperations redeemedDealOperations,
                                                      CommerceContext context)
        {
            if (redeemedDealOperations == null)
            {
                throw new ArgumentNullException("redeemedDealOperations", "Parameter redeemedDealOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            context.Log.Verbose("Updating specified redeemed deals to credit status {0}.", creditStatus);
            context[Key.MerchantRecords] = records;
            context[Key.CreditStatus]    = creditStatus;
            redeemedDealOperations.UpdatePendingPartnerRedeemedDeals();
        }
Exemple #7
0
        /// <summary>
        /// If the calling thread is the currently authorized thread, processes the redeemed deal record received from a partner
        /// against the redeemed deals in the data store.
        /// </summary>
        /// <param name="partner">
        /// The Partner from which the redeemed deal record originated.
        /// </param>
        /// <param name="record">
        /// The redeemed deal record to process.
        /// </param>
        /// <param name="redeemedDealOperations">
        /// The object to use to perform redeemed deal operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <param name="threadId">
        /// The ID of the thread attempting to perform this action.
        /// </param>
        /// <returns>
        /// The ResultCode describing the result of the operation.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// * Parameter redeemedDealOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        public static ResultCode ProcessPartnerRedeemedDealRecord(Partner partner,
                                                                  SettlementDetail record,
                                                                  IRedeemedDealOperations redeemedDealOperations,
                                                                  CommerceContext context)
        {
            if (redeemedDealOperations == null)
            {
                throw new ArgumentNullException("redeemedDealOperations", "Parameter redeemedDealOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            ResultCode result = ResultCode.None;

            try
            {
                context.Log.Verbose("Processing partner redeemed deal record.");
                context[Key.Partner]          = partner;
                context[Key.SettlementDetail] = record;
                result = redeemedDealOperations.ProcessPartnerRedeemedDealRecord();
                if (result == ResultCode.Success)
                {
                    context.Log.Verbose("Partner redeemed deal record processed successfully.");
                }
                else
                {
                    context.Log.Warning("Partner redeemed deal record unsuccessfully processed.\r\n\r\nResultCode: {0}" +
                                        "\r\n\r\nExplanation: {1}", (int)result, result, ResultCodeExplanation.Get(result));
                }
            }
            catch (Exception ex)
            {
                context.Log.Critical("Partner redeemed deal record processing ended with an error.", ex);
            }

            return(result);
        }
Exemple #8
0
        /// <summary>
        /// If the calling thread is the currently authorized thread, retrieves the outstanding redeemed deal records for the
        /// partner in the conext.
        /// </summary>
        /// <param name="partner">
        /// The Partner from which the redeemed deal record originated.
        /// </param>
        /// <param name="redeemedDealOperations">
        /// The object to use to perform redeemed deal operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <returns>
        /// The collection of OutstandingRedeemedDealInfo objects built from the outstanding redeemed deal records.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// * Parameter redeemedDealOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        public static Collection <OutstandingRedeemedDealInfo> RetrieveOutstandingPartnerRedeemedDealRecords(Partner partner,
                                                                                                             IRedeemedDealOperations redeemedDealOperations,
                                                                                                             CommerceContext context)
        {
            if (redeemedDealOperations == null)
            {
                throw new ArgumentNullException("redeemedDealOperations", "Parameter redeemedDealOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            Collection <OutstandingRedeemedDealInfo> result = new Collection <OutstandingRedeemedDealInfo>();

            context.Log.Verbose("Retrieving partner redeemed deal records that are ready for settlement.");
            context[Key.Partner] = partner;
            result = redeemedDealOperations.RetrieveOutstandingPartnerRedeemedDealRecords();
            context.Log.Verbose("Retrieved {0} partner redeemed deal records.", result.Count);

            return(result);
        }