Exemplo n.º 1
0
        public JObject GetSettings([FromUri] ApiClientInfo info)
        {
            var settings = Settings.GetSettings().DeepClone() as JObject;
            var archiveplan = JsonHelper.FindTokenValue<JToken>(settings, "archiveplan");
            var entryNodes = archiveplan != null ? JsonHelper.FindTokenValue<JArray>(archiveplan, "entryNodes") : null;
            
            JsonHelper.AddOrSet(settings, "managementClientSettings", JObject.FromObject(managementClientSettings));

            var selectedLanguage = WebHelper.GetClientLanguage(Request);
            JsonHelper.AddOrSet(settings, "frontendDynamicTextSettings", JObject.FromObject(GetTranslatedFrontendDynamicTextSettings(selectedLanguage)));

            if (entryNodes != null)
            {
                try
                {
                    var access = GetUserAccess(selectedLanguage);

                    var ids = new List<int>();
                    foreach (var node in entryNodes.Children())
                    {
                        ids.Add(JsonHelper.FindTokenValue<int>(node, "archiveRecordId"));
                    }

                    var result = entityProvider.GetEntities<TreeRecord>(ids, access);
                    JsonHelper.Replace(entryNodes, JArray.FromObject(result.Items.Select(i => i.Data).ToArray()));
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "failed to decorate entry nodes");
                }
            }

            return settings;
        }
Exemplo n.º 2
0
        public IHttpActionResult GetEntities(string ids, int?skip = null, int?take = null)
        {
            if (ControllerHelper.HasClaims())
            {
                return(BadRequest("request was authorized, but this API only accepts unauthorized requests"));
            }

            if (take.HasValue && take > 500)
            {
                return(BadRequest("The take parameter must be less or equal than 500"));
            }

            try
            {
                var idList = !string.IsNullOrEmpty(ids)
                    ? ids.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(i =>
                {
                    var val = int.Parse(i);
                    if (val >= 0)
                    {
                        return(val);
                    }

                    throw new ArgumentOutOfRangeException();
                })
                             .Distinct()
                             .ToList()
                    : new List <int>();

                if (idList.Count > 1000)
                {
                    return(BadRequest("A maximum of 1000 ids can be passed."));
                }

                try
                {
                    var access = new UserAccess(ControllerHelper.GetCurrentUserId(), null, null, null, false);

                    // The children should/must always be sorted by treeSequence. Thus we are not allowing a different sort order.
                    var paging = new Paging {
                        OrderBy = "treeSequence", SortOrder = "Ascending", Skip = skip, Take = take
                    };
                    var res = entityProvider.GetEntities <TreeRecord>(idList, access, paging);

                    return(Ok(res));
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "ExternalController: Exception on processing request GetEntities");
                    return(InternalServerError());
                }
            }
            catch (Exception)
            {
                return(BadRequest("Each Id must be a positive integer"));
            }
        }
        public EntityResult <TreeRecord> GetEntities(string ids, string language = null, [FromUri] Paging paging = null)
        {
            var access = GetUserAccess(language ?? WebHelper.GetClientLanguage(Request));

            var idList = !string.IsNullOrEmpty(ids)
                ? ids.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToList()
                : new List <int>();

            return(entityProvider.GetEntities <TreeRecord>(idList, access, paging));
        }
Exemplo n.º 4
0
        private void RebuildObject(object xiObject)
        {
            IEntityProvider lObject = xiObject as IEntityProvider;

            if (lObject != null)
            {
                IEnumerable <Entity> lNew = lObject.GetEntities(mSubject, TextureMode, SelectedMetadata);
                //qq this hacky
                foreach (Entity lNewEntity in lNew)
                {
                    mScene.RemoveMMEdObject(xiObject);
                    mScene.AddObject(lNewEntity);
                    UpdateActiveObjectStatus(xiObject);
                    return;
                }

                RebuildScene();
                UpdateActiveObjectStatus(xiObject);
            }
        }