Exemplo n.º 1
0
 public LogonResultForm GetUserInfo(string userid)
 {
     var mapper = Common.GetMapperFromSession();
     UserDao userdao = new UserDao(mapper);
     var user = userdao.Query(new UserQueryForm { Name = userid }).FirstOrDefault();
     if (user == null) throw new Exception("用户:" + userid + "在系统中不存在!");
     if (user.Enabled == 0) throw new Exception("该用户已被禁用,请联系管理员!");
     LogonResultForm result = new LogonResultForm();
     UserInfoDao userInfoDao = new UserInfoDao(mapper);
     RoleDao roleDao = new RoleDao(mapper);
     LogonHistoryDao historyDao = new LogonHistoryDao(mapper);
     string token = Guid.NewGuid().ToString().Replace("-", "");
     var userinfo = userInfoDao.Query(new UserInfoQueryForm { ID = user.ID }).FirstOrDefault();
     UserEntireInfo u = new UserEntireInfo { User = user };
     if (userinfo != null) u.UserInfo = userinfo;
     u.Role = roleDao.QueryRoleByUserID(u.User.ID);
     CacheItem item = new CacheItem(token, u);
     LogonHistory history = new LogonHistory
     {
         LogonTime = DateTime.Now,
         Token = token,
         UserID = user.ID,
         ActiveTime = DateTime.Now,
     };
     historyDao.Add(history);
     result.token = token;
     result.UserInfo = userinfo;
     cache.AddItem(item, 30 * 60);
     MenuBLL menubll = new MenuBLL();
     result.Menu = menubll.GetCurrentUserMenu(result.token);
     return result;
 }
Exemplo n.º 2
0
        public LogonResultForm GetUserInfo(string userid)
        {
            var     mapper  = Common.GetMapperFromSession();
            UserDao userdao = new UserDao(mapper);
            var     user    = userdao.Query(new UserQueryForm {
                Name = userid
            }).FirstOrDefault();

            if (user == null)
            {
                throw new Exception("用户:" + userid + "在系统中不存在!");
            }
            if (user.Enabled == 0)
            {
                throw new Exception("该用户已被禁用,请联系管理员!");
            }
            LogonResultForm result      = new LogonResultForm();
            UserInfoDao     userInfoDao = new UserInfoDao(mapper);
            RoleDao         roleDao     = new RoleDao(mapper);
            LogonHistoryDao historyDao  = new LogonHistoryDao(mapper);
            string          token       = Guid.NewGuid().ToString().Replace("-", "");
            var             userinfo    = userInfoDao.Query(new UserInfoQueryForm {
                ID = user.ID
            }).FirstOrDefault();
            UserEntireInfo u = new UserEntireInfo {
                User = user
            };

            if (userinfo != null)
            {
                u.UserInfo = userinfo;
            }
            u.Role = roleDao.QueryRoleByUserID(u.User.ID);
            LogonHistory history = new LogonHistory
            {
                LogonTime  = DateTime.Now,
                Token      = token,
                UserID     = user.ID,
                ActiveTime = DateTime.Now,
            };

            historyDao.Add(history);
            result.token    = token;
            result.UserInfo = userinfo;
            cache.AddItem(token, u, 30 * 60);
            MenuBLL menubll = new MenuBLL();

            result.Menu = menubll.GetCurrentUserMenu(result.token);
            return(result);
        }
Exemplo n.º 3
0
 public IndexInitResultForm InitPage()
 {
     IndexInitResultForm form = new IndexInitResultForm();
     MenuBLL menubll = new MenuBLL();
     UserBLL userbll = new UserBLL();
     TaskBLL taskbll = new TaskBLL();
     form.Menu = menubll.GetCurrentUserMenu();
     form.User = userbll.GetCurrentUser();
     var task = taskbll.Query(new QueryMyTaskServiceForm { UserID = form.User.User.ID, Status = (int)TaskProcessStatus.Started });
     task.Sort((l, r) =>
     {
         if (l.CreateTime > r.CreateTime)
         {
             return 0;
         }
         else
         {
             return 1;
         }
     });
     form.ProcessingTask = task;
     return form;
 }