Пример #1
0
        static int usrPwd(string[] args)
        {
            if (ContainsOpt(args, "-f"))
            {
                var userName = GetParm(args, 1);
                var pwd1     = GetParm(args, 2);
                var pwd2     = GetParm(args, 3);
                if (pwd1 != pwd2)
                {
                    logger().Error("Two times input password mismatch.");
                    return(0);
                }
                AccountCtlMain.ChagePwd(userName, pwd1);
            }
            else
            {
                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.");
                }
            }

            return(0);
        }
Пример #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);
        }