public static ActionModelSend Pack(this ActionDM action, bool?isOnline = null) => new ActionModelSend() { IsOnline = (isOnline != null ? isOnline.Value : ApiSocketServer.IsActionOnline(action)), Lander = action.landerid == null ? null : LandersCache.Instance.Get(action.landerid.Value).Name, Prelander = action.prelanderid == null ? null : PrelandersCache.Instance.Get(action.prelanderid.Value).Name, Provider = action.providerid == null ? null : ProvidersCache.Instance.Get(action.providerid.Value), Country = action.countryid == null ? null : CountryCache.Instance.Get(action.countryid.Value), PrelanderData = (!string.IsNullOrEmpty(action.prelander_data) && action.prelanderid.HasValue) ? PrelandersCache.Instance.ConstructTagsForAction(action.prelanderid.Value, action.prelander_data) : null, actionid = action.actionid, trackingid = action.trackingid, affid = action.affid, pubid = action.pubid, input_redirect = action.input_redirect, input_email = action.input_email, input_contact = action.input_contact, has_subscription = action.has_subscription, has_chargeback = action.has_chargeback, has_refund = action.has_refund, times_charged = action.times_charged, times_upsell = action.times_upsell, has_redirectedToProvider = action.has_redirectedToProvider, has_stolen = action.has_stolen, updated = action.updated, created = action.created };
public static UndercoverResult Init(ActionDM action, PostbackDM postback) { postback.Log("CC_NEW:: Starting for : " + action.trackingid); UndercoverResult result = new UndercoverResult(); CCSubmitDirect db = CCSubmitDirect.Instance; string affID = action.affid; string pubID = action.pubid; if (string.IsNullOrEmpty(affID)) { postback.Log("CC_NEW:: There is no AffID for clickID: " + action.trackingid); return(result); } DirectContainer _directContainer; if (!string.IsNullOrEmpty(pubID)) { _directContainer = db.LoadContainer("SELECT * FROM [].cc_undercover WHERE (affid={0} AND pubid={1}) OR (affid={0} AND pubid IS NULL) ORDER BY pubid DESC LIMIT 1;", int.Parse(affID), pubID); } else { _directContainer = db.LoadContainer("SELECT * FROM [].cc_undercover WHERE (affid={0} AND pubid IS NULL) ORDER BY pubid DESC LIMIT 1;", affID); } if (_directContainer.HasValue && _directContainer.GetDouble("tcost").HasValue) { try { return(GetByVariableTCost(_directContainer, action, postback)); } catch (Exception e) { postback.Log("[FATAL WITH tcost] " + e.ToString()); } } postback.Log("CCUndercover will go to old way, for clickID = " + action.trackingid + ", affID=" + affID); return(result); }
private static UndercoverResult GetByVariableTCost(DirectContainer container, ActionDM action, PostbackDM postback) { UndercoverResult result = null; var banana = new BananaclicksUndercoverManager(); double tcost = container.GetDouble("tcost").Value; // // Affiliate price from bananaclicks double?affPrice = banana.GetAffiliateProfit(action.affid); if (!affPrice.HasValue) { postback.Log("[FATAL]:: THERE IS NO affPrice for affiliate=" + action.affid); return(null); } affPrice = DollarConversion.Convert(affPrice.Value); // // Current transactions from database int?currentTransactions = banana.GetAffiliateCurrentTransactions(action.affid); if (!currentTransactions.HasValue) { postback.Log("[FATAL]:: THERE IS NO currentTransactions for affiliate=" + action.affid); return(null); } else { currentTransactions += 1; } // // Current price [bananaclicks price] / [conversions from database] double current_price = 0.0; if (affPrice.Value == 0.0 || affPrice.Value > 0 && currentTransactions.Value == 1) { current_price = 0.0; } else { current_price = affPrice.Value / (currentTransactions.Value * 1.0); } string logString = string.Format("affID={0}, tcost={1}, affiliate_profit={2}, current_price={3}, current_transactions={4} ", action.affid, tcost, Math.Round(affPrice.Value, 2), Math.Round(current_price, 2), currentTransactions.Value); // // Logic for undercover if (current_price == 0 || current_price <= tcost) { logString += " (REPORT)"; result = UndercoverResult.SendToBananaclicks(); } else { logString += " THIS WILL NOT BE REPORTED"; result = new UndercoverResult() { DontSendConversionToBananaclicks = true }; } postback.Log(logString); return(result); }
public static bool IsActionOnline(ActionDM action) => (from s in Sessions where s.Value.Action.Data != null && s.Value.Action.Data.ID.HasValue && s.Value.Action.Data.ID == action.ID select s.Value).FirstOrDefault() != null;
public static void OnActionOffline(ActionDM action) => DashboardSocketsServer.SendToAll(new ActionUpdateModel() { Data = action }.Pack(DashboardEvents.ACTION_UPDATE));
/// /// ACTIONS /// public static void OnActionInsert(ActionDM action) => DashboardSocketsServer.SendToAll(new ActionUpdateModel() { Data = action }.Pack(DashboardEvents.ACTION_INSERT));
public LanderCommunicationChannel(LoggingBase logger, ActionDM action, string user, int?countryID, CCSubmitDirect db) : base(logger, action, user, countryID, db) { }
public async Task <IActionResult> Index(string type, string data) { SocketBackupControllerLogger logger = new SocketBackupControllerLogger( this.Context.CookiesGet(Constants.ActionID), this.Context.CookiesGet(Constants.UserGuidCookie), this.Context.CookiesGetInt(Constants.CountryID), this.Context.HttpContext.Request.Headers["User-Agent"]); SessionType sessionType = (type.Equals("lp") ? Sockets.ApiSockets.Models.SessionType.Lander : Sockets.ApiSockets.Models.SessionType.Prelander); SessionSocket socket = new SessionSocket(this.Context, sessionType); ActionDM action = socket.Action.Data; if (action == null) { logger.StartLoggin("") .Add("type", type) .Add("data", data) .OnException(new Exception("Could not load action")); return(this.ReturnObject(new DistributionModel() { Status = false })); } string[] split = data.Split('|'); if (split.Length != 2) { logger.StartLoggin("") .Add("type", type) .Add("data", data) .OnException(new Exception("Could not get data from object")); return(this.ReturnObject(new DistributionModel() { Status = false })); } string userID = socket.User.Key; int? country = socket.CountryID; if (action.http_flow == false) { action.http_flow = true; action.UpdateLater(); } try { if (type.Equals("pl")) { PrelanderCommunicationChannel channel = new PrelanderCommunicationChannel(logger, action, userID, country, this.Database); return(this.ReturnObject(await channel.Call(split[0], split[1]))); } else if (type.Equals("lp")) { LanderCommunicationChannel channel = new LanderCommunicationChannel(logger, action, userID, country, this.Database); return(this.ReturnObject(await channel.Call(split[0], split[1]))); } else { logger.StartLoggin("") .Add("type", type) .Add("data", data) .OnException(new Exception("Type was not present ")); return(this.ReturnObject(new DistributionModel() { Status = false })); } } catch (Exception e) { logger.StartLoggin("") .Add("type", type) .Add("data", data) .OnException(e); return(this.ReturnObject(new DistributionModel() { Status = false })); } }
public async void Run(ClientDM client) { string email = client.email.ToLower().Replace("à", "a"); if (string.IsNullOrEmpty(email)) { return; } if (!client.GetCountry().HasValue) { return; } LanderDM lander = null; if (!string.IsNullOrEmpty(client.referrer)) { string[] refSplit = client.referrer.Split('/'); if (refSplit.Length >= 3) { string landingName = refSplit[3]; if (Program.Landers.ContainsKey(landingName)) { lander = Program.Landers[landingName]; } } } int leadID = CurrentIndex; if (!EmailCache.ContainsKey(email) && !MsisdnCache.ContainsKey(client.msisdn)) { var leadDM = new LeadDM(Program.Database) { email = email, msisdn = client.msisdn, first_name = client.firstname, last_name = client.lastname, countryid = client.GetCountry(), address = client.address, actions_count = 1, updated = client.created, created = client.created }; leadDM.ID = CurrentIndex; Program.Bulker.Add(new BulkModel(leadDM, 1)); var userDM = new UserDM(Program.Database) { leadid = CurrentIndex, countryid = client.GetCountry(), created = client.created }; userDM.ID = CurrentIndex; Program.Bulker.Add(new BulkModel(userDM, 2)); EmailCache.Add(email, new LeadUser() { ID = CurrentIndex }); if (!string.IsNullOrEmpty(client.msisdn)) { MsisdnCache.Add(client.msisdn, new LeadUser() { ID = CurrentIndex }); } CurrentIndex++; } else if (EmailCache.ContainsKey(email)) { leadID = EmailCache[email].ID; EmailCache[email].actions_count++; } else if (!string.IsNullOrEmpty(client.msisdn) && MsisdnCache.ContainsKey(client.msisdn)) { leadID = MsisdnCache[client.msisdn].ID; MsisdnCache[client.msisdn].actions_count++; } var actionDM = new ActionDM(Program.Database) { leadid = leadID, userid = "", // TODO: get correct userID trackingid = client.clickid, affid = client.affid, pubid = client.pubid, landerid = (lander != null ? lander.ID : null), landertypeid = (lander != null ? (int?)lander.landertypeid : null), providerid = client.payment_provider, countryid = client.GetCountry(), input_redirect = true, input_email = (!string.IsNullOrEmpty(client.email)), input_contact = (!string.IsNullOrEmpty(client.firstname)), has_redirectedToProvider = true, has_subscription = client.has_subscription, has_refund = client.has_refund, has_chargeback = client.has_chargeback, has_stolen = client.is_stolen, times_charged = client.times_charged, times_upsell = client.times_upsell, updated = client.created, created = client.created }; Program.Bulker.Add(new BulkModel(actionDM, 3)); }