Exemplo n.º 1
0
        private RobotResult DoLogIn(RobotContext context)
        {
            try
            {
                IntPtr loginFormWindow = AutoItX.WinGetHandle(LoginFormTitle);
                IntPtr textPassBox     = AutoItX.ControlGetHandle(loginFormWindow, "[CLASS:TCMBStyleEdit72]");
                EnterLoginBox(loginFormWindow, textPassBox, context.LoginPassword);
                ClickButton(loginFormWindow, textPassBox, 70, 70);

                int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "", 10); //login password validate
                if (warningHappen1 == AutoItXSuccess)
                {
                    string errorText = AutoItX.WinGetText("[CLASS:TPbBaseMsgForm]");
                    AutoItX.WinClose("[CLASS:TPbBaseMsgForm]");
                    return(RobotResult.Build(context, RobotStatus.ERROR, $"Login Failed, Error<{errorText.Trim()}>"));
                }

                WaitUtils.UntilWinActive(MainWindowTitle, MainWindowText);
                return(RobotResult.Build(context, RobotStatus.SUCCESS, "Login Success, Awesome!"));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }
Exemplo n.º 2
0
        private RobotResult DoGetBalance(RobotContext context)
        {
            try
            {
                IntPtr mainFormWindow = GetMainFormWindow();
                AutoItX.WinActivate(mainFormWindow);

                ClickButton(mainFormWindow, 50, 80);    // click HomePage button
                Thread.Sleep(TimeSpan.FromSeconds(3));  // sleep wait for [CLASS:Internet Explorer_Server] load done

                ClickButton(mainFormWindow, 230, 480);  // click Statement button
                Thread.Sleep(TimeSpan.FromSeconds(5));  // sleep wait for [CLASS:Internet Explorer_Server] load done

                ClickButton(mainFormWindow, 1580, 390); // click Download button

                WaitUtils.UntilWinActive("[TITLE:File Download; CLASS:#32770]", "");
                AutoItX.WinActivate("[TITLE:File Download; CLASS:#32770]", "");
                Thread.Sleep(TimeSpan.FromSeconds(1));
                AutoItX.ControlClick("[TITLE:File Download; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:2]"); // click Save button

                WaitUtils.UntilWinActive("[TITLE:Save As; CLASS:#32770]", "");
                ChangeDownloadPath($@"{StatementBaseFolder}\{context.FromAccountNumber}");
                Thread.Sleep(TimeSpan.FromSeconds(1));
                AutoItX.ControlClick("[TITLE:Save As; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:2]"); // click Save button

                int warningHappen1 = AutoItX.WinWaitActive("[TITLE:Confirm Save As; CLASS:#32770]", "", 2);
                if (warningHappen1 == AutoItXSuccess)
                {
                    AutoItX.WinActivate("[TITLE:Confirm Save As; CLASS:#32770]", "");
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                    AutoItX.ControlClick("[TITLE:Confirm Save As; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:1]"); // click Yes button
                }

                WaitUtils.UntilWinActive("[TITLE:Download complete; CLASS:#32770]", "");
                AutoItX.WinActivate("[TITLE:Download complete; CLASS:#32770]", "");
                Thread.Sleep(TimeSpan.FromSeconds(1));
                AutoItX.ControlClick("[TITLE:Download complete; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:4]"); // click Close button

                Thread.Sleep(TimeSpan.FromSeconds(2));
                return(RobotResult.Build(context, RobotStatus.SUCCESS, ""));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }
Exemplo n.º 3
0
        private RobotResult DoTransfer(RobotContext context)
        {
            try
            {
                IntPtr mainFormWindow = GetMainFormWindow();
                AutoItX.WinActivate(mainFormWindow);

                ClickButton(mainFormWindow, 50, 80);   // click HomePage button
                Thread.Sleep(TimeSpan.FromSeconds(3)); // sleep wait for [CLASS:Internet Explorer_Server] load done

                ClickButton(mainFormWindow, 60, 320);  // click Transfer button, default 'Same-bank transfer'
                WaitUtils.UntilControlFocus(MainWindowTitle, MainWindowText, "[CLASS:TCMBSearchComboBox; INSTANCE:1]");

                if (string.IsNullOrEmpty(context.ToBankName))
                {
                    FillSameBankTransInfo(mainFormWindow, context);
                }
                else
                {
                    ClickButton(mainFormWindow, 250, 210); // click 'Inter-bank transfer' button
                    WaitUtils.UntilControlFocus(MainWindowTitle, MainWindowText, "[CLASS:TCMBStyleRadioButton; INSTANCE:1]");
                    FillInterBankTransInfo(mainFormWindow, context);
                }

                WaitUtils.UntilControlFocus(MainWindowTitle, MainWindowText, "[CLASS:TCMBEdit; INSTANCE:1]");
                FillWithdrawPin(mainFormWindow, context);

                int errorHappen1 = AutoItX.WinWaitActive("[TITLE:错误; CLASS:TErrorWithHelpForm]", "", 5); //transfer pre-check failed
                if (errorHappen1 == AutoItXSuccess)
                {
                    AutoItX.WinClose("[TITLE:错误;CLASS:TErrorWithHelpForm]");
                    return(RobotResult.Build(context, RobotStatus.ERROR, "Transfer Failed1, Error<Withdraw Validate Failed>"));
                }

                WaitUtils.UntilWinActive("[CLASS:TTransferSuccessFrm]", context.ToAccountName);
                AutoItX.WinClose("[CLASS:TTransferSuccessFrm]");
                return(RobotResult.Build(context, RobotStatus.SUCCESS, ""));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }