コード例 #1
0
ファイル: Executor.cs プロジェクト: Cliveburr/BlueDB
        public Executor(ProcessContext processContext)
        {
            ProcessContext = processContext;
            Results        = new List <IResults>();

            Task.Run(new Action(Execute));
        }
コード例 #2
0
 public void ScheduleToProcess(ProcessContext request)
 {
     lock (_processLock)
     {
         _processQueue.Add(request);
         RunNextRequest();
     }
 }
コード例 #3
0
ファイル: Executor.cs プロジェクト: Cliveburr/BlueDB
        private void FinishExecute()
        {
            var response = new MessageReponse
            {
                Id      = ProcessContext.Request.Id,
                Results = Results.ToArray(),
                Error   = _error?.Message
            };

            ProcessContext.Callback(response);

            ExecutorController.Instance.ReleaseExecutor(this);
        }
コード例 #4
0
ファイル: PreProcess.cs プロジェクト: Cliveburr/BlueDB
        public void Compute(ProcessContext context)
        {
            var hasTransactionCommand = false;

            var tablesToRead = new List <string>();
            var tablesToLock = new List <string>();
            var withDatabase = string.Empty;
            var withTable    = string.Empty;

            foreach (var command in context.Request.Commands)
            {
                switch (command.Type)
                {
                case CommandType.WithDatabase:
                    withDatabase = ((WithDatabaseCommand)command).DatabaseName;
                    break;

                case CommandType.WithTable:
                    withTable = ((WithTableCommand)command).TableName;
                    break;

                case CommandType.Set:
                    tablesToLock.Add($"{withDatabase}.{withTable}");
                    break;

                case CommandType.OpenTransaction:
                case CommandType.CommitTransaction:
                case CommandType.RollbackTransaction:
                    hasTransactionCommand = true;
                    break;
                }
            }

            context.TablesToRead = tablesToRead.ToArray();
            context.TablesToLock = tablesToLock.ToArray();

            var containsTransaction = context.Connection.ContainsItemInBag("Transaction");

            if (!hasTransactionCommand && !containsTransaction)
            {
                CreateVirtualTransaction(context);
            }
        }
コード例 #5
0
ファイル: PreProcess.cs プロジェクト: Cliveburr/BlueDB
        private void CreateVirtualTransaction(ProcessContext context)
        {
            var listCommands = context.Request.Commands
                               .ToList();

            listCommands
            .Insert(0, new OpenTransactionCommand
            {
                IsVirtual = true
            });

            listCommands
            .Add(new CommitTransactionCommand
            {
                IsVirtual = true
            });

            context.Request.Commands = listCommands
                                       .ToArray();
        }