public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ProductEntity>() .WithSave(ProductOperation.Save) .WithQuery(() => p => new { Entity = p, p.Id, p.ProductName, p.Supplier, p.Category, p.QuantityPerUnit, p.UnitPrice, p.UnitsInStock, p.Discontinued }); sb.AddUniqueIndexMList((ProductEntity pe) => pe.AdditionalInformation, mle => new { mle.Parent, mle.Element.Key }); QueryLogic.Expressions.RegisterDictionary((ProductEntity p) => p.AdditionalInformation, ai => ai.Key, ai => ai.Value); ActiveProducts = sb.GlobalLazy(() => Database.Query <ProductEntity>() .Where(a => !a.Discontinued) .Select(p => new { Category = p.Category.Entity, Product = p }) .GroupToDictionary(a => a.Category !, a => a.Product !), /*CSBUG*/ new InvalidateWith(typeof(ProductEntity))); QueryLogic.Queries.Register(ProductQuery.CurrentProducts, () => from p in Database.Query <ProductEntity>() where !p.Discontinued select new { Entity = p, p.Id, p.ProductName, p.Supplier, p.Category, p.QuantityPerUnit, p.UnitPrice, p.UnitsInStock, }); sb.Include <SupplierEntity>() .WithSave(SupplierOperation.Save) .WithQuery(() => s => new { Entity = s, s.Id, s.CompanyName, s.ContactName, s.Phone, s.Fax, s.HomePage, s.Address }); sb.Include <CategoryEntity>() .WithSave(CategoryOperation.Save) .WithQuery(() => s => new { Entity = s, s.Id, s.CategoryName, s.Description, s.Picture }); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <EntityHelpEntity>(); sb.Include <NamespaceHelpEntity>(); sb.Include <AppendixHelpEntity>(); sb.Include <QueryHelpEntity>(); sb.Include <OperationHelpEntity>(); sb.AddUniqueIndex((EntityHelpEntity e) => new { e.Type, e.Culture }); sb.AddUniqueIndexMList((EntityHelpEntity e) => e.Properties, mle => new { mle.Parent, mle.Element.Property }); sb.AddUniqueIndex((NamespaceHelpEntity e) => new { e.Name, e.Culture }); sb.AddUniqueIndex((AppendixHelpEntity e) => new { Name = e.UniqueName, e.Culture }); sb.AddUniqueIndex((QueryHelpEntity e) => new { e.Query, e.Culture }); sb.AddUniqueIndexMList((QueryHelpEntity e) => e.Columns, mle => new { mle.Parent, mle.Element.ColumnName }); sb.AddUniqueIndex((OperationHelpEntity e) => new { e.Operation, e.Culture }); Types = sb.GlobalLazy <ConcurrentDictionary <CultureInfo, Dictionary <Type, EntityHelp> > >(() => new ConcurrentDictionary <CultureInfo, Dictionary <Type, EntityHelp> >(), invalidateWith: new InvalidateWith(typeof(EntityHelpEntity))); Namespaces = sb.GlobalLazy <ConcurrentDictionary <CultureInfo, Dictionary <string, NamespaceHelp> > >(() => new ConcurrentDictionary <CultureInfo, Dictionary <string, NamespaceHelp> >(), invalidateWith: new InvalidateWith(typeof(NamespaceHelpEntity))); Appendices = sb.GlobalLazy <ConcurrentDictionary <CultureInfo, Dictionary <string, AppendixHelp> > >(() => new ConcurrentDictionary <CultureInfo, Dictionary <string, AppendixHelp> >(), invalidateWith: new InvalidateWith(typeof(AppendixHelpEntity))); Queries = sb.GlobalLazy <ConcurrentDictionary <CultureInfo, Dictionary <object, QueryHelp> > >(() => new ConcurrentDictionary <CultureInfo, Dictionary <object, QueryHelp> >(), invalidateWith: new InvalidateWith(typeof(QueryHelpEntity))); Operations = sb.GlobalLazy <ConcurrentDictionary <CultureInfo, Dictionary <OperationSymbol, OperationHelp> > >(() => new ConcurrentDictionary <CultureInfo, Dictionary <OperationSymbol, OperationHelp> >(), invalidateWith: new InvalidateWith(typeof(OperationHelpEntity))); sb.Include <EntityHelpEntity>() .WithSave(EntityHelpOperation.Save) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Type, Description = e.Description.Etc(100) }); sb.Include <NamespaceHelpEntity>() .WithSave(NamespaceHelpOperation.Save) .WithQuery(dqm, () => n => new { Entity = n, n.Id, n.Name, n.Culture, Description = n.Description.Etc(100) }); sb.Include <AppendixHelpEntity>() .WithSave(AppendixHelpOperation.Save) .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.UniqueName, a.Culture, a.Title, Description = a.Description.Etc(100) }); sb.Include <QueryHelpEntity>() .WithSave(QueryHelpOperation.Save) .WithQuery(dqm, () => q => new { Entity = q, q.Id, q.Query, q.Culture, Description = q.Description.Etc(100) }); sb.Include <OperationHelpEntity>() .WithSave(OperationHelpOperation.Save) .WithQuery(dqm, () => o => new { Entity = o, o.Id, o.Operation, o.Culture, Description = o.Description.Etc(100) }); sb.Schema.Synchronizing += Schema_Synchronizing; sb.Schema.Table <OperationSymbol>().PreDeleteSqlSync += operation => Administrator.UnsafeDeletePreCommand(Database.Query <OperationHelpEntity>().Where(e => e.Operation == (OperationSymbol)operation)); sb.Schema.Table <TypeEntity>().PreDeleteSqlSync += type => Administrator.UnsafeDeletePreCommand(Database.Query <EntityHelpEntity>().Where(e => e.Type == (TypeEntity)type)); sb.Schema.Table <QueryEntity>().PreDeleteSqlSync += query => Administrator.UnsafeDeletePreCommand(Database.Query <QueryHelpEntity>().Where(e => e.Query == (QueryEntity)query)); PermissionAuthLogic.RegisterPermissions(HelpPermissions.ViewHelp); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, Func <WorkflowConfigurationEmbedded> getConfiguration) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { PermissionAuthLogic.RegisterPermissions(WorkflowScriptRunnerPanelPermission.ViewWorkflowScriptRunnerPanel); WorkflowLogic.getConfiguration = getConfiguration; sb.Include <WorkflowEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.MainEntityType, e.MainEntityStrategy, }); WorkflowGraph.Register(); dqm.RegisterExpression((WorkflowEntity wf) => wf.WorkflowStartEvent()); DynamicCode.GetCustomErrors += GetCustomErrors; sb.Include <WorkflowPoolEntity>() .WithUniqueIndex(wp => new { wp.Workflow, wp.Name }) .WithSave(WorkflowPoolOperation.Save) .WithDelete(WorkflowPoolOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowPools()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.Workflow, }); sb.Include <WorkflowLaneEntity>() .WithUniqueIndex(wp => new { wp.Pool, wp.Name }) .WithSave(WorkflowLaneOperation.Save) .WithDelete(WorkflowLaneOperation.Delete) .WithExpressionFrom(dqm, (WorkflowPoolEntity p) => p.WorkflowLanes()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.Pool, e.Pool.Workflow, }); sb.Include <WorkflowActivityEntity>() .WithUniqueIndex(w => new { w.Lane, w.Name }) .WithSave(WorkflowActivityOperation.Save) .WithDelete(WorkflowActivityOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowActivities()) .WithExpressionFrom(dqm, (WorkflowLaneEntity p) => p.WorkflowActivities()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.Comments, e.Lane, e.Lane.Pool.Workflow, }); sb.AddUniqueIndexMList((WorkflowActivityEntity a) => a.Jumps, mle => new { mle.Parent, mle.Element.To }); sb.Include <WorkflowEventEntity>() .WithSave(WorkflowEventOperation.Save) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowEvents()) .WithExpressionFrom(dqm, (WorkflowLaneEntity p) => p.WorkflowEvents()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Type, e.Name, e.BpmnElementId, e.Lane, e.Lane.Pool.Workflow, }); new Graph <WorkflowEventEntity> .Delete(WorkflowEventOperation.Delete) { Delete = (e, _) => { if (e.Type.IsTimerStart()) { var scheduled = e.ScheduledTask(); if (scheduled != null) { WorkflowEventTaskLogic.DeleteWorkflowEventScheduledTask(scheduled); } } e.Delete(); }, } .Register(); sb.Include <WorkflowGatewayEntity>() .WithSave(WorkflowGatewayOperation.Save) .WithDelete(WorkflowGatewayOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowGateways()) .WithExpressionFrom(dqm, (WorkflowLaneEntity p) => p.WorkflowGateways()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Type, e.Name, e.BpmnElementId, e.Lane, e.Lane.Pool.Workflow, }); sb.Include <WorkflowConnectionEntity>() .WithSave(WorkflowConnectionOperation.Save) .WithDelete(WorkflowConnectionOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowConnections()) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowMessageConnections(), null) .WithExpressionFrom(dqm, (WorkflowPoolEntity p) => p.WorkflowConnections()) .WithExpressionFrom(dqm, (IWorkflowNodeEntity p) => p.NextConnections(), null) .WithExpressionFrom(dqm, (IWorkflowNodeEntity p) => p.PreviousConnections(), null) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.From, e.To, }); WorkflowGraphLazy = sb.GlobalLazy(() => { using (new EntityCache()) { var events = Database.RetrieveAll <WorkflowEventEntity>().GroupToDictionary(a => a.Lane.Pool.Workflow.ToLite()); var gateways = Database.RetrieveAll <WorkflowGatewayEntity>().GroupToDictionary(a => a.Lane.Pool.Workflow.ToLite()); var activities = Database.RetrieveAll <WorkflowActivityEntity>().GroupToDictionary(a => a.Lane.Pool.Workflow.ToLite()); var connections = Database.RetrieveAll <WorkflowConnectionEntity>().GroupToDictionary(a => a.From.Lane.Pool.Workflow.ToLite()); var result = Database.RetrieveAll <WorkflowEntity>().ToDictionary(workflow => workflow.ToLite(), workflow => { var w = workflow.ToLite(); var nodeGraph = new WorkflowNodeGraph { Workflow = workflow, Events = events.TryGetC(w).EmptyIfNull().ToDictionary(e => e.ToLite()), Gateways = gateways.TryGetC(w).EmptyIfNull().ToDictionary(g => g.ToLite()), Activities = activities.TryGetC(w).EmptyIfNull().ToDictionary(a => a.ToLite()), Connections = connections.TryGetC(w).EmptyIfNull().ToDictionary(c => c.ToLite()), }; nodeGraph.FillGraphs(); return(nodeGraph); }); return(result); } }, new InvalidateWith(typeof(WorkflowConnectionEntity))); Validator.PropertyValidator((WorkflowConnectionEntity c) => c.Condition).StaticPropertyValidation = (e, pi) => { if (e.Condition != null && e.From != null) { var conditionType = Conditions.Value.GetOrThrow(e.Condition).MainEntityType; var workflowType = e.From.Lane.Pool.Workflow.MainEntityType; if (!conditionType.Is(workflowType)) { return(WorkflowMessage.Condition0IsDefinedFor1Not2.NiceToString(conditionType, workflowType)); } } return(null); }; sb.Include <WorkflowConditionEntity>() .WithSave(WorkflowConditionOperation.Save) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.MainEntityType, e.Eval.Script }); new Graph <WorkflowConditionEntity> .Delete(WorkflowConditionOperation.Delete) { Delete = (e, _) => { ThrowConnectionError(Database.Query <WorkflowConnectionEntity>().Where(a => a.Condition == e.ToLite()), e); e.Delete(); }, } .Register(); new Graph <WorkflowConditionEntity> .ConstructFrom <WorkflowConditionEntity>(WorkflowConditionOperation.Clone) { Construct = (e, args) => { return(new WorkflowConditionEntity { MainEntityType = e.MainEntityType, Eval = new WorkflowConditionEval { Script = e.Eval.Script } }); }, } .Register(); WorkflowEventTaskEntity.GetWorkflowEntity = lite => WorkflowGraphLazy.Value.GetOrThrow(lite).Workflow; Conditions = sb.GlobalLazy(() => Database.Query <WorkflowConditionEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(WorkflowConditionEntity))); sb.Include <WorkflowActionEntity>() .WithSave(WorkflowActionOperation.Save) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.MainEntityType, e.Eval.Script }); new Graph <WorkflowActionEntity> .Delete(WorkflowActionOperation.Delete) { Delete = (e, _) => { ThrowConnectionError(Database.Query <WorkflowConnectionEntity>().Where(a => a.Action == e.ToLite()), e); e.Delete(); }, } .Register(); new Graph <WorkflowActionEntity> .ConstructFrom <WorkflowActionEntity>(WorkflowActionOperation.Clone) { Construct = (e, args) => { return(new WorkflowActionEntity { MainEntityType = e.MainEntityType, Eval = new WorkflowActionEval { Script = e.Eval.Script } }); }, } .Register(); Actions = sb.GlobalLazy(() => Database.Query <WorkflowActionEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(WorkflowActionEntity))); sb.Include <WorkflowScriptEntity>() .WithSave(WorkflowScriptOperation.Save) .WithQuery(dqm, () => s => new { Entity = s, s.Id, s.Name, s.MainEntityType, }); new Graph <WorkflowScriptEntity> .Delete(WorkflowScriptOperation.Delete) { Delete = (s, _) => { ThrowConnectionError(Database.Query <WorkflowActivityEntity>().Where(a => a.Script.Script == s.ToLite()), s); s.Delete(); }, } .Register(); Scripts = sb.GlobalLazy(() => Database.Query <WorkflowScriptEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(WorkflowScriptEntity))); sb.Include <WorkflowScriptRetryStrategyEntity>() .WithSave(WorkflowScriptRetryStrategyOperation.Save) .WithDelete(WorkflowScriptRetryStrategyOperation.Delete) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Rule }); } }