예제 #1
0
        bool CanNotRead(string propertyName, object currentObject)
        {
            bool content = !(View.ObjectTypeInfo.FindMember(propertyName) == null || DataManipulationRight.CanRead(View.ObjectTypeInfo.Type, propertyName, null, View.CollectionSource, View.ObjectSpace));
            var  fit     = ((MemberLevelObjectAccessComparer)ObjectAccessComparerBase.CurrentComparer).Fit(currentObject, View.ObjectTypeInfo.FindMember(propertyName), MemberOperation.Read);

            return(content && fit);
        }
예제 #2
0
        Object FindObjectToOpen(GridColumn column, int rowHandle)
        {
            Object result = null;

            if (column != null && GridListEditor != null && GridListEditor.GridView() != null)
            {
                Object    currObject = XtraGridUtils.GetRow(GridListEditor.GridView(), rowHandle);
                ITypeInfo typeInfo   = currObject != null
                                         ? XafTypesInfo.Instance.FindTypeInfo(currObject.GetType())
                                         : _listView.ObjectTypeInfo;

                IMemberInfo memberInfo = typeInfo.FindMember(column.FieldName);
                Object      lastObject = null;
                if (GridListEditor.GridView().ActiveEditor != null)
                {
                    lastObject = GridListEditor.GridView().ActiveEditor.EditValue;
                }
                else if (currObject != null && memberInfo != null)
                {
                    lastObject = FindLastObject(currObject, memberInfo);
                }
                if (memberInfo != null && (IsDetailViewExists(lastObject) &&
                                           DataManipulationRight.CanRead(typeInfo.Type, memberInfo.Name, currObject,
                                                                         LinkToListViewController.FindCollectionSource(
                                                                             Controller.Frame),
                                                                         ObjectSpace)))
                {
                    result = lastObject;
                }
            }
            return(result);
        }
 void appearanceController_CustomApplyAppearance(object sender, ApplyAppearanceEventArgs e)
 {
     if (e.AppearanceObject.Visibility == null || e.AppearanceObject.Visibility == ViewItemVisibility.Show)
     {
         if (View is ListView)
         {
             if (e.Item is ColumnWrapper)
             {
                 if (!DataManipulationRight.CanRead(View.ObjectTypeInfo.Type,
                                                    ((ColumnWrapper)e.Item).PropertyName, null,
                                                    ((ListView)View).CollectionSource, View.ObjectSpace))
                 {
                     e.AppearanceObject.Visibility = ViewItemVisibility.Hide;
                 }
             }
         }
         if (View is DetailView)
         {
             if (e.Item is PropertyEditor)
             {
                 if (!DataManipulationRight.CanRead(View.ObjectTypeInfo.Type,
                                                    ((PropertyEditor)e.Item).PropertyName,
                                                    e.ContextObjects.Length > 0 ? e.ContextObjects[0] : null, null,
                                                    View.ObjectSpace))
                 {
                     e.AppearanceObject.Visibility = ViewItemVisibility.Hide;
                 }
             }
         }
     }
 }
