コード例 #1
0
        public void Handle(DeleteRule command)
        {
            var company = _repository.Get(command.CompanyId);

            company.DeleteRule(command.RuleId);
            _repository.Save(company, command.Id.ToString());
        }
コード例 #2
0
ファイル: RulesIndex.cs プロジェクト: erw13n/squidex
        private async Task DeleteRuleAsync(DeleteRule command)
        {
            var rule = await GetRuleInternalAsync(command.AppId.Id, command.RuleId);

            if (IsFound(rule))
            {
                await Index(rule.AppId.Id).RemoveAsync(rule.Id);
            }
        }
コード例 #3
0
        private async Task DeleteRuleAsync(DeleteRule command)
        {
            var rule = await GetRuleCoreAsync(command.AggregateId);

            if (rule != null)
            {
                await Index(rule.AppId.Id).RemoveAsync(rule.Id);
            }
        }
コード例 #4
0
        protected Task On(DeleteRule command, CommandContext context)
        {
            return(handler.UpdateAsync <RuleDomainObject>(context, c =>
            {
                GuardRule.CanDelete(command);

                c.Delete(command);
            }));
        }
コード例 #5
0
        public object Delete(RuleRequest request)
        {
            var command = new DeleteRule {
                CompanyId = AppConstants.CompanyId, RuleId = request.Id
            };

            _commandBus.Send(command);

            return(new HttpResult(HttpStatusCode.OK, "OK"));
        }
コード例 #6
0
ファイル: RulesIndex.cs プロジェクト: vmnet04/squidex
        private async Task DeleteRuleAsync(DeleteRule command)
        {
            var id = command.RuleId;

            var rule = await grainFactory.GetGrain <IRuleGrain>(id).GetStateAsync();

            if (IsFound(rule.Value))
            {
                await Index(rule.Value.AppId.Id).RemoveAsync(id);
            }
        }
コード例 #7
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(50);

            sb.AppendFormat("Foreign Key {0}: ", Name);
            ToStringAddTable(sb, PrimaryKeyTableName, PrimaryKeyTableColumns);
            sb.Append(", ");
            ToStringAddTable(sb, ForeignKeyTableName, ForeignKeyTableColumns);
            sb.AppendFormat(", On Delete = {0}, On Update = {1}", DeleteRule.ToString(), UpdateRule.ToString());

            return(sb.ToString());
        }
コード例 #8
0
        private void CellGUI(Rect cellRect, TreeViewItem <JObject> item, int column, ref RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case 0:
                Rect toggleRect = cellRect;
                toggleRect.x += cellRect.width - 18;
                var toggle = GUI.Toggle(toggleRect, item.data["enabled"].Value <bool>(), "");
                if (toggle != item.data["enabled"].Value <bool>())
                {
                    RuleEnabledOrDisabled?.Invoke(item.data["id"].Value <string>(), !item.data["enabled"].Value <bool>());
                }
                break;

            case 1:
                var ruleNameStyle = EditorStyles.label;
                ruleNameStyle.wordWrap = false;
                GUI.Label(cellRect, item.displayName, ruleNameStyle);
                break;

            case 2:
                EditorGUI.BeginDisabledGroup(item.data["enabled"].Value <bool>());
                var newPriority = EditorGUI.IntField(cellRect, item.data["priority"].Value <int>());
                if (newPriority != item.data["priority"].Value <int>())
                {
                    var rule = item.data;
                    rule["priority"] = newPriority;
                    RuleAttributesChanged?.Invoke(item.data["id"].Value <string>(), rule);
                }
                EditorGUI.EndDisabledGroup();
                break;

            case 3:
                EditorGUI.LabelField(cellRect, item.data["type"].Value <string>());
                break;

            case 4:
                EditorGUI.BeginDisabledGroup(item.data["enabled"].Value <bool>());
                if (GUI.Button(cellRect, EditorGUIUtility.FindTexture("d_TreeEditor.Trash")))
                {
                    DeleteRule?.Invoke(item.data["id"].Value <string>());
                }
                EditorGUI.EndDisabledGroup();
                break;
            }
        }
