本文整理汇总了C#中IDataContext.SubscribedForums方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.SubscribedForums方法的具体用法?C# IDataContext.SubscribedForums怎么用?C# IDataContext.SubscribedForums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContext
的用法示例。
在下文中一共展示了IDataContext.SubscribedForums方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMessages
//.........这里部分代码省略.........
var processed = 0;
foreach (var msg in messages)
{
if (ForumsSubscriptionHelper.IsTrashForum(msg.forumId))
try
{
var mid = msg.messageId;
db.TopicInfos(ti => ti.MessageID == mid).Delete();
db.Messages(m => m.ID == mid).Delete();
}
catch (Exception)
{
provider.LogError(Resources.ErrorOnMessageDelete + msg.messageId);
}
else
{
var updatedTid = db.Message(msg.messageId, m => (int?) m.TopicID);
if (msg.message.IsNullOrEmpty())
msg.message = "<none>";
var lastModerated =
msg.lastModerated == DateTime.MinValue
? null
: (DateTime?) msg.lastModerated;
try
{
if (!updatedTid.HasValue)
{
var markRead = false;
if (msg.parentId != 0)
markRead = db.Message(msg.parentId, m => m.ReadReplies);
var isRead =
msg.userId == selfid
? provider.GetRequiredService<IRsdnSyncConfigService>().GetConfig().MarkOwnMessages
: markRead;
db
.Messages()
.Value(_ => _.ID, msg.messageId)
.Value(_ => _.ForumID, msg.forumId)
.Value(_ => _.TopicID, msg.topicId)
.Value(_ => _.ParentID, msg.parentId)
.Value(_ => _.Date, msg.messageDate)
.Value(_ => _.UserNick, msg.userNick)
.Value(_ => _.Subject, msg.subject)
.Value(_ => _.Message, msg.message)
.Value(_ => _.UserClass, ToJanusUserClass(msg.userRole))
.Value(_ => _.IsRead, isRead)
.Value(_ => _.UserID, msg.userId)
.Value(_ => _.ArticleId, msg.articleId)
.Value(_ => _.ReadReplies, markRead)
.Value(_ => _.Name, msg.messageName)
.Value(_ => _.LastModerated, lastModerated)
.Value(_ => _.Closed, msg.closed)
.Insert();
msgIds.Add(msg.messageId);
}
else
{
var locMsg = msg;
db
.Messages(m => m.ID == locMsg.messageId)
.Set(_ => _.ForumID, msg.forumId)
.Set(_ => _.TopicID, msg.topicId)
.Set(_ => _.ParentID, msg.parentId)
.Set(_ => _.Date, msg.messageDate)
.Set(_ => _.UserID, msg.userId)
.Set(_ => _.UserNick, msg.userNick)
.Set(_ => _.Subject, msg.subject)
.Set(_ => _.Message, msg.message)
.Set(_ => _.UserClass, ToJanusUserClass(msg.userRole))
.Set(_ => _.ArticleId, msg.articleId)
.Set(_ => _.LastModerated, lastModerated)
.Set(_ => _.Name, msg.messageName)
.Set(_ => _.Closed, msg.closed)
.Update();
topicIds.Add(updatedTid.Value == 0 ? msg.messageId : updatedTid.Value);
}
}
catch (Exception e)
{
// Какая ....!
provider.LogError($"{Resources.ErrorOnMessageProcessing}{msg.messageId} : {e.Message}");
}
}
processed++;
progressHandler?.Invoke(messages.Length, processed);
}
db
.SubscribedForums()
.Set(_ => _.LastSync, 1)
.Update();
updatedTopicIds = topicIds.ToArray();
updatedMessageIds = msgIds.ToArray();
}
示例2: LoadSubscribedForums
private IEnumerable<Forum> LoadSubscribedForums(IDataContext db)
{
var q = db.SubscribedForums().OrderByDescending(f => f.Priority);
q =
Config.Instance.ForumDisplayConfig.ShowFullForumNames
? q.ThenBy(f => f.Descript)
: q.ThenBy(f => f.Name);
var counts =
from ti in db.TopicInfos()
group ti by ti.ForumID into grp
select
new
{
ForumID = grp.Key,
Count = grp.Count() + grp.Sum(iti => iti.AnswersCount),
Unread = grp.Sum(iti => iti.AnswersUnread),
MeUnread = grp.Sum(iti => iti.AnswersToMeUnread)
};
var forums =
from f in q
join ti in counts on f.ID equals ti.ForumID into lj
from ti in lj.DefaultIfEmpty() // left join forcing
select
new Forum(_serviceProvider)
{
ID = f.ID,
Name = f.Name,
LastSync = f.LastSync,
IsSubscribed = true,
IsRateable = f.ServerForum.Rated,
RateLimit = f.ServerForum.RateLimit > 0,
MessagesCount = ti.Count,
RepliesToMeUnread = ti.MeUnread,
Unread = ti.Unread,
InTop = f.ServerForum.InTop,
Priority = f.Priority.GetValueOrDefault(),
ForumDescription = f.Descript
};
return forums.ToList();
}