public Result RL(Registered_SubmitLead req) { base.Init_Request_Data(enumAction.Lead, req, req.IP, req.UA, req.T); string exception = string.Empty; IPHolder cacheIP = null; bool TokenError = false; if (!AppManager.CampaignAlive(base.APICreateDate_ISR, base.ProjectType, ref base.APITransaction, req.P, out TokenError)) { cacheIP = Cache_IP.IP_Get(req.IP, 1, out exception, ref base.APICreateDate_ISR, ref base.ProjectType); #region LOG if(TokenError) if (TokenError) { UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_PayloadError, base.SerializedRequest, "enumReturnStatus.Ends -> is TokenError: " + TokenError.ToString(), "_cacheIP: " + Newtonsoft.Json.JsonConvert.SerializeObject(cacheIP), true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); return(AppResponse.Any(enumReturnStatus.PayloadError, null)); } #endregion return(AppResponse.Any(enumReturnStatus.Ends, null)); } #region MyRegion VALIDATION if (!ModelState.IsValid || !base.ValidRequestFromServerIP || TokenError) { cacheIP = Cache_IP.IP_Get(req.IP, 1, out exception, ref base.APICreateDate_ISR, ref base.ProjectType); #region MyRegion LOG UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_PayloadError, base.SerializedRequest, "base.ValidRequestFromServerIP IP:" + base.ServerIP + " IsValid:" + base.ValidRequestFromServerIP.ToString() + " -> TokenError(P): " + TokenError.ToString(), Newtonsoft.Json.JsonConvert.SerializeObject(ModelState.Keys) + " -> cacheIP: " + Newtonsoft.Json.JsonConvert.SerializeObject(cacheIP), true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); #endregion return(AppResponse.Any(enumReturnStatus.PayloadError, null)); } #endregion #region UNIQUE_Exist if (Cache_Unique.MAC_UNIQUE_IS_EXIST(ref base.APICreateDate, req.Email, ref base.ProjectType)) { #region MyRegion LOG UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_Unique_Not_Allowed, base.SerializedRequest, "_1_MAC_OR_Unique_Address_Not_Allowed", null, true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); #endregion return(AppResponse.Any(enumReturnStatus.Forbidden, null)); } #endregion bool NeedCaptcha = false; #region REGINO CACHE IP AND IF CAPTCH IS NEEDED //ADD TO IP CALL cacheIP = Cache_IP.IP_Get(req.IP, 0, out exception, ref base.APICreateDate_ISR, ref base.ProjectType); if (cacheIP != null && cacheIP.need_Captcha() && string.IsNullOrEmpty(req.CAP)) { NeedCaptcha = true; UtilsDB.API_Log_Insert(base.Action, enumLogType.Request, enumLogType._1_Need_Captcha, base.SerializedRequest, "NEED CAPTCHA -> Captch: " + Newtonsoft.Json.JsonConvert.SerializeObject(cacheIP), null, false, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); return(AppResponse.Any(enumReturnStatus.Captcha, null)); } #endregion #region REGION GOOGLE VERIFICATION string googleRequest = string.Empty, googleResponse = string.Empty; bool GoogleApproved = false; if (cacheIP != null && cacheIP.need_Captcha() && !string.IsNullOrEmpty(req.CAP)) { googleResponse = UtilsWeb.MakeRequest_Google_Captch(req.CAP, req.IP, ref base.APITransaction, ref base.APICreateDate, ref base.APICreateDate_ISR, out googleRequest, ref base.ProjectType); GoogleApproved = googleResponse.ToLower().Contains("true"); if (!GoogleApproved) { NeedCaptcha = true; UtilsDB.API_Log_Insert(base.Action, enumLogType.Request, enumLogType._1_Need_ReCaptcha, "FAIL ON GOOGLE CAPTCHA: " + base.SerializedRequest, googleRequest, googleResponse, false, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); return(AppResponse.Any(enumReturnStatus.ReCaptcha, null)); } } #endregion API_Project_GetResult project = AppManager.GetProject(base.ProjectType); API_Validate_Registered_UserResult user = UtilsDB.API_Validate_Registered_User(base.APITransaction, base.APICreateDate_ISR, req.Email, base.ProjectType); if (user == null) { Dictionary <string, dynamic> result = new Dictionary <string, dynamic>() { { "P", project.Token } }; UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_NeedRegistration, base.SerializedRequest, "Register REQUIRED UForbidden RESPONSE", null, true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); return(AppResponse.Any(enumReturnStatus.UForbidden, result)); } SubmitLead demi = new SubmitLead() { Email = req.Email, IP = req.IP, CAP = req.CAP, P = req.P, T = req.T, UA = req.UA, FName = "NA", LName = "NA", City = req.City, // "NA", Street = req.Street, // "NA", Phone = "NA", FlatNumber = "NA", STNumber = req.STNumber, // "NA" AcceptContent = true, //req.AcceptContent, POBox = req.POBox, Regulation = true // req.Regulation }; API_Lead_InsertResult lead = UtilsDB.API_Lead_Insert(ref demi, -1, ref base.APITransaction, req.CAP, 1, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.Platform, ref base.ProjectType); if (lead == null) { #region LOG UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_InternalError, base.SerializedRequest, "API_Lead_Insert ERROR", null, true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); #endregion return(AppResponse.Any(enumReturnStatus.InternalError, null)); } switch (lead.DBResult.GetValueOrDefault(-1000)) { case -1000: //LOGIC ERROR OR INTERNAL DVB ERROR #region LOG UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_InternalError, base.SerializedRequest, "API_Lead_Insert ERROR", "lead.DBResult is null", true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); #endregion return(AppResponse.Any(enumReturnStatus.InternalError, null)); break; case 200: //OK string ex = null; Cache_IP.AddUpdate_IP(req.IP, new IPHolder(null, req.IP, lead.Count_IP.GetValueOrDefault(), lead.MaxAllowed_IP.GetValueOrDefault(), lead.ExpiredIPAt.GetValueOrDefault()), out ex, ref base.ProjectType); //DataProResult result = UtilsDataPro.SendCouponEmail(req.Email, ref project); //API_Lead_Update_CouponMSGResult coupon = //UtilsDB.API_Lead_Update_CouponMSG(ref base.APITransaction, ref base.APICreateDate, ref base.APICreateDate_ISR, lead.LeadID.GetValueOrDefault(), // Newtonsoft.Json.JsonConvert.SerializeObject(result), result.isSuccess()); #region LOG UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType.Response, base.SerializedRequest, null /*Newtonsoft.Json.JsonConvert.SerializeObject(result)*/, "lead: " + Newtonsoft.Json.JsonConvert.SerializeObject(lead) /*+ " -> coupon update: " + Newtonsoft.Json.JsonConvert.SerializeObject(coupon)*/, true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); #endregion return(AppResponse.OK(null)); break; } #region LOG UtilsDB.API_Log_Insert(this.Action, enumLogType.Response, enumLogType._1_BadRequest, base.SerializedRequest, "BadRequest -> lead: " + Newtonsoft.Json.JsonConvert.SerializeObject(lead), "SHOULD NOT BE HERE", true, base.Refferer, base.IP, base.UA, ref base.APICreateDate, ref base.APICreateDate_ISR, ref base.APITransaction, true, req.Email, base.ProjectType); #endregion return(AppResponse.BadRequest(null)); }
public Result input(string key, bool nd, int?p = null) //(string key) { if (string.IsNullOrEmpty(key) || key != "moblinMNG" + UtilsDateTime.UTC_To_Israel_Time().ToString("yyyy-MM-dd")) { return(null); } if (p == null) { p = 1; } API_Project_GetResult project = AppManager.GetProject(enumProject.Cat); //PetOut pet = AppManager.PetProjectGet(ref base.APICreateDate_ISR, (enumProject)p).FirstOrDefault(); string tokens = "cats: " + AppManager.Cat_ServerToken.ToString(); Dictionary <string, dynamic> data = AppManager.get_data_helper(base.APICreateDate_ISR); in_isAlive isalive = new in_isAlive() { IP = "12.12.12.12", ND = true, UA = "some user aget", T = AppManager.Cat_ServerToken }; SubmitLead lead = new SubmitLead() { AcceptContent = true, Regulation = true, CAP = null, City = "רמת השרון", Email = "*****@*****.**", FlatNumber = "12", FName = "moblin", IP = "12.12.12.12", LName = "test", Phone = "0000000000", POBox = "PO BOXS", STNumber = "1", Street = "STREET", UA = "SOME USER AGENT", P = project.Token, T = AppManager.Cat_ServerToken //, //PetType = pet.T }; Registered_SubmitLead rl = new Registered_SubmitLead() { IP = "12.12.12.12", UA = "some user aget", Email = "email", T = AppManager.Cat_ServerToken, P = project.Token }; return(AppResponse.OK(new Dictionary <string, dynamic>() { { "static_tokens", str(tokens) }, { "a_as_is_alive", str(isalive) }, { "l_as_submit_lead", str(lead) }, { "rl_as_registered_submit_lead", str(rl) }, { "data", str(data) } })); }