public static void ReleaseCPA(CPAPostbackLog log) { try { var where = TableHelper.MakeDictionary("NetworkOfferIdInt", log.OfferId); where.Add("AdvertiserUsername", log.NetworkName); CPAOffer OurOffer = TableHelper.SelectRows <CPAOffer>(where)[0]; //TODO (What if offer has been deleted in the meantime?) //Credit CPAGPTCrediter Crediter = (CPAGPTCrediter)CrediterFactory.Acquire(log.Username, CreditType.CPAGPTOffer); var conditions = TableHelper.MakeDictionary("Username", log.Username); conditions.Add("OfferId", OurOffer.Id); conditions.Add("OfferStatus", (int)OfferStatus.Pending); OfferRegisterEntry entry = TableHelper.SelectRows <OfferRegisterEntry>(conditions)[0]; CPAManager.AcceptEntryManually(entry, new Member(entry.Username)); //Update log log.Status = CPAPostBackLogStatus.CreditedByNetworkPointsUnlocked; log.Save(); } catch (Exception ex) { ErrorLogger.Log(ex); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { //We want to obey OnSort and OnChart events string[] commands = new string[3] { "deny", "accept", "under" }; if (commands.Contains(e.CommandName)) { int index = e.GetSelectedRowIndex() % GridView1.PageSize; GridViewRow row = GridView1.Rows[index]; string AdId = (row.Cells[1].Text); var Ad = new OfferRegisterEntry(Convert.ToInt32(AdId)); Member User = new Member(Ad.Username); if (Ad.Status == OfferStatus.Pending || Ad.Status == OfferStatus.UnderReview) { if (e.CommandName == "accept") { CPAManager.AcceptEntryManually(Ad, User); Response.Redirect("cpaoffers.aspx?go=1"); } else if (e.CommandName == "deny") { CPAManager.DenyEntryManually(Ad, User); Response.Redirect("cpaoffers.aspx?go=1"); } else if (e.CommandName == "under") { CPAManager.PutEntryUnderReview(Ad, User); Response.Redirect("cpaoffers.aspx?go=1"); } } } }
protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(Member.IsLogged && AppSettings.TitanFeatures.EarnersRoleEnabled && AppSettings.TitanFeatures.EarnCPAGPTEnabled && Member.CurrentInCache.IsEarner); FrequencySelectionPlaceHolder.Visible = AppSettings.CPAGPT.DailyNotDailyButtonsEnabled; PreviousPageButton.Visible = CurrentPageNumber > 0; #region Handlers if (Request.QueryString["ignore"] != null) { //ACTION 1 //Proceed with Ignore int OfferId = Convert.ToInt32(Request.QueryString["ignore"]); var Offer = new CPAOffer(OfferId); OfferRegisterEntry.AddNew(Offer, Member.CurrentName, OfferStatus.Ignored); RemoveElementFromSessionList(OfferId); NotificationManager.Refresh(NotificationType.NewCPAOffers); this.DataBind(); Response.Redirect("cpaoffers.aspx?keeporder=1"); } else if (Request.QueryString["report"] != null) { //ACTION 2 //Proceed with Report int OfferId = Convert.ToInt32(Request.QueryString["report"]); var Offer = new CPAOffer(OfferId); string ReportText = "none"; foreach (var t in Request.Form.AllKeys) { if (t.EndsWith("ReportMessage" + OfferId)) { ReportText = Request.Form[t]; break; } } //Validate string regex = @"[a-zA-Z0-9\.\-\,\!\?\&\:\$\@\(\)\+\=\%\*|\\\t\\\n|\\\r|\\\s]{1,600}"; var match = Regex.Match(ReportText, regex, RegexOptions.IgnoreCase); if (match.Success) { // does match var report = new CPAReport(); report.DateReported = DateTime.Now; report.ReportText = ReportText; report.ReportingUsername = Member.CurrentName; report.OfferId = OfferId; report.Save(); OfferRegisterEntry.AddNew(Offer, Member.CurrentName, OfferStatus.Reported, report.Id.ToString()); if (!AppSettings.CPAGPT.ReadOnlyModeEnabled) { RemoveElementFromSessionList(OfferId); } NotificationManager.Refresh(NotificationType.NewCPAOffers); Response.Redirect("cpaoffers.aspx?keeporder=1"); } else { WriteError(L1.BADERRREP); } } else if (Request.QueryString["submit"] != null) { //ACTION 3 //Proceed with Submit int OfferId = Convert.ToInt32(Request.QueryString["submit"]); string LoginID = ""; string EmailID = ""; foreach (var t in Request.Form.AllKeys) { if (t.EndsWith("LoginID" + OfferId)) { LoginID = Request.Form[t]; break; } } foreach (var t in Request.Form.AllKeys) { if (t.EndsWith("EmailID" + OfferId)) { EmailID = Request.Form[t]; break; } } //Validate CPAOffer ThisOffer = new CPAOffer(OfferId); bool isOk1 = true; bool isOk2 = true; if (ThisOffer.LoginBoxRequired) { string regex1 = @"[a-zA-Z0-9\.\-\,\!\?\&\:\$\@\(\)\+\=\%\*|\\\t\\\n|\\\r|\\\s]{1,80}"; var match1 = Regex.Match(LoginID, regex1, RegexOptions.IgnoreCase); isOk1 = match1.Success; } if (ThisOffer.EmailBoxRequired) { string regex2 = @"[a-zA-Z0-9\.\-\,\!\?\&\:\$\@\(\)\+\=\%\*|\\\t\\\n|\\\r|\\\s]{1,400}"; var match2 = Regex.Match(EmailID, regex2, RegexOptions.IgnoreCase); isOk2 = match2.Success; } if (isOk1 && isOk2) { //Does match //Check for duplicates first try { OfferRegisterEntry.CheckDuplicateAndStatus(Member.CurrentName, ThisOffer); if (ThisOffer.GlobalDailySubmitsRestricted) { int submissionsGloballyToday = OfferRegisterEntry.GetAllTodaysSubmissionsCountForOffer(ThisOffer.Id); if (submissionsGloballyToday >= ThisOffer.MaxGlobalDailySubmits) { throw new MsgException(U3900.DAILYBUTABOVETHELIMIT.Replace("%n1%", submissionsGloballyToday.ToString()) .Replace("%n2%", ThisOffer.MaxGlobalDailySubmits.ToString())); } } var entry = OfferRegisterEntry.AddNew(ThisOffer, Member.CurrentName, OfferStatus.Pending, LoginID, EmailID); if (AppSettings.CPAGPT.AutoApprovalEnabled) { CPAManager.AcceptEntryManually(entry, Member.Current); } else { ThisOffer.PerformStatusControlCheck(); } RemoveElementFromSessionList(OfferId); NotificationManager.RefreshWithMember(NotificationType.NewCPAOffers, Member.Current); Response.Redirect("cpaoffers.aspx?keeporder=1"); } catch (MsgException ex) { WriteError(ex.Message); } } else { WriteError(L1.ONEFIELDSABAD); } } else if (Request.QueryString["undo"] != null) { if (Request.QueryString["sender"] != null && Request.QueryString["sender"] != "undefined") { int offerId = Convert.ToInt32(Request.QueryString["undo"]); var where = TableHelper.MakeDictionary("OfferId", offerId); where.Add("Username", Member.CurrentName); if (Request.QueryString["sender"] == "ignored") { where.Add("OfferStatus", (int)OfferStatus.Ignored); } else if (Request.QueryString["sender"] == "pending") { where.Add("OfferStatus", (int)OfferStatus.Pending); } else if (Request.QueryString["sender"] == "reported") { where.Add("OfferStatus", (int)OfferStatus.Reported); } TableHelper.DeleteRows <OfferRegisterEntry>(where); var offer = new CPAOffer(offerId); offer.PerformStatusControlCheck(); } NotificationManager.Refresh(NotificationType.NewCPAOffers); Response.Redirect("cpaoffers.aspx?keeporder=0"); } #endregion Handlers if (!Page.IsPostBack) { PreviousPageButton.Text = "← " + U4000.PREVIOUSPAGE; NextPageButton.Text = U4000.NEXTPAGE + " →"; if (AppSettings.CPAGPT.ReadOnlyModeEnabled) { NavigationPlaceHolder.Visible = false; } if (AppSettings.CPAGPT.ReadOnlyModeEnabled || AppSettings.CPAGPT.AutoApprovalEnabled) { SortBy1.Items.Remove(SortBy1.Items.FindByValue("ARating")); SortBy1.Items.Remove(SortBy1.Items.FindByValue("ALast")); SortBy1.Items.Remove(SortBy1.Items.FindByValue("ATimes")); SortBy1.Items.Remove(SortBy1.Items.FindByValue("DRating")); SortBy1.Items.Remove(SortBy1.Items.FindByValue("DLast")); SortBy1.Items.Remove(SortBy1.Items.FindByValue("DTimes")); } if (TitanFeatures.IsJ5Walter) { InformationPlaceHolder.Visible = false; } if (TitanFeatures.IsJ5WalterFreebiesFromHome) { CustomPageHeaderPlaceHolder.Visible = true; StandardPageHeaderPlaceHolder.Visible = false; SearchBox1.CssClass = "form-control"; SearchButton1.Attributes["style"] = "padding: 6px 12px"; SortBy1.Items.Remove(SortBy1.Items.FindByValue("AMoney")); SortBy1.Items.Remove(SortBy1.Items.FindByValue("DMoney")); } if (TitanFeatures.IsTami9191) { IsDailyCategoryList = true; } if (AppSettings.CPAGPT.AutoApprovalEnabled) // Do not show Pending/Under review/Denied tabs { Button4.Visible = Button6.Visible = Button7.Visible = false; } if (Request.QueryString["o"] != null) { //Show particular offer try { int offerId = Convert.ToInt32(Request.QueryString["o"]); CPAOffer offer = new CPAOffer(offerId); var list = OM.AllActiveOffersForMember; bool exists = false; foreach (var elem in list) { if (elem.Id == offerId) { exists = true; } } OffersPanel0.Controls.Clear(); if (exists) { OffersPanel0.Controls.Add(offer.ToPanel(CurrentUser.Membership.CPAProfitPercent)); } else { Literal temp = new Literal(); temp.Text = U4000.OFFERNOTAVAIL; OffersPanel0.Controls.Add(temp); } MakeCategoriesList(); MakeSortingList(); makeButtons(); } catch (Exception ex) { ErrorLogger.Log(ex); } } else { //Preset the desired device (Desktop is preselected as default) if (AppSettings.CPAGPT.DeviceTypeDistinctionEnabled && Device.Current == DeviceType.Mobile) { OffersDeviceType = DeviceType.Mobile; MobileDeviceTypeButton.CssClass = "ViewSelected"; DesktopDeviceTypeButton.CssClass = ""; } KeepOrder = (Request.QueryString["keeporder"] != null && Request.QueryString["keeporder"] == "1"); DecideAndUpdate(); //ACTIVE //Categories List and active boxes MakeCategoriesList(); MakeSortingList(); makeButtons(); //Recreate if needed //Only for ACTIVE if (KeepOrder && MenuMultiView.ActiveViewIndex == 0) { SearchBox1.Text = SearchBoxInput; CategoriesList.SelectedIndex = CategoryIdInput; SortBy1.SelectedIndex = SortIdInput; } } } //Disabling Daily/Other groups for specific client if (TitanFeatures.IsBobbyDonev) { FrequencySelectionPlaceHolder.Visible = !AppSettings.TitanFeatures.OfferLevelsEnabled; GroupOfferLevelsPlaceHolder.Visible = AppSettings.TitanFeatures.OfferLevelsEnabled; } else { GroupOfferLevelsPlaceHolder.Visible = false; } if (IsDailyCategoryList) { DailyCategoriesButton.CssClass = "ViewSelected"; OtherCategoriesButton.CssClass = ""; } }