Exemple #1
0
        protected virtual NormalWindow SetNormalWindowEntity(NormalWindow win, ModifiableEntity entity, ViewOptionsBase options, EntitySettings es, Control ctrl)
        {
            Type entityType = entity.GetType();

            win.MainControl    = ctrl;
            win.ShowOperations = options.ShowOperations;
            win.ViewMode       = options.ViewButtons;

            entity = options.Clone ? (ModifiableEntity)((ICloneable)entity).Clone() : entity;
            win.OnPreEntityLoaded(entity);
            win.DataContext = entity;

            if (options.ReadOnly ?? OnIsReadOnly(entityType, entity))
            {
                Common.SetIsReadOnly(win, true);
            }

            if (options is ViewOptions)
            {
                win.SaveProtected = ((ViewOptions)options).RequiresSaveOperation ??
                                    (typeof(Entity).IsAssignableFrom(entityType) && EntityKindCache.RequiresSaveOperation(entityType)); //Matters even on Ok
            }
            TaskNormalWindow?.Invoke(win, entity);

            return(win);
        }
Exemple #2
0
        public static MvcHtmlString RenderPopup(HtmlHelper helper, TypeContext typeContext, RenderPopupMode mode, EntityBase line, bool isTemplate = false)
        {
            TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext);

            ViewDataDictionary vdd = GetViewData(helper, line, tc);

            string partialViewName = line.PartialViewName ?? OnPartialViewName(tc);

            vdd[ViewDataKeys.PartialViewName]       = partialViewName;
            vdd[ViewDataKeys.ViewMode]              = !line.ReadOnly;
            vdd[ViewDataKeys.ViewMode]              = ViewMode.View;
            vdd[ViewDataKeys.ShowOperations]        = true;
            vdd[ViewDataKeys.RequiresSaveOperation] = EntityKindCache.RequiresSaveOperation(tc.UntypedValue.GetType());
            vdd[ViewDataKeys.WriteEntityState]      =
                !isTemplate &&
                !(tc.UntypedValue is EmbeddedEntity) &&
                ((ModifiableEntity)tc.UntypedValue).Modified == ModifiedState.SelfModified;

            switch (mode)
            {
            case RenderPopupMode.Popup:
                return(helper.Partial(Navigator.Manager.PopupControlView, vdd));

            case RenderPopupMode.PopupInDiv:
                return(helper.Div(typeContext.Compose(EntityBaseKeys.Entity),
                                  helper.Partial(Navigator.Manager.PopupControlView, vdd),
                                  "",
                                  new Dictionary <string, object> {
                    { "style", "display:none" }
                }));

            default:
                throw new InvalidOperationException();
            }
        }
Exemple #3
0
    internal static SchemaMapInfo GetMapInfo()
    {
        var getStats = GetRuntimeStats();

        var s     = Schema.Current;
        var nodes = (from t in s.Tables.Values
                     where s.IsAllowed(t.Type, true) == null
                     let type = EnumEntity.Extract(t.Type) ?? t.Type
                                select new TableInfo
        {
            typeName = TypeLogic.GetCleanName(t.Type),
            niceName = type.NiceName(),
            tableName = t.Name.ToString(),
            columns = t.Columns.Count,
            entityData = EntityKindCache.GetEntityData(t.Type),
            entityKind = EntityKindCache.GetEntityKind(t.Type),
            entityBaseType = GetEntityBaseType(t.Type),
            @namespace = type.Namespace !,
            rows = getStats.TryGetC(t.Name)?.rows,
            total_size_kb = getStats.TryGetC(t.Name)?.total_size_kb,
            rows_history = t.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.rows),
            total_size_kb_history = t.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.total_size_kb),
            mlistTables = t.TablesMList().Select(ml => new MListTableInfo
            {
                niceName = ml.PropertyRoute.PropertyInfo !.NiceName(),
                tableName = ml.Name.ToString(),
                rows = getStats.TryGetC(ml.Name)?.rows,
                total_size_kb = getStats.TryGetC(ml.Name)?.total_size_kb,
                history_rows = ml.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.rows),
                history_total_size_kb = ml.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.total_size_kb),
                columns = ml.Columns.Count,
            }).ToList()
