public static string GetJsonWithInstantAccrualsValues(int userId, int fromDays = 9) { CheckInstantAccrualsRequirement(); if (!AppSettings.RevShare.AdPack.InstantAccrualsEnabled) { return(string.Empty); } //max 10 days = 9 + today if (fromDays > 9) { fromDays = 9; } var adPackTypeId = GetAdPackTypeId(); var array = new JArray(); var myDate = AppSettings.ServerTime.AddDays(-fromDays); var commissionPerSeconds = 0m; while (AppSettings.ServerTime.Date > myDate.Date) { var date = myDate.Date; var earnings = GetEarningFromDate(userId, date); var percentage = GetAdPackDailyReturnedPercentage(adPackTypeId, date); array.Add(GetJObject(date, earnings, percentage)); myDate = myDate.AddDays(1); } //Current Day var user = new Member(userId); var adpacksCount = GetAdpacksCount(user.Id, adPackTypeId); if (user.RevenueShareAdsWatchedYesterday >= user.Membership.AdPackDailyRequiredClicks && adpacksCount > 0) { AdPackType adPackType; var cache = new AdPackTypesCache(); var adPackTypes = (Dictionary <int, AdPackType>)cache.Get(); adPackTypes.TryGetValue(adPackTypeId, out adPackType); var date = myDate.Date; var percentage = GetAdPackDailyReturnedPercentage(adPackTypeId, date); commissionPerSeconds = (adPackType.Price.ToDecimal() * (percentage / 100) / 24 / 3600) * adpacksCount; var time = (AppSettings.ServerTime.Minute * 60) + AppSettings.ServerTime.Second; var earnings = GetEarningFromDate(userId, date); array.Add(GetJObject(date, earnings, percentage)); } else { array.Add(GetJObject(myDate.Date, Money.Zero, 0.0m)); } array.Add(new JObject(new JProperty("earningPerSecond", commissionPerSeconds))); return(array.ToString()); }
protected void UserS4DSPacksGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { String Addon = Convert.ToDecimal(e.Row.Cells[1].Text) >= 120 ? "Finished: " : "Purchased: "; AdPack adPack = new AdPack(Convert.ToInt32(e.Row.Cells[0].Text)); AdPackTypesCache cache = new AdPackTypesCache(); var adPackTypes = (Dictionary <int, AdPackType>)cache.Get(); e.Row.Cells[1].Text = HtmlCreator.GenerateCPAAdProgressHTML( new Money(Convert.ToDecimal(e.Row.Cells[1].Text)).ToDecimal(), adPack.MoneyToReturn.ToDecimal(), AppSettings.Site.CurrencySign); e.Row.Cells[2].Text = Addon + e.Row.Cells[2].Text; } }
protected void InitControls() { CalculatorMainPlaceHolder.Visible = true; var cache = new AdPackTypesCache(); Dictionary <int, AdPackType> adPacksTypeList = (Dictionary <int, AdPackType>)cache.Get(); AdPackDropDownList.Items.Clear(); foreach (var type in adPacksTypeList) { if (type.Value.Status == Prem.PTC.Advertising.AdPackTypeStatus.Active) { AdPackDropDownList.Items.Add(new ListItem(type.Value.Name, type.Value.Id.ToString())); } } TitleLiteral.Text = string.Format(U6007.ADPACKCALTULATOR, AppSettings.RevShare.AdPack.AdPackNamePlural); CalculateButton.Text = U6007.CALCULATE; }