Beispiel #1
0
        public override void Build(IWorkflowBuilder <object> builder)
        {
            builder.StartWith(x => { })
            .While(d => true)
            .Do(x =>
            {
                IEnumerable <IIndexModel> indexes = null;
                //if ((Mode & WorkflowMode.Test) > 0 && IndexModel != null)
                //{
                //    indexes = new List<IIndexModel> { IndexModel };
                //}
                //else
                //{
                //    var scheduleOptions = scheduleOptionRepository
                //     .GetByWorkflow(Id)
                //     .Where(o => o.IsParallel && o.Enabled);
                //    var entities = entityRepository
                //        .GetAll()
                //        .Where(e => e.Enabled && scheduleOptions.Any(o => o.TargetEntityId == e.Id && o.TargetEntityType == e.EntityType));
                //    var attributes = attributeRepository
                //        .GetAll()
                //        .Where(e => e.Enabled && scheduleOptions.Any(o => o.TargetEntityId == e.Id && o.TargetEntityType == e.EntityType));
                //    indexes = entities
                //        .Select(e => e as IIndexModel)
                //        .Union(attributes.Select(a => a as IIndexModel));
                //}

                /**
                 * WORKFLOW is pre-built, we can only test via settings Enable/Disable in the form
                 **/
                var scheduleOptions = scheduleOptionRepository
                                      .GetByWorkflow(Id)
                                      .Where(o => o.IsParallel && o.Enabled);
                var entities = entityRepository
                               .GetAll()
                               .Where(e => e.Enabled && scheduleOptions.Any(o => o.TargetEntityId == e.Id && o.TargetEntityType == e.EntityType));
                var attributes = attributeRepository
                                 .GetAll()
                                 .Where(e => e.Enabled && scheduleOptions.Any(o => o.TargetEntityId == e.Id && o.TargetEntityType == e.EntityType));
                indexes = entities
                          .Select(e => e as IIndexModel)
                          .Union(attributes.Select(a => a as IIndexModel));
                if (indexes.Count() <= 0)
                {
                    x.StartWith(c => { })
                    .Delay(d => TimeSpan.FromMinutes(10));
                }
                else
                {
                    x.StartWith(s => { })
                    .ForEach(ff => indexes)
                    .Do(dd =>
                    {
                        dd.StartWith <UpdateIndexChangesStep>()
                        .Input(s => s.IndexModel, (d, ctx) => ctx.Item);
                    })
                    .Delay(d => TimeSpan.FromSeconds(1));
                }
            });
        }
 public override void Build(IWorkflowBuilder <object> builder)
 {
     builder.StartWith(x => { })
     .While(d => true)
     .Do(x =>
     {
         var scheduleOptions = scheduleOptionRepository
                               .GetByWorkflow(Id)
                               .Where(o => o.Enabled);
         var entities = entityRepository
                        .GetAll()
                        .Where(e => e.Enabled && scheduleOptions.Any(o => o.TargetEntityId == e.Id && o.TargetEntityType == e.EntityType));
         var attributes = attributeRepository
                          .GetAll()
                          .Where(e => e.Enabled && scheduleOptions.Any(o => o.TargetEntityId == e.Id && o.TargetEntityType == e.EntityType));
         var indexes = entities
                       .Select(e => e as IIndexModel)
                       .Union(attributes.Select(a => a as IIndexModel));
         if (indexes == null || indexes.Count() <= 0)
         {
             x.StartWith(c => { })
             .Delay(d => TimeSpan.FromMinutes(10));
         }
         IStepBuilder <object, QueueIndexChangesStep> ip = null;
         foreach (var i in indexes)
         {
             if (ip == null)
             {
                 ip = x.StartWith <QueueIndexChangesStep>()
                      .Input(s => s.IndexModel, d => i);
             }
             else
             {
                 ip = ip.Then <QueueIndexChangesStep>()
                      .Input(s => s.IndexModel, d => i);
             }
         }
         ip?.Delay(d => TimeSpan.FromSeconds(5));
     });
 }