Exemple #1
0
        private void uiBtnRun_Click(object sender, EventArgs e)
        {
            //build script path and execute
            var scriptFilePath = Path.Combine(_projectPath, cboSelectedScript.Text);
            var projectName    = new DirectoryInfo(_projectPath).Name;
            //initialize Logger
            Logger engineLogger = null;

            switch (_appSettings.EngineSettings.LoggingSinkType)
            {
            case SinkType.File:
                if (string.IsNullOrEmpty(_appSettings.EngineSettings.LoggingValue1.Trim()))
                {
                    _appSettings.EngineSettings.LoggingValue1 = Path.Combine(Folders.GetFolder(FolderType.LogFolder), "OpenBots Engine Logs.txt");
                }

                engineLogger = new Logging().CreateFileLogger(_appSettings.EngineSettings.LoggingValue1, Serilog.RollingInterval.Day,
                                                              _appSettings.EngineSettings.MinLogLevel);
                break;

            case SinkType.HTTP:
                engineLogger = new Logging().CreateHTTPLogger(projectName, _appSettings.EngineSettings.LoggingValue1, _appSettings.EngineSettings.MinLogLevel);
                break;

            case SinkType.SignalR:
                string[] groupNames = _appSettings.EngineSettings.LoggingValue3.Split(',').Select(x => x.Trim()).ToArray();
                string[] userIDs    = _appSettings.EngineSettings.LoggingValue4.Split(',').Select(x => x.Trim()).ToArray();

                engineLogger = new Logging().CreateSignalRLogger(projectName, _appSettings.EngineSettings.LoggingValue1, _appSettings.EngineSettings.LoggingValue2,
                                                                 groupNames, userIDs, _appSettings.EngineSettings.MinLogLevel);
                break;
            }

            frmScriptEngine newEngine = new frmScriptEngine(scriptFilePath, _projectPath, null, engineLogger);

            newEngine.Show();
        }
Exemple #2
0
        private async void uiBtnRun_Click(object sender, EventArgs e)
        {
            if (cboSelectedProject.Text == $"No published projects in '{_publishedProjectsPath}'")
            {
                return;
            }

            string projectPackagePath = Path.Combine(Folders.GetFolder(FolderType.PublishedFolder), cboSelectedProject.Text);

            if (!File.Exists(projectPackagePath))
            {
                MessageBox.Show($"Unable to find '{projectPackagePath}' in Published directory", "Error");
                return;
            }

            string newProjectPath = Path.Combine(Folders.GetFolder(FolderType.TempFolder), Path.GetFileNameWithoutExtension(cboSelectedProject.Text));

            if (Directory.Exists(newProjectPath))
            {
                Directory.Delete(newProjectPath, true);
            }

            try
            {
                Directory.CreateDirectory(newProjectPath);
                File.Copy(projectPackagePath, Path.Combine(Folders.GetFolder(FolderType.TempFolder), cboSelectedProject.Text), true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
                return;
            }

            string  configPath;
            string  projectPath;
            Project project;

            try
            {
                configPath  = Project.ExtractGalleryProject(newProjectPath);
                projectPath = Directory.GetParent(configPath).ToString();
                project     = Project.OpenProject(configPath);
            }
            catch (Exception ex)
            {
                Directory.Delete(newProjectPath, true);
                MessageBox.Show(ex.Message, "Error");
                return;
            }

            switch (project.ProjectType)
            {
            case ProjectType.OpenBots:
                var projectName = new DirectoryInfo(projectPath).Name;
                //initialize Logger
                Logger engineLogger = null;
                switch (_appSettings.EngineSettings.LoggingSinkType)
                {
                case SinkType.File:
                    if (string.IsNullOrEmpty(_appSettings.EngineSettings.LoggingValue.Trim()))
                    {
                        _appSettings.EngineSettings.LoggingValue = Path.Combine(Folders.GetFolder(FolderType.LogFolder), "OpenBots Engine Logs.txt");
                    }

                    engineLogger = new LoggingMethods().CreateFileLogger(_appSettings.EngineSettings.LoggingValue, Serilog.RollingInterval.Day,
                                                                         _appSettings.EngineSettings.MinLogLevel);
                    break;

                case SinkType.HTTP:
                    engineLogger = new LoggingMethods().CreateHTTPLogger(projectName, _appSettings.EngineSettings.LoggingValue, _appSettings.EngineSettings.MinLogLevel);
                    break;
                }

                frmScriptEngine newEngine = new frmScriptEngine(configPath, engineLogger);
                newEngine.ShowDialog();
                newEngine.Dispose();
                break;

            case ProjectType.Python:
            case ProjectType.TagUI:
            case ProjectType.CSScript:
            case ProjectType.PowerShell:
                await ExecutionManager.RunTextEditorProject(configPath, project.ProjectArguments);

                break;
            }

            if (Directory.Exists(newProjectPath))
            {
                Directory.Delete(newProjectPath, true);
            }
        }