Ejemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var ip = UtilX3.GetRealIP();
            var mobile = this.txtMobile.Text.Trim();
            var password = this.txtPassword.Text.Trim();

            if (mobile.Length == 0 || password.Length == 0)
                return;

            if (mobile.Length > 11)
                mobile = mobile.Substring(0, 11);

            var service = new Repository();
            var count = service.GetUserInfoByMobile(mobile, ip);
            if (count == 0)
                return;//todo

            var saltPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(ConfigurationManager.AppSettings["salt"] + password, "MD5");

            var userInfo = new BaseInfo_UserInfo
            {
                Password = saltPassword,
                Mobile = mobile,
            };

            count = service.Login(userInfo);
            if (count > 0)
            {
                UtilX3.SetCookie(ConfigurationManager.AppSettings["cookieName"], userInfo.ID.ToString(), 30);
                Response.Redirect("../FormUI/04Order/List");
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                var productId = this.Request.QueryString["productId"];
                var _orderId = this.Request.QueryString["orderId"];

                var orderId = 0;
                if (!string.IsNullOrEmpty(_orderId))
                    orderId = _orderId.ParseTo<int>();

                var order = new Repository().GetOrderByID(orderId);
                if (order != null)
                {










                }
            }
        }
Ejemplo n.º 3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            var ip = UtilX3.GetRealIP();
            var name = this.txtName.Text.Trim();
            var password = this.txtPassword.Text.Trim();
            var mobile = this.txtPhone.Text.Trim();

            if (mobile.Length == 0 || name.Length == 0 || password.Length == 0)
                return;

            if (mobile.Length > 11)
                mobile = mobile.Substring(0, 11);

            var service = new Repository();
            var count = service.GetUserInfoByMobile(mobile, ip);
            if (count > 0)
                return;

            var saltPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(ConfigurationManager.AppSettings["salt"] + password, "MD5");

            var userInfo = new BaseInfo_UserInfo
            {
                Name = name,
                Password = saltPassword,
                Mobile = mobile,
                Status = 1,
                CreateIP = ip,
                CreateTime = DateTime.Now
            };

            service.AddUserInfo(userInfo);

            UtilX3.SetCookie(ConfigurationManager.AppSettings["cookieName"], userInfo.ID.ToString(), 30);

            Response.Redirect(ConfigurationManager.AppSettings["SiteUrl"] + "FormUI/04Order/List");
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            var action = context.Request["action"];

            var service = new Repository();
            var content = string.Empty;
            var logInfo = string.Empty;
            var mobile = string.Empty;

            switch (action)
            {
                case "GetUserByMobile":
                    mobile = context.Request["mobile"];

                    var num = service.GetUserInfoByMobile(mobile, UtilX3.GetRealIP());
                    content = num.ToString();
                    logInfo = "interface GetUserByMobile --- mobile : {0} , Time : {1}, result : {2}";

                    LogHelper.Info(string.Format(content, mobile, DateTime.Now, num));

                    break;
                case "checkSMS":
                    mobile = context.Request["mobile"];
                    var sms = context.Request["sms"];

                    var result = false;
                    var _key = "SendSMS-Mobile-" + mobile;
                    try
                    {
                        var sendMessage = context.Cache.Get(_key);
                        if (sendMessage != null)
                        {
                            result = sms.ToString() == sendMessage.ToString();
                        }
                    }
                    catch(Exception error)
                    {
                        LogHelper.AppError(error.Message);
                    }

                    content = result ? "1" : "0";
                    logInfo = "interface checkSMS --- mobile : {0} ,sms : {1}, Time : {2}, result : {3}";

                    LogHelper.Info(string.Format(logInfo, mobile, sms, DateTime.Now, content));

                    break;
                case "sendSMS":
                    mobile = context.Request["mobile"];

                    var random = new Random();
                    var _num = random.Next(1000, 9999);
                    var _sms = _num.ToString();

                    try
                    {
                        //new Util().SendRegisteSMS(mobile, new string[] { _sms, "5" });

                        content = "1";
                        var key = "SendSMS-Mobile-" + mobile;
                        context.Cache.Insert(key, _sms, null, DateTime.Now.AddMinutes(5), new TimeSpan(0), CacheItemPriority.Normal, null);
                    }
                    catch (Exception error)
                    {
                        content = "0";
                        LogHelper.AppError(error.Message);
                    }

                    logInfo = "interface sendSMS --- mobile : {0} ,sms : {1}, Time : {2}, result : {3}";

                    LogHelper.Info(string.Format(logInfo, mobile, _sms, DateTime.Now, 0));

                    break;
                case "createOrder":
                    mobile = context.Request["mobile"];


                    logInfo = "interface createOrder --- mobile : {0} ,sms : {1}, Time : {2}, result : {3}";

                    //LogHelper.Info(string.Format(logInfo, mobile, _sms, DateTime.Now, 0));

                    break;
                default:
                    break;
            }

            context.Response.ContentType = "text/json;charset=UTF-8;";
            context.Response.Write(content);
        }