Exemple #4
0
        static void OperationLogic_Initializing()
        {
            try
            {
                var types = Schema.Current.Tables.Keys
                            .Where(t => EntityKindCache.GetAttribute(t) == null)
                            .Select(a => "'" + a.TypeName() + "'")
                            .CommaAnd();

                if (types.HasText())
                {
                    throw new InvalidOperationException($"{0} has not EntityTypeAttribute".FormatWith(types));
                }

                var errors = (from t in Schema.Current.Tables.Keys
                              let attr = EntityKindCache.GetAttribute(t)
                                         where attr.RequiresSaveOperation && !HasExecuteNoLite(t)
                                         select attr.IsRequiresSaveOperationOverriden ?
                                         "'{0}' has '{1}' set to true, but no operation for saving has been implemented.".FormatWith(t.TypeName(), nameof(attr.RequiresSaveOperation)) :
                                         "'{0}' is 'EntityKind.{1}', but no operation for saving has been implemented.".FormatWith(t.TypeName(), attr.EntityKind)).ToList();

                if (errors.Any())
                {
                    throw new InvalidOperationException(errors.ToString("\r\n") + @"
Consider the following options:
    * Implement an operation for saving using 'save' snippet.
    * Change the EntityKind to a more appropiated one. 
    * Exceptionally, override the property EntityTypeAttribute.RequiresSaveOperation for your particular entity.");
                }
            }
            catch (Exception e) when(StartParameters.IgnoredCodeErrors != null)
            {
                StartParameters.IgnoredCodeErrors.Add(e);
            }
        }
Exemple #5
0
 protected virtual bool ShouldWriteExpression(ExpressionInfo ei)
 {
     return(EntityKindCache.GetEntityKind(ei.FromType) switch
     {
         EntityKind.Part or
         EntityKind.String or
         EntityKind.SystemString => false,
         _ => true,
     });
        protected virtual bool ShouldWriteExpression(ExpressionInfo ei)
        {
            switch (EntityKindCache.GetEntityKind(ei.FromType))
            {
            case EntityKind.Part:
            case EntityKind.String:
            case EntityKind.SystemString: return(false);

            default: return(true);
            }
        }
Exemple #7
0
        public static Dictionary <string, TypeInfoTS> GetEntities(IEnumerable <Type> allTypes)
        {
            var models = (from type in allTypes
                          where typeof(ModelEntity).IsAssignableFrom(type) && !type.IsAbstract
                          select type).ToList();

            var queries = QueryLogic.Queries;

            var schema   = Schema.Current;
            var settings = Schema.Current.Settings;

            var result = (from type in TypeLogic.TypeToEntity.Keys.Concat(models)
                          where !type.IsEnumEntity() && !ReflectionServer.ExcludeTypes.Contains(type)
                          let descOptions = LocalizedAssembly.GetDescriptionOptions(type)
                                            let allOperations = !type.IsEntity() ? null : OperationLogic.GetAllOperationInfos(type)
                                                                select KVP.Create(GetTypeName(type), OnAddTypeExtension(new TypeInfoTS
            {
                Kind = KindOfType.Entity,
                FullName = type.FullName,
                NiceName = descOptions.HasFlag(DescriptionOptions.Description) ? type.NiceName() : null,
                NicePluralName = descOptions.HasFlag(DescriptionOptions.PluralDescription) ? type.NicePluralName() : null,
                Gender = descOptions.HasFlag(DescriptionOptions.Gender) ? type.GetGender().ToString() : null,
                EntityKind = type.IsIEntity() ? EntityKindCache.GetEntityKind(type) : (EntityKind?)null,
                EntityData = type.IsIEntity() ? EntityKindCache.GetEntityData(type) : (EntityData?)null,
                IsLowPopulation = type.IsIEntity() ? EntityKindCache.IsLowPopulation(type) : false,
                IsSystemVersioned = type.IsIEntity() ? schema.Table(type).SystemVersioned != null : false,
                ToStringFunction = typeof(Symbol).IsAssignableFrom(type) ? null : LambdaToJavascriptConverter.ToJavascript(ExpressionCleaner.GetFieldExpansion(type, miToString)),
                QueryDefined = queries.QueryDefined(type),
                Members = PropertyRoute.GenerateRoutes(type).Where(pr => InTypeScript(pr))
                          .ToDictionary(p => p.PropertyString(), p =>
                {
                    var mi = new MemberInfoTS
                    {
                        NiceName = p.PropertyInfo?.NiceName(),
                        TypeNiceName = GetTypeNiceName(p.PropertyInfo?.PropertyType),
                        Format = p.PropertyRouteType == PropertyRouteType.FieldOrProperty ? Reflector.FormatString(p) : null,
                        IsReadOnly = !IsId(p) && (p.PropertyInfo?.IsReadOnly() ?? false),
                        Unit = UnitAttribute.GetTranslation(p.PropertyInfo?.GetCustomAttribute <UnitAttribute>()?.UnitName),
                        Type = new TypeReferenceTS(IsId(p) ? PrimaryKey.Type(type).Nullify() : p.PropertyInfo?.PropertyType, p.Type.IsMList() ? p.Add("Item").TryGetImplementations() : p.TryGetImplementations()),
                        IsMultiline = Validator.TryGetPropertyValidator(p)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault()?.MultiLine ?? false,
                        MaxLength = Validator.TryGetPropertyValidator(p)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault()?.Max.DefaultToNull(-1),
                        PreserveOrder = settings.FieldAttributes(p)?.OfType <PreserveOrderAttribute>().Any() ?? false,
                    };

                    return(OnAddPropertyRouteExtension(mi, p));
                }),

                Operations = allOperations == null ? null : allOperations.ToDictionary(oi => oi.OperationSymbol.Key, oi => OnAddOperationExtension(new OperationInfoTS(oi), oi, type)),

                RequiresEntityPack = allOperations != null && allOperations.Any(oi => oi.HasCanExecute != null),
            }, type))).ToDictionaryEx("entities");

            return(result);
        }
Exemple #8
0
 static void EntityEventsGlobal_Saving(Entity ident)
 {
     if (ident.IsGraphModified &&
         EntityKindCache.RequiresSaveOperation(ident.GetType()) && !AllowSaveGlobally && !IsSaveAllowedInContext(ident.GetType()))
     {
         throw new InvalidOperationException("Saving '{0}' is controlled by the operations. Use OperationLogic.AllowSave<{0}>() or execute {1}".FormatWith(
                                                 ident.GetType().Name,
                                                 operations.GetValue(ident.GetType()).Values
                                                 .Where(IsExecuteNoLite)
                                                 .CommaOr(o => o.OperationSymbol.Key)));
     }
 }
        static XElement GenerateField(PropertyInfo pi)
        {
            Type t  = pi.PropertyType;
            Type lt = t.CleanType();

            if (Reflector.IsIEntity(lt))
            {
                if (EntityKindCache.IsLowPopulation(lt))
                {
                    return(new XElement(m + "EntityCombo", new XAttribute(m + "Common.Route", pi.Name)));
                }
                else
                {
                    return(new XElement(m + "EntityLine", new XAttribute(m + "Common.Route", pi.Name)));
                }
            }

            if (t.IsEmbeddedEntity())
            {
                return(new XElement(xmlns + "GroupBox", new XAttribute("Header", pi.Name), new XAttribute(m + "Common.Route", pi.Name),
                                    GenerateStackPanel(t)));
            }

            if (Reflector.IsMList(t))
            {
                Type et = t.ElementType();
                if (Reflector.IsIEntity(et.CleanType()))
                {
                    return(new XElement(xmlns + "GroupBox", new XAttribute("Header", pi.Name),
                                        new XElement(m + "EntityList", new XAttribute(m + "Common.Route", pi.Name), new XAttribute("MaxHeight", "150"))));
                }

                if (et.IsEmbeddedEntity())
                {
                    return(new XElement(xmlns + "GroupBox", new XAttribute("Header", pi.Name),
                                        new XElement(xmlns + "Grid",
                                                     new XElement(xmlns + "Grid.ColumnDefinitions",
                                                                  new XElement(xmlns + "ColumnDefinition", new XAttribute("Width", "*")),
                                                                  new XElement(xmlns + "ColumnDefinition", new XAttribute("Width", "*"))),
                                                     new XElement(m + "EntityList", new XAttribute(m + "Common.Route", pi.Name), new XAttribute("ViewOnCreate", "False"), new XAttribute("Grid.Column", "0"), new XAttribute("MaxHeight", "150")),
                                                     new XElement(m + "DataBorder", new XAttribute(m + "Common.Route", pi.Name + "/"), new XAttribute("Grid.Column", "1"),
                                                                  GenerateStackPanel(et)))));
                }

                return
                    (new XElement(xmlns + "GroupBox", new XAttribute("Header", pi.Name),
                                  new XElement(xmlns + "ListBox", new XAttribute("ItemsSource", "{Binding " + pi.Name + "}"))));
            }

            return(new XElement(m + "ValueLine", new XAttribute(m + "Common.Route", pi.Name)));
        }
Exemple #10
0
        internal static void SetDefaultOrder(FindOptions findOptions, QueryDescription description)
        {
            var entityColumn = description.Columns.SingleOrDefaultEx(cd => cd.IsEntity);

            if (findOptions.OrderOptions.IsNullOrEmpty() && !entityColumn.Implementations.Value.IsByAll)
            {
                var orderType = entityColumn.Implementations.Value.Types.All(t => EntityKindCache.GetEntityData(t) == EntityData.Master) ? OrderType.Ascending : OrderType.Descending;

                var settings = Finder.QuerySettings(description.QueryName);

                var column = description.Columns.SingleOrDefaultEx(c => c.Name == settings.DefaultOrderColumn);

                if (column != null)
                {
                    findOptions.OrderOptions.Add(new OrderOption {
                        Token = new ColumnToken(column, description.QueryName), ColumnName = column.Name, OrderType = orderType
                    });
                }
            }
        }
Exemple #11
0
        public static void CacheTable <T>(SchemaBuilder sb) where T : Entity
        {
            AssertStarted(sb);

            EntityData data = EntityDataOverrides.TryGetS(typeof(T)) ?? EntityKindCache.GetEntityData(typeof(T));

            if (data == EntityData.Master)
            {
                var cc = new CacheController <T>(sb.Schema);
                controllers.AddOrThrow(typeof(T), cc, "{0} already registered");

                TryCacheSubTables(typeof(T), sb);
            }
            else //data == EntityData.Transactional
            {
                controllers.AddOrThrow(typeof(T), null, "{0} already registered");

                TryCacheSubTables(typeof(T), sb);
            }
        }
Exemple #12
0
    static void Schema_SchemaCompleted(SchemaBuilder sb)
    {
        foreach (var kvp in VirtualMList.RegisteredVirtualMLists)
        {
            var type = kvp.Key;

            if (controllers.TryGetCN(type) != null)
            {
                foreach (var vml in kvp.Value)
                {
                    var rType = vml.Value.BackReferenceRoute.RootType;

                    EntityData data = EntityDataOverrides.TryGetS(rType) ?? EntityKindCache.GetEntityData(rType);

                    if (data == EntityData.Transactional)
                    {
                        throw new InvalidOperationException($"Type {rType.Name} should be {nameof(EntityData)}.{nameof(EntityData.Master)} because is in a virtual MList of {type.Name} (Master and cached)");
                    }

                    TryCacheTable(sb, rType);

                    dependencies.Add(type, rType);
                    inverseDependencies.Add(rType, type);
                }
            }
        }

        foreach (var cont in controllers.Values.NotNull())
        {
            cont.BuildCachedTable();
        }

        foreach (var cont in controllers.Values.NotNull())
        {
            cont.CachedTable.SchemaCompleted();
        }
    }
Exemple #13
0
        static EntityBaseType GetEntityBaseType(Type type)
        {
            if (type.IsEnumEntity())
            {
                return(EntityBaseType.EnumEntity);
            }

            if (typeof(Symbol).IsAssignableFrom(type))
            {
                return(EntityBaseType.Symbol);
            }

            if (typeof(SemiSymbol).IsAssignableFrom(type))
            {
                return(EntityBaseType.SemiSymbol);
            }

            if (EntityKindCache.GetEntityKind(type) == EntityKind.Part)
            {
                return(EntityBaseType.Part);
            }

            return(EntityBaseType.Entity);
        }
Exemple #14
0
        internal static string GetEntityHelp(Type type)
        {
            string typeIs = HelpMessage._0IsA1.NiceToString().ForGenderAndNumber(type.BaseType.GetGender()).FormatWith(type.NiceName(), type.BaseType.NiceName());

            string kind = HelpKindMessage.HisMainFunctionIsTo0.NiceToString(GetEntityKindMessage(EntityKindCache.GetEntityKind(type), EntityKindCache.GetEntityData(type), type.GetGender()));

            return(typeIs + ". " + kind + ".");
        }
Exemple #15
0
        protected internal virtual PartialViewResult PopupControl(ControllerBase controller, TypeContext typeContext, PopupOptionsBase popupOptions)
        {
            Type cleanType = typeContext.UntypedValue.GetType();

            ModifiableEntity entity = (ModifiableEntity)typeContext.UntypedValue;

            AssertViewableEntitySettings(entity);

            controller.ViewData.Model = typeContext;
            controller.ViewData[ViewDataKeys.PartialViewName] = popupOptions.PartialViewName ?? Navigator.OnPartialViewName(entity);
            typeContext.ViewOverrides = Navigator.EntitySettings(entity.GetType()).GetViewOverrides();

            bool isReadOnly = popupOptions.ReadOnly ?? Navigator.IsReadOnly(entity);

            if (isReadOnly)
            {
                typeContext.ReadOnly = true;
            }

            ViewMode mode = popupOptions.ViewMode;

            controller.ViewData[ViewDataKeys.ViewMode]       = mode;
            controller.ViewData[ViewDataKeys.ShowOperations] = popupOptions.ShowOperations;
            if (mode == ViewMode.View)
            {
                controller.ViewData[ViewDataKeys.RequiresSaveOperation] = ((PopupViewOptions)popupOptions).RequiresSaveOperation ?? EntityKindCache.RequiresSaveOperation(entity.GetType());
            }

            return(new PartialViewResult
            {
                ViewName = PopupControlView,
                ViewData = controller.ViewData,
                TempData = controller.TempData
            });
        }
Exemple #16
0
        public virtual object View(object entityOrLite, ViewOptions options)
        {
            if (entityOrLite == null)
            {
                throw new ArgumentNullException("entity");
            }

            ModifiableEntity entity   = entityOrLite as ModifiableEntity;
            Type             liteType = null;

            if (entity == null)
            {
                liteType = Lite.Extract(entityOrLite.GetType());
                entity   = Server.Retrieve((Lite <Entity>)entityOrLite);
            }

            EntitySettings es = AssertViewableEntitySettings(entity);

            if (!es.OnIsViewable())
            {
                throw new Exception("{0} is not viewable".FormatWith(entity));
            }

            Control ctrl = options.View ?? es.CreateView(entity, options.PropertyRoute);

            ctrl = es.OnOverrideView(entity, ctrl);

            NormalWindow win = CreateNormalWindow();

            SetNormalWindowEntity(win, (ModifiableEntity)entity, options, es, ctrl);

            if (options.AllowErrors != AllowErrors.Ask)
            {
                win.AllowErrors = options.AllowErrors;
            }

            bool?ok = win.ShowDialog();

            if (ok != true)
            {
                return(null);
            }

            object result = win.DataContext;

            if (liteType != null)
            {
                Entity ident = (Entity)result;

                bool saveProtected = ((ViewOptions)options).RequiresSaveOperation ?? EntityKindCache.RequiresSaveOperation(ident.GetType());

                if (GraphExplorer.HasChanges(ident))
                {
                    if (saveProtected)
                    {
                        throw new InvalidOperationException("The lite '{0}' of type '{1}' is SaveProtected but has changes. Consider setting SaveProtected = false in ViewOptions".FormatWith(entityOrLite, liteType.TypeName()));
                    }

                    return(ident.ToLiteFat());
                }

                return(ident.ToLite());
            }
            return(result);
        }
        public static Control GetValueControl(QueryToken token, string bindingPath)
        {
            Type type = token.Type;

            if (type.IsLite())
            {
                Implementations implementations = token.GetImplementations().Value;

                Type cleanType = Lite.Extract(type);

                if (EntityKindCache.IsLowPopulation(cleanType) && !implementations.IsByAll)
                {
                    EntityCombo ec = new EntityCombo
                    {
                        Type            = type,
                        Implementations = implementations,
                    };

                    ec.SetBinding(EntityCombo.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors   = true,
                        ValidatesOnExceptions   = true,
                    });

                    return(ec);
                }
                else
                {
                    EntityLine el = new EntityLine
                    {
                        Type            = type,
                        Create          = false,
                        Implementations = implementations,
                    };

                    el.SetBinding(EntityLine.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors   = true,
                        ValidatesOnExceptions   = true
                    });

                    return(el);
                }
            }
            else if (type.IsEmbeddedEntity())
            {
                EntityLine el = new EntityLine
                {
                    Type            = type,
                    Create          = false,
                    Autocomplete    = false,
                    Find            = false,
                    Implementations = null,
                };

                el.SetBinding(EntityLine.EntityProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath),
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors   = true,
                    ValidatesOnExceptions   = true
                });

                return(el);
            }
            else
            {
                ValueLine vl = new ValueLine()
                {
                    Type     = type,
                    Format   = token.Format,
                    UnitText = token.Unit,
                };

                if (type.UnNullify().IsEnum)
                {
                    vl.ItemSource = EnumEntity.GetValues(type.UnNullify()).PreAndNull(type.IsNullable()).ToObservableCollection();
                }

                vl.SetBinding(ValueLine.ValueProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath), //odd
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors   = true,
                    ValidatesOnExceptions   = true,
                    Converter = Reflector.IsNumber(type) ? Converters.Identity : null,
                });

                return(vl);
            }
        }
