Appendix

The following example shows how to write a method that sets the value of the attribute to true from 8AM to 8PM server time, Monday through Friday:

//MethodTemplateName=CSharp:Aras.Server.Core.AccessControl.EnvironmentAttributeMethod;
var startWorkTime = new TimeSpan(8, 0, 0);
var endWorkTime = new TimeSpan(20, 0, 0);
var currentDateTime = DateTime.Now;
var isWorkDay = DayOfWeek.Monday <= currentDateTime.DayOfWeek && currentDateTime.DayOfWeek <= DayOfWeek.Friday;
var isWorkTime = startWorkTime <= currentDateTime.TimeOfDay && currentDateTime.TimeOfDay <= endWorkTime;
var isWorkHours = isWorkDay && isWorkTime;
attribute.SetValue(isWorkHours);
Note
It is recommended to make the Methods OS agnostic to use them with different operating systems. The main incompatibility issues in operating systems that need to be considered when implementing the Methods are related to file path case-sensitivity, path separators, OS-specific line-endings, OS-specific code. For more information about cross-platform development please see section “2.3 Cross-platform development” in “Aras Innovator 33 - Programmer’s Guide” document.

The example shown in Figure 24 is a Policy Rule that restricts Update rights for certain Parts.

The policy rule specifies a few conditions:

  1. The Admin can update any part.
  2. Any user with Standard Aras Innovator Permissions can update parts as long as they do not have both the ‘Component’ Classification and the ‘Primary Battery’ xClass.
  3. Users with an Employee number beginning with ‘123’ can Update Parts during work hours which have both the ‘Component’ Classification and the ‘Primary Battery’ xClass.