Difference between revisions of "GroupBuilderRule class"
Nguyenduyan (talk | contribs) |
|||
Line 1: | Line 1: | ||
{{CGscriptClass_Template | {{CGscriptClass_Template | ||
− | |Name=GroupBuilderRule | + | |Name=<nowiki>GroupBuilderRule</nowiki> |
− | |Description=Represents a group builder rule. | + | |Description=<nowiki>Represents a group builder rule.</nowiki> |
− | |Constructors= | + | |InheritsFrom=object|Constructors= |
{{CGscriptConstructors_Template|Parameters= | {{CGscriptConstructors_Template|Parameters= | ||
− | {{CGscriptParameters_Template|Type=GroupBuilderRoot|Name=root|Description=Associate with this root collections group}} | + | {{CGscriptParameters_Template|Type=GroupBuilderRoot|Name=<nowiki>root</nowiki>|Description=<nowiki>Associate with this root collections group</nowiki>}} |
− | |Description=Create a new rule}} | + | |Description=<nowiki>Create a new rule</nowiki>}} |
|Methods= | |Methods= | ||
− | {{CGscriptMethods_Template|ReturnType=Empty|Name=Add|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Add</nowiki>|Parameters= |
− | {{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=variable|Description=Variable to add}} | + | {{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=<nowiki>variable</nowiki>|Description=<nowiki>Variable to add</nowiki>}} |
− | |Description=Add a new variable}} | + | |Description=<nowiki>Add a new variable</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType= | + | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>this[] { get; }</nowiki>|Parameters= |
− | {{CGscriptParameters_Template|Type=int|Name=index|Description=Index}} | + | {{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}} |
− | |Description=Get variable at index}} | + | |Description=<nowiki>Get variable at index</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=bool|Name=Remove|Parameters= | + | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Remove</nowiki>|Parameters= |
− | {{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=variable|Description=Variable to remove}} | + | {{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=<nowiki>variable</nowiki>|Description=<nowiki>Variable to remove</nowiki>}} |
− | |Description=Remove variable. Return true if removed}} | + | |Description=<nowiki>Remove variable. Return true if removed</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=Empty|Name=this[] { set; }|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>this[] { set; }</nowiki>|Parameters= |
− | {{CGscriptParameters_Template|Type=int|Name=index|Description=Index|Comma=,}}{{CGscriptParameters_Template|Type= | + | {{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set</nowiki>}} |
− | |Description=Set variable at index}} | + | |Description=<nowiki>Set variable at index</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}} | + | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}} |
|Properties= | |Properties= | ||
− | {{CGscriptProperties_Template|ReturnType=int|Name=Actual|HasGetter=1|Description=How many of the final group amount was generated from this rule}} | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Actual</nowiki>|HasGetter=1|Description=<nowiki>How many of the final group amount was generated from this rule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=GroupBuilderRuleCollection|Name=Children|HasGetter=1|Description=Child rules for this rule}} | + | {{CGscriptProperties_Template|ReturnType=GroupBuilderRuleCollection|Name=<nowiki>Children</nowiki>|HasGetter=1|Description=<nowiki>Child rules for this rule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=int|Name=Count|HasGetter=1|Description=Number of variables at this level}} | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Count</nowiki>|HasGetter=1|Description=<nowiki>Number of variables at this level</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=bool|Name=IncludeDeleted|HasGetter=1|HasSetter=1|Description=Include deleted users or not}} | + | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IncludeDeleted</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Include deleted users or not</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=bool|Name=IncludeDisabled|HasGetter=1|HasSetter=1|Description=Include disabled users or not}} | + | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IncludeDisabled</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Include disabled users or not</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=bool|Name=IsLeaf|HasGetter=1|Description=True if this rule as no children}} | + | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IsLeaf</nowiki>|HasGetter=1|Description=<nowiki>True if this rule as no children</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=string|Name=Name|HasGetter=1|HasSetter=1|Description=Name of rule}} | + | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Name of rule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}} | + | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=int|Name=Target|HasGetter=1|HasSetter=1|Description=Target amount to build for this group. -1 == all}} | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Target</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Target amount to build for this group. -1 == all</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=number|Name=TargetPct|HasGetter=1|HasSetter=1|Description=Target as pct of parent. -1 == use Target}} | + | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>TargetPct</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Target as pct of parent. -1 == use Target</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | + | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} |
}} | }} | ||
Latest revision as of 05:49, 2 July 2020
GroupBuilderRule
Represents a group builder rule.
Parent class
Inherits from object
Constructors
- (GroupBuilderRoot root "Associate with this root collections group") - Create a new rule
Methods
- Empty Add(GroupBuilderVariable variable "Variable to add") - Add a new variable
- object this[] { get; }(int index "Index") - Get variable at index
- bool Remove(GroupBuilderVariable variable "Variable to remove") - Remove variable. Return true if removed
- Empty this[] { set; }(int index "Index", object value "Value to set") - Set variable at index
- (From object) string ToString() - The string representation of the object.
Properties
- int Actual { get; } - How many of the final group amount was generated from this rule
- GroupBuilderRuleCollection Children { get; } - Child rules for this rule
- int Count { get; } - Number of variables at this level
- bool IncludeDeleted { get; set; } - Include deleted users or not
- bool IncludeDisabled { get; set; } - Include disabled users or not
- bool IsLeaf { get; } - True if this rule as no children
- string Name { get; set; } - Name of rule
- string ObjectTypeName { get; } - The name of the type of object.
- int Target { get; set; } - Target amount to build for this group. -1 == all
- number TargetPct { get; set; } - Target as pct of parent. -1 == use Target
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Example: Add new rule
//Create a new group
string groupName = "Test Group Builder: GroupBuilderRule";
number groupTemplateResourceId=2066;
number parentResourceId = 11088827;
array group = Group_new(groupName, groupTemplateResourceId, parentResourceId);
Group_save(group);
number groupRId = group[GROUP_RESOURCE_ID ];
//Create rule for the group
GroupBuilderRoot root = new GroupBuilderRoot (groupRId);
GroupBuilderRule rule = new GroupBuilderRule (root);
rule.Name = "Main rule";
print(rule.Actual);
print(rule.Count);
print(rule.IsLeaf);
print(rule.Name);
rule.IncludeDeleted = true;
rule.IncludeDisabled = true;
rule.Target=100;
GroupBuilderRuleCollection ruleColection = root.RootRules;
ruleColection.Add(rule);
root.Save();
Example: Add variable for rule
GroupBuilderRoot root = new GroupBuilderRoot (15560828);
GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderRule rule = ruleColection[0];
GroupBuilderOptionDataVariable variable1 = new GroupBuilderOptionDataVariable();
GroupBuilderGroupVariable variable2 = new GroupBuilderGroupVariable (true);
GroupBuilderBulkmailVariable variable3 = new GroupBuilderBulkmailVariable ();
rule.Add(variable1);
rule.Add(variable2);
rule.Add(variable3);
root.Save();
Example: remove variable
GroupBuilderRoot root = new GroupBuilderRoot (15560828);
GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderRule rule = ruleColection[0];
GroupBuilderOptionDataVariable variable1 = rule[0];
rule.Remove(variable1);
root.Save();
Example: Add children rule
GroupBuilderRoot root = new GroupBuilderRoot (15560828);
GroupBuilderRuleCollection rootRules = root.RootRules;
GroupBuilderRule rootRule = rootRules[0];
GroupBuilderRuleCollection supRules = rootRule.Children;
GroupBuilderRule supRule1 = new GroupBuilderRule (root);
supRules.Add(supRule1);
GroupBuilderRule supRule2 = new GroupBuilderRule (root);
supRules.Add(supRule2);
GroupBuilderGroupVariable variable = new GroupBuilderGroupVariable (true);
for (number i=0;i<supRules.Count;i++)
{
supRules[i].IncludeDeleted=true;
supRules[i].IncludeDisabled = true;
supRules[i].TargetPct=20;
supRules[i].Name="subRule "+i;
supRules[i].Add(variable);
}
root.Save();