示例#1
0
        public static EntityPackTS GetEntityPack(Entity entity)
        {
            var canExecutes = OperationLogic.ServiceCanExecute(entity);

            return(new EntityPackTS
            {
                entity = entity,
                canExecute = canExecutes.ToDictionary(a => a.Key.Key, a => a.Value)
            });
        }
示例#2
0
        public static EntityPackTS GetEntityPack(Entity entity)
        {
            var canExecutes = OperationLogic.ServiceCanExecute(entity);

            var result = new EntityPackTS
            {
                entity     = entity,
                canExecute = canExecutes.ToDictionary(a => a.Key.Key, a => a.Value)
            };

            foreach (var action in EntityPackTS.AddExtension.GetInvocationListTyped())
            {
                action(result);
            }

            return(result);
        }
示例#3
0
        public static EntityPackTS GetEntityPack(Entity entity)
        {
            var canExecutes = OperationLogic.ServiceCanExecute(entity);

            var result = new EntityPackTS(entity,
                                          canExecutes.ToDictionary(a => a.Key.Key, a => a.Value)
                                          );

            foreach (var action in EntityPackTS.AddExtension.GetInvocationListTyped())
            {
                try
                {
                    action(result);
                }
                catch (Exception) when(StartParameters.IgnoredDatabaseMismatches != null)
                {
                }
            }

            return(result);
        }
示例#4
0
        public EntityPackWorkflow GetEntity(string caseActivityId)
        {
            var lite = Lite.ParsePrimaryKey <CaseActivityEntity>(caseActivityId);

            var activity = CaseActivityLogic.RetrieveForViewing(lite);

            using (WorkflowActivityInfo.Scope(new WorkflowActivityInfo {
                CaseActivity = activity
            }))
            {
                var ep = SignumServer.GetEntityPack((Entity)activity.Case.MainEntity);

                return(new EntityPackWorkflow
                {
                    activity = activity,
                    canExecuteActivity = OperationLogic.ServiceCanExecute(activity).ToDictionary(a => a.Key.Key, a => a.Value),
                    canExecuteMainEntity = ep.canExecute,
                    Extension = ep.extension,
                });
            }
        }
示例#5
0
 public string GetCanExecuteLite(Lite <Entity> lite, OperationSymbol operationSymbol)
 {
     return(Return(MethodInfo.GetCurrentMethod(), lite.EntityType.Name + " " + operationSymbol,
                   () => OperationLogic.ServiceCanExecute(lite.Retrieve(), operationSymbol)));
 }
示例#6
0
 public string GetCanExecute(Entity entity, OperationSymbol operationSymbol)
 {
     return(Return(MethodInfo.GetCurrentMethod(), entity.GetType().Name + " " + operationSymbol,
                   () => OperationLogic.ServiceCanExecute(entity, operationSymbol)));
 }
示例#7
0
 public Dictionary <OperationSymbol, string> GetCanExecuteLiteAll(Lite <Entity> lite)
 {
     return(Return(MethodInfo.GetCurrentMethod(), lite.EntityType.Name,
                   () => OperationLogic.ServiceCanExecute(Database.Retrieve(lite))));
 }
示例#8
0
 public Dictionary <OperationSymbol, string> GetCanExecuteAll(Entity entity)
 {
     return(Return(MethodInfo.GetCurrentMethod(), entity.GetType().Name,
                   () => OperationLogic.ServiceCanExecute(entity)));
 }
