Beispiel #1
0
        /// <summary>
        /// モジュールを開始する
        /// </summary>
        /// <param name="projectModel"></param>
        private void StartProject(ProjectModel projectModel, MacroStartType macroStartType)
        {
            try
            {
                List <string> errorList = projectModel.CheckMacroInput();
                if (errorList.Count > 0)
                {
                    if (errorList.Count > 0)
                    {
                        string msg = "";
                        foreach (var m in errorList)
                        {
                            if (string.IsNullOrEmpty(msg))
                            {
                                msg = m;
                            }
                            else
                            {
                                msg += "\r\n" + m;
                            }
                            this.ShowErrorDialog(StringValue.PROCESS_NAME + "登録エラー", msg);
                        }
                        return;
                    }
                }
                if (!_autoMode)
                {
                    Hide();
                }

                if (_keyboardHook != null)
                {
                    _keyboardHook.KeyboardHooked -= KeyboardHook_KeyboardHooked;
                    _keyboardHook.Dispose();
                }
                _keyboardHook = new KeyboardHook();
                _keyboardHook.KeyboardHooked += KeyboardHook_KeyboardHooked;
                _execThread = new Thread(new ThreadStart(() => {
                    _macroExecutor            = new MacroExecutor(projectModel, macroStartType);
                    _macroExecutor.OnLogEvent = SetLogText;
                    LogFilePath = Program.EXEC_LOG_PATH;
                    if (!Directory.Exists(LogFilePath))
                    {
                        Directory.CreateDirectory(LogFilePath);
                    }
                    LogFilePath += @"\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + FileUtil.GetInvalidEscapeFileName(projectModel.Name, " ") + ".log";
                    _macroExecutor.Run(true);
                    if (!_autoMode)
                    {
                        Invoke(new MethodInvoker(() => {
                            _keyboardHook.KeyboardHooked -= KeyboardHook_KeyboardHooked;
                            _keyboardHook.Dispose();
                            Show();
                        }));
                    }
                }));
                _execThread.Start();
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }