Ejemplo n.º 1
0
        public virtual ActionResult RestartDWSService()
        {
            LogService.Info("Restart DWS Service Action");

            SystemActions.AddAction(Db,
                                    SystemActionType.RestartService,
                                    "",
                                    null,
                                    null,
                                    AccessManager.UserId);

            return(JsonGet(new { success = true }));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actionDescriptor"></param>
        /// <returns></returns>
        public object RegistAction(List <ControllerActionDescriptor> actionDescriptor)
        {
            try
            {
                var actionLists       = actionDescriptor.Select(t => t.DisplayName.ToString()).ToList();
                var systemActionLists = base.Where <SystemActions>(t => !actionLists.Contains(t.ActionName));
                base.Delete(systemActionLists, true);
                ParentAtions.ParentAtionsList.ForEach(t =>
                {
                    base.Add(new SystemActions {
                        ActionId = t.Id, ActionName = t.Name, ActionDescription = t.Name, Orders = t.Order, Url = t.Url, CreateTime = DateTime.Now
                    });
                });
                var actions = base.Query <SystemActions>().ToList();
                foreach (var a in actionDescriptor)
                {
                    var dbAction = actions.SingleOrDefault(t => t.ActionName == a.DisplayName);
                    if (dbAction != null)
                    {
                        base.Update(dbAction);
                    }
                    else
                    {
                        dbAction = new SystemActions
                        {
                            ActionId   = Guid.NewGuid().ToString("N"),
                            CreateTime = DateTime.Now,
                            ActionName = a.DisplayName
                        };
                        base.Add(dbAction);
                    }
                    a.SetFieldValue("Id", dbAction.ActionId.ToString());
                    var attr = a.MethodInfo.GetCustomAttribute <ActionAttribute>();
                    dbAction.ActionDescription = attr.Name;
                    dbAction.ParentAction      = attr.ParentId;
                    dbAction.Orders            = attr.Order;
                    dbAction.Url = $"/{a.ControllerName}/{a.ActionName}";
                }
                base.Save();
                _menus = base.Query <SystemActions>().Select(t => new MenuModel
                {
                    ActionName        = t.ActionName,
                    ActionId          = t.ActionId,
                    ActionDescription = t.ActionDescription,
                    Url      = t.Url,
                    Orders   = t.Orders ?? 0,
                    ParentId = t.ParentAction
                }).ToList();
                _menus.ForEach(t =>
                {
                    var p = ParentAtions.ParentAtionsList.SingleOrDefault(x => x.Id == t.ParentId);
                    if (p != null)
                    {
                        t.Parent = p.Name;
                    }
                });

                return(_menus);
            }
            catch (Exception ex)
            {
                Log4Net.Error($"[RegistAction:]{ex}");
                throw ex;
            }
        }
Ejemplo n.º 3
0
 public bool CheckPermission(SystemActions permission)
 {
     return(true);
 }
Ejemplo n.º 4
0
        public static PTRobotReturn SystemAction(UInt32 robotID, SystemActions action)
        {
            uint nValue = 0;
            PTRobotReturn ret = PTRobotReturn.Ok;
            try
            {
                nValue = PTRobot_SystemAction(robotID, Convert.ToUInt32(action));
                ret = (PTRobotReturn)nValue;
            }
            catch
            {
                ret = PTRobotReturn.Internal;
            }

            return ret;
        }