示例#1
0
        public static string GetToken(string userId)
        {
            cleanExpired();

            string key = userId;

            lock (lockObject)
            {
                if (dictIdSecretWithSid.ContainsKey(key))
                {
                    return(dictIdSecretWithSid[key].ToString());
                }
            }
            long  sid   = LeafSnowflake.getID();
            Token token = new Token();

            token.UserID     = userId;
            token.ExpireTime = DateTime.Now.AddHours(2);

            AppSessionBLL.SaveToken(sid, token);

            lock (lockObject)
            {
                dictToken.Add(sid, token);
                dictIdSecretWithSid.Add(key, sid);
            }
            return(sid.ToString());
        }
        public static long Add(string appSecret, string name)
        {
            using (var db = new HGDContext())
            {
                //
                AppInfo e = new AppInfo();

                e.Id     = LeafSnowflake.getID();
                e.Secret = MD5Util.getHashStr(appSecret);
                e.Name   = name;

                db.AppInfo.Add(e);

                db.SaveChanges();

                return(e.Id);
            }
        }
示例#3
0
 public ModalBaseLong()
 {
     this.Id        = LeafSnowflake.getID();
     this.CreatTime = DateTime.Now;
 }