示例#1
0
 public ModuleAction GetAction()
 {
     // Quaternion lookRotation = Quaternion.LookRotation(orientation.target - transform.parent.position, transform.parent.up);
     Quaternion rotation = transform.rotation;
     ModuleAction action = new ModuleAction(this, rotation, GetDuration());
     // orientation.target = Vector3.zero;
     return action;
 }
 public ModuleWorkerJob(IPackageService packageService, ModuleDescriptor moduleDescriptor, ModuleAction action)
 {
     Id = Guid.NewGuid().ToString("N");
     CancellationToken = new CancellationToken();
     PackageService = packageService;
     ModuleDescriptor = moduleDescriptor;
     Action = action;
     ProgressLog = new List<ProgressMessage>();
 }
示例#3
0
 public void Run(ModuleAction action)
 {
     if(!orientation.isRunning) {
       orientation.isRunning = true;
     }
     if(Quaternion.Angle(transform.parent.rotation, action.rotationTarget) > .1) {
       transform.parent.gameObject.GetComponent<ShipController>().Reorient(action.rotationTarget, orientation.durationModifier);
     }
     else {
       orientation.isRunning = false;
     }
     transform.rotation = transform.parent.rotation;
 }
示例#4
0
 public void Run(ModuleAction action)
 {
     if(!engine.isRunning) {
       engine.isRunning = true;
       engine.thrustDuration = action.duration;
     }
     if(engine.thrustDuration <= 0) {
       engine.isRunning = false;
     }
     transform.parent.gameObject.GetComponent<ShipController>().AddThrust(engine.thrust);
     // Debug.Log(engine.thrustDuration);
     // Debug.Log(Time.deltaTime);
     engine.thrustDuration -= Time.deltaTime;
 }
