Beispiel #1
0
        /// <summary>
        /// 重置用户登录状态的方法
        /// </summary>
        /// <param name="redisdb">redis连接对象</param>
        public void ResetLoginStatus(IDatabase redisdb)
        {
            NetCarInfo netCarInfo = NetCar.GetNetCarMac();
            string     delkey     = String.Format($"loginstatus{netCarInfo.NetCarMac}");
            string     delprokey  = String.Format($"projectpath{netCarInfo.NetCarMac}");

            this.DelKey(delprokey, redisdb);
            this.DelKey(delkey, redisdb);
        }
Beispiel #2
0
        public string LoginStatusCheck(IDatabase redisdb)
        {
            NetCarModel netCarModel = new NetCarModel();
            RedisModel  redis       = new RedisModel();
            NetCarInfo  netCarInfo  = netCarModel.GetNetCarMac();
            string      rediskey    = String.Format($"loginstatus{netCarInfo.NetCarMac}");
            string      loginstatus = redis.GetLoginStatus(rediskey, redisdb);

            return(loginstatus);
        }
Beispiel #3
0
        /// <summary>
        /// 设置用户登录状态,写入redis
        /// </summary>
        /// <param name="redisdb"></param>
        /// <param name="loginName"></param>
        public void SetUserLoginStatus(IDatabase redisdb, string loginName)
        {
            NetCarModel netCarModel = new NetCarModel();
            //RedisModel redis = new RedisModel();
            NetCarInfo netCarInfo = netCarModel.GetNetCarMac();
            string     rediskey   = String.Format($"loginstatus{netCarInfo.NetCarMac}");

            this.SetLoginStatus(loginName, redisdb, rediskey);
            Console.WriteLine("登录状态设置成功,下次可以不用输入账号密码登录了");
        }
Beispiel #4
0
        /// <summary>
        /// 登录用户初始化方法
        /// </summary>
        /// <param name="conndetail">sql连接对象</param>
        public void UserInit(SqlConnection connection, IDatabase redisdb, UserInfo inituserInfo)
        {
            NetCarModel netCarModel = new NetCarModel();

            //InitUser initUser = new InitUser();
            //RedisModel redis = new RedisModel();
            //SqlAction sqlAction = new SqlAction();
            //UserInfo userInfo = initUser.Init(loginUserinfo);
            this.UserInsert(inituserInfo, connection);
            NetCarInfo netCarInfo = netCarModel.GetNetCarMac();
            string     rediskey   = String.Format($"init{netCarInfo.NetCarMac}");

            this.SetLoginStatus("inited", redisdb, rediskey);
        }
Beispiel #5
0
        /// <summary>
        /// 重置用户初始化状态的方法
        /// </summary>
        /// <param name="redisdb">redis连接对象</param>
        public void ResetInitstatus(IDatabase redisdb, SqlConnection connection, string loginUserName)
        {
            NetCarInfo netCarInfo = NetCar.GetNetCarMac();
            string     delkey     = String.Format($"init{netCarInfo.NetCarMac}");
            string     dellogkey  = String.Format($"loginstatus{netCarInfo.NetCarMac}");
            string     delprokey  = String.Format($"projectpath{netCarInfo.NetCarMac}");

            this.DelKey(delkey, redisdb);
            this.DelKey(dellogkey, redisdb);
            this.DelKey(delprokey, redisdb);
            string sqlcmd = this.UpdataDeleteFlag(loginUserName);

            this.UpdataSQL(sqlcmd, connection);
        }
Beispiel #6
0
        public NetCarInfo GetNetCarMac()
        {
            NetCarInfo MacInfo = new NetCarInfo();

            NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in adapters)
            {
                if (String.Equals(adapter.NetworkInterfaceType.ToString(), "Ethernet") && String.Equals(adapter.OperationalStatus.ToString(), "Up"))
                {
                    if (adapter.GetPhysicalAddress().ToString() != null)
                    {
                        MacInfo.NetCarMac = adapter.GetPhysicalAddress().ToString();
                        break;
                    }
                    else
                    {
                        MacInfo.NetCarMac = adapter.Id;
                        break;
                    }
                }
                else if (String.Equals(adapter.NetworkInterfaceType.ToString(), "Wireless80211") && String.Equals(adapter.OperationalStatus.ToString(), "Up"))
                {
                    MacInfo.NetCarMac = adapter.GetPhysicalAddress().ToString();
                    if (MacInfo.NetCarMac == null)
                    {
                        MacInfo.NetCarMac = adapter.Id;
                        break;
                    }
                }
                //else
                //{
                //    break;
                //}
            }
            //Console.WriteLine(MacInfo.NetCarMac);
            return(MacInfo);
        }