Exemple #18
0
        internal static SchemaMapInfo GetMapInfo(out List <MapColorProvider> providers)
        {
            var getStats = GetRuntimeStats();

            var nodes = (from t in Schema.Current.Tables.Values
                         let type = EnumEntity.Extract(t.Type) ?? t.Type
                                    select new TableInfo
            {
                findUrl = Finder.IsFindable(t.Type) ? Finder.FindRoute(t.Type) : null,
                webTypeName = Navigator.ResolveWebTypeName(t.Type),
                niceName = type.NiceName(),
                tableName = t.Name.ToString(),
                columns = t.Columns.Count,
                entityData = EntityKindCache.GetEntityData(t.Type),
                entityKind = EntityKindCache.GetEntityKind(t.Type),
                entityBaseType = GetEntityBaseType(t.Type),
                @namespace = type.Namespace,
                rows = getStats.GetOrThrow(t.Name).rows,
                total_size_kb = getStats.GetOrThrow(t.Name).total_size_kb,
                mlistTables = t.TablesMList().Select(ml => new MListTableInfo
                {
                    niceName = ml.Field.Route.PropertyInfo.NiceName(),
                    tableName = ml.Name.ToString(),
                    rows = getStats.GetOrThrow(t.Name).rows,
                    total_size_kb = getStats.GetOrThrow(t.Name).total_size_kb,
                    columns = ml.Columns.Count,
                }).ToList()
            }).ToList();


            providers = MapClient.GetColorProviders.GetInvocationListTyped().SelectMany(f => f()).OrderBy(a => a.Order).ToList();



            var extraActions = providers.Select(a => a.AddExtra).NotNull().ToList();

            if (extraActions.Any())
            {
                foreach (var n in nodes)
                {
                    foreach (var action in extraActions)
                    {
                        action(n);
                    }
                }
            }

            var normalEdges = (from t in Schema.Current.Tables.Values
                               from kvp in t.DependentTables()
                               where !kvp.Value.IsCollection
                               select new RelationInfo
            {
                fromTable = t.Name.ToString(),
                toTable = kvp.Key.Name.ToString(),
                lite = kvp.Value.IsLite,
                nullable = kvp.Value.IsNullable
            }).ToList();

            var mlistEdges = (from t in Schema.Current.Tables.Values
                              from tm in t.TablesMList()
                              from kvp in tm.GetTables()
                              select new RelationInfo
            {
                fromTable = tm.Name.ToString(),
                toTable = kvp.Key.Name.ToString(),
                lite = kvp.Value.IsLite,
                nullable = kvp.Value.IsNullable
            }).ToList();

            return(new SchemaMapInfo {
                tables = nodes, relations = normalEdges.Concat(mlistEdges).ToList()
            });
        }
