Exemplo n.º 1
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);
        }
Exemplo n.º 2
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("登录状态设置成功,下次可以不用输入账号密码登录了");
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据项目编号生成网盘挂载路径,并在redis生成项目连接列表,检查输入的项目编号是否为重复输入
        /// </summary>
        /// <param name="connection">数据库连接对象</param>
        /// <param name="projectcode">项目编码</param>
        /// <returns></returns>
        public string GenerateProjectPath(SqlConnection connection, int projectcode, IDatabase redisdb)
        {
            string cmd = this.SelectProjectCode(projectcode);
            var    dt  = this.SeletScript(cmd, connection);

            if (dt.Rows.Count != 0)
            {
                NetCarInfo    netCarInfo = new NetCarModel().GetNetCarMac();
                string        rediskey   = String.Format($"projectpath{netCarInfo.NetCarMac}");
                List <string> pathlist   = this.GetList(rediskey, redisdb);
                //string remotePath = Path.Combine("127.0.0.1", dt.Rows[0][0].ToString());//远程主机IP
                string remotePath = Path.Combine("10.12.2.61", dt.Rows[0][0].ToString());//远程主机IP
                remotePath = String.Format($@"\\{remotePath}");
                try
                {
                    Directory.SetCurrentDirectory(remotePath); //判断生成的原创路径是否可以访问
                    if (pathlist.Count == 0)
                    {
                        this.SetList(rediskey, remotePath, redisdb);
                        Console.WriteLine(@"查询到的项目路径为{0}", remotePath);
                    }
                    else
                    {
                        foreach (var pathitem in pathlist)
                        {
                            if (pathitem != remotePath || pathitem == null)
                            {
                                this.SetList(rediskey, remotePath, redisdb);
                                Console.WriteLine(@"查询到的项目路径为{0}", remotePath);
                                break;
                            }
                            else
                            {
                                Console.WriteLine("输入的项目编号重复");
                                remotePath = null;
                                break;
                            }
                        }
                    }
                    return(remotePath);
                }
                catch (Exception e)
                {
                    Console.WriteLine("网络路径无法正常访问,请连接你们的项目管理员检测下项目文件是否有共享权限,以及网络是否正常");
                    Console.WriteLine(e);
                    return(null);
                }
            }
            else
            {
                Console.WriteLine("项目编号输入错误");
                return(null);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 自动加载已连接过的网盘项目
        /// </summary>
        /// <param name="redisdb"></param>
        public void AutoMountNetDisk(IDatabase redisdb)
        {
            NetCarInfo    netCarInfo = new NetCarModel().GetNetCarMac();
            string        rediskey   = String.Format($"projectpath{netCarInfo.NetCarMac}");
            List <string> pathlist   = this.GetList(rediskey, redisdb);

            if (pathlist.Count != 0)
            {
                CMDScript script = new CMDScript();
                foreach (var pathitem in pathlist)
                {
                    string cmd = script.MountNetDiskScript(pathitem);
                    script.RunCMDscript(cmd);
                }
            }
            else
            {
                Console.WriteLine("------------------------------------------------------------------");
                Console.WriteLine("你还未连接过项目,请连接过项目后再使用此功能,按任意键返回项目菜单");
                Console.WriteLine("------------------------------------------------------------------");
                Console.ReadKey();
                Console.Clear();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 初始化用户信息,用户输入,账号密码小组号写入数据库
        /// </summary>
        /// <returns></returns>
        public UserInfo Init(UserInfo userInfo)
        {
            Console.WriteLine("请输入用户名(如test1,test2,请勿输入纯数字!):");
            Console.WriteLine("-------------------------------------------------");
            userInfo.UserName = Console.ReadLine();
            Console.WriteLine("-------------------------------------------------");
            if (userInfo.UserName != null)
            {
                Console.WriteLine("-------------------------------------------------");
                Console.WriteLine(userInfo.UserName);
                Console.WriteLine("-------------------------------------------------");
            }
            else
            {
                Console.WriteLine("请输入用户名(如test1,test2,请勿输入纯数字!):");
                userInfo.UserName = Console.ReadLine();
            }
            Console.WriteLine("请输入密码(请勿输入个人常用密码):");
            Console.WriteLine("-------------------------------------------------");
            userInfo.Password = Console.ReadLine();
            Console.WriteLine("-------------------------------------------------");
            if (userInfo.Password != null)
            {
                Console.WriteLine("-------------------------------------------------");
                Console.WriteLine("-------------------------------------------------");
            }
            else
            {
                Console.WriteLine("请输入密码(请勿输入个人常用密码):");
                Console.WriteLine("-------------------------------------------------");
                userInfo.UserName = Console.ReadLine();
                Console.WriteLine("-------------------------------------------------");
            }
            Console.WriteLine("请输入小组编号(不知道的可以去问你们领导):");
            Console.WriteLine("-------------------------------------------------");
            userInfo.GroupName = Console.ReadLine();
            Console.WriteLine("-------------------------------------------------");
            if (userInfo.GroupName != null)
            {
                Console.WriteLine(userInfo.GroupName);
            }
            else
            {
                Console.WriteLine("请输入小组编号(不知道的可以去问你们领导):");
                Console.WriteLine("-------------------------------------------------");
                userInfo.GroupName = Console.ReadLine();
                Console.WriteLine("-------------------------------------------------");
            }
            Console.WriteLine("请输入的你姓名");
            Console.WriteLine("-------------------------------------------------");
            userInfo.UserRealName = Console.ReadLine();
            Console.WriteLine("-------------------------------------------------");
            if (userInfo.UserRealName != null)
            {
                Console.WriteLine(userInfo.UserRealName);
            }
            else
            {
                Console.WriteLine("请输入的你姓名");
                Console.WriteLine("-------------------------------------------------");
                userInfo.UserRealName = Console.ReadLine();
                Console.WriteLine("-------------------------------------------------");
            }
            Random r = new Random(int.Parse(DateTime.Now.ToString("HHmmssfff")));

            userInfo.UTid       = r.Next(100000, 999999);//随机生成一个6位整数
            userInfo.CreateDate = DateTime.Now.ToLocalTime();
            userInfo.deleteflag = 0;
            NetCarInfo netCarInfo = new NetCarModel().GetNetCarMac();

            userInfo.UserComputerMac = netCarInfo.NetCarMac;
            return(userInfo);
        }