Exemple #1
0
        /// <summary>
        /// TO BE USED AT IS ALIVE
        /// </summary>
        /// <param name="ISRDate"></param>
        /// <param name="Project"></param>
        /// <param name="APITransaction"></param>
        /// <param name="CurrentToken"></param>
        /// <returns></returns>
        public static bool CampaignAlive(DateTime ISRDate, enumProject Project, ref Guid APITransaction, out Guid CurrentToken)
        {
            if (Last_Config_Update_ISR.AddMinutes(ConfigUpdateAsMinutes) < UtilsDateTime.UTC_To_Israel_Time())
            {
                Update();
            }

            CurrentToken = APITransaction;

            API_Project_GetResult project = null;

            if (Projects.Count > 0)
            {
                project = (from p in Projects where p.ID == (int)Project && p.StartDate <= ISRDate && p.EndIncludeDate >= ISRDate.Date && p.Enabled select p).FirstOrDefault();

                if (project != null)
                {
                    CurrentToken = project.Token;
                    return(true);
                }
            }

            return(false);

            //if (Project == enumProject.Dog)
            //{
            //    return Dog_StartDate.Date <= ISRDate.Date && Dog_EndDate.Date >= ISRDate.Date;
            //}

            //return Cat_StartDate.Date <= ISRDate.Date && Cat_EndDate.Date>= ISRDate.Date ;
        }
Exemple #2
0
        public Result MSG(string key, string email)
        {
            if (string.IsNullOrEmpty(key) || key != "moblinxMNG" + UtilsDateTime.UTC_To_Israel_Time().ToString("yyyy-MM-dd"))
            {
                return(null);
            }

            API_Project_GetResult project = AppManager.GetProject(enumProject.Dog);
            DataProResult         _result = UtilsDataPro.SendCouponEmail(email, ref project);

            //return AppResponse.OK(_result);



            //     SendMsgResults RESULTMSG = null;
            //SendMsgServiceClient client = new SendMsgServiceClient();

            //SendMsgService service = new il.co.sendmsg.api3.SendMsgService();



            // service.se



            //SendMsgUser USER = new SendMsgUser() { EmailAddress = "*****@*****.**" };//, UserIDSpecified=false
            //SendMsgMessage MSG = new SendMsgMessage()
            //{
            //    SenderEmailAddress = "*****@*****.**",
            //    MessageType = SendMsgMessageType.MailMessage,
            //    MessageID = int.Parse(project.Coupon_EmailID)
            //    //UseTemplateID = int.Parse(project.Coupon_EmailID)
            //};
            //SendMsgUser[] _u = new SendMsgUser[1] { USER };

            //SendMsgList msglist = new SendMsgList();
            //msglist.ExistingListID = project.Coupon_GroupID.GetValueOrDefault();

            //SendMsgList[] _msglist = new SendMsgList[1] { msglist };

            ////MSG.MessageContent = "";
            ////MSG.MessageSubject = "";
            ////MSG.MessageInnerName = "";


            //SendMsgResults result;

            //SendMsgServiceClient service = new SendMsgServiceClient();

            //service.AddUsersAndSend(project.Coupon_SiteID.GetValueOrDefault(),
            //                          project.Coupon_APIPassword,
            //                        _u, MSG,
            //                         out result);



            return(AppResponse.OK(_result));
        }
        //private static SendMsgService service = null;

        public static DataProResult SendCouponEmail(string email, ref API_Project_GetResult project)
        {
            SendMsgService service = new il.co.sendmsg.api3.SendMsgService();
            SendMsgResults result  = null;

            try
            {
                SendMsgUser USER = new SendMsgUser()
                {
                    EmailAddress = email
                };
                SendMsgMessage MSG = new SendMsgMessage()
                {
                    MessageType = SendMsgMessageType.MailMessage,
                    MessageID   = int.Parse(project.Coupon_EmailID)
                };
                SendMsgUser[] _u = new SendMsgUser[1] {
                    USER
                };

                SendMsgList msglist = new SendMsgList();
                msglist.ExistingListID = project.Coupon_GroupID.GetValueOrDefault();

                SendMsgList[] _msglist = new SendMsgList[1] {
                    msglist
                };
                MSG.MessageIDSpecified = true;

                bool add_users_and_send_result    = false;
                bool add_users_and_send_specified = false;;

                service.AddUsersAndSend(project.Coupon_SiteID.GetValueOrDefault(),
                                        true, project.Coupon_APIPassword,
                                        _u, MSG,
                                        out add_users_and_send_result,
                                        out add_users_and_send_specified, out result);

                return(new DataProResult()
                {
                    CodeResult = result.ResultID,
                    result = result,
                    add_and_send = add_users_and_send_result,
                    add_and_send_specified = add_users_and_send_specified
                });
            }
            catch (Exception ex)
            {
                return(new DataProResult()
                {
                    CodeResult = -1, exMSG = UtilsException.GetMSG(ref ex), result = result
                });
            }
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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) }
            }));
        }