private void CollectDataForPremiumSms()
        {
            DirectContainer container = MobilePaywallDirect.Instance.LoadContainer(string.Format(@"
        SELECT sce.Keyword, sce.Shortcode FROM MobilePaywall.core.Service AS s
        LEFT OUTER JOIN MobilePaywall.core.ServiceConfigurationEntry AS sce ON s.ServiceConfigurationID=sce.ServiceConfigurationID
        WHERE s.Name='{0}'", this._name));

            if (!container.HasValue)
            {
                this._isPsms = false;
                Log.Error("SuitableService:: Could not load Keyword shortcode for service with name: " + this._name);
                return;
            }

            this._keyword   = container.GetString("Keyword");
            this._shortcode = container.GetString("Shortcode");

            if (string.IsNullOrEmpty(this._keyword))
            {
                this._isPsms = false;
                Log.Error("SuitableService:: Keyword is empty for service with name: " + this._name);
                return;
            }

            if (string.IsNullOrEmpty(this._shortcode))
            {
                this._isPsms = false;
                Log.Error("SuitableService:: Shortcode is empty for service with name: " + this._name);
                return;
            }
        }
Esempio n. 2
0
        public static PremiumSubscriptionModel GetModel(MobilePaywallDirect db, AndroidPremiumCustomer customer)
        {
            DirectContainer container = db.LoadContainer(string.Format(@"
        SELECT s.ServiceID, s.Name AS ServiceName, c.TwoLetterIsoCode, sce.Keyword, sce.Shortcode FROM MobilePaywall.core.TemplateServiceInfo AS i
        LEFT OUTER JOIN MobilePaywall.core.Service AS s ON i.ServiceID=s.ServiceID
        LEFT OUTER JOIN MobilePaywall.core.Country AS c ON s.FallbackCountryID=c.CountryID
        LEFT OUTER JOIN MobilePaywall.core.ServiceConfiguration AS sc ON s.ServiceConfigurationID=sc.ServiceConfigurationID
        LEFT OUTER JOIN MobilePaywall.core.ServiceConfigurationEntry AS sce ON sce.ServiceConfigurationID=sc.ServiceConfigurationID
		    LEFT OUTER JOIN MobilePaywall.core.AndroidPremiumCustomerServiceMap AS apcsm ON apcsm.ServiceID=s.ServiceID
        WHERE i.IsPremiumSms=1 AND sce.Shortcode != '' AND sce.Keyword != '' AND i.Progress IN (5) 
              AND (apcsm.AndroidPremiumCustomerID IS NULL OR apcsm.AndroidPremiumCustomerID!={0} OR (apcsm.AndroidPremiumCustomerID={0} AND apcsm.PaymentRequestID IS NULL)) AND c.CountryID={1}", customer.ID, customer.Country.ID));

            if (!container.HasValue || container.ColumnCount == 0)
            {
                return(null);
            }

            return(new PremiumSubscriptionModel()
            {
                ServiceID = container.GetString("ServiceID"),
                ServiceName = container.GetString("ServiceName"),
                TwoLetterIsoCode = container.GetString("TwoLetterIsoCode"),
                Keyword = container.GetString("Keyword"),
                Shortcode = container.GetString("Shortcode")
            });
        }
        public ActionResult GetClickInformations(string uid)
        {
            int _uid = -1;

            if (!Int32.TryParse(uid, out _uid))
            {
                return(this.Content(""));
            }

            MobilePaywallDirect db    = MobilePaywallDirect.Instance;
            DirectContainer     cache = db.LoadContainer(@"SELECT c.ServiceName, c.CountryCode, c.MobileOperatorName, c.SessionCreated, p.PaymentStatusID, p.PaymentID
        FROM MobilePaywall.core.OLCache AS c
        LEFT OUTER JOIN MobilePaywall.core.Payment AS p ON c.PaymentID=p.PaymentID
        WHERE c.UserSessionID=" + uid);

            if (!cache.HasValue)
            {
                return(this.Content(""));
            }

            ClickInformationModel model = new ClickInformationModel();

            model.UserSessionID = uid;
            model.Logo          = string.Format("http://{0}/logo", cache.GetString("ServiceName"));
            model.Country       = string.Format("../images/_flagsx/{0}.png", cache.GetString("CountryCode"));

            return(PartialView("~/Views/Report/_ClickInformations.cshtml", model));
        }
Esempio n. 4
0
        public static async Task <int?> GetCountryByCode(CCSubmitDirect db, string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(null);
            }

            if (_countryCodeMap == null)
            {
                await Configure(db);
            }

            foreach (var entry in _countryCodeMap)
            {
                if (entry.Key.Contains(code.ToLower()))
                {
                    return(entry.Value);
                }
            }

            DirectContainer dc = await db.LoadContainerAsync(string.Format("SELECT countryid, name, code FROM [].tm_country WHERE code='{0}';", code.ToLower()));

            if (!dc.HasValue)
            {
                return(null);
            }

            _countryNameMap.Add(dc.GetString("name").ToLower(), dc.GetInt("countryid").Value);
            _countryCodeMap.Add(dc.GetString("code").ToLower(), dc.GetInt("countryid").Value);
            db.TransactionalManager.Add("INSERT INTO [].tm_country_used (countryid)", dc.GetInt("countryid").Value);

            return(dc.GetInt("countryid").Value);
        }
        public static UndercoverResult Init(string clickID)
        {
            CCUndercoverAgent.Log(clickID, "CC_NEW:: Starting for : " + clickID);
            UndercoverResult result = new UndercoverResult();
            CCSubmitDirect   db     = CCSubmitDirect.Instance;
            DirectContainer  dc     = db.LoadContainer(string.Format("SELECT affid, pubid, referrer FROM livesports.cc_client WHERE clickid='{0}' ORDER BY clientid DESC LIMIT 1;", clickID));

            if (!dc.HasValue)
            {
                CCUndercoverAgent.Log(clickID, "CC_NEW:: There is no entries for clickID: " + clickID);
                return(result);
            }

            string affID = !string.IsNullOrEmpty(dc.GetString("affid")) ? dc.GetString("affid") : GetParamByName(dc.GetString("referrer"), "affiliate_id");
            string pubID = !string.IsNullOrEmpty(dc.GetString("pubid")) ? dc.GetString("pubid") : GetParamByName(dc.GetString("referrer"), "utm_campaign");

            if (string.IsNullOrEmpty(affID))
            {
                CCUndercoverAgent.Log(clickID, "CC_NEW:: There is no AffID for clickID: " + clickID);
                return(result);
            }

            DirectContainer _directContainer;

            if (!string.IsNullOrEmpty(pubID))
            {
                _directContainer = db.LoadContainer("SELECT * FROM [].cc_undercover WHERE (aff_id={0} AND pub_id={1}) OR (aff_id={0} AND pub_id IS NULL) ORDER BY pub_id DESC LIMIT 1;", int.Parse(affID), pubID);
            }
            else
            {
                _directContainer = db.LoadContainer("SELECT * FROM [].cc_undercover WHERE (aff_id={0} AND pub_id IS NULL) ORDER BY pub_id DESC LIMIT 1;", int.Parse(affID));
            }


            if (_directContainer.HasValue && _directContainer.GetDouble("tcost").HasValue)
            {
                try
                {
                    return(GetByVariableTCost(_directContainer, affID));
                }
                catch (Exception e)
                {
                    Log(clickID, "[FATAL WITH tcost] " + e.ToString());
                }
            }

            Log(clickID, "CCUndercover will go to old way, for clickID = " + clickID + ", affID=" + affID);
            return(result);
        }
Esempio n. 6
0
        public async Task <int?> Get(CCSubmitDirect db, string input)
        {
            input = input.ToLower();
            if (string.IsNullOrEmpty(input))
            {
                return(null);
            }

            if (_data.ContainsKey(input))
            {
                return(_data[input].ID);
            }

            DirectContainer dc = await db.LoadContainerAsync(string.Format("SELECT countryid, name, code FROM [].tm_country WHERE name LIKE '%{0}%' OR code='{0}';", input));

            if (!dc.HasValue)
            {
                return(null);
            }

            CountryCacheModel country = new CountryCacheModel()
            {
                ID   = dc.GetInt("countryid").Value,
                Name = dc.GetString("name").ToLower(),
                Code = dc.GetString("code").ToLower()
            };

            if (!_data.ContainsKey(country.Code))
            {
                _data.Add(country.Code, country);
            }

            if (!_data.ContainsKey(country.Name))
            {
                _data.Add(country.Name, country);
            }

            db.TransactionalManager.Add("INSERT INTO [].tm_country_used (countryid)", dc.GetInt("countryid").Value);
            return(dc.GetInt("countryid").Value);
        }
        /*
         *  REPORT
         */


        // SUMMARY: Load report for specific click
        public ActionResult Report(string uid)
        {
            int _userSessionID = -1;

            if (!Int32.TryParse(uid, out _userSessionID))
            {
                ErrorModel errorModel = new ErrorModel()
                {
                    Title = "Fatal error", Description = "Could not parse UID"
                };
                return(View("~/Views/Error.cshtml", errorModel));
            }

            MobilePaywall.Direct.MobilePaywallDirect database = new Direct.MobilePaywallDirect();
            DirectContainer userSessionCont = database.LoadContainer(@"SELECT UserSessionID, UserSessionGuid, EntranceUrl, IPAddress, Created 
                                                                 FROM MobilePaywall.core.UserSession WHERE UserSessionID=" + _userSessionID);

            if (!userSessionCont.HasValue)
            {
                ErrorModel errorModel = new ErrorModel()
                {
                    Title = "Fatal error", Description = "UserSession could not be loaded"
                };
                return(View("~/Views/Error.cshtml", errorModel));
            }


            ReportModel model = new ReportModel()
            {
                PaywallGuid   = userSessionCont.GetString("UserSessionGuid"),
                UserSessionID = uid,
                Pxid          = "",
                Date          = userSessionCont.GetString("Created"),
                IP            = userSessionCont.GetString("IPAddress"),
                HtmlTitle     = "Report : " + uid
            };

            return(View("~/Views/Report/Index.cshtml", model));
        }
Esempio n. 8
0
        public static int?ExecuteActionImplementation(ActionModel model)
        {
            if (model.ActionID == -1)
            {
                int?actionID = Create(model);
                if (!actionID.HasValue)
                {
                    return(null);
                }

                model.ActionID = actionID.Value;
            }

            DirectContainer dc        = model.Database.LoadContainer("SELECT * FROM [].tm_lead_action WHERE actionid=" + model.ActionID);
            LeadEntry       leadEntry = LeadManager.ManageLeadFromAction(model);

            if ((model.Event == ActionModelEvent.Redirection || model.Event == ActionModelEvent.InputEmail) && !dc.GetBoolean("input_redirect"))
            {
                ActionManager.Update(model, "input_redirect", "1", dc);
            }
            if (model.Event == ActionModelEvent.Create)
            {
                ActionManager.Update(model, "input_redirect", "1", dc);
            }
            if ((model.Event == ActionModelEvent.InputEmail && !dc.GetBoolean("input_email")) || (dc.GetBoolean("input_email") == false && !string.IsNullOrEmpty(leadEntry.Container.GetString("email"))))
            {
                ActionManager.Update(model, "input_email", "1", dc);
            }
            if ((model.Event == ActionModelEvent.InputContact && !dc.GetBoolean("input_contact")) || (dc.GetBoolean("input_contact") == false && !string.IsNullOrEmpty(leadEntry.Container.GetString("first_name")) && !string.IsNullOrEmpty(leadEntry.Container.GetString("last_name"))))
            {
                ActionManager.Update(model, "input_contact", "1", dc);
            }
            if (model.Event == ActionModelEvent.Subscribe)
            {
                ActionManager.Update(model, "has_subscription", "1", dc);
            }
            if (model.Event == ActionModelEvent.Chargeback)
            {
                ActionManager.Update(model, "has_chargeback", "1", dc);
            }
            if (model.Event == ActionModelEvent.Refund)
            {
                ActionManager.Update(model, "has_refund", "1", dc);
            }
            if (model.Event == ActionModelEvent.Charge)
            {
                ActionManager.Update(model, "times_charged", "++", dc);
            }
            if (model.Event == ActionModelEvent.Upsell)
            {
                ActionManager.Update(model, "times_upsell", "++", dc);
            }
            if (model.Event == ActionModelEvent.EndFlow)
            {
                ActionManager.Update(model, "provider_redirection", model.ProviderRedirection, dc);
                ActionManager.Update(model, "has_redirectedToProvider", "1", dc);
            }

            if (model.Service != ActionService.Default && (!dc.GetInt("serviceid").HasValue || (int)model.Service != dc.GetInt("serviceid").Value))
            {
                ActionManager.Update(model, "serviceid", ((int)model.Service).ToString(), dc);
            }
            if (!string.IsNullOrEmpty(model.ClickID) && !dc.GetString("clickid").Equals(model.ClickID))
            {
                ActionManager.Update(model, "clickid", model.ClickID, dc);
            }
            if (model.AffID.HasValue && (!dc.GetInt("affid").HasValue || (dc.GetInt("affid").HasValue&& model.AffID.Value != dc.GetInt("affid").Value)))
            {
                ActionManager.Update(model, "affid", model.AffID.ToString(), dc);
            }
            if (!string.IsNullOrEmpty(model.PubID) && !dc.GetString("pubid").Equals(model.PubID))
            {
                ActionManager.Update(model, "pubid", model.PubID, dc, true);
            }
            if (!string.IsNullOrEmpty(model.LanderUrl) && (string.IsNullOrEmpty(dc.GetString("lander_url")) || !dc.GetString("lander_url").Equals(model.LanderUrl)))
            {
                ActionManager.Update(model, "lander_url", model.LanderUrl, dc, true);
            }

            int?landerID = CCSubmitCacheManager.GetLanderID(model.LanderName, model.Database);

            if (landerID.HasValue && dc.GetInt("landerid").HasValue&& dc.GetInt("landerid").Value != landerID.Value)
            {
                ActionManager.Update(model, "landerid", landerID.Value.ToString(), dc);
            }

            model.SQLUpdateQuery = "UPDATE [].tm_lead_action SET " + model.SQLUpdateQuery + " updated=CURRENT_TIMESTAMP WHERE actionid=" + model.ActionID + ";";
            model.Database.Transactional.Execute(model.SQLUpdateQuery);
            model.Database.Transactional.Run();

            return(model.ActionID);
        }
Esempio n. 9
0
        public static void Update(ActionModel model, string key, string value, DirectContainer cache = null, bool isString = false)
        {
            if (model.Database == null)
            {
                model.Database = CCSubmitDirect.Instance;
            }
            if (cache == null)
            {
                cache = model.Database.LoadContainer("SELECT * FROM [].tm_lead_action WHERE actionid=" + model.ActionID);
            }

            if (!cache.HasValue)
            {
                return;
            }

            string new_value = string.Empty;

            if (value.Equals("++") && !cache.GetInt(key).HasValue)
            {
                new_value = "1";
            }
            else
            {
                new_value = (value.Equals("++") ? (cache.GetInt(key).Value + 1).ToString() : value);
            }

            model.Database.Transactional.Execute("INSERT INTO [].tm_action_history (actionid, name, old_value, new_value)", model.ActionID, key, cache.GetString(key), new_value);

            if (value.Equals("++"))
            {
                model.SQLUpdateQuery += key + "=" + key + "+1,";
            }
            else
            {
                if (isString)
                {
                    model.SQLUpdateQuery += model.Database.Construct(key + "='{0}',", value);
                }
                else
                {
                    model.SQLUpdateQuery += model.Database.Construct(key + "={0},", value);
                }
            }
        }
Esempio n. 10
0
        public static void Update2(int actionid, string key, string value, DirectContainer cache = null, CCSubmitDirect db = null)
        {
            if (db == null)
            {
                db = CCSubmitDirect.Instance;
            }
            if (cache == null)
            {
                cache = db.LoadContainer("SELECT * FROM [].tm_lead_action WHERE actionid=" + actionid);
            }

            string new_value = (value.Equals("++") ? (cache.GetInt(key).Value + 1).ToString() : value);

            db.Execute("INSERT INTO [].tm_action_history (actionid, name, old_value, new_value)", actionid, key, cache.GetString(key), new_value);

            if (value.Equals("++"))
            {
                db.Execute("UPDATE [].tm_lead_action SET " + key + "=" + key + "+1 WHERE actionid={1}", value, actionid);
            }
            else
            {
                db.Execute("UPDATE [].tm_lead_action SET " + key + "={0} WHERE actionid={1}", value, actionid);
            }
        }
Esempio n. 11
0
        public static int?GetCountryID(string country, CCSubmitDirect db = null)
        {
            if (string.IsNullOrEmpty(country))
            {
                return(null);
            }

            if (db == null)
            {
                db = CCSubmitDirect.Instance;
            }
            lock (LOCK_OBJ)
            {
                if (country_map == null)
                {
                    country_map = new Dictionary <string, int>();
                    DirectContainer dc = db.LoadContainer(@"SELECT c.countryid, c.name, c.code FROM livesports.tm_country_used AS u
                                                  LEFT OUTER JOIN livesports.tm_country AS c ON u.countryid=c.countryid");
                    foreach (var r in dc.Rows)
                    {
                        if (!country_map.ContainsKey(r.GetString("name").ToLower()))
                        {
                            country_map.Add(r.GetString("name").ToLower(), r.GetInt("countryid").Value);
                        }
                        if (!country_map.ContainsKey(r.GetString("code").ToLower()))
                        {
                            country_map.Add(r.GetString("code").ToLower(), r.GetInt("countryid").Value);
                        }
                    }
                }
            }

            if (country_map.ContainsKey(country.ToLower()))
            {
                return(country_map[country.ToLower()]);
            }

            lock (LOCK_OBJ)
            {
                DirectContainer dcc = db.LoadContainer(string.Format(@"SELECT countryid, name, code FROM livesports.tm_country WHERE name LIKE '%{0}%' OR code='{1}'", country.ToLower(), country.ToLower()));
                if (!dcc.HasValue)
                {
                    return(null);
                }

                if (db.LoadInt("SELECT COUNT(*) FROM [].tm_country_used WHERE countryid={0}", dcc.GetInt("countryid").Value).Value == 0)
                {
                    db.Execute("INSERT INTO [].tm_country_used (countryid)", dcc.GetInt("countryid").Value);
                }


                if (!country_map.ContainsKey(dcc.GetString("name").ToLower()))
                {
                    country_map.Add(dcc.GetString("name").ToLower(), dcc.GetInt("countryid").Value);
                }
                if (!country_map.ContainsKey(dcc.GetString("code").ToLower()))
                {
                    country_map.Add(dcc.GetString("code").ToLower(), dcc.GetInt("countryid").Value);
                }

                return(dcc.GetInt("countryid").Value);
            }
        }