Exemple #19
0
        private static MvcHtmlString PrintValueField(HtmlHelper helper, Context parent, FilterOption filterOption)
        {
            var implementations = filterOption.Token.GetImplementations();

            if (filterOption.Token.Type.IsLite())
            {
                Lite <IEntity> lite = (Lite <IEntity>)Common.Convert(filterOption.Value, filterOption.Token.Type);
                if (lite != null && string.IsNullOrEmpty(lite.ToString()))
                {
                    Database.FillToString(lite);
                }

                Type cleanType = Lite.Extract(filterOption.Token.Type);
                if (EntityKindCache.IsLowPopulation(cleanType) && !cleanType.IsInterface && !implementations.Value.IsByAll)
                {
                    EntityCombo ec = new EntityCombo(filterOption.Token.Type, lite, parent, "", filterOption.Token.GetPropertyRoute())
                    {
                        Implementations = implementations.Value,
                    };
                    EntityBaseHelper.ConfigureEntityButtons(ec, filterOption.Token.Type.CleanType());
                    ec.FormGroupStyle = FormGroupStyle.None;
                    ec.Create         = false;
                    ec.ReadOnly       = filterOption.Frozen;
                    return(EntityComboHelper.InternalEntityCombo(helper, ec));
                }
                else
                {
                    EntityLine el = new EntityLine(filterOption.Token.Type, lite, parent, "", filterOption.Token.GetPropertyRoute())
                    {
                        Implementations = implementations.Value,
                    };

                    if (el.Implementations.Value.IsByAll)
                    {
                        el.Autocomplete = false;
                    }

                    EntityBaseHelper.ConfigureEntityButtons(el, filterOption.Token.Type.CleanType());
                    el.FormGroupStyle = FormGroupStyle.None;
                    el.Create         = false;
                    el.ReadOnly       = filterOption.Frozen;

                    return(EntityLineHelper.InternalEntityLine(helper, el));
                }
            }
            else if (filterOption.Token.Type.IsEmbeddedEntity())
            {
                EmbeddedEntity lite = (EmbeddedEntity)Common.Convert(filterOption.Value, filterOption.Token.Type);
                EntityLine     el   = new EntityLine(filterOption.Token.Type, lite, parent, "", filterOption.Token.GetPropertyRoute())
                {
                    Implementations = null,
                    Autocomplete    = false,
                };
                EntityBaseHelper.ConfigureEntityButtons(el, filterOption.Token.Type.CleanType());
                el.FormGroupStyle = FormGroupStyle.None;
                el.Create         = false;
                el.ReadOnly       = filterOption.Frozen;

                return(EntityLineHelper.InternalEntityLine(helper, el));
            }
            else
            {
                var vl = new ValueLine(filterOption.Token.Type, filterOption.Value, parent, "", filterOption.Token.GetPropertyRoute())
                {
                    FormGroupStyle = FormGroupStyle.None,
                    ReadOnly       = filterOption.Frozen,
                    Format         = filterOption.Token.Format,
                    UnitText       = filterOption.Token.Unit,
                };

                if (filterOption.Token.Type.UnNullify().IsEnum)
                {
                    vl.EnumComboItems = ValueLine.CreateComboItems(EnumEntity.GetValues(vl.Type.UnNullify()), vl.UntypedValue == null || vl.Type.IsNullable());
                }

                return(ValueLineHelper.ValueLine(helper, vl));
            }

            throw new InvalidOperationException("Invalid filter for type {0}".FormatWith(filterOption.Token.Type.Name));
        }
