本文整理汇总了C#中IDataContext.Message方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.Message方法的具体用法?C# IDataContext.Message怎么用?C# IDataContext.Message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContext
的用法示例。
在下文中一共展示了IDataContext.Message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMessages
/// <summary>
/// Добавление сообшений полученыых с сервера в базу
/// </summary>
/// <param name="provider"></param>
/// <param name="db"></param>
/// <param name="messages">Добавляемые сообщения</param>
/// <param name="selfid"></param>
/// <param name="progressHandler">обработчик прогресса обработки сообщений</param>
/// <param name="updatedTopicIds">Какие топики были обновлены.</param>
/// <param name="updatedMessageIds">Какие сообщения были добавлены.</param>
private static void AddMessages(
[JetBrains.Annotations.NotNull] IServiceProvider provider,
IDataContext db,
JanusMessageInfo[] messages,
int selfid,
Action<int, int> progressHandler,
out int[] updatedTopicIds,
out int[] updatedMessageIds)
{
if (db == null)
throw new ArgumentNullException(nameof(db));
if (messages == null)
throw new ArgumentNullException(nameof(messages));
var msgIds = new List<int>();
var topicIds = new List<int>();
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))
//.........这里部分代码省略.........