Example #1
0
        // ReSharper disable once InconsistentNaming
        public ActionResult GetXmlDownloadJson(int content_item_id, bool live = false)
        {
            var oneTimeKey = Guid.NewGuid().ToString();

            _versionedCacheProvider.Add(true, oneTimeKey, new string[] { }, TimeSpan.FromMinutes(10));

            var urlScheme = Request.Scheme;

            return
                (Json(
                     new
            {
                Type = "Download",
                Url = Url.Action("DownloadXml", "Product", new { content_item_id, live, oneTimeKey }, urlScheme)
            }));
        }
Example #2
0
        public JToken GetDefinition(string customerCode, int definitionId)
        {
            DefinitionDescriptor definition = null;
            var key = $"tnt_definition_{customerCode}_{definitionId}";

            if (_cacheProvider.TryGetValue(key, out object value))
            {
                var definitionCache = value as DefinitionDescriptor;
                var modifiedActual  = GetDefinitionModifiedDate(customerCode, definitionId);

                if (modifiedActual == definitionCache.Modified)
                {
                    definition = definitionCache;
                }
            }

            if (definition == null)
            {
                var actualDefinition = GetActualDefinition(customerCode, definitionId);

                var t    = actualDefinition.SelectTokens("result[?(@.CONTENT_ITEM_ID)]").Select(n => (JObject)n).First();
                var last = t.Children().Last(n => ((JProperty)n).Name.StartsWith("field_")) as JProperty;

                if (last == null)
                {
                    throw new InvalidOperationException("Cannot find definition data");
                }

                definition = new DefinitionDescriptor
                {
                    Modified       = actualDefinition["result"].First().Value <DateTime>("MODIFIED"),
                    JsonDefinition = JObject.Parse(last.Value.ToString())
                };

                _cacheProvider.Add(definition, key, new string[0], _expiration);
            }

            return(definition.JsonDefinition);
        }
Example #3
0
 public void SetValue <T>(T value, string key)
 {
     _cacheProvider.Add(value, GetCacheKey(key), StorageKeyTags[key], CacheTime);
 }