示例#9
0
        public virtual MenuItemBlock ContextualItemsHelper_GetEntityOperationMenuItem(SelectedItemsMenuContext ctx)
        {
            if (ctx.Lites.IsNullOrEmpty())
            {
                return(null);
            }

            if (ctx.Implementations.IsByAll)
            {
                return(null);
            }

            var type = ctx.Lites.Select(a => a.EntityType).Distinct().Only();

            if (type == null)
            {
                return(null);
            }

            var context = (from oi in OperationInfos(type)
                           where oi.IsEntityOperation
                           let os = GetSettings <EntityOperationSettingsBase>(type, oi.OperationSymbol)
                                    let osc = os == null ? null :
                                              ctx.Lites.Count == 1 ? os.ContextualUntyped: os.ContextualFromManyUntyped
                                              let coc = newContextualOperationContext.GetInvoker(os?.OverridenType ?? type)(ctx, oi, osc, os)
                                                        let defaultBehaviour = oi.Lite == true && (ctx.Lites.Count == 1 || oi.OperationType != OperationType.ConstructorFrom)
                                                                               where os == null ? defaultBehaviour :
                                                                               !os.ContextualUntyped.HasIsVisible ? defaultBehaviour && !os.HasIsVisible && (!os.HasClick || os.ContextualUntyped.HasClick) :
                                                                               os.ContextualUntyped.OnIsVisible(coc)
                                                                               select coc).ToList();

            if (context.IsEmpty())
            {
                return(null);
            }

            if (ctx.Lites.Count == 1)
            {
                if (context.Any(eomi => eomi.OperationInfo.HasCanExecute == true))
                {
                    Dictionary <OperationSymbol, string> canExecutes = OperationLogic.ServiceCanExecute(Database.Retrieve(ctx.Lites.Single()));
                    foreach (var coc in context)
                    {
                        var ce = canExecutes.TryGetC(coc.OperationInfo.OperationSymbol);
                        if (ce != null)
                        {
                            coc.CanExecute = ce;
                        }
                    }
                }
            }
            else
            {
                var cleanKeys = context.Where(cod => cod.CanExecute == null && cod.OperationInfo.HasStates == true)
                                .Select(kvp => kvp.OperationInfo.OperationSymbol).ToList();

                if (cleanKeys.Any())
                {
                    Dictionary <OperationSymbol, string> canExecutes = OperationLogic.GetContextualCanExecute(ctx.Lites, cleanKeys);
                    foreach (var cod in context)
                    {
                        var ce = canExecutes.TryGetC(cod.OperationInfo.OperationSymbol);
                        if (ce.HasText())
                        {
                            cod.CanExecute = ce;
                        }
                    }
                }
            }

            List <IMenuItem> menuItems = context
                                         .Where(coc => !coc.HideOnCanExecute || coc.CanExecute == null)
                                         .Select(coc => CreateContextual(coc, DefaultEntityClick))
                                         .OrderBy(a => a.Order).Cast <IMenuItem>().ToList();

            if (menuItems.IsEmpty())
            {
                return(null);
            }

            return(new MenuItemBlock {
                Header = SearchMessage.Operation.NiceToString(), Items = menuItems
            });
        }
示例#10
0
        public virtual ToolBarButton[] ButtonBar_GetButtonBarElement(EntityButtonContext ctx, ModifiableEntity entity)
        {
            Entity ident = entity as Entity;

            if (ident == null)
            {
                return(null);
            }

            Type type = ident.GetType();

            var operations = (from oi in OperationInfos(type)
                              where oi.IsEntityOperation && (oi.AllowsNew.Value || !ident.IsNew)
                              let os = GetSettings <EntityOperationSettingsBase>(type, oi.OperationSymbol)
                                       let eoc = newEntityOperationContext.GetInvoker(os?.OverridenType ?? type)(ident, oi, ctx, os)
                                                 where (os != null && os.HasIsVisible) ? os.OnIsVisible(eoc) : ctx.ShowOperations
                                                 select eoc).ToList();

            if (operations.Any(eoc => eoc.OperationInfo.HasCanExecute == true))
            {
                Dictionary <OperationSymbol, string> canExecutes = OperationLogic.ServiceCanExecute(ident);
                foreach (var eoc in operations)
                {
                    var ce = canExecutes.TryGetC(eoc.OperationInfo.OperationSymbol);
                    if (ce != null && ce.HasText())
                    {
                        eoc.CanExecute = ce;
                    }
                }
            }

            List <ToolBarButton> buttons = new List <ToolBarButton>();
            Dictionary <EntityOperationGroup, ToolBarDropDown> groups = new Dictionary <EntityOperationGroup, ToolBarDropDown>();

            foreach (var eoc in operations.Where(c => c.OperationSettings == null || !c.OperationSettings.HideOnCanExecute || c.CanExecute == null))
            {
                EntityOperationGroup group = GetDefaultGroup(eoc);

                if (group != null)
                {
                    var cm = groups.GetOrCreate(group, () =>
                    {
                        var id = group == EntityOperationGroup.Create ? "tmConstructors" : "";

                        var tbm = new ToolBarDropDown(ctx.Prefix, id)
                        {
                            Title    = group.Description(),
                            Text     = group.Description(),
                            CssClass = group.CssClass,
                            Items    = new List <IMenuItem>(),
                            Order    = group.Order,
                        };

                        buttons.Add(tbm);

                        return(tbm);
                    });

                    cm.Items.Add(CreateToolBarButton(eoc, group).ToMenuItem());
                }
                else
                {
                    buttons.Add(CreateToolBarButton(eoc, null));
                }
            }

            foreach (var item in buttons.OfType <ToolBarDropDown>())
            {
                item.Items = item.Items.OrderBy(a => ((MenuItem)a).Order).ToList();
            }

            return(buttons.OrderBy(a => a.Order).ToArray());
        }