Exemplo n.º 1
0
 public void Raise(ActionLevel action)
 {
     for (int i = listeners.Count - 1; i >= 0; i--)
     {
         listeners[i].OnEventRaised(action);
     }
 }
Exemplo n.º 2
0
        internal void Add(string action, ActionLevel level = ActionLevel.Normal)
        {
            var ac = new GameEvent()
            {
                Info = action, Level = level
            };

            Add(ac);
        }
    public void OnEventRaised(ActionLevel action)
    {
        StoryLine cStoryLine = storyBook.GetStoryLine();

        /*
         * // is this a change of location?
         * ChangeLocation cLocation = cStoryLine as ChangeLocation;
         * if (cLocation != null)
         *  locationBack.sprite = cLocation.location.background;
         */
        if (cStoryLine != null)
        {
            Response.Invoke(cStoryLine);
        }
    }
Exemplo n.º 4
0
        public static void DoPostExcute(ActionLevel actionLevel)
        {
            ProcessCfg processCfg = buildOption.ProcessCfg;

            BuildAction[] actions;
            if (actionLevel == ActionLevel.Common)
            {
                actions = processCfg.CommonActions;
            }
            else
            {
                actions = processCfg.PlatformActions;
            }
            for (int i = actions.Length - 1; i >= 0; i--)
            {
                actions[i].PostExcute(buildOption);
            }
        }
    public StoryLine GetStoryLine(ActionLevel action)
    {
        List <StoryLine> validLines = new List <StoryLine>();

        foreach (StoryLine line in storyLines)
        {
            if (line.CanDo)
            {
                validLines.Add(line);
            }
        }

        if (validLines.Count > 0)
        {
            return(validLines[Random.Range(0, validLines.Count)]);
        }
        // return default
        return(storyLine);
    }
Exemplo n.º 6
0
        public ReturnData <List <UserGroupPrivilege> > FilterPrivileges(string searchText, Role role, ActionLevel level, int?offset = null, int?itemsPerPage = null)
        {
            try
            {
                var response = new ReturnData <List <UserGroupPrivilege> >();
                var query    = new UserQuery
                {
                    SearchText = searchText,
                    EndDate    = null,
                    Skip       = offset,
                    StartDate  = null,
                    Take       = itemsPerPage
                };

                var queryResult = _context.UserGroupPrivileges.Where(p => (p.Role == role || p.Role == Role.All) && p.Level == level).AsQueryable().AsNoTracking().Where(filters.FilterPrivileges(query));
                var data        = queryResult.OrderBy(n => n.Code).ToList();

                if (query.Skip.HasValue)
                {
                    data = data.Skip(query.Skip.Value).ToList();
                }

                if (query.Take.HasValue)
                {
                    data = data.Take(query.Take.Value).ToList();
                }

                if (query.Skip.HasValue && query.Take.HasValue)
                {
                    data = data.Skip(query.Skip.Value).Take(query.Take.Value).ToList();
                }

                response.TotalItems = data.Count();
                response.Data       = data;

                return(response);
            }
            catch (Exception ex)
            {
                return(new ReturnData <List <UserGroupPrivilege> >
                {
                    Success = false,
                    Message = "Sorry, Server error"
                });
            }
        }
Exemplo n.º 7
0
        protected override void ExecuteActions(ActionLevel level, ActionPhase phase)
        {
            InvokeMethodsWithAttribute(typeof(GivenAttribute));

            InvokeMethodsWithAttribute(typeof(WhenAttribute));

            base.ExecuteActions(level, phase);
        }
Exemplo n.º 8
0
        public JsonResult GetGroupPrivileges(string usercode, ActionLevel level)
        {
            var reply = new ReturnData <List <UserGroupPrivilege> >();

            try
            {
                var token = _tokenValidator.Validate(HttpContext);
                if (!token.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        NotAuthenticated = true,
                        Message = $"Unauthorized:-{token.Message}",
                    }));
                }
                var user = _context.Users.FirstOrDefault(u => u.UserName == usercode);
                if (user == null)
                {
                    {
                        reply.Success = false;
                        reply.Message = "User not found";
                        return(Json(reply));
                    }
                }
                var userGroup = _context.UserGroups.FirstOrDefault(g => g.Id == user.UserGroupsId);
                if (userGroup == null)
                {
                    {
                        reply.Success = false;
                        reply.Message = "Usergroup not found";
                        return(Json(reply));
                    }
                }

                if (string.IsNullOrEmpty(userGroup.AllowedPrivileges))
                {
                    {
                        reply.Success = false;
                        reply.Message = "Group Privileges Not set, Please contact admin";
                        return(Json(reply));
                    }
                }

                var groupPrivileges    = new List <UserGroupPrivilege>();
                var privilegeCodeArray = userGroup.AllowedPrivileges.Split(",");

                foreach (var code in privilegeCodeArray)
                {
                    var privileges = _context.UserGroupPrivileges.FirstOrDefault(p => p.Code == code && p.Level == level);
                    if (privileges != null)
                    {
                        groupPrivileges.Add(privileges);
                    }
                }

                reply.Success = true;
                reply.Data    = groupPrivileges;
            }
            catch (Exception ex)
            {
                reply.Success = false;
                reply.Message = ex.Message;
            }

            return(Json(reply));
        }
Exemplo n.º 9
0
 public JsonResult Pages(string searchText, Role role, ActionLevel level, int?offset = null, int?itemsPerPage = null)
 {
     return(Json(_portalServices.FilterPrivileges(searchText, role, level, offset, itemsPerPage)));
 }
Exemplo n.º 10
0
 public DbEntityActionMessage(Type type, List <Tuple <string, object>[]> entitiesReferences, int action, int createdBy, string actionData, int duration, string source, string version, int commentId, ActionLevel actionLevel) : this(Guid.NewGuid().ToString(), type.FullName, DateTime.UtcNow, JsonConvert.SerializeObject(entitiesReferences), action, createdBy, actionData, duration, source, version, commentId, (int)actionLevel)
 {
 }