Sharepoint 2013 类别平铺视图:显示错误的回复计数
在SharePoint社区网站中,类别互动程序视图显示了错误的回复计数。在一般类别中,回复总数为5,但在类别平铺视图中显示为3。我们能够在测试和生产环境中复制这种行为。我们也等待了一天,如果这个问题与爬网有关,但问题仍然存在 请对此提出一些建议 谢谢,Sharepoint 2013 类别平铺视图:显示错误的回复计数,sharepoint-2013,Sharepoint 2013,在SharePoint社区网站中,类别互动程序视图显示了错误的回复计数。在一般类别中,回复总数为5,但在类别平铺视图中显示为3。我们能够在测试和生产环境中复制这种行为。我们也等待了一天,如果这个问题与爬网有关,但问题仍然存在 请对此提出一些建议 谢谢, Sheetal我遇到了完全相同的问题,没有可用的修复方法。在我看来,这些计数器是通过事件接收器更新的,所以这与搜索爬网无关 我通过按代码设置正确的字段来解决此问题: 首先使用此SSOM代码统计主题和回复 /// <summa
Sheetal我遇到了完全相同的问题,没有可用的修复方法。在我看来,这些计数器是通过事件接收器更新的,所以这与搜索爬网无关 我通过按代码设置正确的字段来解决此问题: 首先使用此SSOM代码统计主题和回复
/// <summary>
/// Dictionary: categId, nr disc
/// </summary>
public Dictionary<int, int> CategoryTopicCount
{
get
{
var categoriesDiscussionsCount = new Dictionary<int, int>();
foreach (int categId in Categories)
{
var spquery = new SPQuery();
spquery.Query = ""
+ " <Where>"
+ " <And> "
+ " <IsNull>"
+ " <FieldRef Name='ParentFolderId' />"
+ " </IsNull>"
+ " <Eq>"
+ " <FieldRef Name='CategoriesLookup' LookupId='TRUE' />"
+ " <Value Type='Lookup'>" + categId + "</Value>"
+ " </Eq>"
+ " </And> "
+ " </Where>";
spquery.ViewAttributes = "Scope='RecursiveAll'";
categoriesDiscussionsCount.Add(categId, _discussionList.GetItems(spquery).Count);
}
return categoriesDiscussionsCount;
}
}
/// <summary>
/// Dictionary: categId, nr replies
/// </summary>
public Dictionary<int, int> CategoryReplyCount
{
get
{
var categoriesDiscussionsCount = new Dictionary<int, int>();
foreach (int categId in Categories)
{
//get topics of this category
var spquery = new SPQuery();
spquery.Query = ""
+ " <Where>"
+ " <And> "
+ " <IsNull>"
+ " <FieldRef Name='ParentFolderId' />"
+ " </IsNull>"
+ " <Eq>"
+ " <FieldRef Name='CategoriesLookup' LookupId='TRUE' />"
+ " <Value Type='Lookup'>" + categId + "</Value>"
+ " </Eq>"
+ " </And> "
+ " </Where>";
spquery.ViewAttributes = "Scope='RecursiveAll'";
SPListItemCollection topicsOfThisCategory = _discussionList.GetItems(spquery);
//get nr of replies for each topic of this category
var totalRepliesCategory = 0;
foreach (SPListItem topic in topicsOfThisCategory)
{
var spqueryreplies = new SPQuery();
spqueryreplies.Query = ""
+ " <Where>"
+ " <And> "
+ " <IsNotNull>"
+ " <FieldRef Name='ParentFolderId' />"
+ " </IsNotNull>"
+ " <Eq>"
+ " <FieldRef Name='ParentFolderId' />"
+ " <Value Type='Number'>" + topic.ID + "</Value>"
+ " </Eq>"
+ " </And> "
+ " </Where>";
spqueryreplies.ViewAttributes = "Scope='RecursiveAll'";
totalRepliesCategory += _discussionList.GetItems(spqueryreplies).Count;
}
categoriesDiscussionsCount.Add(categId, totalRepliesCategory);
}
return categoriesDiscussionsCount;
}
}
//
///字典:categId,nr disc
///
公共词典类别
{
得到
{
var categoriesDiscussionsCount=新字典();
foreach(类别中的int categId)
{
var spquery=new spquery();
spquery.Query=“”
+ " "
+"
/// <summary>
/// Update number of topics and replies for each category
/// </summary>
public void UpdateCategoriesCounts()
{
Dictionary<int, int> categoryTopicCount = this.CategoryTopicCount;
Dictionary<int, int> categoryReplyCount = this.CategoryReplyCount;
SPListItemCollection categories = _categoryList.Items;
foreach (SPListItem category in categories)
{
Console.WriteLine("Handling " + category.DisplayName);
int topicCount = category["TopicCount"] == null ? 0 : Convert.ToInt32(category["TopicCount"]);
int replyCount = category["ReplyCount"] == null ? 0 : Convert.ToInt32(category["ReplyCount"]);
Console.WriteLine("Topics: " + categoryTopicCount[category.ID] + " || Replies: " + categoryReplyCount[category.ID]);
_web.AllowUnsafeUpdates = true;
if (categoryTopicCount[category.ID] != topicCount)
category["TopicCount"] = categoryTopicCount[category.ID];
if (categoryReplyCount[category.ID] != replyCount)
category["ReplyCount"] = categoryReplyCount[category.ID];
category.SystemUpdate(false);
_web.AllowUnsafeUpdates = false;
Console.WriteLine("Saved...");
}
Console.WriteLine("Finished");
}