ShareFactoryFindAllRules Method (IContext, ShareObjectType, IEnumerableIGroup, NullableInt32) |
Find or calculate all the appropriate share rules
for the specified object type and groups.
Namespace:
AskiaPortalCmn
Assembly:
AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax public static IEnumerable<IShareRule> FindAllRules(
IContext context,
ShareObjectType objectType,
IEnumerable<IGroup> groups,
Nullable<int> surveyId = null
)
Public Shared Function FindAllRules (
context As IContext,
objectType As ShareObjectType,
groups As IEnumerable(Of IGroup),
Optional surveyId As Nullable(Of Integer) = Nothing
) As IEnumerable(Of IShareRule)
public:
static IEnumerable<IShareRule^>^ FindAllRules(
IContext^ context,
ShareObjectType objectType,
IEnumerable<IGroup^>^ groups,
Nullable<int> surveyId = nullptr
)
Parameters
- context
- Type: AskiaPortalCmnIContext
Context of execution. - objectType
- Type: AskiaPortalCmnShareObjectType
Type of objects to find. - groups
- Type: System.Collections.GenericIEnumerableIGroup
Contacts to find. - surveyId (Optional)
- Type: SystemNullableInt32
Id of the survey, to scope the search.
Return Value
Type:
IEnumerableIShareRuleReturn the list of share rules
Remarks
The rules find could be database records
or calculated rules.
Examples
Find all share rules for surveys.
var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
throw contextValidation.Exception;
}
var groups = GroupFactory.FindAllByIds(context, context.User.Membership.GetIds());
var rules = ShareFactory.FindAllRules(context, ShareObjectType.Survey, groups);
foreach(var rule in rules)
{
Console.WriteLine($@"The groups have the permission {rule.Permission} on the survey id `{rule.ObjectId}`");
}
See Also