Beispiel #1
0
        private RobotResult DoOpenClientApp(RobotContext context)
        {
            try
            {
                TryToKillOldProcess(context.MidasTransactionId);


                SimulateKey.MouseMove(500, 500);
                SimulateKey.MouseClick(500, 500);
                SimulateKey.MouseClick(500, 500);

                //Process process = new Process();
                //process.StartInfo.FileName = LocaleEmulatorFileName;
                //process.StartInfo.WorkingDirectory = LocaleEmulatorWorkingDirectory;
                //process.StartInfo.Arguments = PersonalBankPortalPath;
                //process.Start();

                Thread.Sleep(TimeSpan.FromSeconds(3));
                return(RobotResult.Build(context, RobotStatus.SUCCESS, "Open Client App Success!"));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
 private RobotResult DoOpenClientApp(RobotContext context)
 {
     try
     {
         int processExists = AutoItX.ProcessExists(ProcessName);
         if (processExists != 0)
         {
             int processClose = AutoItX.ProcessClose(ProcessName);
             if (processClose == AutoItXSuccess)
             {
                 LOG.Log(LogLevel.Debug, "TransactionId<{0}>, Kill old process<{1}> done", context.MidasTransactionId, processExists);
             }
         }
         if (AutoItX.WinExists(LoginFormTitle) != AutoItXSuccess)
         {
             AutoItX.Run(ProgramFullPath, "");
             int errorHappen1 = AutoItX.WinWaitActive(LoginFormTitle, "", 5);
             if (errorHappen1 == AutoItXSuccess)
             {
                 Thread.Sleep(TimeSpan.FromSeconds(3));
             }
             else
             {
                 LOG.Error("TransactionId<{0}>, App<{1}> not found", context.MidasTransactionId, ProgramFullPath);
                 throw new Exception("Open App Failed, Error<App Location Not Found>");
             }
         }
         return(RobotResult.Build(context, RobotStatus.SUCCESS, "Open Client App Success!"));
     }
     catch (Exception e)
     {
         return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
     }
 }
Beispiel #4
0
        private RobotResult DoLogIn(RobotContext context)
        {
            try
            {
                IntPtr loginFormWindow = AutoItX.WinGetHandle(LoginFormTitle);
                IntPtr textPassBox     = AutoItX.ControlGetHandle(loginFormWindow, "[CLASS:TCMBStyleEdit72]");
                EnterPinBox(loginFormWindow, textPassBox, context.LoginPassword);
                ClickButton(loginFormWindow, 200, 400);

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

                RobotCMB738Utils.UntilWinActive(context.MidasTransactionId, MainWindowTitle, MainWindowText);
                Thread.Sleep(TimeSpan.FromSeconds(2)); // sleep wait for [CLASS:Internet Explorer_Server] load done
                return(RobotResult.Build(context, RobotStatus.SUCCESS, "Login Success, Awesome!"));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }
Beispiel #5
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));
            }
        }
Beispiel #6
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));
            }
        }
Beispiel #7
0
        private RobotResult DoTransfer(RobotContext context)
        {
            try
            {
                IntPtr mainFormWindow = GetMainFormWindow();
                AutoItX.WinActivate(mainFormWindow);

                ClickButton(mainFormWindow, 60, 320); // click 'Transfer' button
                RobotCMB738Utils.UntilControlFocus(context.MidasTransactionId, MainWindowTitle, MainWindowText, "[CLASS:TCMBStyleEdit72; INSTANCE:4]");

                FillBankTransInfo(mainFormWindow, context);
                ClickButton(mainFormWindow, 180, 650); // click 'Next' button
                RobotCMB738Utils.UntilControlFocus(context.MidasTransactionId, MainWindowTitle, MainWindowText, "[CLASS:TCMBStyleEdit72; INSTANCE:4000]");

                return(RobotResult.Build(context, RobotStatus.SUCCESS, ""));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }
Beispiel #8
0
        private RobotResult DoLogOut(RobotContext context)
        {
            try
            {
                IntPtr mainFormWindow = GetMainFormWindow();
                AutoItX.WinActivate(mainFormWindow);

                Rectangle mainWindowPosition = AutoItX.WinGetPos(mainFormWindow);
                ClickButton(mainFormWindow, mainWindowPosition.Width - 150, 10);

                int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TAppExitForm]", "", 5);
                if (warningHappen1 == AutoItXSuccess)
                {
                    IntPtr warningPopWin1 = AutoItX.WinGetHandle("[CLASS:TAppExitForm]");
                    ClickButton(warningPopWin1, 110, 190);
                }
                int warningHappen2 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "移动证书优KEY还插在电脑", 5);
                if (warningHappen2 == AutoItXSuccess)
                {
                    IntPtr warningPopWin2 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "移动证书优KEY还插在电脑");
                    ClickButton(warningPopWin2, 250, 170);
                }
                int warningHappen3 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "再次确认是否要不拔掉优KEY退出专业版", 5);
                if (warningHappen3 == AutoItXSuccess)
                {
                    IntPtr warningPopWin3 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "再次确认是否要不拔掉优KEY退出专业版");
                    ClickButton(warningPopWin3, 260, 160);
                }
                Thread.Sleep(TimeSpan.FromSeconds(2));
                return(RobotResult.Build(context, RobotStatus.SUCCESS, ""));
            }
            catch (Exception e)
            {
                return(RobotResult.Build(context, RobotStatus.ERROR, e.Message));
            }
        }