Ejemplo n.º 1
0
    public override void DataBind()
    {
        base.DataBind();

        if (Member.IsLogged)
        {
            Member user = Member.CurrentInCache;

            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(user, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(user, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(user, Object);
            EarningsPoints    = user.Membership.AdvertPointsEarnings;
            EarningsAdCredits = user.Membership.PTCCreditsPerView;
        }
        else
        {
            //Public ad view
            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(Membership.Standard, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(Membership.Standard, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(Membership.Standard, Object);
            EarningsPoints    = Membership.Standard.AdvertPointsEarnings;
            EarningsAdCredits = Membership.Standard.PTCCreditsPerView;
        }

        //Display PTC Advert Type
        if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.PTC)
        {
            //Starred Ads
            if (Object.IsStarredAd)
            {
                starImg.Visible  = true;
                starImg2.Visible = true;
            }
            else
            {
                starImg.Visible  = false;
                starImg2.Visible = false;
            }

            //Favorite Ads
            if (AppSettings.PtcAdverts.FavoriteAdsEnabled && Member.IsLogged &&
                FavoriteAd.IsFavorite(Member.CurrentId, Object.Id, FavoriteAdType.PTC))
            {
                favoriteImg.Visible  = true;
                favoriteImg2.Visible = true;
                FavoriteCssClass     = " fav";
            }
            else
            {
                favoriteImg.Visible  = false;
                favoriteImg2.Visible = false;
            }

            if (IsActive)
            {
                ActiveAdvertPlaceHolder.Visible = true;
            }
            else
            {
                InactiveAdvertPlaceHolder.Visible = true;
            }

            if (ImageUrl != null)
            {
                //    PtcImage.ImageUrl = PtcImage2.ImageUrl = ImageUrl;
                ImageBackgroundStyle = "background: url(" + ResolveUrl(ImageUrl) + ");";
            }


            if (AppSettings.PtcAdverts.PTCImagesEnabled)
            {
                ImageClass = "has-image";
            }
            else
            {
                ImageClass = "";
            }

            CashLinkPlaceHolder.Visible = false;
        }
        //Display Cash Links Advert Type
        else if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
        {
            ActiveAdvertPlaceHolder.Visible   = false;
            InactiveAdvertPlaceHolder.Visible = false;
            if (IsActive)
            {
                CashLinkPlaceHolder.Visible = true;
            }
            else
            {
                CashLinkPlaceHolderInActive.Visible = true;
            }

            if (IsPreview) //Preview fix
            {
                CashLinkDiv.Attributes["class"] = "Abox CashLinkBox";
            }
        }
    }
Ejemplo n.º 2
0
        private void TryCreditDirectReferer(PtcAdvert ad)
        {
            if (!User.HasReferer || TitanFeatures.IsGambinos && User.MembershipId == 1)
            {
                return;
            }

            Member referer = new Member(User.ReferrerId);

            if (referer.IsRented)
            {
                return;
            }

            if (referer.HasClickedEnoughToProfitFromReferrals())
            {
                Money amountToCredit = PtcAdvert.CalculateEarningsFromDirectReferral(referer.Membership, ad);

                if (AppSettings.Payments.CommissionBalanceEnabled)
                {
                    referer.AddToCommissionBalance(amountToCredit, "PTC /ref/" + User.Name, BalanceLogType.Other);
                }
                else
                {
                    referer.AddToMainBalance(amountToCredit, "PTC /ref/" + User.Name, BalanceLogType.Other);
                }

                referer.IncreaseEarnings(amountToCredit);
                referer.IncreaseEarningsFromDirectReferral(amountToCredit);
                referer.IncreaseDRClicks();
                referer.IncreaseStatClicks(1);
                referer.IncreaseDRCashLinksEarnings(amountToCredit);

                referer.StatsCommissionsCurrentWeekIncome  += amountToCredit;
                referer.StatsCommissionsCurrentMonthIncome += amountToCredit;

                var pointsEarnings = referer.Membership.DirectReferralAdvertClickEarningsPoints;
                referer.AddToPointsBalance(pointsEarnings, "PTC /ref/" + User.Name);
                referer.IncreaseDirectRefPointsEarnings(pointsEarnings);
                referer.IncreasePointsEarnings(pointsEarnings);

                User.TotalPTCClicksToDReferer    += 1;
                User.TotalEarnedToDReferer       += amountToCredit;
                User.LastDRActivity               = AppSettings.ServerTime;
                User.TotalPointsEarnedToDReferer += pointsEarnings;
                User.SaveStatisticsAndBalances();

                bool isFullSaveRequired1 = false;
                bool isFullSaveRequired2 = false;

                //Achievements trial
                isFullSaveRequired1 = referer.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterClicks, referer.TotalClicks + 1));

                string  inter     = (referer.TotalEarned + amountToCredit).ToClearString();
                Decimal tempMoney = Decimal.Parse(inter, new System.Globalization.CultureInfo("en-US"));

                isFullSaveRequired2 = referer.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterEarning, Convert.ToInt32(tempMoney)));

                if (isFullSaveRequired1 || isFullSaveRequired2)
                {
                    referer.Save();
                }
                else
                {
                    referer.SaveStatisticsAndBalances();
                }
            }
        }
