Beispiel #1
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 ActionResult ClickinformationsAction_CancelPayment(string uid)
        {
            if (string.IsNullOrEmpty(uid))
            {
                return(this.Json(new { status = false, message = "There is no uid param" }));
            }

            MobilePaywallDirect db = MobilePaywallDirect.Instance;

            DirectContainer container = db.LoadContainer(string.Format(@"
        SELECT ol.PaymentID, p.PaymentStatusID FROM MobilePaywall.core.OLCache AS ol
        LEFT OUTER JOIN MobilePaywall.core.Payment AS p ON ol.PaymentID=p.PaymentID
        WHERE UserSessionID={0}", uid));

            if (!container.HasValue)
            {
                return(this.Json(new { status = false, message = "There is no entry for this UserSession" }));
            }

            int?paymentID     = container.GetInt("PaymentID");
            int?paymentStatus = container.GetInt("PaymentStatusID");

            if (!paymentID.HasValue)
            {
                return(this.Json(new { status = false, message = "This UserSession has no payment" }));
            }
            if (!paymentStatus.HasValue)
            {
                return(this.Json(new { status = false, message = "InternalError. There is no status for payment on this US" }));
            }

            if (paymentStatus.Value == 1)
            {
                return(this.Json(new { status = false, message = "Payment status is initialized. You cannot cancel this status" }));
            }
            if (paymentStatus.Value == 2)
            {
                return(this.Json(new { status = false, message = "Payment status is pending. You cannot cancel this status" }));
            }
            if (paymentStatus.Value == 4)
            {
                return(this.Json(new { status = false, message = "Payment status is failed. You cannot cancel this payment" }));
            }
            if (paymentStatus.Value == 5)
            {
                return(this.Json(new { status = false, message = "This payment is allready canceled" }));
            }

            db.Execute("UPDATE MobilePaywall.core.Payment SET PaymentStatusID=5 WHERE PaymentID=" + paymentID.Value);
            return(this.Json(new { status = true, message = "Payment is cancelled" }));
        }
        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);
                }
            }
        }
Beispiel #4
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);
        }
        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);
            }
        }
        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);
        }
        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);
            }
        }