public IEnumerable<string> GetFilterTaskResult(ScheduledFilterTaskDto scheduledFilterTask)
 {
     using (var context = RepositoryContext.Create())
     {
         var repository = context.GetRepository<DraftFilterTaskRepository>();
         var filtertask = repository.Get(scheduledFilterTask.Id);
         return filtertask.Result.ConditionResult.SelectedStocks.ToArray();
     }
 }
 public void ExecFilterTaskImmediatly(ScheduledFilterTaskDto scheduledFilterTaskDto)
 {
     using (var context = RepositoryContext.Create())
     {
         var repository = context.GetRepository<ScheduledFilterTaskRepository>();
         var filtertask = repository.Get(scheduledFilterTaskDto.Id);
         _engine.ExecFilterTaskImmediatly(filtertask);
     }
 }
 public void AddScheduledFilterTask(ScheduledFilterTaskDto scheduledFilterTask, int userId)
 {
     using (var context = RepositoryContext.Create())
     {
         var filtertask = ConvertNew(scheduledFilterTask, userId);
         var repository = context.GetRepository<ScheduledFilterTaskRepository>();
         repository.Add(filtertask);
         context.UnitOfWork.Commit();
     }
 }
        public void AddScheduledFilterTaskTest()
        {
            var taskdto = new ScheduledFilterTaskDto
                {
                    Name = "ScheduledFilterTask",
                    ScheduleExecTime = DateTime.Now,
                    ScheduleRepeat = "OpenDay",
                    Condition = new FilterConditionDto
                    {
                        Name = "ScheduledFilterTaskConditon",
                        ExpressionString = "成交量>100",
                        Indicators = new List<IndicatorDto> { new IndicatorDto { Name = "成交量" } }
                    }
                };
            var service = new FilterTaskAppService();
            service.AddScheduledFilterTask(taskdto, 0);

            using (var context = RepositoryContext.Create())
            {
                var repository = context.GetRepository<ScheduledFilterTaskRepository>();
                var task = repository.GetAll().FirstOrDefault();
                Assert.IsNotNull(task);
            }
        }
 private FilterSchedule Convert(ScheduledFilterTaskDto scheduledFilterTask)
 {
     var repeat = (FilterTaskRepeat)Enum.Parse(typeof(FilterTaskRepeat), scheduledFilterTask.ScheduleRepeat);
     return new FilterSchedule { ExecTime = scheduledFilterTask.ScheduleExecTime, Repeat = repeat };
 }
 public void UpdateScheduledFilterTask(ScheduledFilterTaskDto scheduledFilterTask)
 {
     using (var context = RepositoryContext.Create())
     {
         var filtertask = scheduledFilterTask.ProjectedAs<ScheduledFilterTask>();
         var repository = context.GetRepository<ScheduledFilterTaskRepository>();
         repository.UpdateFilterTask(filtertask);
         context.UnitOfWork.Commit();
     }
 }
 private ScheduledFilterTask ConvertNew(ScheduledFilterTaskDto scheduledFilterTask, int userId)
 {
     var idgenerator = ContainerHelper.Instance.Resolve<IIdentityGenerator>();
     var filtertask = scheduledFilterTask.ProjectedAs<ScheduledFilterTask>();
     var conditionid = idgenerator.NewGuid().ToString();
     var expression = new FilterExpression(conditionid, filtertask.Condition.Expression.ExpressionString, null);
     expression.UpdateFrom(filtertask.Condition.Expression);
     return new ScheduledFilterTask(idgenerator.NewGuid().ToString(), filtertask.Schedule)
         {
             Name = filtertask.Name,
             Condition = new FilterCondition(conditionid, userId, expression)
                 {
                     Name = filtertask.Condition.Name,
                     Description = filtertask.Condition.Description,
                     CutoffTime = filtertask.Condition.CutoffTime
                 }
         };
 }
        public void GetAllScheduledFilterTasksTest()
        {
            var taskdto = new ScheduledFilterTaskDto
                {
                    Name = "ScheduledFilterTask",
                    ScheduleExecTime = DateTime.Now,
                    ScheduleRepeat = "OpenDay",
                    Condition = new FilterConditionDto
                    {
                        Name = "ScheduledFilterTaskConditon",
                        ExpressionString = "成交量>100",
                        Indicators = new List<IndicatorDto> { new IndicatorDto { Name = "成交量" } }
                    }
                };
            var service = new FilterTaskAppService();
            service.AddScheduledFilterTask(taskdto, 0);

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