示例#1
0
        private static void SimulateAccountProcessing(ICommandBus commandBus, IQueryProcessor queryProcessor)
        {
            for (int y = 0; y < 10; y++)
            {
                var newAccountId  = Guid.NewGuid();
                var createAccount = new CreateAccount(newAccountId, "Omar", @"Besiso", "ThoughtDesign",
                                                      RandomGenerator.GenerateRandomEmail());

                try
                {
                    commandBus.Send(createAccount);

                    //Simulate 2 snapshots
                    for (var i = 0; i < 10; i++)
                    {
                        var updateAccount = new UpdateAccountAddress(newAccountId, $"Test {i}", null, null, null, null,
                                                                     "Australia");
                        commandBus.Send(updateAccount);
                    }

                    var approveAccount = new ApproveAccount(newAccountId, "Omar Besiso");
                    commandBus.Send(approveAccount);

                    var deleteAccount = new DeleteAccount(newAccountId, "Testing");
                    commandBus.Send(deleteAccount);

                    var reinstateAccount = new ReinstateAccount(newAccountId);
                    commandBus.Send(reinstateAccount);

                    var query    = new GetAccountDetailsById(newAccountId);
                    var response = queryProcessor.ProcessQuery <GetAccountDetailsById, GetAccountDetailsByIdResponse>(query);

                    Console.WriteLine(response.AccountDetailsDto.AccountId);
                    Console.WriteLine(response.AccountDetailsDto.BusinessName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#2
0
        public ActionResult ProcessDataTableRequest(JQueryDataTableParams dataTablesParam, FilterScaffoldModel <Document> filters)
        {
            // Profule the Document Querying functionality using mini profiler
            var profiler = MiniProfiler.Current;

            // Get the query params and process the query for the document queryable
            var queryParams = _documentParamsProcessor.ProcessParameters(dataTablesParam, filters);

            // Get and Profile the Documents Queryable collection
            var documents = _documentRepository.ReadAllAsQueryable();
            QueryResult <Document> queryProcessResult;

            using (profiler.Step("Document Query Processing"))
            {
                queryProcessResult = _documentQueryProcessor.ProcessQuery(documents, queryParams);
            }

            // Get and Profile The execution of the queryable collection for documents
            List <Document> queriedDocuments;

            using (profiler.Step("Document Query Execution"))
            {
                queriedDocuments = queryProcessResult.ProcessedData.ToList();
            }

            var mappedDocuments = queriedDocuments.Select(Mapper.Map <AdminDocumentGridViewModel>).ToList();

            JQueryDataTableResult jQueryResult = new JQueryDataTableResult()
            {
                aaData = mappedDocuments,
                iTotalDisplayRecords = queryProcessResult.FilteredCount,
                iTotalRecords        = queryProcessResult.TotalCount,
                sEcho = dataTablesParam.sEcho
            };

            return(Json(jQueryResult, JsonRequestBehavior.AllowGet));
        }
示例#3
0
文件: ICrawler.cs 项目: pierewoj/Zeus
 public Option <PageCrawlResult> Crawl(CrawlablePage page)
 {
     _logger.LogInformation($"Crawling page {page.Uri}");
     try
     {
         var uri           = new Uri(page.Uri);
         var contentOption = _queryProcessor.ProcessQuery(uri);
         return(contentOption.Match(content =>
         {
             var links = _linksExtractor.ExtractLinks(content);
             return new PageCrawlResult()
             {
                 Html = content,
                 Url = page.Uri.ToString(),
                 TimeCrawled = DateTime.Now.ToString(CultureInfo.InvariantCulture)
             };
         }, () => Option <PageCrawlResult> .None));
     }
     catch (Exception ex)
     {
         _logger.LogError(0, ex, $"Exception when crawling page {page.Uri}");
         return(Option <PageCrawlResult> .None);
     }
 }
示例#4
0
 public IEnumerable <CanItemDto> GetStock()
 {
     return(_queryProcessor.ProcessQuery <GetAllStock, GetAllStockResponse>(new GetAllStock()).CanItemsDto);
 }
示例#5
0
        protected virtual SchedulePostProcessingAction ProcessLocalServiceSource(ScheduledItem scheduledItem, Activity activity,
                                                                                 string transactionId)
        {
            DataService dataService =
                ServiceManager.ValidateDataService(scheduledItem.SourceId, ServiceType.QueryOrSolicitOrExecuteOrTask);

            // Load the service plugin
            ISolicitProcessor            solicitPlugin = null;
            IQueryProcessor              queryPlugin   = null;
            IExecuteProcessor            executePlugin = null;
            ITaskProcessor               taskPlugin    = null;
            IPluginDisposer              disposer;
            string                       flowName = FlowManager.GetDataFlowNameById(dataService.FlowId);
            RequestType                  requestType;
            SchedulePostProcessingAction postProcessingAction = SchedulePostProcessingAction.ContinueNormally;

            try
            {
                if ((dataService.Type & ServiceType.Task) == ServiceType.Task)
                {
                    disposer    = PluginLoader.LoadTaskProcessor(dataService, out taskPlugin);
                    requestType = RequestType.Task;
                }
                else if ((dataService.Type & ServiceType.Execute) == ServiceType.Execute)
                {
                    disposer    = PluginLoader.LoadExecuteProcessor(dataService, out executePlugin);
                    requestType = RequestType.Execute;
                }
                else if ((dataService.Type & ServiceType.Solicit) == ServiceType.Solicit)
                {
                    disposer    = PluginLoader.LoadSolicitProcessor(dataService, out solicitPlugin);
                    requestType = RequestType.Solicit;
                }
                else
                {
                    disposer    = PluginLoader.LoadQueryProcessor(dataService, out queryPlugin);
                    requestType = RequestType.Query;
                }
            }
            catch (Exception e)
            {
                throw new NotImplementedException(string.Format("Failed to load the service \"{0}\" for the scheduled item \"{1}\"",
                                                                dataService.Name, scheduledItem.Name), e);
            }
            using (disposer)
            {
                string requestId =
                    RequestManager.CreateDataRequest(transactionId, dataService.Id, 0, -1,
                                                     requestType, activity.ModifiedById,
                                                     scheduledItem.SourceArgs);

                if (taskPlugin != null)
                {
                    LogActivity(activity, "Calling ProcessTask()");
                    try
                    {
                        ITaskProcessorEx taskPluginEx = taskPlugin as ITaskProcessorEx;
                        if (taskPluginEx != null)
                        {
                            postProcessingAction = taskPluginEx.ProcessTask(requestId, scheduledItem.Id);
                        }
                        else
                        {
                            taskPlugin.ProcessTask(requestId);
                        }
                    }
                    finally
                    {
                        activity.Append(taskPlugin.GetAuditLogEvents());
                    }
                    LogActivity(activity, "Called ProcessTask()");
                }
                else if (executePlugin != null)
                {
                    LogActivity(activity, "Calling ProcessExecute()");
                    ExecuteContentResult result;
                    try
                    {
                        result = executePlugin.ProcessExecute(requestId);
                    }
                    finally
                    {
                        activity.Append(executePlugin.GetAuditLogEvents());
                    }
                    if (result.Content != null)
                    {
                        _documentManager.AddDocument(transactionId, result);
                    }
                    LogActivity(activity, "Called ProcessExecute()");
                }
                else if (solicitPlugin != null)
                {
                    LogActivity(activity, "Calling ProcessSolicit()");
                    try
                    {
                        solicitPlugin.ProcessSolicit(requestId);
                    }
                    finally
                    {
                        activity.Append(solicitPlugin.GetAuditLogEvents());
                    }
                    LogActivity(activity, "Called ProcessSolicit()");
                }
                else
                {
                    LogActivity(activity, "Calling ProcessQuery()");
                    PaginatedContentResult result;
                    try
                    {
                        result = queryPlugin.ProcessQuery(requestId);
                    }
                    finally
                    {
                        activity.Append(queryPlugin.GetAuditLogEvents());
                    }
                    LogActivity(activity, "Called ProcessQuery()");
                }
            }
            return(postProcessingAction);
        }
        public async Task <GetTestResponse> GetTest(Guid testId)
        {
            var query = new GetTest(testId);

            return(await _queryProcessor.ProcessQuery <GetTest, GetTestResponse>(query));
        }
 public PaymentBalanceDto GetPaymentBalance()
 {
     return(_queryProcessor
            .ProcessQuery <GetBalance, GetBalanceResponse>(new GetBalance()).PaymentBalance);
 }