Exemple #20
0
        public override void Execute()
        {
            #line 4 "..\..\AuthAdmin\Views\Types.cshtml"
            Write(Html.ScriptCss("~/authAdmin/Content/AuthAdmin.css"));


            #line default
            #line hidden
            WriteLiteral("\r\n<script");

            WriteLiteral(" type=\"text/javascript\"");

            WriteLiteral(">\r\n    $(function () {\r\n        require([\"");


            #line 7 "..\..\AuthAdmin\Views\Types.cshtml"
            Write(AuthAdminClient.Module);


            #line default
            #line hidden
            WriteLiteral(@"""], function (AuthAdmin) {
            AuthAdmin.multiSelRadios($(document));
            AuthAdmin.treeView();
            $("".sf-auth-rules .sf-submodule-trigger"").click(AuthAdmin.openDialog);
            $(document).on(""click"", "".sf-auth-rules .sf-remove"", AuthAdmin.removeCondition);
            $(document).on(""click"", "".sf-auth-rules .sf-create"", function (e) {
                e.preventDefault();
                AuthAdmin.chooseConditionToAdd($(this), '");


            #line 14 "..\..\AuthAdmin\Views\Types.cshtml"
            Write(AuthMessage.AuthAdmin_ChooseACondition.NiceToString());


            #line default
            #line hidden
            WriteLiteral("\');\r\n            });\r\n        });\r\n    });\r\n</script>\r\n");


            #line 19 "..\..\AuthAdmin\Views\Types.cshtml"

            bool propertyRules  = Navigator.Manager.EntitySettings.ContainsKey(typeof(PropertyRulePack));
            bool operationRules = Navigator.Manager.EntitySettings.ContainsKey(typeof(OperationRulePack));
            bool queryRules     = Navigator.Manager.EntitySettings.ContainsKey(typeof(QueryRulePack));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 24 "..\..\AuthAdmin\Views\Types.cshtml"
            using (var tc = Html.TypeContext <TypeRulePack>())
            {
            #line default
            #line hidden
                WriteLiteral("    <div");

                WriteLiteral(" class=\"form-compact\"");

                WriteLiteral(">\r\n");

                WriteLiteral("        ");


            #line 27 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(Html.EntityLine(tc, f => f.Role));


            #line default
            #line hidden
                WriteLiteral("\r\n");

                WriteLiteral("        ");


            #line 28 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(Html.ValueLine(tc, f => f.Strategy));


            #line default
            #line hidden
                WriteLiteral("\r\n    </div>\r\n");

                WriteLiteral("    <table");

                WriteLiteral(" class=\"sf-auth-rules\"");

                WriteLiteral(">\r\n        <thead>\r\n            <tr>\r\n                <th>");


            #line 33 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(typeof(TypeEntity).NiceName());


            #line default
            #line hidden
                WriteLiteral("\r\n                </th>\r\n                <th>");


            #line 35 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(TypeAllowed.Create.NiceToString());


            #line default
            #line hidden
                WriteLiteral("\r\n                </th>\r\n                <th>");


            #line 37 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(TypeAllowed.Modify.NiceToString());


            #line default
            #line hidden
                WriteLiteral("\r\n                </th>\r\n                <th>");


            #line 39 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(TypeAllowed.Read.NiceToString());


            #line default
            #line hidden
                WriteLiteral("\r\n                </th>\r\n                <th>");


            #line 41 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(TypeAllowed.None.NiceToString());


            #line default
            #line hidden
                WriteLiteral("\r\n                </th>\r\n                <th>");


            #line 43 "..\..\AuthAdmin\Views\Types.cshtml"
                Write(AuthAdminMessage.Overriden.NiceToString());


            #line default
            #line hidden
                WriteLiteral("\r\n                </th>\r\n");


            #line 45 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 45 "..\..\AuthAdmin\Views\Types.cshtml"
                if (propertyRules)
                {
            #line default
            #line hidden
                    WriteLiteral("                    <th>");


            #line 47 "..\..\AuthAdmin\Views\Types.cshtml"
                    Write(typeof(PropertyRouteEntity).NiceName());


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </th>\r\n");


            #line 49 "..\..\AuthAdmin\Views\Types.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("                ");


            #line 50 "..\..\AuthAdmin\Views\Types.cshtml"
                if (operationRules)
                {
            #line default
            #line hidden
                    WriteLiteral("                    <th>");


            #line 52 "..\..\AuthAdmin\Views\Types.cshtml"
                    Write(typeof(OperationSymbol).NiceName());


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </th>\r\n");


            #line 54 "..\..\AuthAdmin\Views\Types.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("                ");


            #line 55 "..\..\AuthAdmin\Views\Types.cshtml"
                if (queryRules)
                {
            #line default
            #line hidden
                    WriteLiteral("                    <th>");


            #line 57 "..\..\AuthAdmin\Views\Types.cshtml"
                    Write(typeof(QueryEntity).NiceName());


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </th>\r\n");


            #line 59 "..\..\AuthAdmin\Views\Types.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("            </tr>\r\n        </thead>\r\n");


            #line 62 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 62 "..\..\AuthAdmin\Views\Types.cshtml"
                foreach (var iter in tc.TypeElementContext(p => p.Rules).GroupBy(a => a.Value.Resource.Namespace).OrderBy(a => a.Key).Iterate())
                {
            #line default
            #line hidden
                    WriteLiteral("            <tr>\r\n                <td");

                    WriteLiteral(" colspan=\"6\"");

                    WriteLiteral(">\r\n                    <a");

                    WriteLiteral(" class=\"sf-auth-namespace\"");

                    WriteLiteral("><span");

                    WriteAttribute("class", Tuple.Create(" class=\"", 2624), Tuple.Create("\"", 2706)
                                   , Tuple.Create(Tuple.Create("", 2632), Tuple.Create("sf-auth-tree", 2632), true)

            #line 66 "..\..\AuthAdmin\Views\Types.cshtml"
                                   , Tuple.Create(Tuple.Create(" ", 2644), Tuple.Create <System.Object, System.Int32>(iter.IsLast ? "sf-auth-expanded-last" : "sf-auth-expanded"

            #line default
            #line hidden
                                                                                                                      , 2645), false)
                                   );

                    WriteLiteral("></span>\r\n                        <img");

                    WriteAttribute("src", Tuple.Create(" src=\"", 2745), Tuple.Create("\"", 2799)

            #line 67 "..\..\AuthAdmin\Views\Types.cshtml"
                                   , Tuple.Create(Tuple.Create("", 2751), Tuple.Create <System.Object, System.Int32>(Url.Content("~/authAdmin/Images/namespace.png")

            #line default
            #line hidden
                                                                                                                     , 2751), false)
                                   );

                    WriteLiteral(" />\r\n                        <span");

                    WriteLiteral(" class=\"sf-auth-namespace-name\"");

                    WriteLiteral(">");


            #line 68 "..\..\AuthAdmin\Views\Types.cshtml"
                    Write(iter.Value.Key);


            #line default
            #line hidden
                    WriteLiteral("</span> </a>\r\n                </td>\r\n            </tr>\r\n");


            #line 71 "..\..\AuthAdmin\Views\Types.cshtml"
                    foreach (var iter2 in iter.Value.OrderBy(a => a.Value.Resource.CleanName).Iterate())
                    {
                        var item = iter2.Value;
                        var type = item.Value.Resource.ToType();
                        var attr = EntityKindCache.GetAttribute(type);


            #line default
            #line hidden
                        WriteLiteral("            <tr");

                        WriteLiteral(" class=\"sf-auth-type\"");

                        WriteLiteral(" data-ns=\"");


            #line 76 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(iter.Value.Key);


            #line default
            #line hidden
                        WriteLiteral("\"");

                        WriteLiteral(" ");


            #line 76 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(Html.Raw(item.Value.AvailableConditions.Any() ? ("data-type=\"" + item.Value.Resource.ClassName + "\"") : ""));


            #line default
            #line hidden
                        WriteLiteral(">\r\n                <td>\r\n                    <div");

                        WriteAttribute("class", Tuple.Create(" class=\"", 3438), Tuple.Create("\"", 3508)
                                       , Tuple.Create(Tuple.Create("", 3446), Tuple.Create("sf-auth-tree", 3446), true)

            #line 78 "..\..\AuthAdmin\Views\Types.cshtml"
                                       , Tuple.Create(Tuple.Create(" ", 3458), Tuple.Create <System.Object, System.Int32>(iter.IsLast ? "sf-auth-blank" : "sf-auth-line"

            #line default
            #line hidden
                                                                                                                          , 3459), false)
                                       );

                        WriteLiteral(">\r\n                    </div>\r\n                    <div");

                        WriteAttribute("class", Tuple.Create(" class=\"", 3564), Tuple.Create("\"", 3639)
                                       , Tuple.Create(Tuple.Create("", 3572), Tuple.Create("sf-auth-tree", 3572), true)

            #line 80 "..\..\AuthAdmin\Views\Types.cshtml"
                                       , Tuple.Create(Tuple.Create(" ", 3584), Tuple.Create <System.Object, System.Int32>(iter2.IsLast ? "sf-auth-leaf-last" : "sf-auth-leaf"

            #line default
            #line hidden
                                                                                                                          , 3585), false)
                                       );

                        WriteLiteral(">\r\n                    </div>\r\n");


            #line 82 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 82 "..\..\AuthAdmin\Views\Types.cshtml"
                        if (!item.Value.AvailableConditions.IsNullOrEmpty())
                        {
            #line default
            #line hidden
                            WriteLiteral("                        <a");

                            WriteAttribute("title", Tuple.Create(" title=\"", 3821), Tuple.Create("\"", 3879)

            #line 85 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create("", 3829), Tuple.Create <System.Object, System.Int32>(AuthMessage.AuthAdmin_AddCondition.NiceToString()

            #line default
            #line hidden
                                                                                                                             , 3829), false)
                                           );

                            WriteLiteral(" class=\"sf-line-button sf-create sf-auth-condition-button\"");

                            WriteAttribute("style", Tuple.Create(" \r\n                            style=\"", 3938), Tuple.Create("\"", 4076)

            #line 86 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create("", 3976), Tuple.Create <System.Object, System.Int32>(item.Value.Allowed.Conditions.Count == item.Value.AvailableConditions.Count ? "display:none" : ""

            #line default
            #line hidden
                                                                                                                             , 3976), false)
                                           );

                            WriteLiteral(">\r\n                            <span");

                            WriteLiteral(" class=\"glyphicon glyphicon-plus\"");

                            WriteLiteral("></span></a>\r\n");


            #line 88 "..\..\AuthAdmin\Views\Types.cshtml"



            #line default
            #line hidden
                            WriteLiteral("                        <input");

                            WriteLiteral(" type=\"hidden\"");

                            WriteLiteral(" disabled=\"disabled\"");

                            WriteLiteral(" class=\"sf-auth-available-conditions\"");

                            WriteAttribute("value", Tuple.Create(" value=\"", 4287), Tuple.Create("\"", 4395)

            #line 89 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create("", 4295), Tuple.Create <System.Object, System.Int32>(item.Value.AvailableConditions.ToString(ac => "{0}|{1}".FormatWith(ac.Key, ac.NiceToString()), ",")

            #line default
            #line hidden
                                                                                                                             , 4295), false)
                                           );

                            WriteLiteral(" />\r\n");


            #line 90 "..\..\AuthAdmin\Views\Types.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("                    <span");

                        WriteLiteral(" class=\"sf-auth-label\"");

                        WriteLiteral(">");


            #line 91 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(type.NiceName());


            #line default
            #line hidden
                        WriteLiteral("</span> <small>");


            #line 91 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(attr.EntityKind);


            #line default
            #line hidden
                        WriteLiteral("/");


            #line 91 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(attr.EntityData);


            #line default
            #line hidden
                        WriteLiteral("</small>\r\n");

                        WriteLiteral("                    ");


            #line 92 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(Html.HiddenRuntimeInfo(item, i => i.Resource));


            #line default
            #line hidden
                        WriteLiteral("\r\n");

                        WriteLiteral("                    ");


            #line 93 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(Html.Hidden(item.Compose("AllowedBase"), (item.Value.AllowedBase.Fallback?.ToStringParts() ?? "Error") + (item.Value.AllowedBase.Conditions.IsEmpty() ? "" : (";" + item.Value.AllowedBase.Conditions.ToString(a => "{0}-{1}".FormatWith(a.TypeCondition.Key, a.Allowed.ToStringParts()), ";")))));


            #line default
            #line hidden
                        WriteLiteral("\r\n                </td>\r\n");


            #line 95 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 95 "..\..\AuthAdmin\Views\Types.cshtml"
                        using (var fallback = item.SubContext(a => a.Allowed.Fallback))
                        {
            #line default
            #line hidden
                            WriteLiteral("                    <td>\r\n                        <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-create\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                            ");


            #line 99 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(fallback.Compose("Create"), fallback.Value.HasValue && fallback.Value.Value.IsActive(TypeAllowedBasic.Create), new Dictionary <string, object> {
                                { "data-tag", "Create" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                        </a>\r\n                    </td>\r\n");

                            WriteLiteral("                    <td>\r\n                        <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-modify\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                            ");


            #line 104 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(fallback.Compose("Modify"), fallback.Value.HasValue && fallback.Value.Value.IsActive(TypeAllowedBasic.Modify), new Dictionary <string, object> {
                                { "data-tag", "Modify" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                        </a>\r\n                    </td>\r\n");

                            WriteLiteral("                    <td>\r\n                        <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-read\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                            ");


            #line 109 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(fallback.Compose("Read"), fallback.Value.HasValue && fallback.Value.Value.IsActive(TypeAllowedBasic.Read), new Dictionary <string, object> {
                                { "data-tag", "Read" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                        </a>\r\n                    </td>\r\n");

                            WriteLiteral("                    <td>\r\n                        <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-none\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                            ");


            #line 114 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(fallback.Compose("None"), fallback.Value.HasValue && fallback.Value.Value.IsActive(TypeAllowedBasic.None), new Dictionary <string, object> {
                                { "data-tag", "None" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                        </a>\r\n                    </td>\r\n");


            #line 117 "..\..\AuthAdmin\Views\Types.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("                <td");

                        WriteLiteral(" class=\"sf-auth-type-only\"");

                        WriteLiteral(">\r\n");

                        WriteLiteral("                    ");


            #line 119 "..\..\AuthAdmin\Views\Types.cshtml"
                        Write(Html.CheckBox(item.Compose("Overriden"), item.Value.Overriden, new { disabled = "disabled", @class = "sf-auth-overriden" }));


            #line default
            #line hidden
                        WriteLiteral("\r\n                </td>\r\n");


            #line 121 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 121 "..\..\AuthAdmin\Views\Types.cshtml"
                        if (propertyRules)
                        {
            #line default
            #line hidden
                            WriteLiteral("                    <td");

                            WriteLiteral(" class=\"sf-auth-type-only\"");

                            WriteLiteral(">\r\n");


            #line 124 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 124 "..\..\AuthAdmin\Views\Types.cshtml"
                            if (item.Value.Properties.HasValue)
                            {
            #line default
            #line hidden
                                WriteLiteral("                            <div");

                                WriteLiteral(" class=\"sf-auth-property\"");

                                WriteLiteral(">\r\n                                <a");

                                WriteLiteral(" class=\"sf-submodule-trigger\"");

                                WriteAttribute("href", Tuple.Create(" href=\"", 7058), Tuple.Create("\"", 7162)

            #line 127 "..\..\AuthAdmin\Views\Types.cshtml"
                                               , Tuple.Create(Tuple.Create("", 7065), Tuple.Create <System.Object, System.Int32>(Url.Action((AuthAdminController a) => a.Properties(tc.Value.Role, item.Value.Resource.ToLite()))

            #line default
            #line hidden
                                                                                                                                 , 7065), false)
                                               );

                                WriteLiteral(">\r\n                                    <span");

                                WriteAttribute("class", Tuple.Create(" class=\"", 7207), Tuple.Create("\"", 7280)
                                               , Tuple.Create(Tuple.Create("", 7215), Tuple.Create("sf-auth-thumb", 7215), true)
                                               , Tuple.Create(Tuple.Create(" ", 7228), Tuple.Create("sf-auth-", 7229), true)

            #line 128 "..\..\AuthAdmin\Views\Types.cshtml"
                                               , Tuple.Create(Tuple.Create("", 7237), Tuple.Create <System.Object, System.Int32>(item.Value.Properties.ToString().ToLower()

            #line default
            #line hidden
                                                                                                                                 , 7237), false)
                                               );

                                WriteLiteral("></span></a>\r\n                            </div>\r\n");


            #line 130 "..\..\AuthAdmin\Views\Types.cshtml"
                            }


            #line default
            #line hidden
                            WriteLiteral("                    </td>\r\n");


            #line 132 "..\..\AuthAdmin\Views\Types.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("                ");


            #line 133 "..\..\AuthAdmin\Views\Types.cshtml"
                        if (operationRules)
                        {
            #line default
            #line hidden
                            WriteLiteral("                    <td");

                            WriteLiteral(" class=\"sf-auth-type-only\"");

                            WriteLiteral(">\r\n");


            #line 136 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 136 "..\..\AuthAdmin\Views\Types.cshtml"
                            if (item.Value.Operations.HasValue)
                            {
            #line default
            #line hidden
                                WriteLiteral("                            <div");

                                WriteLiteral(" class=\"sf-auth-operation\"");

                                WriteLiteral(">\r\n                                <a");

                                WriteLiteral(" class=\"sf-submodule-trigger\"");

                                WriteAttribute("href", Tuple.Create(" href=\"", 7726), Tuple.Create("\"", 7830)

            #line 139 "..\..\AuthAdmin\Views\Types.cshtml"
                                               , Tuple.Create(Tuple.Create("", 7733), Tuple.Create <System.Object, System.Int32>(Url.Action((AuthAdminController a) => a.Operations(tc.Value.Role, item.Value.Resource.ToLite()))

            #line default
            #line hidden
                                                                                                                                 , 7733), false)
                                               );

                                WriteLiteral(">\r\n                                    <span");

                                WriteAttribute("class", Tuple.Create(" class=\"", 7875), Tuple.Create("\"", 7948)
                                               , Tuple.Create(Tuple.Create("", 7883), Tuple.Create("sf-auth-thumb", 7883), true)
                                               , Tuple.Create(Tuple.Create(" ", 7896), Tuple.Create("sf-auth-", 7897), true)

            #line 140 "..\..\AuthAdmin\Views\Types.cshtml"
                                               , Tuple.Create(Tuple.Create("", 7905), Tuple.Create <System.Object, System.Int32>(item.Value.Operations.ToString().ToLower()

            #line default
            #line hidden
                                                                                                                                 , 7905), false)
                                               );

                                WriteLiteral("></span></a>\r\n                            </div>\r\n");


            #line 142 "..\..\AuthAdmin\Views\Types.cshtml"
                            }


            #line default
            #line hidden
                            WriteLiteral("                    </td>\r\n");


            #line 144 "..\..\AuthAdmin\Views\Types.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("                ");


            #line 145 "..\..\AuthAdmin\Views\Types.cshtml"
                        if (queryRules)
                        {
            #line default
            #line hidden
                            WriteLiteral("                    <td");

                            WriteLiteral(" class=\"sf-auth-type-only\"");

                            WriteLiteral(">\r\n");


            #line 148 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 148 "..\..\AuthAdmin\Views\Types.cshtml"
                            if (item.Value.Queries.HasValue)
                            {
            #line default
            #line hidden
                                WriteLiteral("                            <div");

                                WriteLiteral(" class=\"sf-auth-query\"");

                                WriteLiteral(">\r\n                                <a");

                                WriteLiteral(" class=\"sf-submodule-trigger\"");

                                WriteAttribute("href", Tuple.Create(" href=\"", 8383), Tuple.Create("\"", 8484)

            #line 151 "..\..\AuthAdmin\Views\Types.cshtml"
                                               , Tuple.Create(Tuple.Create("", 8390), Tuple.Create <System.Object, System.Int32>(Url.Action((AuthAdminController a) => a.Queries(tc.Value.Role, item.Value.Resource.ToLite()))

            #line default
            #line hidden
                                                                                                                                 , 8390), false)
                                               );

                                WriteLiteral(">\r\n                                    <span");

                                WriteAttribute("class", Tuple.Create(" class=\"", 8529), Tuple.Create("\"", 8599)
                                               , Tuple.Create(Tuple.Create("", 8537), Tuple.Create("sf-auth-thumb", 8537), true)
                                               , Tuple.Create(Tuple.Create(" ", 8550), Tuple.Create("sf-auth-", 8551), true)

            #line 152 "..\..\AuthAdmin\Views\Types.cshtml"
                                               , Tuple.Create(Tuple.Create("", 8559), Tuple.Create <System.Object, System.Int32>(item.Value.Queries.ToString().ToLower()

            #line default
            #line hidden
                                                                                                                                 , 8559), false)
                                               );

                                WriteLiteral("></span>\r\n                                </a>\r\n                            </div" +
                                             ">\r\n");


            #line 155 "..\..\AuthAdmin\Views\Types.cshtml"
                            }


            #line default
            #line hidden
                            WriteLiteral("                    </td>\r\n");


            #line 157 "..\..\AuthAdmin\Views\Types.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("            </tr>\r\n");


            #line 159 "..\..\AuthAdmin\Views\Types.cshtml"
                        var conditions = item.Compose("Allowed", "Conditions");

                        foreach (var conditionIter in item.Value.Allowed.Conditions.Select((c, i) => new { Condition = c, Index = i, Prefix = TypeContextUtilities.Compose(conditions, i.ToString()) }).Iterate())
                        {
                            var condition = conditionIter.Value.Condition;
                            var prefix    = conditionIter.Value.Prefix;



            #line default
            #line hidden
                            WriteLiteral("            <tr");

                            WriteLiteral(" class=\"sf-auth-condition\"");

                            WriteLiteral(" data-ns=\"");


            #line 166 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(iter.Value.Key);


            #line default
            #line hidden
                            WriteLiteral("\"");

                            WriteLiteral(" data-type=\"");


            #line 166 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(item.Value.Resource.ClassName);


            #line default
            #line hidden
                            WriteLiteral("\"");

                            WriteLiteral(" data-condition=\"");


            #line 166 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(condition.TypeCondition.Key);


            #line default
            #line hidden
                            WriteLiteral("\"");

                            WriteLiteral(" data-index=\"");


            #line 166 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(conditionIter.Value.Index);


            #line default
            #line hidden
                            WriteLiteral("\"");

                            WriteLiteral(">\r\n                <td>\r\n                    <div");

                            WriteAttribute("class", Tuple.Create(" class=\"", 9475), Tuple.Create("\"", 9545)
                                           , Tuple.Create(Tuple.Create("", 9483), Tuple.Create("sf-auth-tree", 9483), true)

            #line 168 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create(" ", 9495), Tuple.Create <System.Object, System.Int32>(iter.IsLast ? "sf-auth-blank" : "sf-auth-line"

            #line default
            #line hidden
                                                                                                                              , 9496), false)
                                           );

                            WriteLiteral(">\r\n                    </div>\r\n                    <div");

                            WriteAttribute("class", Tuple.Create(" class=\"", 9601), Tuple.Create("\"", 9672)
                                           , Tuple.Create(Tuple.Create("", 9609), Tuple.Create("sf-auth-tree", 9609), true)

            #line 170 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create(" ", 9621), Tuple.Create <System.Object, System.Int32>(iter2.IsLast ? "sf-auth-blank" : "sf-auth-line"

            #line default
            #line hidden
                                                                                                                              , 9622), false)
                                           );

                            WriteLiteral(">\r\n                    </div>\r\n                    <div");

                            WriteAttribute("class", Tuple.Create(" class=\"", 9728), Tuple.Create("\"", 9811)
                                           , Tuple.Create(Tuple.Create("", 9736), Tuple.Create("sf-auth-tree", 9736), true)

            #line 172 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create(" ", 9748), Tuple.Create <System.Object, System.Int32>(conditionIter.IsLast ? "sf-auth-leaf-last" : "sf-auth-leaf"

            #line default
            #line hidden
                                                                                                                              , 9749), false)
                                           );

                            WriteLiteral(">\r\n                    </div>\r\n                    <a");

                            WriteLiteral(" class=\"sf-line-button sf-remove sf-auth-condition-button\"");

                            WriteAttribute("title", Tuple.Create(" title=\"", 9923), Tuple.Create("\"", 9986)

            #line 174 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create("", 9931), Tuple.Create <System.Object, System.Int32>(AuthMessage.AuthAdmin_RemoveCondition.NiceToString()

            #line default
            #line hidden
                                                                                                                             , 9931), false)
                                           );

                            WriteLiteral(">\r\n                        <span");

                            WriteLiteral(" class=\"glyphicon glyphicon-remove\"");

                            WriteLiteral("></span></a>\r\n                    <span");

                            WriteLiteral(" class=\"sf-auth-label\"");

                            WriteLiteral(">");


            #line 176 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(condition.TypeCondition.NiceToString());


            #line default
            #line hidden
                            WriteLiteral("</span>\r\n");

                            WriteLiteral("                    ");


            #line 177 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.Hidden(TypeContextUtilities.Compose(prefix, "ConditionName"), condition.TypeCondition.Key));


            #line default
            #line hidden
                            WriteLiteral("\r\n                </td>\r\n\r\n");


            #line 180 "..\..\AuthAdmin\Views\Types.cshtml"


            #line default
            #line hidden

            #line 180 "..\..\AuthAdmin\Views\Types.cshtml"
                            var allowed = TypeContextUtilities.Compose(prefix, "Allowed");

            #line default
            #line hidden
                            WriteLiteral("\r\n\r\n                <td>\r\n                    <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-create\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                        ");


            #line 184 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(TypeContextUtilities.Compose(allowed, "Create"), condition.Allowed.IsActive(TypeAllowedBasic.Create), new Dictionary <string, object> {
                                { "data-tag", "Create" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                    </a>\r\n                </td>\r\n                <td>\r\n        " +
                                         "            <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-modify\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                        ");


            #line 189 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(TypeContextUtilities.Compose(allowed, "Modify"), condition.Allowed.IsActive(TypeAllowedBasic.Modify), new Dictionary <string, object> {
                                { "data-tag", "Modify" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                    </a>\r\n                </td>\r\n                <td>\r\n        " +
                                         "            <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-read\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                        ");


            #line 194 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(TypeContextUtilities.Compose(allowed, "Read"), condition.Allowed.IsActive(TypeAllowedBasic.Read), new Dictionary <string, object> {
                                { "data-tag", "Read" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                    </a>\r\n                </td>\r\n                <td>\r\n        " +
                                         "            <a");

                            WriteLiteral(" class=\"sf-auth-chooser sf-auth-none\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                        ");


            #line 199 "..\..\AuthAdmin\Views\Types.cshtml"
                            Write(Html.CheckBox(TypeContextUtilities.Compose(allowed, "None"), condition.Allowed.IsActive(TypeAllowedBasic.None), new Dictionary <string, object> {
                                { "data-tag", "None" }
                            }));


            #line default
            #line hidden
                            WriteLiteral("\r\n                    </a>\r\n                </td>\r\n\r\n                <td");

                            WriteAttribute("colspan", Tuple.Create(" colspan=\"", 11749), Tuple.Create("\"", 11839)

            #line 203 "..\..\AuthAdmin\Views\Types.cshtml"
                                           , Tuple.Create(Tuple.Create("", 11759), Tuple.Create <System.Object, System.Int32>(1 + (propertyRules ? 1 : 0) + (operationRules ? 1 : 0) + (queryRules ? 1 : 0)

            #line default
            #line hidden
                                                                                                                              , 11759), false)
                                           );

                            WriteLiteral("></td>\r\n            </tr>\r\n");


            #line 205 "..\..\AuthAdmin\Views\Types.cshtml"
                        }
                    }
                }


            #line default
            #line hidden
                WriteLiteral("    </table>\r\n");


            #line 209 "..\..\AuthAdmin\Views\Types.cshtml"
            }


            #line default
            #line hidden
        }
Exemple #21
0
        public void OnLoaded()
        {
            if (loaded)
            {
                return;
            }

            loaded = true;

            if (FilterColumn.HasText())
            {
                FilterOptions.Add(new FilterOption
                {
                    ColumnName = FilterColumn,
                    Operation  = FilterOperation.EqualTo,
                    Frozen     = true,
                }.Bind(FilterOption.ValueProperty, new Binding("DataContext" + (FilterRoute.HasText() ? "." + FilterRoute : null))
                {
                    Source = this
                }));

                if (QueryUtils.IsColumnToken(FilterColumn))
                {
                    ColumnOptions.Add(new ColumnOption(FilterColumn));
                    ColumnOptionsMode = ColumnOptionsMode.Remove;
                }
                if (this.NotSet(SearchOnLoadProperty))
                {
                    SearchOnLoad = true;
                }
            }

            if (OrderOptions.IsNullOrEmpty() && !entityColumn.Implementations.Value.IsByAll)
            {
                var orderType = entityColumn.Implementations.Value.Types.All(t => EntityKindCache.GetEntityData(t) == EntityData.Master) ? OrderType.Ascending : OrderType.Descending;

                var column = Description.Columns.SingleOrDefaultEx(c => c.Name == "Id");

                if (column != null)
                {
                    OrderOptions.Add(new OrderOption(column.Name, orderType));
                }
            }

            btCreate.ToolTip = SearchMessage.CreateNew0_G.NiceToString()
                               .ForGenderAndNumber(entityColumn.Implementations.Value.Types.FirstOrDefault()?.GetGender() ?? 'm')
                               .FormatWith(entityColumn.Implementations.Value.Types.CommaOr(a => a.NiceName()));

            if (this.NotSet(SearchControl.NavigateProperty) && Navigate)
            {
                Navigate = Implementations.IsByAll ? true :
                           Implementations.Types.Any(t => Navigator.IsNavigable(t, isSearch: true));
            }

            if (this.NotSet(EntityBase.CreateProperty) && Create)
            {
                Create = Implementations.IsByAll ? false :
                         Implementations.Types.Any(t => Navigator.IsCreable(t, isSearch: true));
            }

            ColumnOption.SetColumnTokens(ColumnOptions, Description);

            if (this.CanAddFilters || this.AllowChangeColumns)
            {
                headerContextMenu = new ContextMenu();

                if (this.CanAddFilters)
                {
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = SearchMessage.AddFilter.NiceToString()
                    }.Handle(MenuItem.ClickEvent, filterHeader_Click));
                }

                if (this.CanAddFilters && this.AllowChangeColumns)
                {
                    headerContextMenu.Items.Add(new Separator());
                }

                if (this.AllowChangeColumns)
                {
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = SearchMessage.Rename.NiceToString()
                    }.Handle(MenuItem.ClickEvent, renameMenu_Click));
                    headerContextMenu.Items.Add(new MenuItem {
                        Header = EntityControlMessage.Remove.NiceToString()
                    }.Handle(MenuItem.ClickEvent, removeMenu_Click));
                }
            }

            GenerateListViewColumns();

            FilterOption.SetFilterTokens(FilterOptions, Description);

            filterBuilder.Filters = FilterOptions;
            ((INotifyCollectionChanged)FilterOptions).CollectionChanged += FilterOptions_CollectionChanged;

            OrderOption.SetOrderTokens(OrderOptions, Description);

            SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

            if (IsVisible)
            {
                FillMenuItems();

                if (SearchOnLoad)
                {
                    Search();
                }
            }
            else
            {
                IsVisibleChanged += SearchControl_IsVisibleChanged;
            }

            UpdateVisibility();

            AutomationProperties.SetName(this, QueryUtils.GetKey(QueryName));

            foreach (var item in FilterOptions)
            {
                item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged);
            }
        }