Пример #1
0
        // GET api/<controller>
        public HttpResponseMessage Get()
        {
            LocalCacheProvider cacheProvider = new LocalCacheProvider();
            string             cacheKey      = "Fx.Manage.AppController.ApplicationList";
            string             result        = cacheProvider.GetCache <string>(cacheKey);

            if (string.IsNullOrEmpty(result))
            {
                List <SysApplicationEntity> appList = logic.GetSysApplicationList().ToList <SysApplicationEntity>();
                List <AppReponseDTO>        list    = new List <AppReponseDTO>();
                foreach (SysApplicationEntity item in appList)
                {
                    list.Add(new AppReponseDTO()
                    {
                        AppId = item.AppId, AppEName = item.AppEName, AppName = item.AppName, AppTypeId = item.AppTypeId, Status = item.Status, SubSystemId = item.SubSystemId
                    });
                }
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                result = serializer.Serialize(list);
                if (!string.IsNullOrEmpty(result))
                {
                    cacheProvider.SetCache <string>(cacheKey, result, DateTime.Now.AddHours(1));
                }
            }
            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Пример #2
0
        public ContentResult MetricsKey()
        {
            LocalCacheProvider cacheProvider = new LocalCacheProvider();
            string             cacheKey      = "Fx.Manage.Dashboard.MetricsKey";
            string             result        = cacheProvider.GetCache <string>(cacheKey);

            if (string.IsNullOrEmpty(result))
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                List <MetricsKey>    list       = logic.GetMetricsKeys();
                List <string>        keys       = new List <string>();
                foreach (MetricsKey key in list)
                {
                    keys.Add(key.Key);
                }
                result = serializer.Serialize(keys);
                if (!string.IsNullOrEmpty(result))
                {
                    cacheProvider.SetCache <string>(cacheKey, result, DateTime.Now.AddDays(1));
                }
            }
            return(Content(result));
        }