SetPeriodAccess(Begin_: DateTime; End_: DateTime; Grant: Boolean);
SetPeriodAccess(@Begin: System.DateTime; @End: System.DateTime; Grant: boolean);
Begin_ - the initial time of the time interval.
End_ - the final time of the time interval.
Grant - a parameter that determines accessibility in the specified time interval. If value of the parameter is True, the access in this time interval is allowed. If value of the parameter is False, the access will be denied.
The SetPeriodAccess method sets parameters of the user access for the specified time interval.
Time interval is formed setting initial and final time in the Begin_ and End_ parameters, respectively. The Grant parameter determines whether this time interval is available to access.
The SetPeriodAccess method sets time interval with accuracy up to a second, the millisecond field must contain the 0 value.
Executing the example requires the user registered in the platform with the User_1 identifier.
Add links to the Metabase system assembly.
Sub UserProc;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
MP: IMetabasePolicy;
User: ISecuritySubject;
LogonHP: ILogonHoursPolicy;
LH: ILogonHours;
d1, d2, d3, d4: DateTime;
i: Integer;
Begin
MB := MetabaseClass.Active;
MS := MB.Security;
MP := MS.Policy;
User := MS.ResolveName("User_1");
LogonHP := MP.LogonHoursPolicy(User);
d1 := DateTime.ComposeTimeOfDay(0, 0, 0, 0);
d2 := DateTime.ComposeTimeOfDay(9, 0, 0, 0);
d3 := DateTime.ComposeTimeOfDay(18, 0, 0, 0);
d4 := DateTime.ComposeTimeOfDay(23, 59, 0, 0);
For i := 1 To 5 Do
LH := LogonHP.WeekDayHours(i As CalendarDayOfWeek);
LH.SetPeriodAccess(d1, d2, False);
LH.SetPeriodAccess(d2, d3, True);
LH.SetPeriodAccess(d3, d4, False);
LogonHP.WeekDayHours(i As CalendarDayOfWeek) := LH;
End For;
//Saturday
LH := LogonHP.WeekDayHours(CalendarDayOfWeek.Saturday);
LH.SetPeriodAccess(d1, d4, False);
LogonHP.WeekDayHours(CalendarDayOfWeek.Saturday) := LH;
//Sunday
LH := LogonHP.WeekDayHours(CalendarDayOfWeek.Sunday);
LH.SetPeriodAccess(d1, d4, False);
LogonHP.WeekDayHours(CalendarDayOfWeek.Sunday) := LH;
MS.Apply;
End Sub UserProc;
After executing the example access parameters by weekdays are changed for the User_1 user. Access from this user's account is available from Monday to Friday, from 9 AM till 6 PM.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Add links to the ForeSystem system assembly.
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MS: IMetabaseSecurity;
MP: IMetabasePolicy;
User: ISecuritySubject;
LogonHP: ILogonHoursPolicy;
LH: ILogonHours;
d1, d2, d3, d4: DateTime;
i: Integer;
Begin
MB := Params.Metabase;
MS := MB.Security;
MP := MS.Policy;
User := MS.ResolveName("User_1");
LogonHP := MP.LogonHoursPolicy[User];
d1 := DateTime.Parse("0, 0, 0, 0, 0");
d2 := DateTime.Parse("9, 0, 0, 0, 0");
d3 := DateTime.Parse("18, 0, 0, 0, 0");
d4 := DateTime.Parse("23, 59, 0, 0, 0");
For i := 1 To 5 Do
LH := LogonHP.WeekDayHours[i As CalendarDayOfWeek];
LH.SetPeriodAccess(d1, d2, False);
LH.SetPeriodAccess(d2, d3, True);
LH.SetPeriodAccess(d3, d4, False);
LogonHP.WeekDayHours[i As CalendarDayOfWeek] := LH;
End For;
//Saturday
LH := LogonHP.WeekDayHours[CalendarDayOfWeek.dowSaturday];
LH.SetPeriodAccess(d1, d4, False);
LogonHP.WeekDayHours[CalendarDayOfWeek.dowSaturday] := LH;
//Sunday
LH := LogonHP.WeekDayHours[CalendarDayOfWeek.dowSunday];
LH.SetPeriodAccess(d1, d4, False);
LogonHP.WeekDayHours[CalendarDayOfWeek.dowSunday] := LH;
MS.Apply();
End Sub;
See also: