예제 #1
0
            internal JobContext(CommandLineSandbox shell, CancellationToken cancellationToken, ProgressViewModel progress, HistoryEventVM eventVM, OutputVM output)
            {
                Shell             = shell;
                Progress          = progress;
                OutputVM          = output;
                CancellationToken = cancellationToken;
                Information       = new T();
                DbConnection      = AppDataManager.ConnectToSqlite();

                try
                {
                    HistoryVM = eventVM;
                    eventVM.Insert(DbConnection);
                    if (!HistoryVM.ID.HasValue)
                    {
                        throw new InvalidOperationException("No ID obtained for Job from DB.");
                    }

                    string logPath = AppDataManager.GetLogFilePath(HistoryVM.ID.Value);
                    output.Cls();
                    output.StartWritingLog(logPath);
                }
                catch (Exception e)
                {
                    log.ErrorFormat($"Exception while trying to setup context for command '{eventVM.Command}': {e.Message}");
                    DbConnection.Dispose();
                    throw;
                }
            }
예제 #2
0
        internal static OperationResult Bootstrap(CancellationToken cancellationToken, ProgressViewModel progress, string path, string stream, HistoryVM history)
        {
            if (string.IsNullOrEmpty(path) || !Directory.Exists(path) || string.IsNullOrEmpty(stream))
            {
                return(OperationResult.Failed);
            }

            var shell = new CommandLineSandbox(path);
            var vm    = history.CreateHistoryEvent();

            vm.Command = "bentleybootstrap.py " + stream;
            vm.JobName = "Bootstrap";
            vm.Stream  = stream;
            vm.SrcDir  = path;

            var context = new JobContext <BootstrapInfo>(shell, cancellationToken, progress, vm, history?.Parent?.OutputVM);

            return(Execute(context, ProcessBootstrapOutput));
        }
예제 #3
0
        public static CommandLineSandbox SetupEnv(string src, string outPath, string strategy, string title, bool debug, params string[] commands)
        {
            CommandLineSandbox cmd = null;

            if (!Directory.Exists(src))
            {
                throw new InvalidOperationException($"Cannot setup env because directory {src} does not exist.");
            }

            try
            {
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }

                cmd = new CommandLineSandbox(src);
                foreach (var line in GetSetupEnvScript(src, outPath, strategy, title, debug, false, commands))
                {
                    if (!cmd.ExecuteCommand(line).Success)
                    {
                        throw new UserfriendlyException("Failed to set-up environment. The following command failed: " + line);
                    }
                }
            }
            catch (Exception)
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }

                throw;
            }

            return(cmd);
        }