本文整理汇总了C#中Npgsql.NpgsqlConnector.FireNotification方法的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlConnector.FireNotification方法的具体用法?C# NpgsqlConnector.FireNotification怎么用?C# NpgsqlConnector.FireNotification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npgsql.NpgsqlConnector
的用法示例。
在下文中一共展示了NpgsqlConnector.FireNotification方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessBackendResponses_Ver_3
//.........这里部分代码省略.........
NpgsqlBackEndKeyData backend_keydata = new NpgsqlBackEndKeyData(context.BackendProtocolVersion, stream);
context.BackEndKeyData = backend_keydata;
// Wait for ReadForQuery message
break;
case BackEndMessageCode.NoticeResponse:
// Notices and errors are identical except that we
// just throw notices away completely ignored.
context.FireNotice(new NpgsqlError(context.BackendProtocolVersion, stream));
break;
case BackEndMessageCode.CompletedResponse:
PGUtil.ReadInt32(stream);
yield return new CompletedResponse(stream);
break;
case BackEndMessageCode.ParseComplete:
NpgsqlEventLog.LogMsg(resman, "Log_ProtocolMessage", LogLevel.Debug, "ParseComplete");
// Just read up the message length.
PGUtil.ReadInt32(stream);
yield break;
case BackEndMessageCode.BindComplete:
NpgsqlEventLog.LogMsg(resman, "Log_ProtocolMessage", LogLevel.Debug, "BindComplete");
// Just read up the message length.
PGUtil.ReadInt32(stream);
yield break;
case BackEndMessageCode.EmptyQueryResponse:
NpgsqlEventLog.LogMsg(resman, "Log_ProtocolMessage", LogLevel.Debug, "EmptyQueryResponse");
PGUtil.ReadInt32(stream);
break;
case BackEndMessageCode.NotificationResponse:
// Eat the length
PGUtil.ReadInt32(stream);
context.FireNotification(new NpgsqlNotificationEventArgs(stream, true));
if (context.IsNotificationThreadRunning)
{
yield break;
}
break;
case BackEndMessageCode.ParameterStatus:
NpgsqlEventLog.LogMsg(resman, "Log_ProtocolMessage", LogLevel.Debug, "ParameterStatus");
NpgsqlParameterStatus parameterStatus = new NpgsqlParameterStatus(stream);
NpgsqlEventLog.LogMsg(resman, "Log_ParameterStatus", LogLevel.Debug, parameterStatus.Parameter,
parameterStatus.ParameterValue);
context.AddParameterStatus(parameterStatus);
if (parameterStatus.Parameter == "server_version")
{
// Deal with this here so that if there are
// changes in a future backend version, we can handle it here in the
// protocol handler and leave everybody else put of it.
string versionString = parameterStatus.ParameterValue.Trim();
for (int idx = 0; idx != versionString.Length; ++idx)
{
char c = parameterStatus.ParameterValue[idx];
if (!char.IsDigit(c) && c != '.')
{
versionString = versionString.Substring(0, idx);
break;
}
}
context.ServerVersion = new Version(versionString);
}
break;
示例2: ProcessBackendResponses_Ver_2
//.........这里部分代码省略.........
sb.Append(b.ToString("x2"));
}
String prehash = sb.ToString();
byte[] prehashbytes = ENCODING_UTF8.GetBytes(prehash);
byte[] saltServer = new byte[4];
stream.Read(saltServer, 0, 4);
// Send the PasswordPacket.
ChangeState(context, NpgsqlStartupState.Instance);
// 2.
crypt_buf = new byte[prehashbytes.Length + saltServer.Length];
prehashbytes.CopyTo(crypt_buf, 0);
saltServer.CopyTo(crypt_buf, prehashbytes.Length);
sb = new StringBuilder("md5"); // This is needed as the backend expects md5 result starts with "md5"
hashResult = md5.ComputeHash(crypt_buf);
foreach (byte b in hashResult)
{
sb.Append(b.ToString("x2"));
}
context.Authenticate(ENCODING_UTF8.GetBytes(sb.ToString()));
break;
default:
// Only AuthenticationClearTextPassword and AuthenticationMD5Password supported for now.
errors.Add(
new NpgsqlError(context.BackendProtocolVersion,
String.Format(resman.GetString("Exception_AuthenticationMethodNotSupported"), authType)));
throw new NpgsqlException(errors);
}
break;
case BackEndMessageCode.RowDescription:
yield return lastRowDescription = new NpgsqlRowDescriptionV2(stream, context.OidToNameMapping, context.CompatVersion);
;
break;
case BackEndMessageCode.DataRow:
yield return new ForwardsOnlyRow(new StringRowReaderV2(lastRowDescription, stream));
break;
case BackEndMessageCode.BinaryRow:
throw new NotSupportedException();
case BackEndMessageCode.ReadyForQuery:
ChangeState(context, NpgsqlReadyState.Instance);
if (errors.Count != 0)
{
throw new NpgsqlException(errors);
}
yield break;
case BackEndMessageCode.BackendKeyData:
context.BackEndKeyData = new NpgsqlBackEndKeyData(context.BackendProtocolVersion, stream);
break;
case BackEndMessageCode.NoticeResponse:
context.FireNotice(new NpgsqlError(context.BackendProtocolVersion, stream));
break;
case BackEndMessageCode.CompletedResponse:
yield return new CompletedResponse(stream);
break;
case BackEndMessageCode.CursorResponse:
// This is the cursor response message.
// It is followed by a C NULL terminated string with the name of
// the cursor in a FETCH case or 'blank' otherwise.
// In this case it should be always 'blank'.
// [FIXME] Get another name for this function.
NpgsqlEventLog.LogMsg(resman, "Log_ProtocolMessage", LogLevel.Debug, "CursorResponse");
String cursorName = PGUtil.ReadString(stream);
// Continue waiting for ReadyForQuery message.
break;
case BackEndMessageCode.EmptyQueryResponse:
NpgsqlEventLog.LogMsg(resman, "Log_ProtocolMessage", LogLevel.Debug, "EmptyQueryResponse");
PGUtil.ReadString(stream);
break;
case BackEndMessageCode.NotificationResponse:
context.FireNotification(new NpgsqlNotificationEventArgs(stream, false));
if (context.IsNotificationThreadRunning)
{
yield break;
}
break;
case BackEndMessageCode.IO_ERROR:
// Connection broken. Mono returns -1 instead of throw an exception as ms.net does.
throw new IOException();
default:
// This could mean a number of things
// We've gotten out of sync with the backend?
// We need to implement this type?
// Backend has gone insane?
throw new DataException("Backend sent unrecognized response type");
}
}
}
}