private void RemoveIconToolStripMenuItem_Click(object sender, EventArgs e) { Rule.Icon = null; UpdateRule?.Invoke(this, Rule); SetPictureBoxImage(); RaiseHideForm(); }
public async Task CanUpdate_should_throw_exception_if_action_and_trigger_are_null() { var command = new UpdateRule(); await ValidationAssert.ThrowsAsync(() => GuardRule.CanUpdate(command, appId.Id, appProvider), new ValidationError("Either trigger or action is required.", "Trigger", "Action")); }
public static Task CanUpdate(UpdateRule command, Guid appId, IAppProvider appProvider) { Guard.NotNull(command, nameof(command)); return(Validate.It(() => "Cannot update rule.", async error => { if (command.Trigger == null && command.Action == null) { error(new ValidationError("Either trigger or action is required.", nameof(command.Trigger), nameof(command.Action))); } if (command.Trigger != null) { var errors = await RuleTriggerValidator.ValidateAsync(appId, command.Trigger, appProvider); errors.Foreach(error); } if (command.Action != null) { var errors = await RuleActionValidator.ValidateAsync(command.Action); errors.Foreach(error); } })); }
public void Handle(UpdateRule command) { var company = _repository.Get(command.CompanyId); company.UpdateRule(command.RuleId, command.Name, command.Message, command.ZoneList, command.ZoneRequired, command.ExcludeCircularZone, command.ExcludedCircularZoneLatitude, command.ExcludedCircularZoneLongitude, command.ExcludedCircularZoneRadius, command.AppliesToCurrentBooking, command.AppliesToFutureBooking, command.AppliesToPickup, command.AppliesToDropoff, command.DaysOfTheWeek, command.StartTime, command.EndTime, command.ActiveFrom, command.ActiveTo, command.Priority, command.IsActive, command.Market, command.DisableFutureBookingOnError); _repository.Save(company, command.Id.ToString()); }
public void Update_should_create_events() { var newTrigger = new ContentChangedTrigger { Schemas = new List <ContentChangedTriggerSchema>() }; var newAction = new WebhookAction { Url = new Uri("https://squidex.io/v2") }; CreateRule(); var command = new UpdateRule { Trigger = newTrigger, Action = newAction }; sut.Update(CreateRuleCommand(command)); sut.GetUncomittedEvents() .ShouldHaveSameEvents( CreateRuleEvent(new RuleUpdated { Trigger = newTrigger, Action = newAction }) ); }
public static Task CanUpdate(UpdateRule command, ISchemaProvider schemas) { Guard.NotNull(command, nameof(command)); return(Validate.It(() => "Cannot update rule.", async error => { if (command.Trigger == null && command.Action == null) { error(new ValidationError("Either trigger or action must be defined.", nameof(command.Trigger), nameof(command.Action))); } if (command.Trigger != null) { var errors = await RuleTriggerValidator.ValidateAsync(command.Trigger, schemas); errors.Foreach(error); } if (command.Action != null) { var errors = await RuleActionValidator.ValidateAsync(command.Action); errors.Foreach(error); } })); }
public static Task CanUpdate(UpdateRule command, Guid appId, IAppProvider appProvider, Rule rule) { Guard.NotNull(command); return(Validate.It(() => "Cannot update rule.", async e => { if (command.Trigger == null && command.Action == null && command.Name == null) { e(Not.Defined("Either trigger, action or name"), nameof(command.Trigger), nameof(command.Action)); } if (command.Trigger != null) { var errors = await RuleTriggerValidator.ValidateAsync(appId, command.Trigger, appProvider); errors.Foreach(x => x.AddTo(e)); } if (command.Action != null) { var errors = command.Action.Validate(); errors.Foreach(x => x.AddTo(e)); } if (command.Name != null && string.Equals(rule.Name, command.Name)) { e(Not.New("Rule", "name"), nameof(command.Name)); } })); }
public void Update_should_create_events() { var newTrigger = new ContentChangedTrigger { Schemas = ImmutableList <ContentChangedTriggerSchema> .Empty }; var newAction = new WebhookAction { Url = new Uri("https://squidex.io/v2") }; CreateRule(); var command = new UpdateRule { Trigger = newTrigger, Action = newAction }; sut.Update(CreateRuleCommand(command)); Assert.Same(newTrigger, sut.State.RuleDef.Trigger); Assert.Same(newAction, sut.State.RuleDef.Action); sut.GetUncomittedEvents() .ShouldHaveSameEvents( CreateRuleEvent(new RuleUpdated { Trigger = newTrigger, Action = newAction }) ); }
public async Task CanUpdate_should_not_throw_exception_if_rule_has_already_this_name() { var command = new UpdateRule { Name = "MyName" }; await GuardRule.CanUpdate(command, Rule(), appProvider); }
private void deleteRule_Click(object sender, RoutedEventArgs e) { var rule = (Rule)listRules.SelectedItem; ruleManager = new RuleManager(); ruleManager.DeleteRule(rule); UpdateRule?.Invoke(); }
protected Task On(UpdateRule command, CommandContext context) { return(handler.UpdateSyncedAsync <RuleDomainObject>(context, async r => { await GuardRule.CanUpdate(command, appProvider); r.Update(command); })); }
protected Task On(UpdateRule command, CommandContext context) { return(handler.UpdateAsync <RuleDomainObject>(context, async c => { await GuardRule.CanUpdate(command, schemas); c.Update(command); })); }
public InvariantResult IsValid(UpdateRule obj) { // Validate rule priority. if (obj.Priority <= 0) { return(InvariantResult.ForInvalid(this.Code, string.Format(InvariantResources.R003, obj.Priority))); } return(InvariantResult.ForValid(this.Code)); }
public async Task CanUpdate_should_throw_exception_if_rule_has_already_this_name() { var command = new UpdateRule { Name = "MyName" }; await ValidationAssert.ThrowsAsync(() => GuardRule.CanUpdate(command, appId.Id, appProvider, rule_0), new ValidationError("Rule has already this name.", "Name")); }
private void editRule_Click(object sender, RoutedEventArgs e) { var rule = (Rule)listRules.SelectedItem; var form = new ChangeInfoForm("Название правила:", "Изменить"); if (form.ShowDialog() == true) { ruleManager.RenameRule(rule, form.TextInfo); } UpdateRule?.Invoke(); }
public UpdateRule ToCommand(Guid id) { var command = new UpdateRule { RuleId = id, Action = Action }; if (Trigger != null) { command.Trigger = Trigger.ToTrigger(); } return(command); }
public UpdateRule ToCommand(DomainId id) { var command = new UpdateRule { RuleId = id, Action = Action, Name = Name }; if (Trigger != null) { command.Trigger = Trigger.ToTrigger(); } return(command); }
public async Task CanUpdate_should_not_throw_exception_if_trigger_and_action_valid() { var command = new UpdateRule { Trigger = new ContentChangedTrigger { Schemas = ImmutableList <ContentChangedTriggerSchema> .Empty }, Action = new TestAction { Url = validUrl } }; await GuardRule.CanUpdate(command, appId.Id, appProvider); }
public async Task CanUpdate_should_not_throw_exception_if_trigger_and_action_valid() { var command = new UpdateRule { Trigger = new ContentChangedTrigger { Schemas = new List <ContentChangedTriggerSchema>() }, Action = new WebhookAction { Url = validUrl } }; await GuardRule.CanUpdate(command, schemas); }
public async Task CanUpdate_should_not_throw_exception_if_trigger_and_action_valid() { var command = new UpdateRule { Trigger = new ContentChangedTriggerV2 { Schemas = ReadOnlyCollection.Empty <ContentChangedTriggerSchemaV2>() }, Action = new TestAction { Url = validUrl } }; await GuardRule.CanUpdate(command, appId.Id, appProvider); }
public FieldUnit(OperationRegion operationRegion, int startBitIndex, int numBits, AccessType accessType, AccessAttrib accessAttrib, LockRule lockRule, UpdateRule updateRule) { if (startBitIndex < 0 || (startBitIndex + numBits + 7) / 8 > (int)operationRegion.Length) { throw new ArgumentException("Field unit not in bounds of operation region"); } this.operationRegion = operationRegion; this.startBitIndex = startBitIndex; this.numBits = numBits; this.accessType = accessType; this.accessAttrib = accessAttrib; this.lockRule = lockRule; this.updateRule = updateRule; }
public static UpdateRule ToCommand(this UpdateRuleDto dto, Guid id) { var command = new UpdateRule { RuleId = id }; if (dto.Action != null) { command.Action = dto.Action.ToAction(); } if (dto.Trigger != null) { command.Trigger = dto.Trigger.ToTrigger(); } return(command); }
// SortedList will be Dictionary<string, FieldUnit> when generics are available public static SortedList CreateFromFieldList(OperationRegion operationRegionNode, FieldElement[] fieldList, AccessType initialAccessType, AccessAttrib initialAccessAttrib, LockRule lockRule, UpdateRule updateRule ) { SortedList result = new SortedList(); // = new Dictionary<string, FieldUnit>(); AccessType accessType = initialAccessType; AccessAttrib accessAttrib = initialAccessAttrib; int bitIndex = 0; foreach (FieldElement fieldElement in fieldList) { switch (fieldElement.Tag) { case FieldElement.TagValue.NamedField: AmlParser.NamedField namedField = fieldElement.GetAsNamedField(); result.Add(namedField.nameSeg.data, new FieldUnit(operationRegionNode, bitIndex, namedField.bitWidth, accessType, accessAttrib, lockRule, updateRule)); bitIndex += namedField.bitWidth; break; case FieldElement.TagValue.ReservedField: AmlParser.ReservedField reservedField = fieldElement.GetAsReservedField(); bitIndex += reservedField.bitWidth; break; case FieldElement.TagValue.AccessField: AmlParser.AccessField accessField = fieldElement.GetAsAccessField(); accessType = accessField.accessType; accessAttrib = accessField.accessAttrib; break; default: throw new LoadException("Unhandled alternative in switch over 'FieldElement'"); } } return(result); }
public async Task <RuleResultDto> Update(Guid tenantId, Guid id, UpdateRuleDto updateRuleDto) { RuleKey ruleKey = RuleKey.New(tenantId, id); Rule rule = await this.ruleRepository.GetById(ruleKey); if (rule == null) { throw new NotFoundException(FormattableString.Invariant($"{nameof(Rule)} was not found. TenantId = {tenantId} | Id = {id}")); } UpdateRule updateRule = this.updateRuleConversionProfile.Convert(tenantId, id, updateRuleDto); RuleResult ruleResult = await this.updateRuleService.UpdateRule(updateRule); return(new RuleResultDto { AffectedRule = ruleResult.AffectedRule != null?this.ConvertToDto(ruleResult.AffectedRule) : null, ErrorMessages = ruleResult.ErrorMessages.Select(m => new { m.Code, m.Message }) }); }
public static Task CanUpdate(UpdateRule command, IRuleEntity rule, IAppProvider appProvider) { Guard.NotNull(command, nameof(command)); return(Validate.It(async e => { if (command.Trigger != null) { var errors = await RuleTriggerValidator.ValidateAsync(rule.AppId.Id, command.Trigger, appProvider); errors.Foreach((x, _) => x.AddTo(e)); } if (command.Action != null) { var errors = command.Action.Validate(); errors.Foreach((x, _) => x.AddTo(e)); } })); }
public InvariantResult IsValid(UpdateRule obj) { // Validate rule interval. if (obj.DateEnd.HasValue) { RuleKey ruleKey = RuleKey.New(obj.TenantId, obj.Id); Rule rule = this.ruleRepository.GetById(ruleKey).GetAwaiter().GetResult(); if (rule != null) { DateTime dateBegin = rule.DateBegin; DateTime dateEnd = obj.DateEnd.GetValueOrDefault(); if (dateEnd <= dateBegin) { return(InvariantResult.ForInvalid(this.Code, string.Format(InvariantResources.R002, dateBegin, dateEnd))); } } } return(InvariantResult.ForValid(this.Code)); }
public void Update() { if (IterationNumber == 0) { UpdateRule.Init(this); } PreIteration(); UpdateRule.Update(_gradients, _flat.Weights); Error = _errorCalculation.Calculate(); PostIteration(); EngineArray.Fill(_gradients, 0); _errorCalculation.Reset(); if (Training is BatchDataSet) { ((BatchDataSet)Training).Advance(); } }
public override void Iteration() { for (int i = 0; i < Training.Count; i++) { Process(Training[i]); } if (IterationNumber == 0) { UpdateRule.Init(this); } PreIteration(); Update(); PostIteration(); if (Training is BatchDataSet) { ((BatchDataSet)Training).Advance(); } }
private void SetIconToolStripMenuItem_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog() { AddExtension = true, CheckFileExists = true, CheckPathExists = true, Filter = "Icon File (*.ico)|*.ico|Executable (*.exe)|*.exe", Multiselect = false, Title = "Select file to get icon" }; if (ofd.ShowDialog() == DialogResult.OK) { Rule.Icon = Path.GetExtension(ofd.FileName) == ".exe" ? GetExeIcon(ofd.FileName) : new Icon(ofd.FileName).ToBitmap(); UpdateRule?.Invoke(this, Rule); SetPictureBoxImage(); } RaiseHideForm(); }
public void Update(UpdateRule command) { RaiseEvent(SimpleMapper.Map(command, new RuleUpdated())); }