Ejemplo n.º 3
0
        private void HandleOwnerUser(Member OwnerUser, PtcAdvert Ad, bool FiredByDirectReferral = false, Member WhoFired = null)
        {
            bool CreditMoney = OwnerUser.HasClickedEnoughToProfitFromReferrals();

            //Check if earning only from Standard and Extended is enabled
            //TO REMOVE
            if (CreditMoney && AppSettings.Misc.ExposureRefEarningsEnabled)
            {
                if (Ad.ExposureType == AdExposure.Standard || Ad.ExposureType == AdExposure.Extended)
                {
                    CreditMoney = true;
                }
                else
                {
                    CreditMoney = false;
                }
            }

            if (CreditMoney)
            {
                var Earnings = FiredByDirectReferral ? PtcAdvert.CalculateEarningsFromDirectReferral(OwnerUser, Ad) : PtcAdvert.CalculateEarningsFromRentedReferral(OwnerUser, Ad);

                if (FiredByDirectReferral)
                {
                    OwnerUser.AddToMainBalance(Earnings, "PTC /ref/" + Username, BalanceLogType.Other);
                }
                else
                {
                    OwnerUser.AddToMainBalance(Earnings, "PTC /ref/", BalanceLogType.Other);
                }

                bool isFullSaveRequired1 = false;
                bool isFullSaveRequired2 = false;

                //Achievements trial
                isFullSaveRequired1 = OwnerUser.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterClicks, OwnerUser.TotalClicks + 1));

                string  inter     = (OwnerUser.TotalEarned + Earnings).ToClearString();
                Decimal tempMoney = Decimal.Parse(inter, new System.Globalization.CultureInfo("en-US"));


                isFullSaveRequired2 = OwnerUser.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterEarning, Convert.ToInt32(tempMoney)));

                OwnerUser.IncreaseEarnings(Earnings);
                OwnerUser.IncreaseStatClicks(1);

                if (FiredByDirectReferral)
                {
                    var pointsEarnings = OwnerUser.Membership.DirectReferralAdvertClickEarningsPoints;
                    OwnerUser.AddToPointsBalance(pointsEarnings, "PTC /ref/" + Username);
                    OwnerUser.IncreaseDRClicks();
                    OwnerUser.IncreaseEarningsFromDirectReferral(Earnings);
                    if (WhoFired != null)
                    {
                        WhoFired.TotalPTCClicksToDReferer += 1;
                        WhoFired.TotalEarnedToDReferer    += Earnings;
                        WhoFired.SaveStatisticsAndBalances();
                    }
                }
                else
                {
                    OwnerUser.IncreaseRRClicks();
                }

                if (isFullSaveRequired1 || isFullSaveRequired2)
                {
                    OwnerUser.Save();
                }
                else
                {
                    OwnerUser.SaveStatisticsAndBalances();
                }
            }
            else
            {
                OwnerUser.IncreaseStatClicks(1);

                if (FiredByDirectReferral)
                {
                    var Earnings = PtcAdvert.CalculateEarningsFromDirectReferral(OwnerUser, Ad);
                    OwnerUser.AddToMainBalance(Earnings, "PTC /ref/" + Username, BalanceLogType.Other);
                    OwnerUser.IncreaseEarnings(Earnings);

                    var pointsEarnings = OwnerUser.Membership.DirectReferralAdvertClickEarningsPoints;
                    OwnerUser.AddToPointsBalance(pointsEarnings, "PTC /ref/" + Username);
                    OwnerUser.IncreaseDRClicks();
                    OwnerUser.TotalEarned += Earnings;

                    if (WhoFired != null)
                    {
                        WhoFired.TotalPTCClicksToDReferer += 1;
                        WhoFired.TotalEarnedToDReferer    += Earnings;
                        WhoFired.LastDRActivity            = AppSettings.ServerTime;
                        WhoFired.SaveStatisticsAndBalances();
                    }
                }
                else
                {
                    OwnerUser.IncreaseRRClicks();
                }

                OwnerUser.SaveStatisticsAndBalances();
            }
        }