示例#1
0
        /// <summary>
        /// Checks whether the member passes the geolocation requirements in GeolocationUnit or not
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool IsGeolocationMeet(GeolocationUnit unit, Member user)
        {
            CPAOffer offer = new CPAOffer();

            offer.AddGeolocation(unit);
            return(offer.IsGeolocationMeet(user));
        }
        public override void Synchronize()
        {
            AffiliateNetwork Network = base.Network;

            try
            {
                DataTable dt = new DataTable();
                using (var bridge = ParserPool.Acquire(Database.Client))
                {
                    dt = bridge.Instance.ExecuteRawCommandToDataTable("SELECT * FROM CPAOffers WHERE NetworkName = '" + Network.Name + "' ORDER BY NetworkOfferIdInt ASC");
                }

                XmlDocument doc  = GetElement(Network.PublisherPassword, Network.PublisherUsername, ThrowExceptions);
                XmlElement  root = doc.DocumentElement;

                var InterestingList = TableHelper.GetListFromDataTable <CPAOffer>(dt, 100, true);
                var idNodes         = root.SelectNodes("/campaigns/campaign/id");

                foreach (XmlNode node in idNodes)
                {
                    string id = node.InnerText;
                    //Check if already on the list
                    CPAOffer ThisOffer = SyncedNetwork.HasThisOffer(InterestingList, id);
                    if (ThisOffer != null)
                    {
                        //We have it
                        ThisOffer.Status = Advertising.AdvertStatus.WaitingForAcceptance;
                    }
                }

                //Now, remove the offers that shouldn't be on the list
                foreach (var elem in InterestingList)
                {
                    if (elem.Status != AdvertStatus.WaitingForAcceptance)
                    {
                        //"Delete" it
                        elem.Status            = AdvertStatus.Rejected;
                        elem.IsSyncWithNetwork = false;
                        elem.Save();
                    }
                }

                Network.LastSyncDate = DateTime.Now;
                Network.Save();
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                if (base.ThrowExceptions)
                {
                    throw new MsgException("There was a problem with synchronizing " + Network.Name + ": " + ex.Message + ". Check your Affiliate Id/API Key and if the website is available");
                }
            }
        }
示例#3
0
        /// <summary>
        /// Throws MsgException with corresponding outut message
        /// Performs check on duplicate & status (Igored, Reported, Denied)
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="theOffer"></param>
        /// <returns></returns>
        public static void CheckDuplicateAndStatus(string Username, CPAOffer theOffer, bool isPostBack = false)
        {
            var list = GetAllSubmissionsForOffer(Username, theOffer);

            //No point in checking submissions, when there are no submisions other then 'Report'
            if (list.Count > 0 && !AppSettings.CPAGPT.ReadOnlyModeEnabled)
            {
                //Daily
                int howManyWasSubmitedToday = 0;

                foreach (var submission in list)
                {
                    if (submission.DateAdded.Date == AppSettings.ServerTime.Date)
                    {
                        howManyWasSubmitedToday++;
                    }

                    if (!isPostBack)
                    {
                        if (submission.Status == OfferStatus.Ignored || submission.Status == OfferStatus.Reported ||
                            submission.Status == OfferStatus.Denied)
                        {
                            throw new MsgException("This offer has been " + submission.Status);
                        }
                    }
                }

                if (!theOffer.IsDaily)
                {
                    throw new MsgException(Resources.U3900.ALREADYSUBMITED);
                }

                if (howManyWasSubmitedToday >= theOffer.MaxDailyCredits)
                {
                    throw new MsgException(Resources.U3900.DAILYBUTABOVETHELIMIT.Replace("%n1%", howManyWasSubmitedToday.ToString())
                                           .Replace("%n2%", theOffer.MaxDailyCredits.ToString()));
                }
            }
        }
示例#4
0
        public static List <OfferRegisterEntry> GetAllSubmissionsForOffer(string Username, CPAOffer ThisOffer)
        {
            var dict = TableHelper.MakeDictionary("Username", Username);

            dict.Add("OfferId", ThisOffer.Id);

            return(TableHelper.SelectRows <OfferRegisterEntry>(dict));
        }
示例#5
0
 public static OfferRegisterEntry AddNew(CPAOffer offer, string username, OfferStatus firststatus, string loginID = null, string EmailID = null, int OfferLevel = 0)
 {
     return(AddNew(offer.Id, username, firststatus, offer.IsDaily, offer.DeviceType, loginID, EmailID, OfferLevel));
 }