Exemplo n.º 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));
     }
 }
Exemplo n.º 2
0
        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));
                }
            }
        }
Exemplo n.º 3
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;
         }
     }
 }
 public int ProcessExists(string process)
 {
     return(AutoItX.ProcessExists(process));
 }