コード例 #1
0
        public t_user getUser()
        {
            var context = HttpContext.Current;

            if (context == null)
            {
                throw new InvalidOperationException();
            }

            var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cookie == null)
            {
                return(null);
            }

            var ticket = FormsAuthentication.Decrypt(cookie.Value);

            string code = ticket.Name;


            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("code", code);

            var model = new Dal.Basedata.t_userDal(dic, "code").ToList();

            if (model.Count == 0)
            {
                return(null);
            }

            return(model.First());
        }
コード例 #2
0
        public JsonResult Login(string code, string pwd)
        {
            //方便测试用,删除??
            //if (string.IsNullOrEmpty(code))
            //{
            //    code = "001";
            //    pwd = "a";
            //}



            if (string.IsNullOrEmpty(code))
            {
                return(Json(new { success = "error", message = "对不起,用户名不能为空" }));
            }
            if (string.IsNullOrEmpty(pwd))
            {
                return(Json(new { success = "error", message = "对不起,密码不能为空" }));
            }


            // //测试测试
            // DataTable dd = DataHelper.GetDataTable("select * from  t_user");
            //dd.TableName = "f**k";
            //string aaa = new DtToXML().ConvertDataTableToXML(dd);



            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("code", code);
            dic.Add("pwd", pwd);

            var model = new Dal.Basedata.t_userDal(dic, "code", "pwd").ToList();

            if (model.Count == 0)
            {
                return(Json(new { success = "error", message = "对不起,用户名或者密码错误" }));
            }

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                1,
                model.First().code,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false, model.First().name
                //  JsonConvert.SerializeObject(model.First())
                );
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));

            Response.Cookies.Add(cookie);
            HttpCookie cookienew = new HttpCookie("user");

            cookienew.Value = model.First().code;
            Response.AppendCookie(cookienew);
            return(Json(new { success = "ok", message = "登陆成功,请稍等,正在跳转。。" }));
        }
コード例 #3
0
        public JsonResult list(ListData obj)
        {
            List <t_user> list = new Dal.Basedata.t_userDal(obj).ToList();

            return(Json(new
            {
                rows = list,
                total = new Dal.Basedata.t_userDal().getDataCount(obj)
            }));
        }
コード例 #4
0
        public JsonResult PersonTree()
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();


            var Deptlist = new Dal.Basedata.t_bmDal(dic).ToList();
            var UserList = new Dal.Basedata.t_userDal(dic).ToList();


            Tree[] t = new Tree[] {
                new Tree()
                {
                    id      = "~",
                    text    = "主菜单",
                    iconCls = "icon-main",
                    link    = "",
                    state   = "open"
                },
            };

            List <Tree> list = new List <Tree>();

            foreach (var i in Deptlist)
            {
                Tree tTree = new Tree()
                {
                    id      = i.code,
                    text    = i.name,
                    iconCls = "icon-qizi",
                };
                var temp = from p in UserList
                           where p.deptcode == i.code
                           select p;
                List <Tree> ulist = new List <Tree>();
                foreach (var s in temp)
                {
                    ulist.Add(new Tree()
                    {
                        id      = s.code,
                        text    = "[" + s.code + "]" + s.name,
                        iconCls = "icon-man"
                    });
                }
                tTree.children = ulist.ToArray();
                list.Add(tTree);
            }
            t[0].children = list.ToArray();
            return(Json(t));
        }
コード例 #5
0
        //获取人员
        public JsonResult GetUser()
        {
            List <Option> list = new List <Option>();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            var list2 = new Dal.Basedata.t_userDal(dic).ToList();

            foreach (var i in list2)
            {
                list.Add(new Option()
                {
                    id   = i.code,
                    text = i.name,
                });
            }

            return(Json(list));
        }