protected void AutopayOnButton_Click(object sender, EventArgs e) { ClearPanels(); bool hasErrors = false; //AutoPay using (var bridge = ParserPool.Acquire(Database.Client)) { int referralsDone = 0; for (int i = 0; i < DirectRefsGridView.Rows.Count; i++) { if (((HtmlInputCheckBox)DirectRefsGridView.Rows[i].FindControl("chkSelect")).Checked) { int ExpireDays = Int32.Parse(DirectRefsGridView.Rows[i].Cells[4].Text.Replace(" " + L1.DAYS, "")); string refId = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim()); int RefId = Int32.Parse(refId); //Should we turn on or off if (ExpireDays < AppSettings.RentedReferrals.MinDaysToStartAutoPay) { hasErrors = true; } else { referralsDone++; RentReferralsSystem.SetAutopayOnReferral(RefId, bridge.Instance); } } } if (!hasErrors) //so bad, exceptions [*] { SuccMessagePanel2.Visible = true; SuccMessage2.Text = U3501.REFACTIONSUCC2; } else { ErrorMessagePanel2.Visible = true; ErrorMessage2.Text = L1.OPPREFAPARTIAL + " " + L1.OPREFAP; ErrorMessage2.Text = ErrorMessage2.Text.Replace("%n%", referralsDone.ToString()); ErrorMessage2.Text = ErrorMessage2.Text.Replace("%n2%", AppSettings.RentedReferrals.MinDaysToStartAutoPay.ToString()); } DirectRefsGridView.DataBind(); } }
public void CreditUser(Money amount, string what, TrafficGridPrizeType type, int?points = null) { switch (type) { case TrafficGridPrizeType.PurchaseBalance: User.AddToPurchaseBalance(amount, "TrafficGrid win", BalanceLogType.Other); User.SaveBalances(); History.AddTrafficGridWin(User.Name, what); break; case TrafficGridPrizeType.MainBalance: CreditMainBalance(amount, "TrafficGrid win", BalanceLogType.Other); History.AddTrafficGridWin(User.Name, what); break; case TrafficGridPrizeType.TrafficBalance: User.AddToTrafficBalance(amount, "TrafficGrid win", BalanceLogType.Other); User.SaveBalances(); History.AddTrafficGridWin(User.Name, what); break; case TrafficGridPrizeType.DirectReferralLimit: User.DirectReferralLimitEnlargedBy++; User.Save(); History.AddTrafficGridWin(User.Name, what); break; case TrafficGridPrizeType.RentedReferrals: var rrm = new RentReferralsSystem(User.Name, User.Membership); if (rrm.GetUserRentedReferralsCount() >= User.Membership.RentedReferralsLimit) { throw new MsgException(L1.WONERROR); } rrm.RentReferrals(1); History.AddTrafficGridWin(User.Name, what); break; case TrafficGridPrizeType.Points: CreditPoints(points.Value, "TrafficGrid win", BalanceLogType.Other); History.AddTrafficGridWin(User.Name, what); break; } }
protected void RecycleButton_Click(object sender, EventArgs e) { ClearPanels(); //Recycle try { using (var bridge = ParserPool.Acquire(Database.Client)) { Member User = Member.Current; Money SingleOperationCost = User.Membership.RentedReferralRecycleCost; int referralsDone = 0; for (int i = 0; i < DirectRefsGridView.Rows.Count; i++) { if (((HtmlInputCheckBox)DirectRefsGridView.Rows[i].FindControl("chkSelect")).Checked) { if (SingleOperationCost > User.PurchaseBalance) { throw new MsgException(L1.OPPREFPARTIAL.ToString().Replace("%n%", referralsDone.ToString())); } string refId = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim()); RentReferralsSystem.RecycleReferral(Int32.Parse(refId), bridge.Instance); User.SubtractFromPurchaseBalance(SingleOperationCost, "Ref: recycle"); User.SaveBalances(); referralsDone++; } } RentReferralsSystem.TryForceAutopay(User.Name); SuccMessagePanel2.Visible = true; SuccMessage2.Text = U3501.REFACTIONSUCC; } } catch (MsgException ex) { ErrorMessagePanel2.Visible = true; ErrorMessage2.Text = ex.Message; } DirectRefsGridView.DataBind(); }
protected void AutopayAllOffButton_Click(object sender, EventArgs e) { ClearPanels(); //AutoPay using (var bridge = ParserPool.Acquire(Database.Client)) { int referralsDone = 0; for (int i = 0; i < DirectRefsGridView.Rows.Count; i++) { int ExpireDays = Int32.Parse(DirectRefsGridView.Rows[i].Cells[4].Text.Replace(" " + L1.DAYS, "")); string refId = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim()); int RefId = Int32.Parse(refId); referralsDone++; RentReferralsSystem.SetAutopayOffReferral(RefId, bridge.Instance); } SuccMessagePanel2.Visible = true; SuccMessage2.Text = U6011.REFACTIONSUCC; DirectRefsGridView.DataBind(); } }
protected void DirectRefsGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { if (TitanFeatures.IsTrafficThunder) { e.Row.Cells[17].Text = "Comission"; e.Row.Cells[20].Visible = false; for (int i = 0; i < 27; i++) { e.Row.Cells[i].Style.Add("color", "#f15f79"); } } else { e.Row.Cells[17].Text = U4000.MONEY; } if (!AppSettings.TitanFeatures.UpgradeEnabled) { e.Row.Cells[21].Visible = false; } if (!AppSettings.Ethereum.ERC20TokenEnabled) { e.Row.Cells[18].Visible = false; } } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[0].Text = ""; var chbox = ((HtmlInputCheckBox)e.Row.FindControl("chkSelect")); chbox.Attributes.Add("onclick", SelectedPanel.ClientID + ".style.display = 'block';hideIfUnchecked('" + SelectedPanel.ClientID + "');"); //Create an instance of the datarow var userName = e.Row.Cells[19].Text; Member User = new Member(userName); //Lets generate avatar + colored login OR encrypt if (AppSettings.DirectReferrals.AreUsernamesEncrypted) { e.Row.Cells[2].Text = MemberAuthenticationService.ComputeHash(userName).Substring(0, 16); } else { e.Row.Cells[2].Text = HtmlCreator.CreateAvatarPlusUsername(User); } if (TitanFeatures.isAri) { e.Row.Cells[6].Text = User.ActiveAdPacks.ToString(); } //Count the AVG [] Clicks[] RegDate[] int clicks = Int32.Parse(e.Row.Cells[10].Text); DateTime registered = Convert.ToDateTime(e.Row.Cells[7].Text); if (registered < AppSettings.ServerTime.AddYears(-100)) { e.Row.Cells[7].Text = Member.CurrentInCache.Registered.ToShortDateString(); } e.Row.Cells[11].Text = HtmlCreator.GetColoredAVGValue(RentReferralsSystem.GetAVG(clicks, registered)); //Last activity[5] string lastActivityString; if (string.IsNullOrEmpty(e.Row.Cells[8].Text) || e.Row.Cells[8].Text == " " || Convert.ToDateTime(e.Row.Cells[8].Text) < DateTime.Now.AddYears(-100)) { lastActivityString = "<i>" + L1.NEVER + "</i>"; } else { DateTime lastActivity = Convert.ToDateTime(e.Row.Cells[8].Text); int days = (int)Math.Ceiling(DateTime.Now.Subtract(lastActivity).TotalDays); switch (days) { case 1: lastActivityString = L1.TODAY; break; case 2: lastActivityString = L1.YESTERDAY; break; default: lastActivityString = days.ToString() + " " + L1.DAYSAGO; break; } } e.Row.Cells[8].Text = lastActivityString; e.Row.Cells[15].Text = new Money(Convert.ToDecimal(e.Row.Cells[15].Text)).ToString(); e.Row.Cells[17].Text = Money.Parse(e.Row.Cells[17].Text).ToString(); if (AppSettings.Ethereum.ERC20TokenEnabled) { e.Row.Cells[18].Text = (new CryptocurrencyMoney(CryptocurrencyType.ERC20Token, Decimal.Parse(e.Row.Cells[18].Text))).ToString(); } else { e.Row.Cells[18].Visible = false; } if (AppSettings.DirectReferrals.DirectReferralBuyingEnabled && User.ReferrerExpirationDate.HasValue) { e.Row.Cells[20].Text = GetTimeToExpiration(User.ReferrerExpirationDate.Value); } else if (AppSettings.DirectReferrals.DirectReferralExpirationEnabled) { var expirationDate = Convert.ToDateTime(e.Row.Cells[20].Text).AddDays(AppSettings.DirectReferrals.DirectReferralExpiration); e.Row.Cells[20].Text = GetTimeToExpiration(expirationDate); } else { e.Row.Cells[20].Text = "-"; } e.Row.Cells[21].Text = new Membership(Convert.ToInt32(e.Row.Cells[21].Text)).Name; if (!AppSettings.TitanFeatures.UpgradeEnabled) { e.Row.Cells[21].Visible = false; } if (TitanFeatures.IsTrafficThunder) { e.Row.Cells[20].Visible = false; } if (TitanFeatures.IsSardaryify) { // Get id of current user // Id is in the last column var id = Convert.ToInt32(e.Row.Cells[26].Text); e.Row.Cells[23].Text = AdPackManager.GetNumberOfUsersAdPacks(id, true).ToString(); e.Row.Cells[24].Text = Member.GetDirectReferralsCount(id).ToString(); var amount = TableHelper.SelectScalar(string.Format(@" SELECT SUM(Price) FROM Adpacks AS A JOIN AdPackTypes AS B ON A.AdPackTypeId = B.Id WHERE A.UserId = {0} AND BalanceBoughtType = {1} ", id, (int)PurchaseBalances.Cash)).ToString(); Money amountInMoney; if (!string.IsNullOrWhiteSpace(amount)) { amountInMoney = Money.Parse(amount); } else { amountInMoney = new Money(0); } e.Row.Cells[25].Text = amountInMoney.ToString(); } } }
public static void ProceedDailyTasks() { log = new StringBuilder(); var Entry = new CronEntry(); Entry.Date = DateTime.Now; try { Log("Starting CRON procedure"); //Make sure it runs only once if (CanRun()) { AppSettings.IsOffline = true; AppSettings.Misc.LastCRONRun = DateTime.Now; AppSettings.Misc.Save(); stime = DateTime.Now; AntiCheatSystem.CRON(); Log("OK [1] AntiCheatSystem. Elapsed time: " + GetTimeString(stime)); RentReferralsSystem.CRON(); Log("OK [2] RentedReferralsSystem. Elapsed time: " + GetTimeString(stime)); StatisticsManager.CRON(); Log("OK [3a] StatisticsManager. Elapsed time: " + GetTimeString(stime)); //MUST BE RUN BEFORE MEMBERMANAGER.CRON() !!! CustomFeaturesManager.CRON(); Log("OK [3b] CustomFeaturesManager. Elapsed time: " + GetTimeString(stime)); MemberManager.CRON(); Log("OK [4] Member. Elapsed time: " + GetTimeString(stime)); SyncedNetworkFactory.SynchronizeAll(); Log("OK [5] CPA Offers. Elapsed time: " + GetTimeString(stime)); AppSettings.Payments.CRON(); Log("OK [6] Payments. Elapsed time: " + GetTimeString(stime)); ShoutboxManager.CRON(); Log("OK [7] Shoutbox. Elapsed time: " + GetTimeString(stime)); CLPManager.CRON(); Log("OK [8] CLPManager. Elapsed time: " + GetTimeString(stime)); BannerAuctionManager.CRON(); Log("OK [10] BannerAuctionManager. Elapsed time: " + GetTimeString(stime)); PointsLockingManager.CRON(); Log("OK [11] PointsLockingManager. Elapsed time: " + GetTimeString(stime)); DBArchiver.CRON(); Log("OK [12] DBArchiver. Elapsed time: " + GetTimeString(stime)); RevenueSharesDistributionManager.CRON(); Log("OK [13] RevenueSharesDistributionManager. Elapsed time: " + GetTimeString(stime)); CreditLineManager.CRON(); Log("OK [14] CreditLineManager. Elapsed time: " + GetTimeString(stime)); PoolRotatorManager.CRON(); Log("OK [15] PoolRotatorManager. Elapsed time: " + GetTimeString(stime)); JackpotManager.CRON(); Log("OK [16] JackpotManager. Elapsed time: " + GetTimeString(stime)); TrafficExchangeManager.CRON(); Log("OK [17] TrafficExchangeManager. Elapsed time: " + GetTimeString(stime)); DailyPoolManager.CRON(); Log("OK [18] DailyPoolManager. Elapsed time: " + GetTimeString(stime)); //Matrix MatrixBase matrix = MatrixFactory.GetMatrix(); if (matrix != null) { matrix.CRON(); } Log("OK [19] MatrixBase. Elapsed time: " + GetTimeString(stime)); ApiAccessToken.CRON(); Log("OK [20] ApiAccessToken. Elapsed time: " + GetTimeString(stime)); InvestmentPlatformManager.CRON(); Log("OK [21] InvestmentPlatformManager. Elapsed time: " + GetTimeString(stime)); MarketplaceBalanceLogManager.CRON(); Log("OK [22] MarketplaceBalanceLogManager. Elapsed time: " + GetTimeString(stime)); MiniVideoManager.CRON(); Log("OK [23] MiniVideoManager. Elapsed time: " + GetTimeString(stime)); PaidToPromoteManager.CRON(); Log("OK [24] PaidToPromoteManager. Elapsed time: " + GetTimeString(stime)); RollDiceLotteryManager.CRON(); Log("OK [25] RollDiceLotteryManager. Elapsed time: " + GetTimeString(stime)); WalletManager.CRON(); Log("OK [26] WalletManager. Elapsed time: " + GetTimeString(stime)); NewsManager.CRON(); Log("OK [27] NewsManager. Elapsed time: " + GetTimeString(stime)); Entry.Type = 1; Entry.Text = "Procedure completed successfully (27/27 100%) after " + GetTimeString(stime); } else { Entry.Type = 2; Entry.Text = "Procedure prevented from multiple run"; } } catch (Exception ex) { ErrorLogger.Log(ex); Log("Fatal error (exception thrown).."); Entry.Type = 3; Entry.Text = "Fatal error during procedure execution. Check logs for more information"; Mailer.SendCRONFailureMessage(); } finally { ErrorLogger.Log(log.ToString(), LogType.CRON); AppSettings.IsOffline = false; Entry.Save(); HttpContext.Current.Response.Write(Entry.Text); } }
public Money CreditMember(PtcAdvert Ad, bool isFromAutosurf = false) { Money Calculated = PtcAdvert.CalculateNormalMemberEarnings(User, Ad); base.CreditMainBalance(Calculated, "PTC", BalanceLogType.Other); //To not overflow the logs if (User.Membership.AdvertPointsEarnings > 0) { base.CreditPoints(User.Membership.AdvertPointsEarnings, "PTC", BalanceLogType.Other); } //Ad Credits? if (AppSettings.PtcAdverts.PTCCreditsEnabled) { User.AddToPTCCredits(User.Membership.PTCCreditsPerView, "PTC"); //Credit advertiser if (Ad.Advertiser.Is(Advertiser.Creator.Member) && Ad.AdvertiserUserId != User.Id) { Member UplineAdvertiser = new Member(Ad.AdvertiserUserId); UplineAdvertiser.AddToPointsBalance(UplineAdvertiser.Membership.PointsYourPTCAdBeingViewed, "PTC Ad Viewed"); UplineAdvertiser.SaveBalances(); Ad.PointsEarnedFromViews += UplineAdvertiser.Membership.PointsYourPTCAdBeingViewed; Ad.Save(); } } //OK mark as watched and credit List <int> av = User.AdsViewed; av.Add(Ad.Id); User.AdsViewed = av; User.LastActive = DateTime.Now; if (isFromAutosurf) { User.PtcAutoSurfClicksThisMonth += 1; } User.PtcSurfClicksThisMonth += 1; //Achievements User.TryToAddAchievements( Prem.PTC.Achievements.Achievement.GetProperAchievements( Prem.PTC.Achievements.AchievementType.AfterClicks, User.TotalClicks + 1)); Money NewTotalEarned = (User.TotalEarned + Calculated); User.TryToAddAchievements( Prem.PTC.Achievements.Achievement.GetProperAchievements( Prem.PTC.Achievements.AchievementType.AfterEarning, NewTotalEarned.GetRealTotals())); User.IncreaseUserStatClicks(1); User.IncreaseStatClicks(1); User.IncreaseCashLinksEarnings(Calculated); //Slot machine chances SlotMachine.SlotMachine.TryAddChances(User); User.Save(); //Check the contests Prem.PTC.Contests.ContestManager.IMadeAnAction(Prem.PTC.Contests.ContestType.Click, User.Name, null, 1); var rrm = new RentReferralsSystem(User.Name, User.Membership); rrm.IClicked(Ad); TryCreditDirectReferer(Ad); return(Calculated); }
public static void CheckAndUpdateStatistics(StatisticsType Type) { Statistics Stat; switch (Type) { case StatisticsType.TotalMembersCount: Stat = new Statistics(Type); var where1 = new Dictionary <string, object>(); where1.Add("AccountStatusInt", (int)MemberStatus.Active); int totalmember = TableHelper.CountOf <Member>(where1); where1.Add(Member.Columns.MembershipName, Memberships.Membership.Standard.Name); int upgradedmember = TableHelper.CountOf <Member>(where1); upgradedmember = totalmember - upgradedmember; //Now update var list1 = TableHelper.GetIntListFromString(Stat.Data1); list1[0] = totalmember; Stat.Data1 = TableHelper.GetStringFromIntList(list1); var list2 = TableHelper.GetIntListFromString(Stat.Data2); list2[0] = upgradedmember; Stat.Data2 = TableHelper.GetStringFromIntList(list2); Stat.Save(); break; case StatisticsType.PointsInSystem: Stat = new Statistics(Type); //Now update var list888 = TableHelper.GetIntListFromString(Stat.Data1); list888[0] = AppSettings.Points.TotalInSystem; Stat.Data1 = TableHelper.GetStringFromIntList(list888); Stat.Save(); break; case StatisticsType.PointsGenerated: Stat = new Statistics(Type); //Now update var list999 = TableHelper.GetIntListFromString(Stat.Data1); int totalNow = AppSettings.Points.TotalGenerated; int totalYesterday = AppSettings.Points.TotalGeneratedUpToYesterday; int totalToday = totalNow - totalYesterday; list999[0] = totalToday; Stat.Data1 = TableHelper.GetStringFromIntList(list999); Stat.Save(); break; case StatisticsType.AvailableReferrals: Stat = new Statistics(Type); //Now update var list3 = TableHelper.GetIntListFromString(Stat.Data1); list3[0] = RentReferralsSystem.GetAvailableNormalReferralsCount(); Stat.Data1 = TableHelper.GetStringFromIntList(list3); Stat.Save(); break; case StatisticsType.NormalRentedReferrals: Stat = new Statistics(Type); //Now update var list4 = TableHelper.GetIntListFromString(Stat.Data1); list4[0] = RentReferralsSystem.GetRentedNormalReferralsCount(); Stat.Data1 = TableHelper.GetStringFromIntList(list4); Stat.Save(); break; case StatisticsType.BotRentedReferrals: Stat = new Statistics(Type); //Now update var list5 = TableHelper.GetIntListFromString(Stat.Data1); list5[0] = RentReferralsSystem.GetRentedBotReferralsCount(); Stat.Data1 = TableHelper.GetStringFromIntList(list5); Stat.Save(); break; case StatisticsType.MoneyDistributedPerAdPack: Stat = new Statistics(Type); //Now update //TO DO: review var list6 = TableHelper.GetMoneyListFromString(Stat.Data1); AdPackType type = AdPackType.Standard; list6[0] = new Money(type.Price.ToDecimal() * (type.FixedDistributionValuePercent / (Decimal)100)); Stat.Data1 = TableHelper.GetStringFromMoneyList(list6); Stat.Save(); break; case StatisticsType.AvailableFunds: //Handle var list = PaymentAccountDetails.AllGateways; foreach (var account in list) { var where = TableHelper.MakeDictionary("Type", (int)StatisticsType.AvailableFunds); where.Add("Data1", StatisticsManager.GetPaymentAccountName(account)); var TempStatList = TableHelper.SelectRows <Statistics>(where); if (TempStatList.Count > 0) { Statistics stat = TempStatList[0]; if (stat != null) { stat.SetData2(account.Account.Balance); stat.Save(); } } } //var where2 = TableHelper.MakeDictionary("Type", (int)StatisticsType.AvailableFunds); //where2.Add("Data1", AppSettings.Cryptocurrencies.APIProvider.ToString()); //var tempStatList2 = TableHelper.SelectRows<Statistics>(where2); //if (tempStatList2.Count > 0) //{ // var stat = tempStatList2[0]; // if (stat != null) // { // stat.SetData2(BitcoinAPIFacotry.Get().GetAccountBalance()); // stat.Save(); // } //} break; } }
protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { //We want to obey OnSort and OnChart events string[] commands = new string[4] { "comDelete", "comRenew", "comRecycle", "comAutopay" }; if (commands.Contains(e.CommandName)) { int index = e.GetSelectedRowIndex(); GridViewRow row = DirectRefsGridView.Rows[index]; ClearPanels(); try { using (var bridge = ParserPool.Acquire(Database.Client)) { if (e.CommandName == "comDelete") { string refId = (row.Cells[1].Text.Trim()); RentReferralsSystem.DeleteReferral(Int32.Parse(refId), bridge.Instance); Response.Redirect("rented.aspx"); } else if (e.CommandName == "comRenew") { Member User = Member.Logged(Context); Money SingleOperationCost = CalcRenewCost(User.Membership.RenewalDiscount, User.Membership.ReferralRentCost); if (User.PurchaseBalance < SingleOperationCost) { throw new MsgException(L1.NOTENOUGHFUNDS); } User.SubtractFromPurchaseBalance(SingleOperationCost, "Ref: renew"); User.SaveBalances(); string refId = (row.Cells[1].Text.Trim()); RentReferralsSystem.RenewReferral(Int32.Parse(refId), bridge.Instance); } else if (e.CommandName == "comRecycle") { Member User = Member.Logged(Context); Money SingleOperationCost = User.Membership.RentedReferralRecycleCost; if (User.PurchaseBalance < SingleOperationCost) { throw new MsgException(L1.NOTENOUGHFUNDS); } string refId = (row.Cells[1].Text.Trim()); RentReferralsSystem.RecycleReferral(Int32.Parse(refId), bridge.Instance); User.SubtractFromPurchaseBalance(SingleOperationCost, "Ref: recycle"); User.SaveBalances(); } else if (e.CommandName == "comAutopay") { bool setOn = true; string refId = (row.Cells[1].Text.Trim()); if (row.Cells[7].Text.Contains("img")) // I know its bad, very bad { setOn = false; } if (setOn) { int ExpireDays = Int32.Parse(row.Cells[4].Text.Replace(" " + L1.DAYS, "")); if (ExpireDays < AppSettings.RentedReferrals.MinDaysToStartAutoPay) { throw new MsgException((L1.OPREFAP).ToString().Replace("%n2%", AppSettings.RentedReferrals.MinDaysToStartAutoPay.ToString())); } RentReferralsSystem.SetAutopayOnReferral(Int32.Parse(refId), bridge.Instance); } else { RentReferralsSystem.SetAutopayOffReferral(Int32.Parse(refId), bridge.Instance); } } DirectRefsGridView.DataBind(); SuccMessagePanel2.Visible = true; SuccMessage2.Text = L1.OP_SUCCESS; } } catch (MsgException ex) { ErrorMessagePanel2.Visible = true; ErrorMessage2.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.ReferralsRentedEnabled); Member User = Member.Current; RentReferralsSystem rrs; //For Chrome compatibility Context.Response.AppendHeader("X-XSS-Protection", "0"); //Lets check if user clicked the pack and want to make a purchase if (Request.Params.Get("__PACKID") != null && IsParameterANumber() && !AppSettings.Site.TrafficExchangeMod) { SuccMessagePanel.Visible = false; ErrorMessagePanel.Visible = false; int packID = Int32.Parse(Request.Params.Get("__PACKID")); rrs = new RentReferralsSystem(User.Name, User.Membership); try { AppSettings.DemoCheck(); ReferralPackage pack = new ReferralPackage(packID); // Check if all valid HasValidRequirements(User, pack, rrs, true); //Purchase the pack and save the user rrs.RentReferrals(pack.RefsInPackage); //throws MsgException if no ref available Money totalPrice = CalculatePackCost(User, pack); User.SubtractFromPurchaseBalance(totalPrice, "Ref: rent"); User.LastRentDate = DateTime.Now; //Check if achievement should be applied rrs = new RentReferralsSystem(User.Name, User.Membership); User.TryToAddAchievements( Prem.PTC.Achievements.Achievement.GetProperAchievements( Prem.PTC.Achievements.AchievementType.AfterHavingRentedReferrals, rrs.GetUserRentedReferralsCount())); User.Save(); // 4. Write success info SuccMessagePanel.Visible = true; SuccMessage.Text = U3501.REFSUCC; //Ad history entry History.AddPurchase(User.Name, totalPrice, pack.RefsInPackage.ToString() + " rented referrals"); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } } //Lang DirectRefsGridView.EmptyDataText = L1.NORENTEDREFERRALS; LangAdder.Add(Button1, L1.MANAGE); LangAdder.Add(Button2, L1.RENTNEW); UserName.Text = Member.CurrentName; RemoveButton.Text = L1.REMOVE; RecycleButton.Text = string.Format("{0} ({1} {2})", L1.RECYCLE, User.Membership.RentedReferralRecycleCost, U6011.PERONE); AutopayAllOnButton.Text = AutopayOnButton.Text = U6004.AUTOPAYON; AutopayAllOffButton.Text = AutopayOffButton.Text = U6004.AUTOPAYOFF; RenewButton.Text = L1.RENEW; //Data rrs = new RentReferralsSystem(User.Name, User.Membership); RefLimit.Text = User.Membership.RentedReferralsLimit.ToString(); MaxRefPack.Text = User.Membership.MaxRefPackageCount.ToString(); RefCount.Text = rrs.GetUserRentedReferralsCount().ToString(); RentalTimeLabel.Text = AppSettings.RentedReferrals.CanBeRentedFor.Days.ToString(); RefGauranteeLabel.Text = (AppSettings.RentedReferrals.MinLastClickingActivity == TimeSpan.MinValue) ? L1.NONE : L1.CLICKEDINLAST + " " + AppSettings.RentedReferrals.MinLastClickingActivity.Days.ToString() + " " + L1.DAYS; MinClicksLabel.Text = AppSettings.Referrals.MinTotalClicksToRentRefs.ToString(); LastRentedLiteral.Text = (User.LastRentDate == null) ? L1.NEVER : User.LastRentDate.ToString(); MinRentInterval.Text = User.Membership.MinRentingInterval.Days.ToString(); TotalClicksLiteral.Text = User.TotalClicks.ToString(); //Autopay available? AutopayOnButton.Visible = AutopayOffButton.Visible = User.Membership.CanAutoPay && AppSettings.Referrals.RentedRefAutopayPolicy == AppSettings.Referrals.AutopayPolicy.UserChooses; AutopayAllPlaceHolder.Visible = User.Membership.CanAutoPay && AppSettings.Referrals.RentedRefAutopayPolicy == AppSettings.Referrals.AutopayPolicy.AllReferrals; //Generate pack images RefBoxesLiteral.Text = string.Empty; var packList = TableHelper.SelectAllRows <ReferralPackage>(); packList.Sort(Comparison); for (int i = 0; i < packList.Count; ++i) { bool isActive = HasValidRequirements(User, packList[i], rrs, false); Money packPrice = CalculatePackCost(User, packList[i]); RefBoxesLiteral.Text += HtmlCreator.GenerateRentRefBox(packList[i].RefsInPackage, packPrice, isActive, packList[i].Id); } if (AppSettings.Referrals.Renting == AppSettings.Referrals.RentingOption.DirectReferrals) { InfoPlaceHolder.Visible = false; Button1.Visible = false; Button2.CssClass = "ViewSelected"; MenuMultiView.ActiveViewIndex = 1; } //Warning displays if (!User.HasClickedEnoughToProfitFromReferrals() && DirectRefsGridView.Rows.Count != 0) { WarningPanel.Visible = true; WarningLiteral.Text = L1.REFNOPROFITS; WarningLiteral.Text = WarningLiteral.Text.Replace("%n%", AppSettings.Referrals.MinDailyClicksToEarnFromRefs.ToString()); } RemoveButton.Visible = AppSettings.RentedReferrals.IsDeletingEnabled; RecycleButton.Visible = AppSettings.RentedReferrals.IsRecyclingEnabled; RegisterStartupGridViewCode(DirectRefsGridView, SelectedPanel, ref jsSelectAllCode); }