Esempio n. 1
0
        public ProfileForm()
        {
            InitializeComponent(); if (DesignMode || (Site != null && Site.DesignMode))
            {
                return;
            }
            //template
            Mapper["Id"]        = PickList[btnPLProfile] = txtId;
            Mapper["CreatedBy"] = txtCreatedBy;
            Mapper["CreatedOn"] = txtCreatedOn;
            Mapper["UpdatedBy"] = txtUpdatedBy;
            Mapper["UpdatedOn"] = txtUpdatedOn;
            Mapper["ReadOnly"]  = chkReadOnly;
            //data
            Mapper["ProfileName"] = txtProfileName;
            Mapper["ProfileDesc"] = txtProfileDesc;
            //actions
            SaveButton   = btnSave;
            DeleteButton = btnDelete;
            NewButton    = btnNew;
            //pick lists
            PickList[btnPLEntitlementGroup] = txtEntitlementGroupId;

            entitlements = DBControllersFactory.Entitlement().Read().ToList();
        }
Esempio n. 2
0
 public UserController()
 {
     CntrlAU = DBControllersFactory.Audit();
     CntrlEG = DBControllersFactory.EntitlementGroup();
     CntrlET = DBControllersFactory.Entity();
     CntrlEN = DBControllersFactory.Entitlement();
     CntrlPE = DBControllersFactory.ProfileEntitlement();
 }
Esempio n. 3
0
 private MainView()
 {
     InitializeComponent(); if (DesignMode || (Site != null && Site.DesignMode))
     {
         return;
     }
     CntrlLG = DBControllersFactory.Language();
     CntrlWD = DBControllersFactory.Word();
     CntrlEG = DBControllersFactory.EntitlementGroup();
     CntrlEN = DBControllersFactory.Entitlement();
     CntrlET = DBControllersFactory.Entity();
     CntrlPE = DBControllersFactory.ProfileEntitlement();
     CntrlUS = DBControllersFactory.User();
 }
 public void InitializeDBValues() {
     foreach (var pe in Read()) { Delete(pe); }
     var es = DBControllersFactory.Entitlement().Read();
     var ps = DBControllersFactory.Profile().Read();
     foreach(ProfileModel p in ps) {
         foreach(EntitlementModel e in es) {
             Save(new ProfileEntitlementModel() {
                 ProfileId=p.Id,
                 EntitlementId=e.Id,
                 AllowRead=true,
                 AllowUpdate=true,
                 AllowCreate=true,
             });
         }
     }
 }
Esempio n. 5
0
        public PermissionsHelper(BaseView <M, C> view)
        {
            if (view == null)
            {
                throw new ArgumentException("view cannot be null");
            }
            //if(model==default) throw new ArgumentException("model cannot be null");
            var CntrlEN = DBControllersFactory.Entitlement();
            var CntrlPE = DBControllersFactory.ProfileEntitlement();
            var CntrlPR = DBControllersFactory.Profile();
            var CntrlET = DBControllersFactory.Entity();

            var usr = MVCHISSession.Instance.CurrentUser;

            if (usr == null)
            {
                return;
            }
            //var mdl = view?.GetType().GetCustomAttributes().OfType<ForModelAttribute>().FirstOrDefault();
            //if (mdl == null) return;

            var entity = CntrlET.Find(new EntityModel()
            {
                EntityName = $"{typeof(M).Name}".Replace("Model", "")
            }, "EntityName");

            var ent = CntrlEN.Find(new EntitlementModel()
            {
                EntityId = entity.Id
            }, "EntityId");

            if (ent == null)
            {
                return;
            }

            var pen = CntrlPE.Find(new ProfileEntitlementModel()
            {
                ProfileId     = usr.ProfileId,
                EntitlementId = ent.Id
            }, "ProfileId", "EntitlementId");

            if (view.NewButton != null)
            {
                view.SetNewButtonEnabled(view.NewButton.Enabled && pen.AllowCreate);
            }
            if (view.SaveButton != null)
            {
                view.SetSaveButtonEnabled(view.SaveButton.Enabled && pen.AllowUpdate);
            }
            if (view.DeleteButton != null)
            {
                view.SetDeleteButtonEnabled(view.DeleteButton.Enabled && pen.AllowDelete);
            }

            if (!pen.AllowRead)
            {
                FormsHelper.Error($"You don't have enough permissions to open {view}.");
                view.GotFocus += (x, y) => {
                    view.Enabled = false;
                    view.BeginInvoke(new MethodInvoker(view.Hide));
                };
            }
        }