public string GetCanEdit(string schemaName, Guid primaryColumnValue, bool isNew)
        {
            var userConnection = (UserConnection)HttpContext.Current.Session["UserConnection"];
            var schema         = userConnection.EntitySchemaManager.GetInstanceByName(schemaName);
            var rightsHelper   = GetRightsServiceHelper();
            SchemaOperationRightLevels rightLevels = userConnection.LicHelper.GetSchemaLicRights(schemaName, true);

            if (isNew)
            {
                bool canAppend = (rightLevels & SchemaOperationRightLevels.CanAppend) == SchemaOperationRightLevels.CanAppend;
                return(rightsHelper.GetCanAppendSchemaOperationRight(schemaName)
                                        ? string.Empty
                                        : (canAppend
                                                ? string.Format(new LocalizableString("Terrasoft.Core", "Entity.Exception.NoRightFor.Insert"), schema.Caption.Value)
                                                : string.Format(new LocalizableString("Terrasoft.Core", "LicHelper.Exception.LicenceNotFound"))));
            }
            bool canEditByLicRight   = (rightLevels & SchemaOperationRightLevels.CanEdit) == SchemaOperationRightLevels.CanEdit;
            bool canEditSchemaRecord = rightsHelper.GetCanEditSchemaRecordRight(schemaName, primaryColumnValue);

            if (rightsHelper.GetCanEditSchemaOperationRight(schemaName) && canEditSchemaRecord)
            {
                return(string.Empty);
            }
            if (!canEditSchemaRecord)
            {
                return(string.Format(new LocalizableString("Terrasoft.Core", "Entity.Exception.NoRightFor.Update"), schema.Caption.Value));
            }
            return(canEditByLicRight ? string.Format(new LocalizableString("Terrasoft.Core", "Entity.Exception.NoRightFor.Update"), schema.Caption.Value)
                                : string.Format(new LocalizableString("Terrasoft.Core", "LicHelper.Exception.LicenceNotFound")));
        }
        private bool HasRightsOnSchema(string schemaName)
        {
            SchemaOperationRightLevels rightsOnSchema = UserConnection.DBSecurityEngine.GetEntitySchemaOperationsRightLevel(schemaName);
            var hasAllRights    = rightsOnSchema.HasFlag(SchemaOperationRightLevels.All);
            var hasAppendRights = rightsOnSchema.HasFlag(SchemaOperationRightLevels.CanAppend);

            return(hasAllRights || hasAppendRights);
        }
        public string GetCanDelete(string schemaName, string primaryColumnValue)
        {
            var userConnection = (UserConnection)HttpContext.Current.Session["UserConnection"];
            var rightsHelper   = GetRightsServiceHelper();

            if (!rightsHelper.GetCanDeleteSchemaRecordRight(schemaName, new Guid(primaryColumnValue)))
            {
                SchemaOperationRightLevels rightLevels = userConnection.LicHelper.GetSchemaLicRights(schemaName, true);
                bool hasLicRight = (rightLevels & SchemaOperationRightLevels.CanDelete) == SchemaOperationRightLevels.CanDelete;
                if (hasLicRight)
                {
                    return("RightLevelWarningMessage");
                }
                return(string.Format(new LocalizableString("Terrasoft.Core", "LicHelper.Exception.LicenceNotFound")));
            }
            return(string.Empty);
        }
        public string GetSchemaDeleteRights(string schemaName)
        {
            var rightsHelper = GetRightsServiceHelper();

            if (rightsHelper.GetCanDeleteSchemaOperationRight(schemaName))
            {
                return(string.Empty);
            }
            var userConnection = (UserConnection)HttpContext.Current.Session["UserConnection"];
            SchemaOperationRightLevels rightLevels = userConnection.LicHelper.GetSchemaLicRights(schemaName, true);
            bool hasLicRight = (rightLevels & SchemaOperationRightLevels.CanDelete) == SchemaOperationRightLevels.CanDelete;

            if (hasLicRight)
            {
                return("RightLevelWarningMessage");
            }
            return("LicenceNotFound");
        }