Esempio n. 1
0
        static int Exec(string cmd, string[] args)
        {
            switch (cmd)
            {
            case "init":
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var sure = Console.ReadLine();
                if (sure == "yes" || ContainsOpt(args, "-f"))
                {
                    AccountCtlMain.Init();
                }
                break;

            case "act.print":
                AccountCtlMain.AccoutPrint();
                break;

            case "act.create":
                AccountCtlMain.CreateAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.load":
                AccountCtlMain.LoadAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.unload":
                var parm1 = GetParm(args, 1);
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes = Console.ReadLine();
                if (yes == "yes" || ContainsOpt(args, "-f"))
                {
                    AccountCtlMain.UnloadAccount(parm1);
                }
                break;

            case "act.init":
                var parm2 = GetParm(args, 1);
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes1 = Console.ReadLine();
                if (yes1 == "yes" || ContainsOpt(args, "-f"))
                {
                    if (ContainsOpt(args, "-k"))
                    {
                        AccountCtlMain.InitAccount(parm2, "-k");
                    }
                    else
                    {
                        AccountCtlMain.InitAccount(parm2);
                    }
                }
                break;

            case "usr.pwd":
                usrPwd(args);
                break;

            case "usr.add":
                usrAdd(args);
                break;

            case "usr.delete":
                var duserName = GetParm(args, 1);
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes2 = Console.ReadLine();
                if (yes2 == "yes" || ContainsOpt(args, "-f"))
                {
                    AccountCtlMain.DeleteUser(duserName);
                }
                break;

            case "usr.print":
                AccountCtlMain.UserPrint();
                break;

            default:
                logger().Debug(string.Format("Don't has this command [{0}].", cmd));
                throw new FinanceException(FinanceResult.IMPERFECT_DATA);
            }
            logger().Warn("执行成功.");
            return(0);
        }
Esempio n. 2
0
        static int Exec(string cmd, string[] args)
        {
            switch (cmd)
            {
            case "init":
                logger.Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var sure = Console.ReadLine();
                if (sure == "yes")
                {
                    AccountCtlMain.Init();
                }
                break;

            case "act.print":
                AccountCtlMain.AccoutPrint();
                break;

            case "act.create":
                AccountCtlMain.CreateAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.load":
                AccountCtlMain.LoadAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.unload":
                var parm1 = GetParm(args, 1);
                logger.Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes = Console.ReadLine();
                if (yes == "yes")
                {
                    AccountCtlMain.UnloadAccount(parm1);
                }
                break;

            case "act.init":
                var parm2 = GetParm(args, 1);
                logger.Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes1 = Console.ReadLine();
                if (yes1 == "yes")
                {
                    if (args.Count() > 2)
                    {
                        AccountCtlMain.InitAccount(parm2, GetParm(args, 2));
                    }
                    else
                    {
                        AccountCtlMain.InitAccount(parm2);
                    }
                }
                break;

            case "usr.pwd":
                var userName = GetParm(args, 1);
                Console.Write("Please input user's old password : "******"Please input user's new password : "******"Confirm new password : "******"Two times input password mismatch.");
                        return(0);
                    }
                    AccountCtlMain.ChagePwd(userName, pwd1);
                }
                else
                {
                    Console.WriteLine("Incorrect user name or password.");
                }
                break;

            case "usr.add":
                var no   = GetParm(args, 1);
                var name = GetParm(args, 2);
                Console.Write("Please input user's password : "******"Confirm password : "******"Two times input password mismatch.");
                    return(0);
                }
                AccountCtlMain.AddUser(no, name, apwd1);
                break;

            case "usr.delete":
                var duserName = GetParm(args, 1);
                Console.Write("Please input user's password : "******"Incorrect user name or password.");
                }
                break;

            case "usr.print":
                AccountCtlMain.UserPrint();
                break;

            default:
                logger.Debug(string.Format("Don't has this command [{0}].", cmd));
                throw new FinanceException(FinanceResult.IMPERFECT_DATA);
            }
            logger.Info("execute success.");
            return(0);
        }