/// <summary> /// 项目菜单选择,根据个人权限生成的项目目录 /// </summary> /// <param name="redisdb">reidis数据库连接对象</param> /// <param name="sqlConnection">sql数据库连接对象</param> /// <param name="loginUsername">用户登录名</param> public void ChooseProjecMenu(IDatabase redisdb, SqlConnection sqlConnection, string loginUsername) { CMDScript cmdScript = new CMDScript(); //ProjectMenuListInfo projectMenuList = new ProjectMenuListInfo(); FunctionProject functionProject = new FunctionProject(); FunctionReset functionReset = new FunctionReset(); var list = functionProject.GenerateProjectList(sqlConnection, redisdb, loginUsername); while (true) { int projectcode = this.Projectmenu(list); if (projectcode == 00000) { break; } else if (projectcode == 99996) //加载已连接项目 { functionProject.AutoMountNetDisk(redisdb); } else if (projectcode == 99997) //重置登录状态 { functionReset.ResetLoginStatus(redisdb); Console.WriteLine("重置登录状态完成,请重新登录,按任意键退出程序"); Console.ReadKey(); Environment.Exit(0); } else if (projectcode == 99998) //重置初始化状态 { functionReset.ResetInitstatus(redisdb, sqlConnection, loginUsername); functionReset.ResetLoginStatus(redisdb); Console.WriteLine("重置初始化设置完成,请重新登录,按任意键退出程序"); Console.ReadKey(); Environment.Exit(0); } else if (projectcode == 99999) //退出项目 { string disk = this.UnProject(); string unmountshell = cmdScript.UnMountNetDiskScript(disk); cmdScript.RunCMDscript(unmountshell); } else { Console.Clear(); string remotePath = functionProject.GenerateProjectPath(sqlConnection, projectcode, redisdb);//生成路径 if (remotePath != null) { //挂载网络盘 string mountshell = cmdScript.MountNetDiskScript(remotePath); cmdScript.RunCMDscript(mountshell); } else if (remotePath == null) { Console.WriteLine("---------------------------------------------------------------------------"); Console.WriteLine("项目编号输入错误或重复,无法正常挂载项目网络路径,请重新输入项目编号"); Console.WriteLine("---------------------------------------------------------------------------"); } } } }
/// <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(); } }