示例#1
0
        public IMenu GetMenu(Model.Table.User u)
        {
            Esunnet.Model.Frame.IMenu m = new Esunnet.Model.Frame.Dhtmlx.Menu.Menu();
            UP_GetMenu us = new UP_GetMenu(u.id, u.permission);

            using (DbClinet db = new DbClinet())
            {
                List <Dictionary <string, object> > mv = db.Select(us);
                for (int i = 0; i < mv.Count; i++)
                {
                    Node n = new Node();
                    n.id    = mv[i]["id"];
                    n.pid   = mv[i]["pid"];
                    n.text  = mv[i]["text"] as string;
                    n.title = mv[i]["title"] as string;
                    n.type  = "node";
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add(C.FUN, mv[i]["function"] as string);
                    dic.Add(C.PATH, mv[i]["path"] as string);
                    dic.Add(C.PARAM, mv[i]["remark"] as string);
                    n.userdata = dic;
                    m.Add(n);
                }
            }
            return(m);
        }
示例#2
0
        public User Login(Model.Table.User u)
        {
            String pw = u.userPassword;

            u.userId = "admin";
            //  u.userPassword = "******";
            using (DbClinet db = new DbClinet())
            {
                db.AddParameter("@userId", u.userId);
                List <Dictionary <string, object> > mv = db.Select("select * from SYS_User where userId=@userId");

                if (mv.Count > 0)
                {
                    string userPasswordTemp = mv.FirstOrDefault()["userPassword"] as string;
                    if (userPasswordTemp.Equals(u.userPassword, StringComparison.OrdinalIgnoreCase))
                    {
                        //u.lastLoginIp = mv.FirstOrDefault()["lastLoginIp"] as string;
                        u.State = 1;
                        db.AddParameter("@userId", u.userId);
                        db.AddParameter("@ip", u.lastLoginIp);
                        db.ExecuteNonQuery("update SYS_User set lastLoginTime=GETDATE(),lastLoginIp=@ip  where userId=@userId");
                    }
                    else
                    {
                        //密码错误
                        u.State = -1;
                    }
                }
                else
                {
                    u.State = -2; //不存在用户
                }
            }
            return(u);
        }