コード例 #1
0
 public IEnumerable<string> GetFilterTaskResult(DraftFilterTaskDto draftFilterTask)
 {
     using (var context = RepositoryContext.Create())
     {
         var repository = context.GetRepository<DraftFilterTaskRepository>();
         var filtertask = repository.Get(draftFilterTask.Id);
         return filtertask.Result.ConditionResult.SelectedStocks.ToArray();
     }
 }
コード例 #2
0
 public void ExecFilterTaskImmediatly(DraftFilterTaskDto draftFilterTaskDto)
 {
     using (var context = RepositoryContext.Create())
     {
         var repository = context.GetRepository<DraftFilterTaskRepository>();
         var filtertask = repository.Get(draftFilterTaskDto.Id);
         _engine.ExecFilterTaskImmediatly(filtertask);
     }
 }
コード例 #3
0
 public void UpdateDraftFilterTask(DraftFilterTaskDto draftFilterTask)
 {
     using (var context = RepositoryContext.Create())
     {
         var filtertask = draftFilterTask.ProjectedAs<DraftFilterTask>();
         var repository = context.GetRepository<DraftFilterTaskRepository>();
         repository.UpdateFilterTask(filtertask);
         context.UnitOfWork.Commit();
     }
 }
コード例 #4
0
 public void AddDraftFilterTask(DraftFilterTaskDto draftFilterTask, int userId)
 {
     using (var context = RepositoryContext.Create())
     {
         var filtertask = ConvertNew(draftFilterTask, userId);
         var repository = context.GetRepository<DraftFilterTaskRepository>();
         repository.Add(filtertask);
         context.UnitOfWork.Commit();
     }
 }
コード例 #5
0
        public void AddDraftFilterTaskTest()
        {
            var taskdto = new DraftFilterTaskDto
                {
                    Name = "DraftTask",
                    Condition = new FilterConditionDto
                    {
                        Name = "DraftTaskConditon",
                        ExpressionString = "成交量>100",
                        Indicators = new List<IndicatorDto> { new IndicatorDto { Name = "成交量" } }
                    }
                };
            var service = new FilterTaskAppService();
            service.AddDraftFilterTask(taskdto, 0);

            using (var context = RepositoryContext.Create())
            {
                var repository = context.GetRepository<DraftFilterTaskRepository>();
                var task = repository.GetAll().FirstOrDefault();
                Assert.IsNotNull(task);
            }
        }
コード例 #6
0
 private DraftFilterTask ConvertNew(DraftFilterTaskDto draftFilterTask, int userId)
 {
     var idgenerator = ContainerHelper.Instance.Resolve<IIdentityGenerator>();
     var filtertask = draftFilterTask.ProjectedAs<DraftFilterTask>();
     var conditionid = idgenerator.NewGuid().ToString();
     var expression = new FilterExpression(conditionid, filtertask.Condition.Expression.ExpressionString, null);
     expression.UpdateFrom(filtertask.Condition.Expression);
     return new DraftFilterTask(idgenerator.NewGuid().ToString())
         {
             Name = filtertask.Name,
             Condition = new FilterCondition(conditionid, userId, expression)
                 {
                     Name = filtertask.Condition.Name,
                     Description = filtertask.Condition.Description,
                     CutoffTime = filtertask.Condition.CutoffTime
                 }
         };
 }
コード例 #7
0
        public void GetAllDraftFilterTasksTest()
        {
            var taskdto = new DraftFilterTaskDto
                {
                    Name = "DraftTask",
                    Condition = new FilterConditionDto
                    {
                        Name = "DraftTaskConditon",
                        ExpressionString = "成交量>100",
                        Indicators = new List<IndicatorDto> { new IndicatorDto { Name = "成交量" } }
                    }
                };
            var service = new FilterTaskAppService();
            service.AddDraftFilterTask(taskdto, 0);

            var tasks = service.GetAllDraftFilterTasks(0).ToList();
            Assert.IsNotNull(tasks);
            Assert.AreEqual(1, tasks.Count);
        }