Beispiel #1
0
        public static void Start(SchemaBuilder sb, params Type[] registerExpressionsFor)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <AlertEntity>()
                .WithQuery(() => a => new
                {
                    Entity = a,
                    a.Id,
                    a.AlertDate,
                    a.AlertType,
                    a.State,
                    a.Title,
                    Text = a.Text.Etc(100),
                    a.Target,
                    a.Recipient,
                    a.CreationDate,
                    a.CreatedBy,
                    a.AttendedDate,
                    a.AttendedBy,
                });

                AlertGraph.Register();



                sb.Include <AlertTypeEntity>()
                .WithSave(AlertTypeOperation.Save)
                .WithDelete(AlertTypeOperation.Delete)
                .WithQuery(() => t => new
                {
                    Entity = t,
                    t.Id,
                    t.Name,
                    t.Key,
                });

                SemiSymbolLogic <AlertTypeEntity> .Start(sb, () => SystemAlertTypes);

                if (registerExpressionsFor != null)
                {
                    var alerts         = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity ident) => ident.Alerts());
                    var myActiveAlerts = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity ident) => ident.MyActiveAlerts());
                    foreach (var type in registerExpressionsFor)
                    {
                        QueryLogic.Expressions.Register(new ExtensionInfo(type, alerts, alerts.Body.Type, "Alerts", () => typeof(AlertEntity).NicePluralName()));
                        QueryLogic.Expressions.Register(new ExtensionInfo(type, myActiveAlerts, myActiveAlerts.Body.Type, "MyActiveAlerts", () => AlertMessage.MyActiveAlerts.NiceToString()));
                    }
                }


                Started = true;
            }
        }
Beispiel #2
0
        public static void Start(SchemaBuilder sb, params Type[] registerExpressionsFor)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <NoteEntity>()
                .WithSave(NoteOperation.Save)
                .WithQuery(() => n => new
                {
                    Entity = n,
                    n.Id,
                    n.CreatedBy,
                    n.CreationDate,
                    n.Title,
                    Text = n.Text.Etc(100),
                    n.Target
                });

                new Graph <NoteEntity> .ConstructFrom <Entity>(NoteOperation.CreateNoteFromEntity)
                {
                    Construct = (a, _) => new NoteEntity {
                        CreationDate = TimeZoneManager.Now, Target = a.ToLite()
                    }
                }

                .Register();

                sb.Include <NoteTypeEntity>()
                .WithSave(NoteTypeOperation.Save)
                .WithQuery(() => t => new
                {
                    Entity = t,
                    t.Id,
                    t.Name,
                    t.Key,
                });

                SemiSymbolLogic <NoteTypeEntity> .Start(sb, () => SystemNoteTypes);

                if (registerExpressionsFor != null)
                {
                    var exp = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity ident) => ident.Notes());
                    foreach (var type in registerExpressionsFor)
                    {
                        QueryLogic.Expressions.Register(new ExtensionInfo(type, exp, exp.Body.Type, "Notes", () => typeof(NoteEntity).NicePluralName()));
                    }
                }

                started = true;
            }
        }