public async System.Threading.Tasks.Task EvaluateTask(DNet_DataContracts.Processing.Task task, List <ModuleHubWrapper> modules)
        {
            switch (task.Type)
            {
            case TaskType.Search:
                await SearchTaskContextMiddleware(task);

                break;

            case TaskType.Calculate:
                task.PerformancePoints = (int)task.CalculateContext.ApproximateResultTypeMemoryConsumption;
                break;

            case TaskType.DataRequest:
                task.PerformancePoints = (int)task.DataRequestContext.ApproximateResultTypeMemoryConsumption;
                break;

            default:
                break;
            }



            await Helper.SortByMinDifference(task.PerformancePoints, modules);
        }
Beispiel #2
0
        public override async System.Threading.Tasks.Task SendTask(DNet_DataContracts.Processing.Task task)
        {
            //task = new DNet_DataContracts.Processing.Task
            //{
            //    Id = Guid.NewGuid().ToString(),
            //    Type = TaskType.Search,
            //    ModuleType = "DB, DB_Postgres",
            //    //TestAction = new Action(() =>
            //    //{
            //    //    int x = 60, y = 10;

            //    //    Console.WriteLine(x + y);
            //    //    Console.WriteLine("Hello!");
            //    //})
            //};

            //SearchTaskContext context = new SearchTaskContext
            //{
            //    SearchArea = "user",
            //    ApproximateResultTypeMemoryConsumption = _typeEvaluateService.TypeMemoryConsumptionDictionary["User"]
            //};
            //task.SearchContext = context;


            await base.SendTask(task);
        }
        private void _taskHandlerService_ResultRecieve(DNet_DataContracts.Processing.Task task)
        {
            if (task.IsFinished)
            {
                Console.WriteLine($"Task with ID: \'{task.Id}\' successfully finished");
            }

            SomeThing = (string)task.SearchContext.Result;
            Invoke(StateHasChanged);

            //throw new NotImplementedException();
        }
        private async void PostgreSQLDemonstrationTaskHandlerService_TaskRecieve(DNet_DataContracts.Processing.Task task)
        {
            Console.WriteLine("PSQL Service: " + task.Id);

            if (!task.ModuleType.Contains(_connectionInstance.ModuleType) || task.Type != DNet_DataContracts.Processing.TaskType.Search)
            {
                await _connectionInstance.SendToHub("ModuleUnsupportTaskType", task);

                return;
            }

            SearchTaskContext context = task.SearchContext;

            Type       type = null;
            IQueryable queryable;

            switch (context.SearchArea)
            {
            case "user":
                type = typeof(User);
                //queryable = _context.Users.Where(context.SearchExpression);
                break;

            case "news":
                type = typeof(News);
                break;

            default:
                break;
            }

            if (type == null)
            {
                await _connectionInstance.SendToHub("ModuleUnsupportTaskType", task);

                return;
            }

            task.IsFinished           = true;
            task.SearchContext.Result = "Scope from DB";

            await _connectionInstance.SendToHub("TaskResult", task);

            //ParameterExpression usedType = Expression.Parameter(type, context.SearchAlias);

            //LambdaExpression e = DynamicExpressionParser.ParseLambda(new ParameterExpression[] { usedType }, null, context.SearchExpression);
        }
        public async System.Threading.Tasks.Task SearchTaskContextMiddleware(DNet_DataContracts.Processing.Task task)
        {
            task.PerformancePoints = (int)task.SearchContext.ApproximateResultTypeMemoryConsumption;

            if (task.SearchContext.SearchArea.ToLower().Contains("sql"))                                    //Detecting direct sql querry
            {
                task.PerformancePoints += (int)(70 * (task.SearchContext.SearchExpression.Length / 100.0)); //add 70% of lenght

                task.PerformancePoints += await Helper.AccountingBrackets(task.SearchContext.SearchExpression);
            }
            else
            {
                task.PerformancePoints += task.SearchContext.SearchExpression.Length;

                task.PerformancePoints += await Helper.AccountingBrackets(task.SearchContext.SearchExpression);
            }
        }
        internal string GetTaskStatus(DNet_DataContracts.Processing.Task task)
        {
            string res = string.Empty;

            if (task.IsFinished)
            {
                res = "Завершена";
            }
            else if (task.IsExecuting)
            {
                res = "Выполняется";
            }
            else if (task.IsCanceled)
            {
                res = "Отменена";
            }
            else
            {
                res = "Не найден исполнитель";
            }

            return(res);
        }
        internal async void SendTask()
        {
            //DNet_DataContracts.Processing.Task task = new DNet_DataContracts.Processing.Task
            //{
            //    Id = Guid.NewGuid().ToString(),
            //    Type = TaskType.Search,
            //    ModuleType = "DB, DB_Postgres"
            //};

            //SearchTaskContext context = new SearchTaskContext
            //{
            //    SearchAlias = "user"
            //};
            //task.SearchContext = context;

            var task = new DNet_DataContracts.Processing.Task
            {
                Id         = Guid.NewGuid().ToString(),
                Type       = TaskType.Search,
                ModuleType = TaskModuleTypes
            };

            SearchTaskContext context = new SearchTaskContext
            {
                SearchArea = "user"
            };

            if (uITypeEvaluateService.TypeMemoryConsumptionDictionary.TryGetValue("User", out long temp))
            {
                context.ApproximateResultTypeMemoryConsumption = temp;
            }

            task.SearchContext = context;

            await _taskHandlerService.SendTask(task);
        }
 public async System.Threading.Tasks.Task TaskEvaluate(Task task)
 {
     int _performancePoints = 0;
 }
 private void _connectionInstance_TaskRecieve(DNet_DataContracts.Processing.Task task)
 {
     //throw new NotImplementedException();
     Console.WriteLine("PSQL 11 Service: " + task.Id);
 }
Beispiel #10
0
 private void UITaskHandlerService_ResultRecieve(DNet_DataContracts.Processing.Task task)
 {
     ResultRecieve?.Invoke(task);
 }