示例#1
0
        public Olb_User GetLoginerByMd5Cookie(string md5Cookie)
        {
            Olb_User    dbinfo = null;
            LoginerInfo info   = LoginerManageHelper.getInstance().List.Where(p => p.Md5Key == md5Cookie).SingleOrDefault();

            if (info != null && info.OperID != null && info.OperID != string.Empty)
            {
                DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);
                dbinfo = dd.GetTable <Olb_User>().Where(p => p.Account == info.OperID).SingleOrDefault();
            }
            return(dbinfo);
        }
示例#2
0
 /// <summary>
 /// 入口
 /// </summary>
 /// <returns></returns>
 public static LoginerManageHelper getInstance()
 {
     if (objInstance == null)
     {
         lock (_object)
         {
             if (objInstance == null)
             {
                 objInstance = new LoginerManageHelper();
             }
         }
     }
     return(objInstance);
 }
示例#3
0
        public Message UnLRegisterClientByMd5Cookie(string md5Cookie)
        {
            Message jMessage;

            try
            {
                LoginerManageHelper.getInstance().Semaphore.WaitOne();
                LoginerManageHelper.getInstance().List.RemoveAll(p => p.Md5Key == md5Cookie);
                LoginerManageHelper.getInstance().Semaphore.Release();
                jMessage = new Message()
                {
                    Result = true, TxtMessage = "注销成功。"
                };
            }
            catch (Exception e)
            {
                jMessage = new Message()
                {
                    Result = false, TxtMessage = "服务繁忙。"
                };
            }
            return(jMessage);
        }
示例#4
0
        public Message UserLogin(string md5Cookie, string account)
        {
            Message jMessage;

            try
            {
                LoginerManageHelper.getInstance().Semaphore.WaitOne();
                LoginerManageHelper.getInstance().List.RemoveAll(p => p.ExpiredDate <= System.DateTime.Now);
                LoginerManageHelper.getInstance().List.RemoveAll(p => p.Md5Key == md5Cookie);
                while (LoginerManageHelper.getInstance().List.Count > 800)
                {
                    LoginerManageHelper.getInstance().List.RemoveRange(0, 300);
                }
                LoginerManageHelper.getInstance().List.Add(new LoginerInfo()
                {
                    AddTime     = System.DateTime.Now,
                    ClientType  = 1,
                    OperID      = account,
                    ExpiredDate = System.DateTime.Now.AddHours(24),
                    Md5Key      = md5Cookie
                });
                LoginerManageHelper.getInstance().Semaphore.Release();
                jMessage = new Message()
                {
                    Result = true, TxtMessage = "登录成功。"
                };
            }
            catch (Exception e)
            {
                jMessage = new Message()
                {
                    Result = false, TxtMessage = "服务繁忙。"
                };
            }
            return(jMessage);
        }