コード例 #1
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));
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: wukan1986/StockAnalysis
        static void Run(string exePath, string account, string password)
        {
            bool existsMainWindow = ExistsMainWindow();

            int processId = 0;

            if (!existsMainWindow)
            {
                processId = AutoItX.Run(exePath, Path.GetDirectoryName(exePath));

                if (processId == 0)
                {
                    throw new InvalidOperationException(
                              string.Format("Failed to run {0}", exePath));
                }
            }

            try
            {
                if (!existsMainWindow)
                {
                    Login(account, password);
                }

                ExportData();
            }
            finally
            {
                if (processId != 0)
                {
                    AutoItX.ProcessClose(processId.ToString());
                }
            }
        }
コード例 #3
0
ファイル: RobotCMB.cs プロジェクト: lhunnelSpiral/MyProject
        private void TryToKillOldProcess(string midasTxnId)
        {
            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", midasTxnId, processExists);
                    Thread.Sleep(TimeSpan.FromSeconds(2));
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Закрытие процесса
 /// </summary>
 /// <param name="nameproces">Наименование процеса пример "AcroRd32.exe",
 /// "FoxitPhantom.exe"
 /// </param>
 /// <param name="timer">Время ожидания процесса</param>
 public static void Process(string nameproces, int timer)
 {
     AutoItX.ProcessWait(nameproces, timer);
     AutoItX.Sleep(2000); //Можно контролить  процесс
     while (true)
     {
         if (AutoItX.ProcessExists(nameproces) > 0)
         {
             AutoItX.ProcessClose(nameproces);
         }
         if (AutoItX.ProcessExists(nameproces) == 0)
         {
             break;
         }
     }
 }
コード例 #5
0
 public int ProcessClose(string process)
 {
     return(AutoItX.ProcessClose(process));
 }