コード例 #9
0
ファイル: RulesIndexTests.cs プロジェクト: jrlost/squidex
        public async Task Should_remove_rule_from_index_on_delete()
        {
            var rule = SetupRule(0);

            var command = new DeleteRule {
                RuleId = rule.Id, AppId = appId
            };

            var context =
                new CommandContext(command, commandBus)
                .Complete();

            await sut.HandleAsync(context);

            A.CallTo(() => cache.RemoveAsync(rule.Id))
            .MustHaveHappened();
        }
コード例 #10
0
        public async Task Delete_should_update_create_events()
        {
            var command = new DeleteRule();

            await ExecuteCreateAsync();

            var result = await sut.ExecuteAsync(CreateRuleCommand(command));

            result.ShouldBeEquivalent(new EntitySavedResult(1));

            Assert.True(sut.Snapshot.IsDeleted);

            LastEvents
            .ShouldHaveSameEvents(
                CreateRuleEvent(new RuleDeleted())
                );
        }
コード例 #11
0
 private void SwitchRuleEnabled()
 {
     try
     {
         var enabled = firewallService.SwitchEnabled(firewallRuleDto);
         pboxRule.Image = enabled ? icon : iconGrayScale;
     }
     catch (Exception exc)
     {
         if (MessageBox.Show(
                 "The following error occurred: \n" + exc.Message + "\nDelete this rule?", "Error",
                 MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
         {
             DeleteRule?.Invoke(this, Rule);
         }
     }
 }
コード例 #12
0
        public void DeleteRule()
        {
            string expected = File.ReadAllText(Path.Combine(_requestsTestDataPath, "DeleteRule.xml"));
            var    request  = new DeleteRule
            {
                SessionId = "sid",
                Who       = "*****@*****.**",
                RuleID    = 1
            };
            var xml = request.ToXml().InnerXmlFormatted();

            Assert.AreEqual(expected, xml);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(File.ReadAllText(Path.Combine(_responsesTestDataPath, "DeleteRule.xml")));
            var response = request.FromHttpRequestResult(new HttpRequestResult {
                Response = doc.InnerXml
            });

            Assert.AreEqual("result", response.Type);
            Assert.True(response.Success);
        }
コード例 #13
0
        private void ConfirmButtonClick(object sender, EventArgs e)
        {
            if (Globals.RenameRules == null)
            {
                Globals.RenameRules = new List <IRenameRule>();
            }
            switch (RuleTypeTabControl.SelectedIndex)
            {
            case 0:
                InsertRule insertRule = new InsertRule(insertText: InsertTextTextBox.Text,
                                                       numberSequence: InsertNumberSeqRadioButton.Checked,
                                                       numberSequenceStart: (int)InsertNumberSeqStartingAtNumericUpDown.Value,
                                                       numberSequenceLeadingZeroes: (int)InsertNumberSeqLeadingZeroesNumericUpDown.Value,
                                                       beforeTextStr: InsertBeforeTextTextBox.Text,
                                                       afterTextStr: InsertAfterTextTextBox.Text,
                                                       prefix: InsertPrefixRadioButton.Checked,
                                                       suffix: InsertSuffixRadioButton.Checked,
                                                       position: InsertAtPositionRadioButton.Checked,
                                                       positionRightToLeft: InsertPositionRightLeftCheckBox.Checked,
                                                       beforeText: InsertBeforeTextRadioButton.Checked,
                                                       afterText: InsertAfterTextRadioButton.Checked,
                                                       replaceFileName: ReplaceCurrentFileNameRadioButton.Checked,
                                                       ignoreExtension: InsertIgnoreExtensionCheckBox.Checked,
                                                       positionIndex: (int)InsertPositionNumericUpDown.Value);

                if (editMode)
                {
                    int oldRuleIndex = Globals.RenameRules.IndexOf(Globals.RenameRules.Find(rule => rule.Id == currentlyEditedRule.Id));
                    Globals.RenameRules[oldRuleIndex] = insertRule;
                }
                else
                {
                    Globals.RenameRules.Add(insertRule);
                }

                DialogResult = DialogResult.OK;
                break;

            case 1:
                DeleteRule deleteRule = new DeleteRule(fromPosition: DeleteFromPositionRadioButton.Checked,
                                                       fromDelimiter: DeleteFromDelimiterRadioButton.Checked,
                                                       toPosition: DeleteToPositionRadioButton.Checked,
                                                       toDelimiter: DeleteToDelimiterRadioButton.Checked,
                                                       deleteToEnd: DeleteToEndRadioButton.Checked,
                                                       deleteEntireFileName: DeleteEntireFileNameCheckBox.Checked,
                                                       ignoreExtension: DeleteIgnoreExtensionCheckBox.Checked,
                                                       keepDelimiters: DeleteKeepDelimitersCheckBox.Checked,
                                                       fromPositionIndex: (int)DeleteFromPositionNumericUpDown.Value,
                                                       toPositionIndex: (int)DeleteToPositionNumericUpDown.Value,
                                                       fromDelimiterStr: DeleteFromDelimiterTextBox.Text,
                                                       toDelimiterStr: DeleteToDelimiterTextBox.Text);

                if (editMode)
                {
                    int oldRuleIndex = Globals.RenameRules.IndexOf(Globals.RenameRules.Find(rule => rule.Id == currentlyEditedRule.Id));
                    Globals.RenameRules[oldRuleIndex] = deleteRule;
                }
                else
                {
                    Globals.RenameRules.Add(deleteRule);
                }

                DialogResult = DialogResult.OK;
                break;

            case 2:
                RemoveRule removeRule = new RemoveRule(removeText: RemoveTextTextBox.Text,
                                                       allOccurrences: RemoveAllOccurrencesRadioButton.Checked,
                                                       firstOccurrence: RemoveFirstOccurrenceRadioButton.Checked,
                                                       lastOccurrence: RemoveLastOccurrenceRadioButton.Checked,
                                                       caseSensitive: RemoveCaseSensitiveCheckBox.Checked,
                                                       ignoreExtension: RemoveIgnoreExtensionCheckBox.Checked
                                                       );

                if (editMode)
                {
                    int oldRuleIndex = Globals.RenameRules.IndexOf(Globals.RenameRules.Find(rule => rule.Id == currentlyEditedRule.Id));
                    Globals.RenameRules[oldRuleIndex] = removeRule;
                }
                else
                {
                    Globals.RenameRules.Add(removeRule);
                }

                DialogResult = DialogResult.OK;
                break;

            case 3:
                ReplaceRule replaceRule = new ReplaceRule(findText: ReplaceFindTextBox.Text,
                                                          replaceText: ReplaceTextTextBox.Text,
                                                          allOccurrences: ReplaceAllOccurrencesRadioButton.Checked,
                                                          firstOccurrence: ReplaceFirstOccurrenceRadioButton.Checked,
                                                          lastOccurrence: ReplaceLastOccurrenceRadioButton.Checked,
                                                          caseSensitive: ReplaceCaseSensitiveCheckBox.Checked,
                                                          ignoreExtension: ReplaceIgnoreExtensionCheckBox.Checked
                                                          );

                if (editMode)
                {
                    int oldRuleIndex = Globals.RenameRules.IndexOf(Globals.RenameRules.Find(rule => rule.Id == currentlyEditedRule.Id));
                    Globals.RenameRules[oldRuleIndex] = replaceRule;
                }
                else
                {
                    Globals.RenameRules.Add(replaceRule);
                }

                DialogResult = DialogResult.OK;
                break;

            case 4:
                CleanRule cleanRule = new CleanRule(cleanLatinAlphabet: CleanLatinAlphabetCheckBox.Checked,
                                                    cleanDigits: CleanDigitsCheckBox.Checked,
                                                    cleanBrackets: CleanBracketsCheckBox.Checked,
                                                    cleanSymbols: CleanSymbolsCheckBox.Checked,
                                                    cleanUserDefined: CleanUserDefinedCheckBox.Checked,
                                                    cleanUserDefinedText: CleanUserDefinedTextBox.Text,
                                                    caseSensitive: CleanCaseSensitiveCheckBox.Checked,
                                                    ignoreExtension: CleanIgnoreExtensionCheckBox.Checked
                                                    );

                if (editMode)
                {
                    int oldRuleIndex = Globals.RenameRules.IndexOf(Globals.RenameRules.Find(rule => rule.Id == currentlyEditedRule.Id));
                    Globals.RenameRules[oldRuleIndex] = cleanRule;
                }
                else
                {
                    Globals.RenameRules.Add(cleanRule);
                }

                DialogResult = DialogResult.OK;
                break;

            case 5:
                RegexRule regexRule = new RegexRule(regexFindText: RegexFindTextTextBox.Text,
                                                    replaceText: RegexReplaceTextTextBox.Text,
                                                    ignoreExtension: CleanIgnoreExtensionCheckBox.Checked
                                                    );

                if (editMode)
                {
                    int oldRuleIndex = Globals.RenameRules.IndexOf(Globals.RenameRules.Find(rule => rule.Id == currentlyEditedRule.Id));
                    Globals.RenameRules[oldRuleIndex] = regexRule;
                }
                else
                {
                    Globals.RenameRules.Add(regexRule);
                }

                DialogResult = DialogResult.OK;
                break;

            default:
                MessageBox.Show("An unknown error has occurred.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.Cancel;
                break;
            }
        }
コード例 #14
0
ファイル: RuleDomainObject.cs プロジェクト: vmnet04/squidex
 public void Delete(DeleteRule command)
 {
     RaiseEvent(SimpleMapper.Map(command, new RuleDeleted()));
 }
コード例 #15
0
 public GuidForeignKeyAttribute(string columnName, bool isNullable, DeleteRule deleteRule) :
     base(columnName, DbType.Guid, 0, isNullable, deleteRule)
 {
 }
コード例 #16
0
 public ForeignKeyAttribute(string columnName, DbType columnType, int columnSize,
                            bool isNullable, DeleteRule deleteRule) :
     base(columnName, columnType, columnSize, isNullable)
 {
     m_DeleteRule = deleteRule;
 }
コード例 #17
0
        public void CanDelete_should_not_throw_exception()
        {
            var command = new DeleteRule();

            GuardRule.CanDelete(command);
        }
コード例 #18
0
 private void Delete(DeleteRule command)
 {
     Raise(command, new RuleDeleted());
 }
コード例 #19
0
ファイル: GuardRule.cs プロジェクト: stevenalanstark/squidex
 public static void CanDelete(DeleteRule command)
 {
     Guard.NotNull(command);
 }
コード例 #20
0
 private async Task OnDeleteAsync(DeleteRule delete)
 {
     await Cache(delete.AppId.Id).RemoveAsync(delete.RuleId);
 }
コード例 #21
0
        internal static IRule ReadRule(XmlReader xml, bool includeFilter=true)
        {
            IRule rule;

            var elementName = xml.Name;

            switch (elementName.ToLower())
            {
                case "recycle":
                    rule = new RecycleRule();
                    break;
                case "delete":
                    rule = new DeleteRule();
                    break;
                case "ignore":
                    rule = new IgnoreRule();
                    break;
                case "move":
                    rule = new MoveRule();
                    break;
                case "rename":
                    rule = new RenameRule();
                    break;
                default:
                    xml.Skip();
                    throw new IgnoredElementException(elementName);
            }

            var attributes = new AttributeParser(xml);

            rule.Target              = attributes.GetOptional("Target").AsEnum(RuleTarget.FilesAndFolders);
            rule.AppliesToSubfolders = attributes.GetOptional("ApplyToSubfolders").AsBool(true);

            if (rule is MoveRuleBase)
            {
                ((MoveRuleBase)rule).IfExists =
                    attributes.GetOptional("ifexists").AsEnum(MoveRuleBase.IfExistsMode.Cancel);
            }

            if( rule is MoveRule)
            {
                ((MoveRule)rule).Destination = attributes.GetMandatory("destination").AsString();
                ((MoveRule)rule).CreateFolder = attributes.GetOptional("createfolder").AsBool(true);
            }

            if (rule is RenameRule)
            {
                ((RenameRule)rule).Name = attributes.GetMandatory("name").AsString();
            }

            attributes.AssertNoUnused();

            if (includeFilter)
            {
                var filters = ReadFilters(xml).ToArray();

                if (filters.Length == 0)
                    throw new Exception("You must specificy a filter for this rule");

                if (filters.Length > 1)
                    throw new Exception("You can only specify one filter at rule's root. Please use <MatchingAll>, <MatchingAny> or <MatchingNone>.");

                rule.Filter = filters.First();
            }

            return rule;
        }
コード例 #22
0
 public void Delete(DeleteRule command)
 {
     Raise(command, new RuleDeleted());
 }
コード例 #23
0
ファイル: RuleControl.cs プロジェクト: dcg90/Firewall.Widget
 private void RemoveRuleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DeleteRule?.Invoke(this, Rule);
     RaiseHideForm();
 }
コード例 #24
0
        internal static IRule ReadRule(XmlReader xml, bool includeFilter = true)
        {
            IRule rule;

            var elementName = xml.Name;

            switch (elementName.ToLower())
            {
            case "recycle":
                rule = new RecycleRule();
                break;

            case "delete":
                rule = new DeleteRule();
                break;

            case "ignore":
                rule = new IgnoreRule();
                break;

            case "move":
                rule = new MoveRule();
                break;

            case "rename":
                rule = new RenameRule();
                break;

            default:
                xml.Skip();
                throw new IgnoredElementException(elementName);
            }

            var attributes = new AttributeParser(xml);

            rule.Target = attributes.GetOptional("Target").AsEnum(RuleTarget.FilesAndFolders);
            rule.AppliesToSubfolders = attributes.GetOptional("ApplyToSubfolders").AsBool(true);

            if (rule is MoveRuleBase)
            {
                ((MoveRuleBase)rule).IfExists =
                    attributes.GetOptional("ifexists").AsEnum(MoveRuleBase.IfExistsMode.Cancel);
            }

            if (rule is MoveRule)
            {
                ((MoveRule)rule).Destination  = attributes.GetMandatory("destination").AsString();
                ((MoveRule)rule).CreateFolder = attributes.GetOptional("createfolder").AsBool(true);
            }

            if (rule is RenameRule)
            {
                ((RenameRule)rule).Name = attributes.GetMandatory("name").AsString();
            }

            attributes.AssertNoUnused();

            if (includeFilter)
            {
                var filters = ReadFilters(xml).ToArray();

                if (filters.Length == 0)
                {
                    throw new Exception("You must specificy a filter for this rule");
                }

                if (filters.Length > 1)
                {
                    throw new Exception("You can only specify one filter at rule's root. Please use <MatchingAll>, <MatchingAny> or <MatchingNone>.");
                }

                rule.Filter = filters.First();
            }

            return(rule);
        }
コード例 #25
0
        public void Delete(DeleteRule command)
        {
            VerifyCreatedAndNotDeleted();

            RaiseEvent(SimpleMapper.Map(command, new RuleDeleted()));
        }