/// <summary> /// 从缓存中得到指定排序的空间列表 /// </summary> /// <param name="orderby">排序字段</param> /// <returns></returns> public DataTable GetTopSpaceListFromCache(string orderBy) { DNTCache cache = DNTCache.GetCacheService(); DataTable __topSpaceList = cache.RetrieveObject("/Space/Top" + orderBy + "SpaceList") as DataTable; if (__topSpaceList == null) { //声明新的缓存策略接口 //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy(); //cache.LoadCacheStrategy(ics); switch (orderBy) { case "commentcount": { //ics.TimeOut = AggregationConfig.GetConfig().TopcommentcountPostListTimeout * 60; __topSpaceList = GetTopSpaceList(orderBy, AggregationConfig.GetConfig().TopcommentcountSpaceListCount); cache.AddObject("/Space/Top" + orderBy + "SpaceList", __topSpaceList, AggregationConfig.GetConfig().TopcommentcountPostListTimeout * 60); break; } case "visitedtimes": { //ics.TimeOut = AggregationConfig.GetConfig().TopvisitedtimesSpaceListTimeout * 60; __topSpaceList = GetTopSpaceList(orderBy, AggregationConfig.GetConfig().TopvisitedtimesSpaceListCount); cache.AddObject("/Space/Top" + orderBy + "SpaceList", __topSpaceList, AggregationConfig.GetConfig().TopvisitedtimesSpaceListTimeout * 60); break; } } } //cache.LoadDefaultCacheStrategy(); return(__topSpaceList); }
protected AggregationServiceTestBase() { _metadata = new EntityMetadata(1, 3); _property0 = _metadata.Properties[0]; _property1 = _metadata.Properties[1]; _property2 = _metadata.Properties[2]; _aggregatorConfig0 = new WgtAvgPropertyAggregatorConfig(0, _property0, _property1); _aggregatorConfig1 = new WgtAvgPropertyAggregatorConfig(1, _property1, _property2); _aggregatorConfig2 = new WgtAvgPropertyAggregatorConfig(2, _property0, _property2); _entity0 = CreateEntity(0, 10, 20, 30); _entity1 = CreateEntity(1, 11, 21, 31); _entity2 = CreateEntity(2, 12, 22, 32); _set = new EntitySet { _entity0, _entity1 }; var config = new AggregationConfig(_metadata, new[] { _aggregatorConfig0, _aggregatorConfig1, _aggregatorConfig2 }); var service = new TAggregationService(); _root = service.Aggregate(_set, config, _metadata); _root.Start(); _set.Add(_entity2); _rootResult = _root.Result; }
/// <summary> /// 保存主题显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveTopicDisplay_Click(object sender, EventArgs e) { #region 保存主题显示 //if (!Utils.IsNumeric(topnumber.Text)) //{ // base.RegisterStartupScript("", "<script>alert('显示主题条数必须为数字!');</script>"); // return; //} //if (Convert.ToInt32(topnumber.Text) <= 0) //{ // base.RegisterStartupScript("", "<script>alert('显示主题条数至少是1条!');</script>"); // return; //} XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs"); //doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum"); if (doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum") == null) { doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum"); } XmlElement BBS = doc.CreateElement("Bbs"); doc.AppendChildElementByNameValue(ref BBS, "Topnumber", topnumber.Text, false); doc.AppendChildElementByNameValue(ref BBS, "Showtype", showtype.SelectedValue, false); doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(BBS); doc.Save(configPath); AggregationConfig.ResetConfig(); AggregationFacade.ForumAggregation.ClearAllDataBind(); #endregion }
public AggregationResult(EntityMetadata metadata, AggregationConfig config, int keyIndex) { _metadata = metadata; _config = config; _keyIndex = keyIndex; _aggregators = config.Aggregators.Select(c => c.CreateAggregator()).ToArray(); _groupResults = keyIndex < metadata.KeyCount ? new ConcurrentDictionary <int, AggregationResult>() : null; }
public AggregationResult(EntityMetadata metadata, AggregationConfig config, int keyIndex) { _metadata = metadata; _config = config; _keyIndex = keyIndex; _aggregators = config.Aggregators.Select(c => c.CreateAggregator()).ToArray(); _groupResults = keyIndex < metadata.KeyCount ? new ConcurrentDictionary<int, AggregationResult>() : null; }
private static void Dump(IAggregationResult result, EntityMetadata metadata, AggregationConfig config, string filepath) { using (var writer = new StreamWriter(File.Create(filepath))) { writer.Write(String.Join("", Enumerable.Range(0, metadata.KeyCount).Select(i => "Key" + i + ","))); writer.WriteLine(String.Join(",", config.Aggregators.Select(a => "\"" + a.Name + "\""))); var keys = new int[metadata.KeyCount]; Dump(writer, result, config, keys, 0); } }
/// <summary> /// 从缓存中获得指定排序的空间日志列表 /// </summary> /// <param name="orderby">排序字段</param> /// <returns></returns> public DataTable GetTopSpacePostListFromCache(string orderBy) { lock (lockHelper) { DNTCache cache = DNTCache.GetCacheService(); DataTable __topSpacePostList = cache.RetrieveObject("/Space/Top" + orderBy + "PostList") as DataTable; if (__topSpacePostList == null) { //声明新的缓存策略接口 //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy(); //cache.LoadCacheStrategy(ics); switch (orderBy) { case "commentcount": { //ics.TimeOut = AggregationConfig.GetConfig().TopcommentcountPostListTimeout * 60; __topSpacePostList = GetTopSpacePostList(orderBy, AggregationConfig.GetConfig().TopcommentcountPostListCount); cache.AddObject("/Space/Top" + orderBy + "PostList", __topSpacePostList, AggregationConfig.GetConfig().TopcommentcountPostListTimeout * 60); break; } case "views": { //ics.TimeOut = AggregationConfig.GetConfig().TopviewsPostListTimeout * 60; __topSpacePostList = GetTopSpacePostList(orderBy, AggregationConfig.GetConfig().TopviewsPostListCount); cache.AddObject("/Space/Top" + orderBy + "PostList", __topSpacePostList, AggregationConfig.GetConfig().TopviewsPostListTimeout * 60); break; } default: { orderBy = "commentcount"; __topSpacePostList = GetTopSpacePostList(orderBy, 1); __topSpacePostList.Rows.Clear(); cache.AddObject("/Space/Top" + orderBy + "PostList", __topSpacePostList, 300); break; } } //try //{ // cache.AddObject("/Space/Top" + orderBy + "PostList", __topSpacePostList); //} //finally //{ // cache.LoadDefaultCacheStrategy(); //} } return(__topSpacePostList); } }
public AggregationConfigTest() { var metadata = new EntityMetadata(1, 3); _property0 = metadata.Properties[0]; _property1 = metadata.Properties[1]; _property2 = metadata.Properties[2]; _aggregatorConfig0 = new WgtAvgPropertyAggregatorConfig(0, _property0, _property1); _aggregatorConfig1 = new WgtAvgPropertyAggregatorConfig(1, _property1, _property2); _aggregatorConfig2 = new WgtAvgPropertyAggregatorConfig(2, _property0, _property2); _config = new AggregationConfig(metadata, new[] { _aggregatorConfig0, _aggregatorConfig1, _aggregatorConfig2 }); }
public AggregationResult(EntityMetadata metadata, AggregationConfig config, int keyIndex) { _metadata = metadata; _config = config; _keyIndex = keyIndex; _aggregators = config.Aggregators.Select(c => c.CreateAggregator()).ToArray(); _groupResults = keyIndex < metadata.KeyCount ? new ConcurrentDictionary <int, AggregationResult>() : null; _cts = new CancellationTokenSource(); var executionOptions = new ExecutionDataflowBlockOptions { CancellationToken = _cts.Token, SingleProducerConstrained = true }; _changeBlock = new ActionBlock <AggregationChange>((Action <AggregationChange>)ProcessChange, executionOptions); }
public AggregationResult(EntityMetadata metadata, AggregationConfig config, int keyIndex) { _metadata = metadata; _config = config; _keyIndex = keyIndex; _aggregators = config.Aggregators.Select(c => c.CreateAggregator()).ToArray(); _groupResults = keyIndex < metadata.KeyCount ? new ConcurrentDictionary<int, AggregationResult>() : null; _cts = new CancellationTokenSource(); var executionOptions = new ExecutionDataflowBlockOptions { CancellationToken = _cts.Token, SingleProducerConstrained = true }; _changeBlock = new ActionBlock<AggregationChange>((Action<AggregationChange>)ProcessChange, executionOptions); }
private static void Dump(TextWriter writer, IAggregationResult result, AggregationConfig config, int[] keys, int level) { for (var i = 0; i < keys.Length; i++) { if (i < level) { writer.Write(keys[i] + ","); } else { writer.Write("-,"); } } writer.WriteLine(String.Join(",", config.Aggregators.Select(a => result.Get(a).ToString("")))); foreach (var groupKey in result.Keys.OrderBy(k => k)) { keys[level] = groupKey; Dump(writer, result.Get(groupKey), config, keys, level + 1); } }
protected void Page_Load(object sender, EventArgs e) { #region 装载信息 if (!IsPostBack) { AggregationConfigInfo aci = AggregationConfig.GetConfig(); newcommentcount.Text = aci.SpaceTopNewCommentsCount.ToString(); newcommentcounttimeout.Text = aci.SpaceTopNewCommentsTimeout.ToString(); maxarticlecommentcount.Text = aci.TopcommentcountPostListCount.ToString(); maxarticlecommentcounttimeout.Text = aci.TopcommentcountPostListTimeout.ToString(); maxarticleviewcount.Text = aci.TopviewsPostListCount.ToString(); maxarticleviewcounttimeout.Text = aci.TopviewsPostListTimeout.ToString(); maxcommentcount.Text = aci.TopcommentcountSpaceListCount.ToString(); maxcommentcounttimeout.Text = aci.TopcommentcountSpaceListTimeout.ToString(); maxspaceviewcount.Text = aci.TopvisitedtimesSpaceListCount.ToString(); maxspaceviewcounttimeout.Text = aci.TopvisitedtimesSpaceListTimeout.ToString(); maxpostarticlespacecount.Text = aci.ToppostcountSpaceListCount.ToString(); maxpostarticlespacecounttimeout.Text = aci.ToppostcountSpaceListTimeout.ToString(); updatespacecount.Text = aci.RecentUpdateSpaceAggregationListCount.ToString(); updatespacetimeout.Text = aci.RecentUpdateSpaceAggregationListTimeout.ToString(); } #endregion }
/// <summary> /// 最新空间评论数 /// </summary> /// <returns></returns> public DataTable GetSpaceTopComments() { DNTCache cache = DNTCache.GetCacheService(); DataTable __topNComments = cache.RetrieveObject("/Space/SpaceTopNewComments") as DataTable; if (__topNComments == null) { __topNComments = GetSpaceTopComments(AggregationConfig.GetConfig().SpaceTopNewCommentsCount); foreach (DataRow dr in __topNComments.Rows) { dr["author"] = Utils.HtmlEncode(dr["author"].ToString().Trim()); dr["posttitle"] = Utils.HtmlEncode(dr["posttitle"].ToString().Trim()); dr["content"] = Utils.HtmlEncode(dr["content"].ToString().Trim()); } //声明新的缓存策略接口 //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy(); //ics.TimeOut = AggregationConfig.GetConfig().SpaceTopNewCommentsTimeout * 60; //cache.LoadCacheStrategy(ics); cache.AddObject("/Space/SpaceTopNewComments", __topNComments, AggregationConfig.GetConfig().SpaceTopNewCommentsTimeout * 60); //cache.LoadDefaultCacheStrategy(); } return(__topNComments); }
protected override void ShowPage() { pagetitle = "日志列表"; if (config.Enablespace != 1) { AddErrLine("个人空间功能已被关闭"); return; } newtopiclist = AggregationFacade.ForumAggregation.GetForumTopicList(10, 0, 0, TopicTimeType.All, TopicOrderType.PostDateTime, false, false); hottopiclist = AggregationFacade.ForumAggregation.GetForumTopicList(10, 0, 0, TopicTimeType.All, TopicOrderType.Views, false, false); recentupdatespacelist = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount); // 得到公告 announcementlist = Announcements.GetSimplifiedAnnouncementList(nowdatetime, "2999-01-01 00:00:00"); announcementcount = 0; if (announcementlist != null) { announcementcount = announcementlist.Rows.Count; } rotatepicdata = AggregationFacade.BaseAggregation.GetRotatePicData(); currentpage = DNTRequest.GetInt("page", 1); blogsCount = AggregationFacade.SpaceAggregation.GetSpacePostsCount(); pagecount = blogsCount % pageSize == 0 ? blogsCount / pageSize : blogsCount / pageSize + 1; if (pagecount == 0) { pagecount = 1; } if (currentpage < 1) { currentpage = 1; } if (currentpage > pagecount) { currentpage = pagecount; } spacepostlist = AggregationFacade.SpaceAggregation.GetSpacePostList("Spaceindex"); pagenumbers = Utils.GetPageNumbers(currentpage, pagecount, "bloglist.aspx", 8); postslist = AggregationFacade.SpaceAggregation.SpacePostsList(pageSize, currentpage); if (config.Enablealbum == 1) { recommendalbumlist = AggregationFacade.AlbumAggregation.GetRecommandAlbumList("Spaceindex"); } topspacecomments = AggregationFacade.SpaceAggregation.GetSpaceTopComments(); }
public AggregationRoot(EntitySet set, AggregationConfig config, EntityMetadata metadata) : base(set, config) { _result = new AggregationResult(metadata, config, 0); }
private void Btn_SaveInfo_Click(object sender, EventArgs e) { #region 保存自动提取数据 int inewcommentcount = Convert.ToInt32(newcommentcount.Text); if (!ValidateCount(inewcommentcount)) { return; } int inewcommentcounttimeout = Convert.ToInt32(newcommentcounttimeout.Text); if (!ValidateTimeout(inewcommentcounttimeout)) { return; } int imaxarticlecommentcount = Convert.ToInt32(maxarticlecommentcount.Text); if (!ValidateCount(imaxarticlecommentcount)) { return; } int imaxarticlecommentcounttimeout = Convert.ToInt32(maxarticlecommentcounttimeout.Text); if (!ValidateTimeout(imaxarticlecommentcounttimeout)) { return; } int imaxarticleviewcount = Convert.ToInt32(maxarticleviewcount.Text); if (!ValidateCount(imaxarticleviewcount)) { return; } int imaxarticleviewcounttimeout = Convert.ToInt32(maxarticleviewcounttimeout.Text); if (!ValidateTimeout(imaxarticleviewcounttimeout)) { return; } int imaxcommentcount = Convert.ToInt32(maxcommentcount.Text); if (!ValidateCount(imaxcommentcount)) { return; } int imaxcommentcounttimeout = Convert.ToInt32(maxcommentcounttimeout.Text); if (!ValidateTimeout(imaxcommentcounttimeout)) { return; } int imaxspaceviewcount = Convert.ToInt32(maxspaceviewcount.Text); if (!ValidateCount(imaxspaceviewcount)) { return; } int imaxspaceviewcounttimeout = Convert.ToInt32(maxspaceviewcounttimeout.Text); if (!ValidateTimeout(imaxspaceviewcounttimeout)) { return; } int imaxpostarticlespacecount = Convert.ToInt32(maxpostarticlespacecount.Text); if (!ValidateCount(imaxpostarticlespacecount)) { return; } int imaxpostarticlespacecounttimeout = Convert.ToInt32(maxpostarticlespacecounttimeout.Text); if (!ValidateTimeout(imaxpostarticlespacecounttimeout)) { return; } int iupdatespacecount = Convert.ToInt32(updatespacecount.Text); if (!ValidateCount(iupdatespacecount)) { return; } int iupdatespacetimeout = Convert.ToInt32(updatespacetimeout.Text); if (!ValidateTimeout(iupdatespacetimeout)) { return; } DNTCache cache = DNTCache.GetCacheService(); cache.RemoveObject("/Space/SpaceTopNewComments"); cache.RemoveObject("/Space/TopcommentcountPostList"); cache.RemoveObject("/Space/TopviewsPostList"); cache.RemoveObject("/Space/TopcommentcountSpaceList"); cache.RemoveObject("/Space/TopvisitedtimesSpaceList"); cache.RemoveObject("/Space/ToppostcountSpaceList"); cache.RemoveObject("/Space/RecentUpdateSpaceAggregationList"); AggregationConfigInfo aci = AggregationConfig.GetConfig(); aci.SpaceTopNewCommentsCount = inewcommentcount; aci.SpaceTopNewCommentsTimeout = inewcommentcounttimeout; aci.TopcommentcountPostListCount = imaxarticlecommentcount; aci.TopcommentcountPostListTimeout = imaxarticlecommentcounttimeout; aci.TopviewsPostListCount = imaxarticleviewcount; aci.TopviewsPostListTimeout = imaxarticleviewcounttimeout; aci.TopcommentcountSpaceListCount = imaxcommentcount; aci.TopcommentcountSpaceListTimeout = imaxcommentcounttimeout; aci.TopvisitedtimesSpaceListCount = imaxspaceviewcount; aci.TopvisitedtimesSpaceListTimeout = imaxspaceviewcounttimeout; aci.ToppostcountSpaceListCount = imaxpostarticlespacecount; aci.ToppostcountSpaceListTimeout = imaxpostarticlespacecounttimeout; aci.RecentUpdateSpaceAggregationListCount = iupdatespacecount; aci.RecentUpdateSpaceAggregationListTimeout = iupdatespacetimeout; AggregationConfig.SaveConfig(aci); AggregationFacade.BaseAggregation.ClearAllDataBind(); #endregion }
protected override void ShowPage() { pagetitle = config.Spacename + "首页"; if (config.Enablespace != 1) { AddErrLine("个人空间功能已被关闭"); return; } if (config.Rssstatus == 1) { AddLinkRss("tools/spacerss.aspx", "最新日志"); } newtopiclist = AggregationFacade.ForumAggregation.GetForumTopicList(10, 0, 0, TopicTimeType.All, TopicOrderType.PostDateTime, false, false); hottopiclist = AggregationFacade.ForumAggregation.GetForumTopicList(10, 0, 0, TopicTimeType.All, TopicOrderType.Views, false, false); recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount); // 得到公告 announcementlist = Announcements.GetSimplifiedAnnouncementList(nowdatetime, "2999-01-01 00:00:00"); announcementcount = 0; if (announcementlist != null) { announcementcount = announcementlist.Rows.Count; } rotatepicdata = AggregationFacade.SpaceAggregation.GetRotatePicData(); spacepostlist = AggregationFacade.SpaceAggregation.GetSpacePostList("Spaceindex"); spaceconfigs = AggregationFacade.SpaceAggregation.GetSpaceListFromFile("Spaceindex"); topspacelistbycommentcount = AggregationFacade.SpaceAggregation.GetTopSpaceListFromCache("commentcount"); topspacelistbyvisitedtimes = AggregationFacade.SpaceAggregation.GetTopSpaceListFromCache("visitedtimes"); topspacepostcommentcount = AggregationFacade.SpaceAggregation.GetTopSpacePostListFromCache("commentcount"); topspacepostviews = AggregationFacade.SpaceAggregation.GetTopSpacePostListFromCache("views"); topspacecomments = AggregationFacade.SpaceAggregation.GetSpaceTopComments(); if (config.Enablealbum == 1) { recommendalbumlist = AggregationFacade.AlbumAggregation.GetRecommandAlbumList("Spaceindex"); } }
public IAggregationRoot Aggregate(EntitySet set, AggregationConfig config, EntityMetadata metadata) { return(new AggregationRoot(set, config, metadata)); }
protected override void ShowPage() { pagetitle = config.Albumname + "首页"; if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } if (config.Rssstatus == 1) { AddLinkRss("tools/photorss.aspx", "最新图片"); } announcementlist = Announcements.GetAnnouncementList(Utils.GetDateTime(), "2999-01-01 00:00:00"); if (announcementlist != null) { announcementcount = announcementlist.Rows.Count; } //轮显图片 rotatepicdata = AggregationFacade.AlbumAggregation.GetRotatePicData(); //推荐图片 recommendphotolist = AggregationFacade.AlbumAggregation.GetRecommandPhotoList("Albumindex"); //焦点图片 focusphotolist = AggregationFacade.AlbumAggregation.GetFocusPhotoList(photoconfig.Focusphotoshowtype, photoconfig.Focusphotocount, photoconfig.Focusphotodays); //推荐相册 recommendalbumlist = AggregationFacade.AlbumAggregation.GetRecommandAlbumList("Albumindex"); //焦点相册 focusalbumlist = AggregationFacade.AlbumAggregation.GetAlbumList(photoconfig.Focusalbumshowtype, photoconfig.Focusalbumcount, photoconfig.Focusalbumdays); //一周热图总排行 weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot); //相册分类 albumcategorylist = DTOProvider.GetAlbumCategory(); if (config.Enablespace == 1) { recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount); } }
/// <summary> /// 得到最近更新的空间列表 /// </summary> /// <param name="count">返回的记录数</param> /// <returns></returns> public DataTable GetRecentUpdateSpaceList(int count) { DNTCache cache = DNTCache.GetCacheService(); //声明新的缓存策略接口 //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy(); //ics.TimeOut = AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListTimeout * 60; //cache.LoadCacheStrategy(ics); DataTable __recentUpdateSpaceList = cache.RetrieveObject("/Space/RecentUpdateSpaceAggregationList") as DataTable; if (__recentUpdateSpaceList == null) { __recentUpdateSpaceList = SpacePluginProvider.GetInstance().GetWebSiteAggRecentUpdateSpaceList(count); cache.AddObject("/Space/RecentUpdateSpaceAggregationList", __recentUpdateSpaceList, AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListTimeout * 60); } cache.LoadDefaultCacheStrategy(); return(__recentUpdateSpaceList); }
public IAggregationRoot Aggregate(EntitySet set, AggregationConfig config, EntityMetadata metadata) { return new AggregationRoot(set, config, metadata); }
protected override void ShowPage() { if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } pagetitle = "图片排行"; announcementlist = Announcements.GetAnnouncementList(Utils.GetDateTime(), "2999-01-01 00:00:00"); if (announcementlist != null) { announcementcount = announcementlist.Rows.Count; } type = type < 0 ? 0 : type; type = type > 3 ? 3 : type; if (type < 3) { photolist = DTOProvider.GetPhotoRankList(type, photocount); } else { albumlist = DTOProvider.GetAlbumRankList(photocount); } //一周热图总排行 weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot); //相册分类 albumcategorylist = DTOProvider.GetAlbumCategory(); recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount); }