public Task UpdateAsync( TaskAttribute attribute, Dictionary <string, string> headers = default, CancellationToken ct = default) { return(_factory.PatchAsync(_host + "/Tasks/Attributes/v1/Update", null, attribute, headers, ct)); }
public virtual TaskAttributeValueModel PrepareTaskAttributeValueModel(TaskAttributeValueModel model, TaskAttribute taskAttribute, TaskAttributeValue taskAttributeValue, bool excludeProperties = false) { if (taskAttribute == null) { throw new ArgumentNullException(nameof(taskAttribute)); } Action <TaskAttributeValueLocalizedModel, int> localizedModelConfiguration = null; if (taskAttributeValue != null) { //fill in model values from the entity model = model ?? taskAttributeValue.ToModel <TaskAttributeValueModel>(); //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = _localizationService.GetLocalized(taskAttributeValue, entity => entity.Name, languageId, false, false); }; } model.TaskAttributeId = taskAttribute.Id; if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } return(model); }
public virtual TaskAttributeModel PrepareTaskAttributeModel(TaskAttributeModel model, TaskAttribute taskAttribute, bool excludeProperties = false) { Action <TaskAttributeLocalizedModel, int> localizedModelConfiguration = null; if (taskAttribute != null) { //fill in model values from the entity model = model ?? taskAttribute.ToModel <TaskAttributeModel>(); //prepare nested search model PrepareTaskAttributeValueSearchModel(model.TaskAttributeValueSearchModel, taskAttribute); //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = _localizationService.GetLocalized(taskAttribute, entity => entity.Name, languageId, false, false); }; } if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } return(model); }
public override void SetEventDelegate (TaskAttribute tAttribute) { base.SetEventDelegate (tAttribute); tAttribute.eventDelegate.parameters [0].obj = InputField; InputField.value = bool.Parse(tAttribute.Value); InputField.onChange.Add (tAttribute.eventDelegate); }
public async Task <ActionResult <Guid> > Create(TaskAttribute attribute, CancellationToken ct = default) { attribute.AccountId = _userContext.AccountId; var id = await _taskAttributesService.CreateAsync(_userContext.UserId, attribute, ct); return(Created("Get", id)); }
protected virtual void UpdateAttributeLocales(TaskAttribute taskAttribute, TaskAttributeModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(taskAttribute, x => x.Name, localized.Name, localized.LanguageId); } }
public void ShouldReturnDefaultValues() { //Act var result = new TaskAttribute(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(TaskAttribute)); Assert.AreEqual(int.MaxValue, result.PositionInSequence); Assert.AreEqual(0, result.DelayStartBy); Assert.AreEqual(0, result.Group); }
public async Task <ActionResult> Update(TaskAttribute attribute, CancellationToken ct = default) { var oldAttribute = await _taskAttributesService.GetAsync(attribute.Id, true, ct); if (oldAttribute == null) { return(NotFound(attribute.Id)); } return(await ActionIfAllowed( () => _taskAttributesService.UpdateAsync(_userContext.UserId, oldAttribute, attribute, ct), Roles.Tasks, oldAttribute.AccountId)); }
public TaskAttributeBuilder( IDefaultRequestHeadersService defaultRequestHeadersService, ITaskAttributesClient taskAttributesClient) { _taskAttributesClient = taskAttributesClient; _defaultRequestHeadersService = defaultRequestHeadersService; _attribute = new TaskAttribute { Id = Guid.NewGuid(), Type = AttributeType.Text, Key = "Test".WithGuid(), IsDeleted = false }; }
public virtual void DeleteTaskAttribute(TaskAttribute taskAttribute) { if (taskAttribute == null) { throw new ArgumentNullException(nameof(taskAttribute)); } _taskAttributeRepository.Delete(taskAttribute); _cacheManager.RemoveByPattern(GSTaskServiceDefaults.TaskAttributesPatternCacheKey); _cacheManager.RemoveByPattern(GSTaskServiceDefaults.TaskAttributeValuesPatternCacheKey); //event notification _eventPublisher.EntityDeleted(taskAttribute); }
private void spawnPrefab(TaskAttribute ta){ switch (ta.AttributeType) { case TaskAttributeType.STRING: spawnPrefab(StringPrefab).SetEventDelegate(ta); break; case TaskAttributeType.FLOAT: spawnPrefab(FloatPrefab).SetEventDelegate(ta); break; case TaskAttributeType.INT: spawnPrefab(IntPrefab).SetEventDelegate(ta); break; case TaskAttributeType.BOOL: spawnPrefab(BoolPrefab).SetEventDelegate(ta); break; } }
public static TaskAttributeChange CreateWithLog( this TaskAttribute attribute, Guid userId, Action <TaskAttribute> action) { action(attribute); return(new TaskAttributeChange { AttributeId = attribute.Id, ChangerUserId = userId, CreateDateTime = DateTime.UtcNow, OldValueJson = string.Empty, NewValueJson = attribute.ToJsonString() }); }
public void ShouldCreateANewTaskAttribute() { //Act var result = new TaskAttribute { PositionInSequence = 1, DelayStartBy = 500, Group = 1 }; //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(TaskAttribute)); Assert.AreEqual(1, result.PositionInSequence); Assert.AreEqual(500, result.DelayStartBy); Assert.AreEqual(1, result.Group); }
public async Task UpdateAsync( Guid userId, TaskAttribute oldAttribute, TaskAttribute newAttribute, CancellationToken ct) { var change = oldAttribute.UpdateWithLog(userId, x => { x.AccountId = newAttribute.AccountId; x.Type = newAttribute.Type; x.Key = newAttribute.Key; x.ModifyDateTime = DateTime.UtcNow; x.IsDeleted = newAttribute.IsDeleted; }); _storage.Update(oldAttribute); await _storage.AddAsync(change, ct); await _storage.SaveChangesAsync(ct); }
public async Task <Guid> CreateAsync(Guid userId, TaskAttribute attribute, CancellationToken ct) { var newAttribute = new TaskAttribute(); var change = newAttribute.CreateWithLog(userId, x => { x.Id = attribute.Id; x.AccountId = attribute.AccountId; x.Type = attribute.Type; x.Key = attribute.Key; x.IsDeleted = attribute.IsDeleted; x.CreateDateTime = DateTime.UtcNow; }); var entry = await _storage.AddAsync(newAttribute, ct); await _storage.AddAsync(change, ct); await _storage.SaveChangesAsync(ct); return(entry.Entity.Id); }
public async Task WhenCreate_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var attribute = new TaskAttribute { Id = Guid.NewGuid(), Type = AttributeType.Text, Key = "Test".WithGuid(), IsDeleted = false }; var createdAttributeId = await _taskAttributesClient.CreateAsync(attribute, headers); var createdAttribute = await _taskAttributesClient.GetAsync(createdAttributeId, headers); Assert.NotNull(createdAttribute); Assert.Equal(createdAttributeId, createdAttribute.Id); Assert.Equal(attribute.Type, createdAttribute.Type); Assert.Equal(attribute.Key, createdAttribute.Key); Assert.Equal(attribute.IsDeleted, createdAttribute.IsDeleted); Assert.True(createdAttribute.CreateDateTime.IsMoreThanMinValue()); }
/// <summary> /// Generates a task description for the specified task type. /// </summary> /// <param name="taskType"> Task type. </param> /// <returns> Task description. </returns> public static TaskDescription Generate(Type taskType) { // Check for task attribute. TaskAttribute[] taskAttributes = taskType.GetCustomAttributes(typeof(TaskAttribute), true) as TaskAttribute[]; if (taskAttributes == null || taskAttributes.Length == 0) { throw new ArgumentException( "Type {0} doesn't have a task attribute which specifies the class as a behavior tree task.", taskType.Name); } TaskAttribute taskAttribute = taskAttributes[0]; TaskDescription description = new TaskDescription { Name = taskAttribute.Name, Description = taskAttribute.Description, IsDecorator = taskAttribute.IsDecorator, ClassName = taskType.Name, TypeName = taskType.AssemblyQualifiedName, ParameterDescriptions = new List <TaskParameterDescription>() }; MemberInfo[] parameterMembers = taskType.GetMembers(); foreach (MemberInfo parameterMember in parameterMembers) { TaskParameterDescription parameterDescription = TaskParameterDescription.Generate(parameterMember); if (parameterDescription == null) { continue; } description.ParameterDescriptions.Add(parameterDescription); } return(description); }
public virtual TaskAttributeValueListModel PrepareTaskAttributeValueListModel(TaskAttributeValueSearchModel searchModel, TaskAttribute taskAttribute) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (taskAttribute == null) { throw new ArgumentNullException(nameof(taskAttribute)); } var taskAttributeValues = _taskAttributeService.GetTaskAttributeValues(taskAttribute.Id); var model = new TaskAttributeValueListModel { //fill in model values from the entity Data = taskAttributeValues.PaginationByRequestModel(searchModel) .Select(value => value.ToModel <TaskAttributeValueModel>()), Total = taskAttributeValues.Count }; return(model); }
public virtual void SetEventDelegate(TaskAttribute tAttribute){ attributeName.text = tAttribute.AttributeName; }
public override void Awake () { base.Awake (); healthTa = addAttribute ("HP less than:",TaskAttributeType.FLOAT,health.ToString(), "setHP"); info = "HP less than:"+ health; }
public override void Awake () { base.Awake (); distanceTa = addAttribute ("Distance less than:",TaskAttributeType.FLOAT,distance.ToString(), "setDistance"); info = "Distance less than:"; }
public override void Awake () { base.Awake (); waitTimeTa = addAttribute ("WaitTime",TaskAttributeType.FLOAT,WaitTime.ToString(), "setWaitTime"); info = "Wait:"+WaitTime+" sec"; }
public override void Awake () { base.Awake (); messageTa = addAttribute ("Message",TaskAttributeType.STRING,Message, "setMessage"); info = "Out:" + Message; }
public override void Awake () { base.Awake (); info = "HP is equal to:"+ health; healthTa = addAttribute ("HP equals:",TaskAttributeType.FLOAT,health.ToString(), "setHP"); }
protected virtual TaskAttributeValueSearchModel PrepareTaskAttributeValueSearchModel(TaskAttributeValueSearchModel searchModel, TaskAttribute taskAttribute) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (taskAttribute == null) { throw new ArgumentNullException(nameof(taskAttribute)); } searchModel.TaskAttributeId = taskAttribute.Id; //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
public TaskWithInfo(MethodInfo task, TaskAttribute attribute) { this.Task = task; this._attribute = attribute; }
public virtual TaskAttribute addAttribute(string attributeName,TaskAttributeType t,string defaultValue, string functionName){ TaskAttribute ta = new TaskAttribute (attributeName, t, defaultValue, this, functionName); attributes.Add (ta); return ta; }