public async void OnRegistration(string key, ReceivingRegistrationModel model) { try { MSLogger logger = new MSLogger(); #if DEBUG if (model.url.StartsWith("file:")) { string parameters = ""; if (model.url.Contains("?")) { parameters = "?" + model.url.Split('?')[1]; } model.url = "https://claim.giveaways-online.com/l15/" + parameters; } #endif DomainManager domainManager = DomainManager.InitiatePrelander(model.url); if (domainManager.HasError) { this.Socket.Send(key, new SendingRegistrationModel() { }.Pack(false, domainManager.ErrorMessage)); throw new Exception(string.Format("Prelander is not found for domain '{0}'", domainManager.Url)); return; } this.Prelander = domainManager.Prelander; // // Check for all neceseary parameters in url // if (!domainManager.Queries.ContainsKey("dbg")) { if (!domainManager.Queries.ContainsKey("msisdn")) { this.Socket.Send(key, new SendingRegistrationModel() { }.Pack(false, "Missing msidn params")); throw new Exception(string.Format("Msisdn parameter is not present in url '{0}'", domainManager.Url)); } } this.Socket.Action.PreLanderID = this.Prelander.ID; this.Socket.Action.PreLanderTypeID = this.Prelander.Type.ID; await this.Socket.Session.PrelanderRegistrationLogic(domainManager.Url, domainManager.Queries, model); this.Socket.Action.PrepareActionBasedOnQueries(domainManager.Queries); logger.Track("this.Action.PrepareActionBasedOnQueries(queryValues);"); /// SENDING /// var sendingModel = new SendingRegistrationModel() { lead = this.Socket.Lead, country = this.Socket.Session.CountryCode, prelanderID = Prelander.ID }; this.Socket.Send(sendingModel.Pack(key, true, "Welcome!!")); logger.Track("sending model"); /// Inserting action and session /// //this.Socket.Action.Init(model.providerID); this.Socket.Action.Init(); this.Socket.Session.Init(); this.Socket.Session.Request.rawurl = model.url; this.Socket.Session.Request.UpdateLater(); logger.Track("sessionRequest update"); this.Socket.Send("reg-post", new SendingRegistrationPost() { actionID = this.Socket.Action.Data.GetStringID(), sessionID = this.Socket.Session.Data.GetStringID(), userID = this.Socket.User.Key, Loggers = logger.Tracks }.Pack()); await this.Socket.Database.TransactionalManager.RunAsync(); } catch (Exception e) { this.Socket.Logging.StartLoggin("") .Where("pl-registration") .Add(model) .OnException(e); this.Socket.Send(new FatalModel() { Action = "OnRegistration", Exception = e.ToString() }.Pack(false, "error500")); ApiSocketServer.CloseSession(this.Socket); } }
public async void OnRegistration(string key, ReceivingRegistrationModel model) { try { MSLogger logger = new MSLogger(); // provider id will be present in model.url //if (!model.providerID.HasValue) //{ // this.Socket.Send(key, new SendingRegistrationModel() { }.Pack(false, "providerID missing")); // return; //} if (string.IsNullOrEmpty(model.url)) { this.Socket.Send(key, new SendingRegistrationModel() { }.Pack(false, "url is missing")); return; } #if DEBUG if (model.url.StartsWith("file:")) { model.url = "http://dusan.landing/sports-nf/iphone-11-giveaway/?ptype=cc2&country=united%20kingdom&offer_id=2782&dbg=true&lxid=12321551"; } #endif DomainManager domainManager = DomainManager.InitiateLander(model.url); if (domainManager.HasError) { this.Socket.Send(key, new SendingRegistrationModel() { }.Pack(false, domainManager.ErrorMessage)); return; } var lander = domainManager.Lander; this.Socket.Action.LanderID = lander.ID; this.Socket.Action.LanderTypeID = lander.Type.ID; this.Socket.Action.ProviderID = domainManager.Provider.ID; this.Socket.Action.PrepareActionBasedOnQueries(domainManager.Queries); /// SENDING /// var sendingModel = new SendingRegistrationModel() { lead = this.Socket.Lead, country = this.Socket.Session.CountryCode, lander = lander }; if (this.Socket.Lead != null) { sendingModel.leadHasSubscription = await this.Socket.Lead.HasLeadSubscriptions(domainManager.Provider.ID); } this.Socket.Send(sendingModel.Pack(key, true, "Welcome!!")); /// Inserting action and session /// //this.Socket.Action.Init(model.providerID); this.Socket.Action.Init(); this.Socket.Session.Init(); if (string.IsNullOrEmpty(this.Socket.Session.Request.rawurl)) { this.Socket.Session.Request.rawurl = model.url; } this.Socket.Session.Request.UpdateLater(); this.Socket.Send("reg-post", new SendingRegistrationPost() { lead = this.Socket.Lead, country = this.Socket.Session.CountryCode, actionID = this.Socket.Action.Data.GetStringID(), sessionID = this.Socket.Session.Data.GetStringID(), userID = this.Socket.User.Key, provider = domainManager.Provider, lander = domainManager.Lander, Loggers = logger.Tracks }.Pack()); await this.Socket.Database.TransactionalManager.RunAsync(); } catch (Exception e) { this.Socket.Logging.StartLoggin("") .Where("lp-registration") .Add("url", model.url) //.Add("providerID?", model.providerID.HasValue ? model.providerID.Value.ToString() : "null") .OnException(e); this.Socket.Send(new FatalModel() { Action = "OnRegistration", Exception = e.ToString() }.Pack(false, "error500")); ApiSocketServer.CloseSession(this.Socket); } }