public JsonResult CacheUpdate()
 {
     try
     {
         using (var client = new HomePageClient())
         {
             var res = client.RefreshHomePagePopCache();
             if (res.Success && res.Result)
             {
                 return(Json(1));
             }
             else
             {
                 return(Json(-1));
             }
         }
     }
     catch (Exception exp)
     {
         WebLog.LogException(exp);
         return(Json(-1));
     }
 }
Example #2
0
        public List <OverdueActivityConfig> GetActivityConfigList(string pageId, string type = "H5")
        {
            List <OverdueActivityConfig> activityConfigList = new List <OverdueActivityConfig>();
            DateTime nowday    = DateTime.Now.Date;
            string   searchkey = "activity/index?id=";
            string   regexstr  = @"(.*)activity/index\?id=(\w*)";

            if (type.Equals("lightApp", StringComparison.OrdinalIgnoreCase))
            {
                searchkey = "luck/luck2?id=";
                regexstr  = @"(.*)luck/luck2\?id=(\w*)";
            }
            using (var homepageclient = new HomePageClient())
            {
                var response = homepageclient.GetLightAppHomePageModuleInfoByModuleKey(pageId);
                if (response != null && response.Result != null)
                {
                    //   var homemodels = response.Result.HomePageModels.Where(p => p.Contents.Where(q => q.Uri.IndexOf("activity/index?id=") >= 0).Count()>0).ToList();
                    foreach (var homeModel in response.Result.HomePageModels.Where(p => p != null))
                    {
                        var homepageName = homeModel.Title;
                        var typeName     = homeModel.TypeName;
                        foreach (var content in homeModel.Contents.Where(p => p != null))
                        {
                            if (content.Uri?.IndexOf(searchkey) >= 0)
                            {
                                Regex idreg   = new Regex(regexstr);
                                Match idMatch = idreg.Match(content.Uri);
                                if (idMatch.Success)
                                {
                                    var hashkey = idMatch.Result("$2");
                                    List <ActivePage> promotionItemList = ModuleContentConfigDAL.GetActivePageByHashKey(hashkey);
                                    if (promotionItemList != null && promotionItemList.FirstOrDefault() != null)
                                    {
                                        var      promotionItem = promotionItemList.First();
                                        var      endDate       = promotionItem.EndDate.Date;
                                        TimeSpan sp            = endDate - nowday;
                                        int      status        = 0;
                                        if (sp.Days <= 4 && sp.Days > 0)
                                        {
                                            status = 1;
                                        }
                                        else if (sp.Days <= 0)
                                        {
                                            status = -1;
                                        }
                                        if (status != 0)
                                        {
                                            var overdueActivityConfigItem = new OverdueActivityConfig()
                                            {
                                                ModuleName = homepageName,
                                                //  HomePageName = promotionModuleItem.HomePageName,
                                                HelperModuleName = content.Title,
                                                Url     = "https://wx.tuhu.cn/staticpage/promotion/activity/?id=" + hashkey,
                                                Title   = promotionItem.Title,
                                                EndDate = promotionItem.EndDate,
                                                Status  = status,
                                                Type    = typeName
                                            };

                                            activityConfigList.Add(overdueActivityConfigItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(activityConfigList);
        }