예제 #4
0
        protected virtual bool HasRights(ChoiceActionItem item, IModelView view)
        {
            var data = (ViewShortcut)item.Data;

            if (view == null)
            {
                throw new ArgumentException(string.Format("Cannot find the '{0}' view specified by the shortcut: {1}",
                                                          data.ViewId, data));
            }
            Type type = (view is IModelObjectView) ? ((IModelObjectView)view).ModelClass.TypeInfo.Type : null;

            if (type != null)
            {
                if (!string.IsNullOrEmpty(data.ObjectKey) && !data.ObjectKey.StartsWith("@"))
                {
                    try {
                        using (IObjectSpace space = CreateObjectSpace()) {
                            object objectByKey = space.GetObjectByKey(type, space.GetObjectKey(type, data.ObjectKey));
                            return(DataManipulationRight.CanRead(type, null, objectByKey, null, space) &&
                                   DataManipulationRight.CanNavigate(type, objectByKey, space));
                        }
                    } catch {
                        return(true);
                    }
                }
                return(DataManipulationRight.CanNavigate(type, null, null));
            }
            return(true);
        }
        protected virtual bool HasRights(ChoiceActionItem item, IModelView view)
        {
            var data = (ViewShortcut)item.Data;

            if (view == null)
            {
                if (Application.GetPlatform() == Platform.Win)
                {
                    throw new ArgumentException($"Cannot find the '{data.ViewId}' view specified by the shortcut: {data}");
                }

                var webApi = Application.WhenWeb().Wait();
                webApi.Redirect(webApi.GetRequestUri().GetLeftPart(UriPartial.Authority));
            }
            var  objectView = view as IModelObjectView;
            Type type       = objectView?.ModelClass.TypeInfo.Type;

            if (type != null)
            {
                if (!string.IsNullOrEmpty(data.ObjectKey) && !data.ObjectKey.StartsWith("@"))
                {
                    try {
                        using IObjectSpace space = CreateObjectSpace();
                        object objectByKey = space.GetObjectByKey(type, space.GetObjectKey(type, data.ObjectKey));
                        return(DataManipulationRight.CanRead(type, null, objectByKey, null, space) &&
                               DataManipulationRight.CanNavigate(type, objectByKey, space));
                    }
                    catch {
                        return(true);
                    }
                }
                return(DataManipulationRight.CanNavigate(type, null, null));
            }
            return(true);
        }
        bool GetCanRead(string name)
        {
            bool canRead = DataManipulationRight.CanRead(View.ObjectTypeInfo.Type, name, View.CurrentObject, null, View.ObjectSpace);
            bool fit     = ((MemberLevelObjectAccessComparer)ObjectAccessComparerBase.CurrentComparer).Fit(View.CurrentObject, View.ObjectTypeInfo.FindMember(name), MemberOperation.Read);

            return(!fit || canRead);
        }
예제 #7
0
        protected override void OnActivated()
        {
            base.OnActivated();
            var bussinessObjectType = XafTypesInfo.Instance.FindBussinessObjectType(typeof(ISerializationConfigurationGroup));

            _ioAction.Active["Security"] = DataManipulationRight.CanRead(bussinessObjectType, null, null, null, ObjectSpace);
        }
예제 #8
0
 public override void UpdateOpenObjectActionState(object objectToOpen)
 {
     base.UpdateOpenObjectActionState(objectToOpen);
     if (objectToOpen != null)
     {
         OpenObjectAction.Enabled[HasReadPermissionToTargetObjectEnabledKey] =
             DataManipulationRight.CanRead(objectToOpen.GetType(), null, objectToOpen,
                                           LinkToListViewController.FindCollectionSource(Controller.Frame),
                                           ObjectSpace);
     }
 }
예제 #9
0
        public override void OnControllerActivated()
        {
            base.OnControllerActivated();
            _listView = (ListView)Controller.View;
            OpenObjectAction.Active[
                DevExpress.ExpressApp.Win.SystemModule.OpenObjectController.ActiveKeyHasReadPermissionToTargetType] =
                DataManipulationRight.CanRead(_listView.ObjectTypeInfo.Type, null, null, _listView.CollectionSource,
                                              ObjectSpace);
            bool hasObjectRefControl = false;

            if (_listView.Model != null)
            {
                if (
                    _listView.Model.Columns.Select(
                        columnInfo => _listView.ObjectTypeInfo.FindMember(columnInfo.PropertyName)).Any(
                        findMember => findMember != null && IsDetailViewExists(findMember.MemberType)))
                {
                    hasObjectRefControl = true;
                }
            }
            OpenObjectAction.Active[ViewContainsObjectEditorActiveKey] = hasObjectRefControl;
            _listView.ControlsCreated += listView_ControlsCreated;
        }