public override bool Validate(out string message) { try { var ok = true; //IsLoading = true; var task = Task.Run(async() => { var allAttributes = attributeRepository.GetAll(); foreach (var attr in allAttributes) { var initialized = true; var entity = entityRepository.GetById(attr.EntityId.ToString()); var options = attributeRepository.LoadOptions(attr.Id.ToString()); var connection = connectionRepository.GetById(attr.SourceConnectionId.ToString()); var puller = pullers.FirstOrDefault(p => p.IsImplemented(attr.SourceProcessorId, entity.SourceProcessorId, connection.ProviderId)); var indexer = indexers.FirstOrDefault(p => p.IsImplemented(attr.SourceProcessorId, entity.SourceProcessorId, connection.ProviderId)); puller.SetIndex(attr); puller.SetOptions(options.Select(o => new OptionItem { Name = o.Key, Value = o.Value })); initialized = initialized && puller.Initialized(); indexer.SetIndex(attr); indexer.SetOptions(options.Select(o => new OptionItem { Name = o.Key, Value = o.Value })); initialized = initialized && entityRepository.Initialized(attr); ok = ok && initialized; if (!ok) { logger.Information($@"Index ""{entity.Name}"" is not initialized."); break; } } }); task.Wait(); message = "All attributes has been initialized."; logger.Information(message); return(true); } catch (Exception ex) { errorLogger.Error(ex, ex.Message); throw; } finally { //IsLoading = false; } return(true); }
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 IActionResult Get() { var attributes = attributeRepository.GetAll(); var entities = entityRepository.GetByIds(attributes.Select(a => a.EntityId.ToString())); var options = attributeRepository.LoadOptions(attributes.Select(c => c.Id.ToString())); return(Ok(attributes.Select(a => { var jEntity = JObject.FromObject(a, serializer); var entity = entities.FirstOrDefault(e => e.Id == a.EntityId); var templateOpts = new List <OptionItem>(); templateOpts.AddRange(GetPullerTemplateOptions(entity, a)); templateOpts.AddRange(GetPusherTemplateOptions(entity, a)); templateOpts.AddRange(GetIndexerTemplateOptions(entity, a)); var destConnection = connectionRepository.GetById(a.DestinationConnectionId.ToString()); var cOptions = options.Where(o => o.EntityId == a.Id.ToString() && o.EntityType == EntityType.Attribute); var optionItems = new List <OptionItem>(); foreach (var po in templateOpts) { var o = cOptions.FirstOrDefault(oo => oo.Key == po.Name); if (o != null) { po.Value = o.Value; } optionItems.Add(po); } jEntity.Add("options", JArray.FromObject(optionItems, serializer)); return jEntity; }))); }
public void AttributeRepositoryTest() { var repo = new AttributeRepository(factory); var all = repo.GetAll(); var one = repo.Single(x => x.Id == 3); var query = repo.Get(x => x.Family.Contains("Tecno")); }
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)); }); }
public List <CharacterAttribute> GetAll() { return(_attributeRepository.GetAll()); }