Esempio n. 1
0
        /// <summary>
        /// 返回缓存帐号信息
        /// </summary>
        /// <param name="LoginCode">登录帐号</param>
        /// <returns></returns>
        public LoginCodeModel Get(int LoginCode)
        {
            var model = new LoginCodeModel();

            if (!this.Exists(LoginCode))
            {
                var db = new UCMS.Entitys.UCMSContext();
                var t  = db.SysUserBasis.Where(c => c.IsDelete == 0 && c.LoginCode == LoginCode).FirstOrDefault();
                if (t != null)
                {
                    var query = from a in db.SysRoleBasis
                                from b in db.SysRoleUser
                                where a.Id == b.RoleId && b.UserId == t.Id && a.IsDelete == (int)Common.EnumModel.EIsDelete.NotDelete
                                select new { a.RoleCode };
                    int type = 0;
                    foreach (var item in query)
                    {
                        if (item.RoleCode.ToLower() == "system")
                        {
                            type = 1;
                            break;
                        }
                    }
                    model = new LoginCodeModel
                    {
                        UserId    = t.Id,
                        LoginCode = LoginCode,
                        Passwords = t.Passwords,
                        RealName  = t.RealName,
                        LastTime  = t.LastTime,
                        Mobile    = t.Mobile,
                        QQ        = t.QQ,
                        Sex       = t.Sex,
                        Weixin    = t.Weixin,
                        UserType  = type
                    };
                    //保存缓存
                    this.Set(model);
                }
                else
                {
                    model = null;
                }
            }
            else
            {
                model = (LoginCodeModel)mc.Get(this.GetCacheName(LoginCode));
            }
            return(model);
        }
Esempio n. 2
0
 /// <summary>
 /// 添加缓存,如存在则更新
 /// </summary>
 /// <param name="model"></param>
 public bool Set(LoginCodeModel model)
 {
     return(mc.Set(this.GetCacheName(model.LoginCode), model, DateTime.Now.AddDays(7)));
 }