Exemplo n.º 1
0
        /// <summary>
        /// Copy Constructor. Sets the fields to the same as the one sent in
        /// </summary>
        /// <param name="copy"></param>
        public PlayerComp(PlayerComp copy)
        {
            this.Id                                  = copy.Id;
            this.Name                                = copy.Name;
            this.StartDate                           = copy.StartDate;
            this.EndDate                             = copy.EndDate;
            this.Value                               = copy.Value;
            this.CouponMaxUsage                      = copy.CouponMaxUsage;
            this.CouponType                          = copy.CouponType;
            this.EarnedPackageIDs                    = copy.EarnedPackageIDs; // US4941
            this.AwardType                           = copy.AwardType;
            this.UnlockSpend                         = copy.UnlockSpend;
            this.UnlockSessionCount                  = copy.UnlockSessionCount;
            this.MinimumSpendToQualify               = copy.MinimumSpendToQualify; //US4852
            this.RestrictedPackageIds                = copy.RestrictedPackageIds;
            this.RestrictedProductIds                = copy.RestrictedProductIds;  //US4852
            this.IsPartOfMultiPackageCoupon          = copy.IsPartOfMultiPackageCoupon;
            this.PackageID                           = copy.PackageID;
            this.IgnoreValidationsForIgnoredPackages = copy.IgnoreValidationsForIgnoredPackages;
            this.PercentDiscount                     = copy.PercentDiscount;
            this.CompAwardId                         = copy.CompAwardId;
            this.OperatorId                          = copy.OperatorId;
            this.ShortName                           = copy.ShortName;
            this.Credit                              = copy.Credit;
            this.LastAwardedDate                     = copy.LastAwardedDate;
            this.RemainingComp                       = copy.RemainingComp;

            this.ProgramLimit = copy.ProgramLimit;
            this.DailyLimit   = copy.DailyLimit;
            this.WeeklyLimit  = copy.WeeklyLimit;
            this.MonthlyLimit = copy.MonthlyLimit;
            this.YearlyLimit  = copy.YearlyLimit;

            this.m_specificProgramLimits = new Dictionary <int, int?>(copy.m_specificProgramLimits);
            this.m_dayOfWeekLimits       = new Dictionary <DayOfWeek, int?>(copy.DayOfWeekLimits);
            this.m_monthOfYearLimits     = new Dictionary <int, int?>(copy.MonthOfYearLimits);
            this.m_sessionNumberLimits   = new Dictionary <int, int?>(copy.m_sessionNumberLimits);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the response received from the server.
        /// </summary>
        protected override void UnpackResponse()
        {
            base.UnpackResponse();

            // Create the streams we will be reading from.
            MemoryStream responseStream = new MemoryStream(m_responsePayload);
            BinaryReader responseReader = new BinaryReader(responseStream, Encoding.Unicode);

            // Check the response length.
            if (responseStream.Length < MinResponseMessageLength)
            {
                throw new MessageWrongSizeException("Get Player Comp List");
            }

            // Try to unpack the data.
            try
            {
                // Seek past return code.
                responseReader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin);

                // Get the count of comps.
                ushort compCount = responseReader.ReadUInt16();

                // Clear the comps array.
                m_comps.Clear();

                // Setup our test container.
                string stemp = string.Empty;

                // Read all the comps.
                for (ushort x = 0; x < compCount; x++)
                {
                    PlayerComp comp = new PlayerComp();

                    // Comp Id
                    comp.Id = responseReader.ReadInt32();

                    // Comp Award Id
                    comp.CompAwardId = responseReader.ReadInt32();

                    // Comp Name
                    comp.Name = ReadString(responseReader);

                    // Comp Expire Date
                    stemp = ReadString(responseReader);

                    if (stemp != string.Empty)
                    {
                        comp.EndDate = DateTime.Parse(stemp, CultureInfo.InvariantCulture);
                    }

                    // Comp Awarded Date
                    stemp = ReadString(responseReader);

                    // Comp Value (0 if none).
                    stemp = ReadString(responseReader);

                    if (stemp != string.Empty)
                    {
                        comp.Value = decimal.Parse(stemp, CultureInfo.InvariantCulture);
                    }

                    // Remaining Comps
                    comp.RemainingComp = responseReader.ReadInt32();

                    // Comp Type Id
                    comp.CouponType = (PlayerComp.CouponTypes)responseReader.ReadInt32();

                    if (comp.CouponType == PlayerComp.CouponTypes.PercentPackage)
                    {
                        comp.PercentDiscount = comp.Value / 100M;
                    }
                    else
                    {
                        comp.PercentDiscount = 0;
                    }

                    //Minimum spend to qualify //US4852
                    comp.MinimumSpendToQualify = decimal.Parse(ReadString(responseReader), CultureInfo.InvariantCulture);

                    //Restricted products (do not count these products toward any minimum spend).
                    //count of restricted products //US4852
                    var count = responseReader.ReadInt16();

                    for (var i = 0; i < count; i++)
                    {
                        //restricted product ID //US4852
                        var restrictedProductId = responseReader.ReadInt32();

                        comp.RestrictedProductIds.Add(restrictedProductId);
                    }

                    //Qualifying packages (list of packages attached to this coupon).
                    //count of packages //US4852
                    count = responseReader.ReadInt16();

                    for (var i = 0; i < count; i++)
                    {
                        var PackageId = responseReader.ReadInt32();

                        comp.EarnedPackageIDs.Add(PackageId);
                    }

                    //Restricted packages (do not count these packages toward any minimum spend).
                    //count of restricted products //US4852
                    count = responseReader.ReadInt16();

                    for (var i = 0; i < count; i++)
                    {
                        var restrictedPackageId = responseReader.ReadInt32();

                        //DE13275
                        comp.RestrictedPackageIds.Add(restrictedPackageId);
                    }

                    //Ignore validations on restricted packages
                    comp.IgnoreValidationsForIgnoredPackages = responseReader.ReadByte() != 0;

                    //split multiple package coupons into multiple individual coupons
                    if (comp.EarnedPackageIDs.Count > 1 && SplitMultiPackageCoupons)
                    {
                        PlayerComp splitComp;

                        for (int i = 0; i < comp.EarnedPackageIDs.Count; i++)
                        {
                            splitComp = new PlayerComp(comp);
                            splitComp.IsPartOfMultiPackageCoupon = true;
                            splitComp.PackageID = comp.EarnedPackageIDs[i];

                            m_comps.Add(splitComp);
                        }
                    }
                    else
                    {
                        if (comp.EarnedPackageIDs.Count == 1)
                        {
                            comp.PackageID = comp.EarnedPackageIDs[0];
                        }

                        m_comps.Add(comp);
                    }
                }
            }
            catch (EndOfStreamException e)
            {
                throw new MessageWrongSizeException("Get Player Comp List", e);
            }
            catch (Exception e)
            {
                throw new ServerException("Get Player Comp List", e);
            }

            // Close the streams.
            responseReader.Close();
        }