示例#5
0
 public ModuleAction GetAction()
 {
     ModuleAction action = new ModuleAction(this, Vector3.zero, engine.thrustDuration);
     engine.thrustDuration = 0;
     return action;
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// LoadActions loads the Actions collections
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private void LoadActions(HttpRequest request)
        {
            _actions = new ModuleActionCollection();
            if (PortalSettings.IsLocked)
            {
                return;
            }

            _moduleGenericActions = new ModuleAction(GetNextActionID(), Localization.GetString("ModuleGenericActions.Action", Localization.GlobalResourceFile), string.Empty, string.Empty, string.Empty);
            int maxActionId = Null.NullInteger;

            //check if module Implements Entities.Modules.IActionable interface
            var actionable = _moduleControl as IActionable;
            if (actionable != null)
            {
                _moduleSpecificActions = new ModuleAction(GetNextActionID(), Localization.GetString("ModuleSpecificActions.Action", Localization.GlobalResourceFile), string.Empty, string.Empty, string.Empty);

                ModuleActionCollection moduleActions = actionable.ModuleActions;

                foreach (ModuleAction action in moduleActions)
                {
                    if (ModulePermissionController.HasModuleAccess(action.Secure, "CONTENT", Configuration))
                    {
                        if (String.IsNullOrEmpty(action.Icon))
                        {
                            action.Icon = "edit.gif";
                        }
                        if (action.ID > maxActionId)
                        {
                            maxActionId = action.ID;
                        }
                        _moduleSpecificActions.Actions.Add(action);

                        if (!UIUtilities.IsLegacyUI(ModuleId, action.ControlKey, PortalId) && action.Url.Contains("ctl"))
                        {
                            action.ClientScript = UrlUtils.PopUpUrl(action.Url, _moduleControl as Control, PortalSettings, true, false);
                        }
                    }
                }
                if (_moduleSpecificActions.Actions.Count > 0)
                {
                    _actions.Add(_moduleSpecificActions);
                }
            }

            //Make sure the Next Action Id counter is correct
            int actionCount = GetActionsCount(_actions.Count, _actions);
            if (_nextActionId < maxActionId)
            {
                _nextActionId = maxActionId;
            }
            if (_nextActionId < actionCount)
            {
                _nextActionId = actionCount;
            }

            //Custom injection of Module Settings when shared as ViewOnly
            if (Configuration != null && (Configuration.IsShared && Configuration.IsShareableViewOnly)
                    && TabPermissionController.CanAddContentToPage())
            {
                _moduleGenericActions.Actions.Add(GetNextActionID(),
                             Localization.GetString("ModulePermissions.Action", Localization.GlobalResourceFile),
                             "ModulePermissions",
                             "",
                             "action_settings.gif",
                             NavigateUrl(TabId, "ModulePermissions", false, "ModuleId=" + ModuleId, "ReturnURL=" + FilterUrl(request)),
                             false,
                             SecurityAccessLevel.ViewPermissions,
                             true,
                             false);
            }
            else
            {
                if (!Globals.IsAdminControl() && ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "DELETE,MANAGE", Configuration))
                {
                    if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "MANAGE", Configuration))
                    {
                        _moduleGenericActions.Actions.Add(GetNextActionID(),
                                                          Localization.GetString(ModuleActionType.ModuleSettings, Localization.GlobalResourceFile),
                                                          ModuleActionType.ModuleSettings,
                                                          "",
                                                          "action_settings.gif",
                                                          NavigateUrl(TabId, "Module", false, "ModuleId=" + ModuleId, "ReturnURL=" + FilterUrl(request)),
                                                          false,
                                                          SecurityAccessLevel.Edit,
                                                          true,
                                                          false);
                    }
                }
            }

            if (!string.IsNullOrEmpty(Configuration.DesktopModule.BusinessControllerClass))
            {
                //check if module implements IPortable interface, and user has Admin permissions
                if (Configuration.DesktopModule.IsPortable)
                {
                    if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "EXPORT", Configuration))
                    {
                        _moduleGenericActions.Actions.Add(GetNextActionID(),
                                     Localization.GetString(ModuleActionType.ExportModule, Localization.GlobalResourceFile),
                                     ModuleActionType.ExportModule,
                                     "",
                                     "action_export.gif",
                                     NavigateUrl(PortalSettings.ActiveTab.TabID, "ExportModule", false, "moduleid=" + ModuleId, "ReturnURL=" + FilterUrl(request)),

                                     "",
                                     false,
                                     SecurityAccessLevel.View,
                                     true,
                                     false);
                    }
                    if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "IMPORT", Configuration))
                    {
                        _moduleGenericActions.Actions.Add(GetNextActionID(),
                                     Localization.GetString(ModuleActionType.ImportModule, Localization.GlobalResourceFile),
                                     ModuleActionType.ImportModule,
                                     "",
                                     "action_import.gif",
                                     NavigateUrl(PortalSettings.ActiveTab.TabID, "ImportModule", false, "moduleid=" + ModuleId, "ReturnURL=" + FilterUrl(request)),
                                     "",
                                     false,
                                     SecurityAccessLevel.View,
                                     true,
                                     false);
                    }
                }
                if (Configuration.DesktopModule.IsSearchable && Configuration.DisplaySyndicate)
                {
                    AddSyndicateAction();
                }
            }

            //help module actions available to content editors and administrators
            const string permisisonList = "CONTENT,DELETE,EDIT,EXPORT,IMPORT,MANAGE";
            if (ModulePermissionController.HasModulePermission(Configuration.ModulePermissions, permisisonList) 
                    && request.QueryString["ctl"] != "Help"
                    && !Globals.IsAdminControl())
            {
                AddHelpActions();
            }

            //Add Print Action
            if (Configuration.DisplayPrint)
            {
                //print module action available to everyone
                AddPrintAction();
            }

            if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Host, "MANAGE", Configuration) && !Globals.IsAdminControl())
            {
                _moduleGenericActions.Actions.Add(GetNextActionID(),
                             Localization.GetString(ModuleActionType.ViewSource, Localization.GlobalResourceFile),
                             ModuleActionType.ViewSource,
                             "",
                             "action_source.gif",
                             NavigateUrl(TabId, "ViewSource", false, "ModuleId=" + ModuleId, "ctlid=" + Configuration.ModuleControlId, "ReturnURL=" + FilterUrl(request)),
                             false,
                             SecurityAccessLevel.Host,
                             true,
                             false);
            }



            if (!Globals.IsAdminControl() && ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "DELETE,MANAGE", Configuration))
            {
                if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "DELETE", Configuration))
                {
                    //Check if this is the owner instance of a shared module.
                    string confirmText = "confirm('" + ClientAPI.GetSafeJSString(Localization.GetString("DeleteModule.Confirm")) + "')";
                    if (!Configuration.IsShared)
                    {
                        var portal = PortalController.Instance.GetPortal(PortalSettings.PortalId);
                        if (PortalGroupController.Instance.IsModuleShared(Configuration.ModuleID, portal))
                        {
                            confirmText = "confirm('" + ClientAPI.GetSafeJSString(Localization.GetString("DeleteSharedModule.Confirm")) + "')";
                        }
                    }

                    _moduleGenericActions.Actions.Add(GetNextActionID(),
                                 Localization.GetString(ModuleActionType.DeleteModule, Localization.GlobalResourceFile),
                                 ModuleActionType.DeleteModule,
                                 Configuration.ModuleID.ToString(),
                                 "action_delete.gif",
                                 "",
                                 confirmText,
                                 false,
                                 SecurityAccessLevel.View,
                                 true,
                                 false);
                }
                if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "MANAGE", Configuration))
                {
                    _moduleGenericActions.Actions.Add(GetNextActionID(),
                                 Localization.GetString(ModuleActionType.ClearCache, Localization.GlobalResourceFile),
                                 ModuleActionType.ClearCache,
                                 Configuration.ModuleID.ToString(),
                                 "action_refresh.gif",
                                 "",
                                 false,
                                 SecurityAccessLevel.View,
                                 true,
                                 false);
                }

                if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "MANAGE", Configuration))
                {
                    //module movement
                    AddMenuMoveActions();
                }
            }

            if (_moduleGenericActions.Actions.Count > 0)
            {
                _actions.Add(_moduleGenericActions);
            }

            if (_moduleMoveActions != null && _moduleMoveActions.Actions.Count > 0)
            {
                _actions.Add(_moduleMoveActions);
            }

            foreach (ModuleAction action in _moduleGenericActions.Actions)
            {
                if (!UIUtilities.IsLegacyUI(ModuleId, action.ControlKey, PortalId) && action.Url.Contains("ctl"))
                {
                    action.ClientScript = UrlUtils.PopUpUrl(action.Url, _moduleControl as Control, PortalSettings, true, false);
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddMenuMoveActions Adds the Move actions to the Action Menu
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private void AddMenuMoveActions()
        {
            //module movement
            _moduleMoveActions = new ModuleAction(GetNextActionID(), Localization.GetString(ModuleActionType.MoveRoot, Localization.GlobalResourceFile), string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, false);

            //move module up/down
            if (Configuration != null)
            {
                if ((Configuration.ModuleOrder != 0) && (Configuration.PaneModuleIndex > 0))
                {
                    _moduleMoveActions.Actions.Add(GetNextActionID(),
                                               Localization.GetString(ModuleActionType.MoveTop, Localization.GlobalResourceFile),
                                               ModuleActionType.MoveTop,
                                               Configuration.PaneName,
                                               "action_top.gif",
                                               "",
                                               false,
                                               SecurityAccessLevel.View,
                                               true,
                                               false);
                    _moduleMoveActions.Actions.Add(GetNextActionID(),
                                               Localization.GetString(ModuleActionType.MoveUp, Localization.GlobalResourceFile),
                                               ModuleActionType.MoveUp,
                                               Configuration.PaneName,
                                               "action_up.gif",
                                               "",
                                               false,
                                               SecurityAccessLevel.View,
                                               true,
                                               false);
                }
                if ((Configuration.ModuleOrder != 0) && (Configuration.PaneModuleIndex < (Configuration.PaneModuleCount - 1)))
                {
                    _moduleMoveActions.Actions.Add(GetNextActionID(),
                                               Localization.GetString(ModuleActionType.MoveDown, Localization.GlobalResourceFile),
                                               ModuleActionType.MoveDown,
                                               Configuration.PaneName,
                                               "action_down.gif",
                                               "",
                                               false,
                                               SecurityAccessLevel.View,
                                               true,
                                               false);
                    _moduleMoveActions.Actions.Add(GetNextActionID(),
                                               Localization.GetString(ModuleActionType.MoveBottom, Localization.GlobalResourceFile),
                                               ModuleActionType.MoveBottom,
                                               Configuration.PaneName,
                                               "action_bottom.gif",
                                               "",
                                               false,
                                               SecurityAccessLevel.View,
                                               true,
                                               false);
                }
            }

            //move module to pane
            foreach (object obj in PortalSettings.ActiveTab.Panes)
            {
                var pane = obj as string;
                if (!string.IsNullOrEmpty(pane) && Configuration != null && !Configuration.PaneName.Equals(pane, StringComparison.InvariantCultureIgnoreCase))
                {
                    _moduleMoveActions.Actions.Add(GetNextActionID(),
                                               Localization.GetString(ModuleActionType.MovePane, Localization.GlobalResourceFile) + " " + pane,
                                               ModuleActionType.MovePane,
                                               pane,
                                               "action_move.gif",
                                               "",
                                               false,
                                               SecurityAccessLevel.View,
                                               true,
                                               false);
                }
            }

        }
        public async Task <IActionResult> InvokeAction(HttpContext httpContext, ModuleAction moduleAction, ActionContext actionContext)
        {
            IActionResult result = null;

            var targetController = _allControllers.FirstOrDefault(c => c.Namespace == moduleAction.ControllerNamespace && c.Name == moduleAction.ControllerName + ControllerTypeNameSuffix);

            if (targetController == null)
            {
                throw new Exception("Module Controller not found");
            }

            var targetAction = targetController.GetMethods().FirstOrDefault(m => m.Name == moduleAction.ActionName);

            if (targetAction == null)
            {
                throw new Exception("Module Action not found");
            }

            var executor = _cache.GetExecutor(targetAction, targetController);

            var actionArguments = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            var arguments = PrepareArguments(actionArguments, executor);

            var returnType = executor.MethodReturnType;

            var controllerContext = new ControllerContext(actionContext);
            //var controller1 = _controllerFactory.CreateController(controllerContext);

            var serviceProvider = httpContext.RequestServices;
            var controller      = _typeActivatorCache.CreateInstance <object>(serviceProvider, targetController.AsType()); //Returns

            foreach (var propertyActivator in _propertyActivators)
            {
                propertyActivator.Activate(controllerContext, controller);
            }

            //((Deviser.Core.Library.Controllers.DeviserController)controller).TempData = new TempDataDictionary()

            if (returnType == typeof(void))
            {
                executor.Execute(controller, arguments);
                result = new EmptyResult();
            }
            else if (returnType == typeof(Task))
            {
                await(Task) executor.Execute(controller, arguments);
                result = new EmptyResult();
            }
            else if (executor.TaskGenericType == typeof(IActionResult))
            {
                result = await(Task <IActionResult>) executor.Execute(controller, arguments);
                if (result == null)
                {
                    throw new InvalidOperationException(
                              Resources.FormatActionResult_ActionReturnValueCannotBeNull(typeof(IActionResult)));
                }
            }
            else if (executor.IsTypeAssignableFromIActionResult)
            {
                if (executor.IsMethodAsync)
                {
                    result = (IActionResult)await executor.ExecuteAsync(controller, arguments);
                }
                else
                {
                    result = (IActionResult)executor.Execute(controller, arguments);
                }

                if (result == null)
                {
                    throw new InvalidOperationException(
                              Resources.FormatActionResult_ActionReturnValueCannotBeNull(executor.TaskGenericType ?? returnType));
                }
            }
            else if (!executor.IsMethodAsync)
            {
                var resultAsObject = executor.Execute(controller, arguments);
                result = new ObjectResult(resultAsObject)
                {
                    DeclaredType = returnType,
                };
            }
            else if (executor.TaskGenericType != null)
            {
                var resultAsObject = await executor.ExecuteAsync(controller, arguments);

                result = new ObjectResult(resultAsObject)
                {
                    DeclaredType = executor.TaskGenericType,
                };
            }
            else
            {
                // This will be the case for types which have derived from Task and Task<T> or non Task types.
                throw new InvalidOperationException(Resources.FormatActionExecutor_UnexpectedTaskInstance(
                                                        executor.MethodInfo.Name,
                                                        executor.MethodInfo.DeclaringType));
            }

            ((IDisposable)controller).RegisterForDispose(httpContext);

            return(result);
        }
示例#9
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Recursive function to add module's actions to the DNNNodeCollection based off of passed in ModuleActions
 /// </summary>
 /// <param name="parentAction">Parent action</param>
 /// <param name="parentNode">Parent node</param>
 /// <param name="rootNode">Root Node.</param>
 /// <param name="actionControl">ActionControl to base actions off of</param>
 /// <param name="intDepth">How many levels deep should be populated</param>
 /// <remarks>
 /// </remarks>
 /// -----------------------------------------------------------------------------
 private static void AddChildActions(ModuleAction parentAction, DNNNode parentNode, DNNNode rootNode, IActionControl actionControl, int intDepth)
 {
     //Add Menu Items
     foreach (ModuleAction action in parentAction.Actions)
     {
         bool isActionPending = IsActionPending(parentNode, rootNode, intDepth);
         if (action.Title == "~")
         {
             if (isActionPending == false)
             {
                 //A title (text) of ~ denotes a break
                 parentNode.DNNNodes.AddBreak();
             }
         }
         else
         {
             //if action is visible and user has permission
             if (action.Visible &&
                 (action.Secure != SecurityAccessLevel.Anonymous ||
                  (!ModuleHost.IsViewMode(actionControl.ModuleControl.ModuleContext.Configuration, PortalSettings.Current)) &&
                  ModulePermissionController.HasModuleAccess(action.Secure, Null.NullString, actionControl.ModuleControl.ModuleContext.Configuration)))
             {
                 if (isActionPending)
                 {
                     parentNode.HasNodes = true;
                 }
                 else
                 {
                     int     i    = parentNode.DNNNodes.Add();
                     DNNNode node = parentNode.DNNNodes[i];
                     node.ID   = action.ID.ToString();
                     node.Key  = action.ID.ToString();
                     node.Text = action.Title; //no longer including SPACE in generic node collection, each control must handle how they want to display
                     if (string.IsNullOrEmpty(action.ClientScript) && string.IsNullOrEmpty(action.Url) && string.IsNullOrEmpty(action.CommandArgument))
                     {
                         node.Enabled = false;
                     }
                     else if (!string.IsNullOrEmpty(action.ClientScript))
                     {
                         node.JSFunction  = action.ClientScript;
                         node.ClickAction = eClickAction.None;
                     }
                     else
                     {
                         node.NavigateURL = action.Url;
                         if (action.UseActionEvent == false && !String.IsNullOrEmpty(node.NavigateURL))
                         {
                             node.ClickAction = eClickAction.Navigate;
                             if (action.NewWindow)
                             {
                                 node.Target = "_blank";
                             }
                         }
                         else
                         {
                             node.ClickAction = eClickAction.PostBack;
                         }
                     }
                     node.Image = action.Icon;
                     if (action.HasChildren()) //if action has children then call function recursively
                     {
                         AddChildActions(action, node, rootNode, actionControl, intDepth);
                     }
                 }
             }
         }
     }
 }
示例#10
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// This function provides a central location to obtain a generic node collection of the actions associated
 /// to a module based off of the current user's context
 /// </summary>
 /// <param name="objActionRoot">Root module action</param>
 /// <param name="objControl">ActionControl to base actions off of</param>
 /// <returns></returns>
 /// <remarks>
 /// </remarks>
 /// -----------------------------------------------------------------------------
 public static DNNNodeCollection GetActionNodes(ModuleAction objActionRoot, Control objControl)
 {
     return(GetActionNodes(objActionRoot, objControl, -1));
 }