本文整理汇总了C#中Persistence.InsertMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Persistence.InsertMessage方法的具体用法?C# Persistence.InsertMessage怎么用?C# Persistence.InsertMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Persistence
的用法示例。
在下文中一共展示了Persistence.InsertMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleSubmit
private void HandleSubmit(HttpListenerContext ctx, CallInfo callInfo)
{
Logger.Debug("Received message submission for id: " + callInfo.ClientId);
string hash = ctx.Request.Headers[HttpHeaders.ContentMd5Key];
byte[] buffer = GetBuffer(ctx);
string myHash = Hasher.Hash(buffer);
if (myHash != hash)
{
CloseResponseAndWarn(ctx, "MD5 hash received does not match hash calculated on server. Consider resubmitting.", 412);
return;
}
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30) }))
{
var p = new Persistence { ConnectionString = connString };
p.InsertMessage(DateTime.UtcNow, callInfo.ClientId, Convert.FromBase64String(callInfo.MD5), buffer, ctx.Request.Headers);
scope.Complete();
}
ReportSuccess(ctx);
}