public static int?GetPrelanderTypeID(string type, CCSubmitDirect db = null) { if (db == null) { db = CCSubmitDirect.Instance; } if (string.IsNullOrEmpty(type)) { return(null); } int?prelandertypeid = null; if (!CCSubmitCacheManager.PrelanderTypes.ContainsKey(type)) { prelandertypeid = db.LoadInt("SELECT prelandertypeid FROM [].tm_prelandertype WHERE name={0}", type); if (!prelandertypeid.HasValue) { prelandertypeid = db.Execute("INSERT INTO [].tm_prelandertype (name)", type); } if (!prelandertypeid.HasValue) { return(null); } CCSubmitCacheManager.PrelanderTypes.Add(type, prelandertypeid.Value); } else { prelandertypeid = CCSubmitCacheManager.PrelanderTypes[type]; } return(prelandertypeid); }
public static LeadEntry ManageLeadFromAction(ActionModel model) { CCSubmitDirect db = model.Database; if (db == null) { db = CCSubmitDirect.Instance; } int? leadid = db.LoadInt("SELECT leadID FROM [].tm_lead_action WHERE actionid=" + model.ActionID); LeadEntry leadEntry = null; if (leadid.HasValue) { // this action has valid lead, so we update values leadEntry = new LeadEntry(leadid.Value, db); leadEntry.CheckValue("first_name", model.FirstName); leadEntry.CheckValue("last_name", model.LastName); leadEntry.CheckValue("msisdn", model.Msisdn); leadEntry.CheckValue("email", model.Email); leadEntry.CheckValue("address", model.Address); leadEntry.CheckValue("zip", model.Zip); leadEntry.CheckValue("country", model.Country); leadEntry.CheckValue("city", model.City); } else { // this action does not have valid lead, so we need to create/find new one // we try to find it by email, msisdn leadid = LeadManager.GetLeadID(model.Msisdn, model.Email, db); if (leadid.HasValue) { // if we find it, we try to update values leadEntry = new LeadEntry(leadid.Value, db); leadEntry.CheckValue("first_name", model.FirstName); leadEntry.CheckValue("last_name", model.LastName); leadEntry.CheckValue("address", model.Address); leadEntry.CheckValue("email", model.Email); leadEntry.CheckValue("zip", model.Zip); leadEntry.CheckValue("country", model.Country); leadEntry.CheckValue("city", model.City); leadEntry.CheckValue("msisdn", model.Msisdn); leadEntry.UpdateSql += "actions_count=actions_count+1,"; } else { // if not, we create new one leadid = CreateLead(model.Msisdn, model.Email, model.FirstName, model.LastName, model.Country, model.Address, model.City, model.Zip, model.device_model, model.carrier, model.device_mf, model.device_os, 1); leadEntry = new LeadEntry(leadid.Value, db); } db.Transactional.Execute("UPDATE [].tm_lead_action SET leadid={0} WHERE actionid={1}", leadid.Value, model.ActionID); } leadEntry.FinishUpdateSql(); return(leadEntry); }
public static int?GetActionID(string clickid, CCSubmitDirect db = null) { if (db == null) { db = CCSubmitDirect.Instance; } return(db.LoadInt("SELECT actionid FROM [].tm_lead_action WHERE clickid={0}", clickid)); }
public static int?GetLeadID(string msisdn, string email, CCSubmitDirect db = null) { if (string.IsNullOrEmpty(msisdn) && string.IsNullOrEmpty(email)) { return(null); } if (db == null) { db = CCSubmitDirect.Instance; } if (!string.IsNullOrEmpty(msisdn) && !string.IsNullOrEmpty(email)) { string query = string.Format(" (msisdn='{0}' AND email='{1}') OR (msisdn=null AND email='{1}') OR (msisdn='{0}' AND email=null)", msisdn, email); int? id = db.LoadInt(string.Format("SELECT leadid FROM [].tm_lead WHERE {0}", query)); if (id.HasValue) { return(id); } } if (!string.IsNullOrEmpty(msisdn)) { string query = string.Format(" msisdn='{0}'", msisdn); int? id = db.LoadInt(string.Format("SELECT leadid FROM [].tm_lead WHERE {0}", query)); if (id.HasValue) { return(id); } } if (!string.IsNullOrEmpty(email)) { string query = string.Format(" email='{0}'", email); int? id = db.LoadInt(string.Format("SELECT leadid FROM [].tm_lead WHERE {0}", query)); if (id.HasValue) { return(id); } } return(null); }
public int?GetAffiliateCurrentTransactions(string affiliateID) { CCSubmitDirect ccdb = CCSubmitDirect.Instance; DateTime startDate = DateTime.Today.AddHours(-2); string startDateQuery = string.Format("{0}-{1}-{2} {3}:00:00", startDate.Year, startDate.Month, startDate.Day, startDate.Hour); DateTime endDate = startDate.AddDays(1); string endDateQuery = string.Format("{0}-{1}-{2} {3}:00:00", endDate.Year, endDate.Month, endDate.Day, endDate.Hour); string query = string.Format("SELECT COUNT(*) FROM [].tm_action WHERE affid={0} AND created>=\"{1}\" AND created<=\"{2}\" AND (has_subscription=1 OR (has_subscription=0 AND times_charged=1)) ORDER BY actionid;", affiliateID, startDateQuery, endDateQuery); int?result = ccdb.LoadInt(query); Console.WriteLine(affiliateID + " - " + result.Value); return(result); }
public static bool HasPrelanderLocker(CCSubmitDirect db, DomainManager domainManager) { if (domainManager.Queries.ContainsKey("dbg")) { return(true); } if (!domainManager.Queries.ContainsKey("msisdn") || string.IsNullOrEmpty(domainManager.Queries["msisdn"])) { return(false); } string lockerID = string.Format("{0}_{1}", domainManager.Prelander.ID, domainManager.Queries["msisdn"]); int? result = db.LoadInt("SELECT COUNT(*) FROM [].tm_locker WHERE lockerid={0}", lockerID); if (result.HasValue && result.Value > 0) { return(false); } db.Execute("INSERT INTO [].tm_locker (lockerid)", lockerID); return(true); }
public static int?GetLanderID(string name, CCSubmitDirect db = null) { if (db == null) { db = CCSubmitDirect.Instance; } if (string.IsNullOrEmpty(name)) { return(null); } int?id = null; if (!CCSubmitCacheManager.Landers.ContainsKey(name)) { id = db.LoadInt("SELECT landerid FROM [].tm_lander WHERE name={0}", name); if (!id.HasValue) { id = db.Execute("INSERT INTO [].tm_lander (name)", name); } if (!id.HasValue) { return(null); } CCSubmitCacheManager.Landers.Add(name, id.Value); } else { id = CCSubmitCacheManager.Landers[name]; } return(id); }
// CALLBACK -> CCCash //[Route("cccashcallback")] public ActionResult cccashcallback() { this.CreateLog(); string firstname = Request["firstname"] != null ? Request["firstname"].ToString() : string.Empty; string lastname = Request["lastname"] != null ? Request["lastname"].ToString() : string.Empty; string address = Request["address"] != null ? Request["address"].ToString() : string.Empty; string email = Request["email"] != null ? Request["email"].ToString() : string.Empty; string zip = Request["zip"] != null ? Request["zip"].ToString() : string.Empty; string country = Request["country"] != null ? Request["country"].ToString() : string.Empty; string city = Request["city"] != null ? Request["city"].ToString() : string.Empty; string clickid = Request["clickid"] != null ? Request["clickid"].ToString() : string.Empty; string ievent = Request["event"] != null ? Request["event"].ToString().ToLower() : string.Empty; string offer = ""; int affid = -1; int aid = -1; string pubid = ""; string msisdn = ""; string subtracking = Request["subtracking"] != null ? Request["subtracking"].ToString().ToLower() : string.Empty; if (!string.IsNullOrEmpty(subtracking)) { string[] subtracking_info = subtracking.Split('_'); if (subtracking_info.Length == 3) { offer = subtracking_info[0]; int.TryParse(subtracking_info[1], out affid); pubid = subtracking_info[2]; } if (subtracking_info.Length == 4) { offer = subtracking_info[0]; int.TryParse(subtracking_info[1], out affid); pubid = subtracking_info[2]; msisdn = subtracking_info[3]; } if (subtracking_info.Length == 5) { offer = subtracking_info[0]; int.TryParse(subtracking_info[1], out affid); pubid = subtracking_info[2]; msisdn = subtracking_info[3]; if (!string.IsNullOrEmpty(subtracking_info[4])) { int.TryParse(subtracking_info[4], out aid); } } } this.Log($"CCCash: sent us: firstname:{firstname}, lastname:{lastname}, address:{address}, zip:{zip}, country:{country}, city:{city}, clickid:{clickid}"); //CCSubmitDirect.Instance.Execute($"UPDATE livesports.cc_client SET country='{country}', firstname='{firstname}', lastname='{lastname}', address='{address}', zip='{zip}', city='{city}' WHERE clickid='{clickid}'"); CCSubmitDirect db = CCSubmitDirect.Instance; #region # NEW TRACKING DATABSE # /* * NEW TRACKING MANAGER */ ActionModelEvent action_event = ActionModelEvent.Create; if (!string.IsNullOrEmpty(ievent) && ievent.Equals("join")) { action_event = ActionModelEvent.Charge; } if (aid != -1) { ActionManager.ExecuteAction(new ActionModel() { Database = db, Service = ActionService.CCCash, Event = action_event, ActionID = aid, FirstName = firstname, LastName = lastname, ClickID = clickid, Email = email, Msisdn = msisdn, Address = address, Zip = zip, City = city, Country = country }); } #endregion int?ccid = db.LoadInt($"SELECT clientid FROM livesports.cc_client WHERE clickid='{clickid}'"); int PAYMENT_PROVIDER_ID = 4; if (!ccid.HasValue) { ccid = db.Execute("INSERT INTO livesports.cc_client (payment_provider, country, host, email, firstname, lastname, address, zip, city, clickid, affid, msisdn, pubid, updated, created)", PAYMENT_PROVIDER_ID, country, offer, email, firstname, lastname, address, zip, city, clickid, affid, msisdn, pubid, DirectTime.Now, DirectTime.Now); } else { db.Execute("UPDATE [].cc_client SET msisdn={0}, affid={1}, pubid={2} WHERE clickid={3}", msisdn, affid, pubid, clickid); } if (!string.IsNullOrEmpty(ievent) && ievent.Equals("join")) { bool _isStolen = false; this.SendPostbackToSports_Subscribe(clickid, "", "", ""); UndercoverResult undercover = CCUndercoverAgent.Init(clickid); if (!undercover.DontSendConversionToBananaclicks) { this.Log("This transaction will not be stolen and will be sent to banana ::clickid=" + clickid); this.SendPostbackToBananaclicks(clickid); } else { _isStolen = true; this.Log("THIS TRANSACTION WILL BE STOLEN ::clickid=" + clickid); } this.SendPostbackToSpots_CallbackInformation(clickid, "settle", HttpContext.Request.RawUrl.ToString(), false, _isStolen); } return(this.Content("")); }
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); } }