WeekDayHours(Index: CalendarDayOfWeek): ILogonHours;
Index - the day of the week for which it is required to determine the parameters of the access of the user to the platform.
The WeekDayHours property defines user's access parameters by weekdays.
Executing the example requires the user, registered in the platform with the User_1 identifier.
Sub Main;
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.Saturday);
LH.SetPeriodAccess(d1, d4, False);
LogonHP.WeekDayHours(CalendarDayOfWeek.Sunday) := LH;
MS.Apply;
End Sub Main;
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 a. m. till 6 p. m.
See also: