Beispiel #1
0
        //public void SecondMenu()
        //{
        //    Console.WriteLine();
        //    Console.WriteLine("8:\t退\t出\t项\t目\t");
        //}
        /// <summary>
        /// 功能菜单
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="sqlConnection">SQL连接对象</param>
        /// <param name="redisdb">REDIS连接对象</param>
        /// <param name="userMenu">用户菜单类</param>
        /// <param name="projectMenuList">项目菜单类</param>
        public void FunctionMenu(UserInfo userInfo, SqlConnection sqlConnection, IDatabase redisdb, UserMenu userMenu, ProjectMenuListInfo projectMenuList)
        {
            int funcCode = this.Stratmuem();

            if (funcCode.ToString().Length == 1)
            {
                if (funcCode == 1)
                {
                    UserInfo          loguserInfo = userMenu.LoginUserInfo(userInfo);
                    FunctionUserLogin userLogin   = new FunctionUserLogin();
                    int logincode = userLogin.UserLogin(sqlConnection, loguserInfo);
                    if (logincode == 1)
                    {
                        Console.Clear();
                        Console.WriteLine("用户名密码正确,登录成功");
                        userLogin.SetUserLoginStatus(redisdb, loguserInfo.UserName);
                        projectMenuList.ChooseProjecMenu(redisdb, sqlConnection, loguserInfo.UserName);
                        #region 这个是旧的项目权限获取方法及菜单调用的写法
                        //CMDScript cmdScript = new CMDScript();
                        //FunctionProject functionProject = new FunctionProject();
                        //var list = functionProject.GenerateProjectList(sqlConnection, redisdb, loguserInfo.UserName);
                        //ProjectMenuListInfo projectMenuList = new ProjectMenuListInfo();
                        //while (true)
                        //{
                        //    int projectcode = projectMenuList.Projectmenu(list);
                        //    if (projectcode == 00000)
                        //    {
                        //        break;
                        //    }
                        //    else if (projectcode == 99999)
                        //    {
                        //        string disk = projectMenuList.UnProject();
                        //        string unmountshell = cmdScript.UnMountNetDiskScript(disk);
                        //        cmdScript.RunCMDscript(unmountshell);
                        //    }
                        //    else
                        //    {
                        //        Console.Clear();
                        //        string remotePath = functionProject.GenerateProjectPath(sqlConnection, projectcode);
                        //        string mountshell = cmdScript.MountNetDiskScript(remotePath);
                        //        cmdScript.RunCMDscript(mountshell);
                        //    }


                        //}
                        #endregion
                    }
                    else if (logincode == 0)
                    {
                        Console.Clear();
                        Console.WriteLine("用户名密码错误,登录失败,请重新登录");
                        new MenuAction().ChooseFunction(redisdb, sqlConnection);
                    }
                }
                else if (funcCode == 0)
                {
                    Environment.Exit(0);
                }
            }
            else
            {
                Console.WriteLine("-----------------------------------");
                Console.WriteLine("请输入正确的功能编号");
                Console.WriteLine("-----------------------------------");
                this.FunctionMenu(userInfo, sqlConnection, redisdb, userMenu, projectMenuList);
            }
        }
Beispiel #2
0
        public void ChooseFunction(IDatabase redisdb, SqlConnection sqlConnection)
        {
            ProjectMenuListInfo projectMenuList = new ProjectMenuListInfo();
            FunctionCheck       check           = new FunctionCheck();
            UserMenu            userMenu        = new UserMenu();
            UserInfo            userInfo        = new UserInfo();
            string         checkresult          = check.InitCheck(redisdb);
            ClineMuemModel clineMuem            = new ClineMuemModel();

            if (String.Equals(checkresult, "inited"))
            {
                #region 这里要检查是否为第一次登录的状态
                string loginUsername = check.LoginStatusCheck(redisdb);
                if (loginUsername != null)
                {
                    Console.WriteLine();
                    projectMenuList.ChooseProjecMenu(redisdb, sqlConnection, loginUsername);
                }
                else if (loginUsername == null)
                {
                    clineMuem.FunctionMenu(userInfo, sqlConnection, redisdb, userMenu, projectMenuList);
                }

                #endregion
                //int funcCode = clineMuem.Stratmuem();
                //if (funcCode == 1)
                //{

                //    CMDScript cmdScript = new CMDScript();
                //    UserInfo loguserInfo = userMenu.LoginUserInfo(userInfo);
                //    FunctionUserLogin userLogin = new FunctionUserLogin();
                //    int logincode= userLogin.UserLogin(sqlConnection, loguserInfo);
                //    if (logincode==1)
                //    {
                //        Console.Clear();
                //        Console.WriteLine("用户名密码正确,登录成功");
                //        ProjectMenuListInfo projectMenuList = new ProjectMenuListInfo();
                //        FunctionProject functionProject = new FunctionProject();
                //        var list= functionProject.GenerateProjectList(sqlConnection, redisdb, loguserInfo.UserName);
                //        while (true)
                //        {
                //            int projectcode = projectMenuList.Projectmenu(list);
                //            if (projectcode==00000)
                //            {
                //                break;
                //            }
                //            else if (projectcode == 99999)
                //            {
                //                string disk = projectMenuList.UnProject();
                //                string unmountshell = cmdScript.UnMountNetDiskScript(disk);
                //                cmdScript.RunCMDscript(unmountshell);
                //            }
                //            else
                //            {
                //                Console.Clear();
                //                string remotePath = functionProject.GenerateProjectPath(sqlConnection, projectcode);
                //                string mountshell = cmdScript.MountNetDiskScript(remotePath);
                //                cmdScript.RunCMDscript(mountshell);
                //            }


                //        }

                //    }
                //    else if (logincode == 0)
                //    {
                //        Console.Clear();
                //        Console.WriteLine("用户名密码错误,登录失败,请重新登录");
                //        this.ChooseFunction(redisdb, sqlConnection);
                //    }
                //}
                //else if (funcCode == 0)
                //{
                //    Environment.Exit(0);
                //}
            }
            else //检查初始化状态,当不是初始化的时候代码跑这里
            {
                Console.WriteLine("--------------------------------------");
                userMenu.NoiceInfo();
                UserInfo         inituserInfo = userMenu.Init(userInfo);
                FunctionUserInit userInit     = new FunctionUserInit();
                userInit.UserInit(sqlConnection, redisdb, inituserInfo);
                clineMuem.FunctionMenu(userInfo, sqlConnection, redisdb, userMenu, projectMenuList);
            }
        }