Пример #1
0
 public IHttpActionResult GetTransactionPassword(string v1)
 {
     try
     {
         string objectId = HttpContext.Current.Request.Headers["objectId"];
         //查询交易密码
         List <Wheres> whs = new List <Wheres>()
         {
             new Wheres("objectId", "=", objectId)
         };
         var    dir = bll.QuerySingleByWheres(whs);
         string transaction_password = dir.transaction_password;
         if (transaction_password.Equals(objectId.Md5()))
         {
             return(ok("0"));
         }
         else
         {
             return(ok("1"));
         }
     }
     catch (Exception e)
     {
         return(execept(e.Message));
     }
 }
Пример #2
0
        public ActionResult LogIn()
        {
            string username = Request.Form["username"]; //获取用户名
            string password = Request.Form["password"]; //获取密码

            try
            {
                //表单验证
                if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
                {
                    return(Content("<script> alert('用户名密码不得为空'); location.href = '" + Url.Action("Index", "Account") + "'</script>"));
                }
                else
                {
                    if (username != "admin")
                    {
                        return(Content("<script> alert('该用户没有权限登录'); location.href = '" + Url.Action("Index", "Account") + "'</script>"));
                    }
                    List <Wheres> whs = new List <Wheres>()
                    {
                        new Wheres("username", "=", username)
                    };
                    var dir = bll.QuerySingleByWheres(whs);
                    if (dir != null)
                    {
                        string obj = (string)(dir.objectId);
                        string pas = (string)(dir.password);
                        //string li = "raw:" + password + "  sql:" + pas + "  jiami:" + (password + obj).Md5();
                        //string ss = (password + obj).Md5();
                        if ((password.Md5() + obj).Md5().Equals(pas))
                        {
                            string sessionToken = Guid.NewGuid().ToString();
                            bll.UpdateById(obj, new Dictionary <string, object> {
                                { "sessionToken", sessionToken }
                            });

                            _User model = bll.QuerySingleById(obj);
                            Session["CurrentUser"] = username;
                            return(RedirectToAction("GetItems", "Items"));
                            //return ok(model);
                        }
                        else
                        {
                            return(Content("<script> alert('密码错误'); location.href = '" + Url.Action("Index", "Account") + "'</script>"));
                            // return notFound("密码错误" + li);
                        }
                    }
                    else
                    {
                        return(Content("<script> alert('用户不存在'); location.href = '" + Url.Action("Index", "Account") + "'</script>"));
                        //return notFound("用户不存在");
                    }
                }
            }
            catch (Exception e)
            {
                return(Content("<script> alert('" + e.Message + "'); location.href = '" + Url.Action("Index", "Account") + "'</script>"));
                //return execept(e.Message);
            }
        }
        public Task <System.Net.Http.HttpResponseMessage> ExecuteActionFilterAsync(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken, Func <Task <System.Net.Http.HttpResponseMessage> > continuation)
        {
            string token = HttpContext.Current.Request.Headers["Session-Token"];

            _UserBLL bll   = new _UserBLL();
            var      model = bll.QuerySingleByWheres(new List <Wheres> {
                new Wheres("sessionToken", "=", token)
            });

            if (model == null)
            {
                return(Task <HttpResponseMessage> .Factory.StartNew(() =>
                {
                    return actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, new { error = "未登录", code = (int)HttpStatusCode.Unauthorized });
                }));
            }
            HttpContext.Current.Request.Headers.Add("objectId", model.objectId);
            return(continuation());
        }
