protected override void SetCopyData(PHmiModel.Entities.User item, string[] data) { item.Description = data[0]; item.Enabled = bool.Parse(data[1]); item.CanChange = bool.Parse(data[2]); item.Privilege = Int32ToPrivilegedConverter.ConvertBack(data[3]); }
protected override void SetCopyData(users item, string[] data) { item.description = data[0]; item.enabled = bool.Parse(data[1]); item.can_change = bool.Parse(data[2]); item.privilege = Int32ToPrivilegedConverter.ConvertBack(data[3]); }
protected override void SetCopyData(PHmiModel.Entities.AlarmTag item, string[] data) { item.DigTag = _digitalTagsDictionary[data[0] + "." + data[1]]; item.Location = data[2]; item.Description = data[3]; item.Acknowledgeable = bool.Parse(data[4]); item.Privilege = Int32ToPrivilegedConverter.ConvertBack(data[5]); }
private bool IsUserPrivileged(Identity identity, int privilege) { var userPrivilege = GetPrivilege(identity); if (!userPrivilege.HasValue) { return(false); } var userAdminPrivelege = Int32ToPrivilegedConverter.ConvertBack(privilege.ToString(CultureInfo.InvariantCulture)); if (!userAdminPrivelege.HasValue) { return(false); } return((userPrivilege.Value & userAdminPrivelege.Value) != 0); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var user = values[1] as User; var privilegeStr = values[0] as string; if (string.IsNullOrEmpty(privilegeStr)) { return(true); } var privilege = Int32ToPrivilegedConverter.ConvertBack(privilegeStr); if (!privilege.HasValue || privilege.Value == 0) { return(true); } if (user == null || !user.Privilege.HasValue) { return(false); } return((user.Privilege.Value & privilege.Value) != 0); }