92 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Text;
 | |
| using Csla;
 | |
| 
 | |
| namespace VEPROMS.CSLA.Library
 | |
| {
 | |
| 	public partial class Permission
 | |
| 	{
 | |
| 		private static List<vlnValueKey> _permADLookup;
 | |
| 		private static List<vlnValueKey> _permLevelLookup;
 | |
| 		private static void setupLookup()
 | |
| 		{
 | |
| 			if (_permADLookup == null)
 | |
| 			{
 | |
| 				_permADLookup = new List<vlnValueKey>();
 | |
| 				_permADLookup.Add(new vlnValueKey(0,"Allow"));
 | |
| 				_permADLookup.Add(new vlnValueKey(1, "Deny"));
 | |
| 			}
 | |
| 			if (_permLevelLookup == null)
 | |
| 			{
 | |
| 				_permLevelLookup = new List<vlnValueKey>();
 | |
| 				_permLevelLookup.Add(new vlnValueKey(0, "Security"));
 | |
| 				_permLevelLookup.Add(new vlnValueKey(1, "System"));
 | |
| 				_permLevelLookup.Add(new vlnValueKey(2, "RO"));
 | |
| 				_permLevelLookup.Add(new vlnValueKey(3, "Procedure"));
 | |
| 				_permLevelLookup.Add(new vlnValueKey(4, "Sections"));
 | |
| 				_permLevelLookup.Add(new vlnValueKey(5, "Steps"));
 | |
| 				_permLevelLookup.Add(new vlnValueKey(6, "Comments"));
 | |
| 			}
 | |
| 		}
 | |
| 		public static List<vlnValueKey> PermADLookup
 | |
| 		{
 | |
| 			get { setupLookup(); return _permADLookup; }
 | |
| 		}
 | |
| 		public static List<vlnValueKey> PermLevelLookup
 | |
| 		{
 | |
| 			get { setupLookup(); return _permLevelLookup; }
 | |
| 		}
 | |
| 		public bool ReadAccess
 | |
| 		{
 | |
| 			get { return ((PermValue & 1) == 1); }
 | |
| 			set { PermValue = (value?PermValue|1:PermValue^(PermValue&1));}
 | |
| 		}
 | |
| 		public bool WriteAccess
 | |
| 		{
 | |
| 			get { return ((PermValue & 2) == 2); }
 | |
| 			set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
 | |
| 		}
 | |
| 		public bool CreateAccess
 | |
| 		{
 | |
| 			get { return ((PermValue & 4) == 4); }
 | |
| 			set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
 | |
| 		}
 | |
| 		public bool DeleteAccess
 | |
| 		{
 | |
| 			get { return ((PermValue & 8) == 8); }
 | |
| 			set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
 | |
| 		}
 | |
| 		//    partial class Extension : extensionBase
 | |
| 		//    {
 | |
| 		// TODO: Override automatic defaults
 | |
| 		//			public virtual int DefaultPermad
 | |
| 		//			{
 | |
| 		//				get { return 0; }
 | |
| 		//			}
 | |
| 		//			public virtual SmartDate DefaultStartDate
 | |
| 		//			{
 | |
| 		//				get { return DateTime.Now.ToShortDateString(); }
 | |
| 		//			}
 | |
| 		//			public virtual DateTime DefaultDts
 | |
| 		//			{
 | |
| 		//				get { return DateTime.Now; }
 | |
| 		//			}
 | |
| 		//			public virtual string DefaultUsrid
 | |
| 		//			{
 | |
| 		//				get { return Environment.UserName.ToUpper(); }
 | |
| 		//			}
 | |
| 		//      public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | |
| 		//      {
 | |
| 		//        //rules.AllowRead(Dbid, "<Role(s)>");
 | |
| 		//      }
 | |
| 		//      public new void AddValidationRules(Csla.Validation.ValidationRules rules)
 | |
| 		//      {
 | |
| 		//			rules.AddRule(
 | |
| 		//				Csla.Validation.CommonRules.StringMaxLength, 
 | |
| 		//				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
 | |
| 		//      }
 | |
| 		//    }
 | |
| 	}
 | |
| }
 |