Пример #4
0
        static void Main(string[] args)
        {
            _UserBLL      bll = new _UserBLL();
            List <Wheres> whs = new List <Wheres>()
            {
                new Wheres("objectId", "like", "%1%")
            };
            var dir = bll.QuerySingleByWheres(whs);
            //object c = new { name = "1", id = "2" };
            //var props = c.GetType().GetProperties();
            //foreach (var prop in props)
            //{
            //    string name = prop.Name;
            //    object value = prop.GetValue(c);

            //}

            //Random ran = new Random();
            //for (int i=0; i < 20; i++) {

            //    int num=ran.Next(-3, 3);
            //    Console.WriteLine(num);
            //}

            string initPassword = "******";
            string str          = initPassword.Md5();
            string str1         = (initPassword.Md5() + "af5e02e5-4ceb-4cf8-81d2-bcca13a24952").Md5();
            string str2         = (initPassword.Md5() + "5efb2ff4-fee6-46dc-a0e1-aaa35fea9bce").Md5();
            string str3         = (initPassword.Md5() + "8879e932-f4d7-4766-9d93-f95c53c90e6e").Md5();

            //5efb2ff4-fee6-46dc-a0e1-aaa35fea9bce
            //8879e932-f4d7-4766-9d93-f95c53c90e6e
            Console.WriteLine(str);
            Console.WriteLine(str1);
            Console.WriteLine(str2);
            Console.WriteLine(str3);
            //string raw = "abcd1234";
            //string jiami=raw.Md5();

            //Console.WriteLine(jiami);
            //string str = jiami + "e6d21995-50c3-4aac-81ec-a99d72f2de7f";
            //string jiami1=str.Md5();
            //Console.WriteLine(jiami1);
            //_UserBLL bll = new _UserBLL();

            //Dictionary<string, string[]> dir = new Dictionary<string, string[]>(){
            //   {"_User",new string[]{"createdAt","password"}}
            //};
            //var models=bll.QueryListX(0, 3, dir);
            //string str = JsonHelper.Serialize(models);
            //Console.WriteLine(str);

            //var model=bll.QuerySingleByIdX(@"2d1d6669-059e-4931-9365-f964f1ce93c4", dir);
            //string str = JsonHelper.Serialize(model);
            //Console.WriteLine(str);
            //RestClient client = new RestClient("http://192.168.191.1");

            //List<Columns> li = new List<Columns>();

            //Columns col = new Columns();
            //col.key = "aa";
            //col.value = 2;

            //Columns col1 = new Columns();
            //col1.key = "ab";
            //col1.value = 2;

            //li.Add(col);
            //li.Add(col1);



            //Dictionary<string, object> dic = new Dictionary<string, object>() { { "22", 3 }, { "23", 3 } };
            //string[] arr = { "1", "2", "3" };
            //string str = JsonHelper.Serialize(li);
            //string str1 = JsonHelper.Serialize(dic);
            //string str2 = JsonHelper.Serialize(arr);
            //Console.WriteLine(str);
            //Console.WriteLine(str1);
            //Console.WriteLine(str2);
            //string[] arr1 = JsonHelper.Deserialize<string[]>(str2);
            //Console.WriteLine(arr1[0]);


            //string[] cc = null;
            //object cdd = cc;
            //string[] ee = (string[])cdd;
            //Console.WriteLine(ee);
            //Console.WriteLine("11");
            //#region Get 方式请求列表
            //string str = client.Get("api/values");

            //Console.WriteLine(str);
            //#endregion

            //#region Get 方式请求id对应的数据
            //string strGetById = client.Get("api/values/2");

            //Console.WriteLine(strGetById);
            //#endregion

            //#region Post 方式 添加数据

            //string postUri = "api/users?code=333";

            //string userJson = @"{""username"":""11131323"",""password"":""12""}";

            //string postResponse = client.Post(userJson, postUri);

            //Console.WriteLine(postResponse);
            //#endregion

            //#region Delete

            //string deleteUri = "api/values/3";
            //string deleteResponse = client.Delete(deleteUri);

            //Console.WriteLine(deleteResponse);
            //#endregion

            //#region Put
            //string putUri = "api/values/123";

            //string userJson3 = @"{""Id"":11123,""Age"":12,""UserName"":""111""}";

            //string putResponse = client.Post(userJson3, putUri);

            //Console.WriteLine(putResponse);
            //#endregion

            Console.ReadKey();
        }
Пример #5
0
 public IHttpActionResult GetIsExit(string v1, bool isNew = false, string where = null)
 {
     try
     {
         if (isNew)
         {
             List <Wheres> list = new List <Wheres>();
             //条件
             if (string.IsNullOrEmpty(where))
             {
                 return(notFound("请求失败"));
             }
             list = JsonHelper.Deserialize <List <Wheres> >(where);
             _User user = new _User();
             if (where.Contains("openId"))
             {
                 var m = wechat_bll.QuerySingleByWheres(list);
                 if (m != null)
                 {
                     List <Wheres> wheres = new List <Wheres>()
                     {
                         new Wheres("wechatId", "=", m.objectId)
                     };
                     var n = auth_bll.QuerySingleByWheres(wheres);
                     if (n != null)
                     {
                         List <Wheres> whes = new List <Wheres>()
                         {
                             new Wheres("authDataId", "=", n.objectId)
                         };
                         user = bll.QuerySingleByWheres(whes);
                     }
                 }
             }
             else
             {
                 user = bll.QuerySingleByWheres(list);
             }
             if (user != null)
             {
                 if (user.authData == null)
                 {
                     return(ok(new { objectId = user.objectId, credit = user.credit }));
                 }
                 else
                 {
                     return(ok(new { objectId = user.objectId, openId = user.authData.wechat.openId, inopenId = user.authData.wechat.inopenId, credit = user.credit, username = user.username, sign_in = user.sign_in }));
                 }
             }
             else
             {
                 return(notFound("用户不存在"));
             }
         }
         else
         {
             List <Wheres> list = new List <Wheres>();
             //条件
             if (!string.IsNullOrEmpty(where))
             {
                 list = JsonHelper.Deserialize <List <Wheres> >(where);
             }
             int count = bll.QueryCount(list);
             return(ok(new { count = count }));
         }
     }
     catch (Exception e)
     {
         return(execept(e.Message));
     }
 }