本文整理汇总了C#中Snowlight.Storage.SqlDatabaseClient.ExecuteQueryRow方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabaseClient.ExecuteQueryRow方法的具体用法?C# SqlDatabaseClient.ExecuteQueryRow怎么用?C# SqlDatabaseClient.ExecuteQueryRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Snowlight.Storage.SqlDatabaseClient
的用法示例。
在下文中一共展示了SqlDatabaseClient.ExecuteQueryRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCharacterInfo
public static CharacterInfo GetCharacterInfo(SqlDatabaseClient MySqlClient, uint CharacterId, uint LinkedClientId, bool IgnoreCache)
{
if (SessionManager.ContainsCharacterId(CharacterId))
{
Session Session = SessionManager.GetSessionByCharacterId(CharacterId);
return Session.CharacterInfo;
}
if (!IgnoreCache)
{
CharacterInfo CachedInfo = TryGetInfoFromCache(CharacterId);
if (CachedInfo != null)
{
return CachedInfo;
}
}
MySqlClient.SetParameter("id", CharacterId);
DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM characters WHERE id = @id LIMIT 1");
if (Row != null)
{
return GenerateCharacterInfoFromRow(MySqlClient, LinkedClientId, Row);
}
return null;
}
示例2: FriendshipExists
public static bool FriendshipExists(SqlDatabaseClient MySqlClient, uint UserId1, uint UserId2, bool ConfirmedOnly)
{
MySqlClient.SetParameter("user1", UserId1);
MySqlClient.SetParameter("user2", UserId2);
MySqlClient.SetParameter("confirmed", (ConfirmedOnly ? 0 : 2));
return (MySqlClient.ExecuteQueryRow("SELECT null FROM messenger_friendships WHERE user_1_id = @user1 AND user_2_id = @user2 AND confirmed != @confirmed OR user_2_id = @user1 AND user_1_id = @user2 AND confirmed != @confirmed LIMIT 1") != null);
}
示例3: TryAuthenticate
/// <summary>
/// Attemps to authenticate an user using an SSO (Single Sign On) ticket.
/// </summary>
/// <param name="Ticket">The ticket string.</param>
/// <returns>Character id on success, 0 on authentication failure.</returns>
public static uint TryAuthenticate(SqlDatabaseClient MySqlClient, string Ticket, string RemoteAddress)
{
lock (mAuthSyncRoot)
{
// Remove any spacing from single sign on ticket
Ticket = Ticket.Trim();
// Ensure the ticket meets the minimum length requirement
if (Ticket.Length <= 5)
{
mFailedLoginCount++;
Output.WriteLine("Login from " + RemoteAddress + " rejected: SSO ticket too short.");
return 0;
}
// Debug
string DebugTicket = (string)ConfigManager.GetValue("debug.sso");
if (DebugTicket.Length > 0 && Ticket == DebugTicket)
return 1;
// Check the database for a matching single sign on ticket
uint UserId = 0;
string LogName = string.Empty;
MySqlClient.SetParameter("ticket", Ticket);
DataRow Row = MySqlClient.ExecuteQueryRow("SELECT id,username FROM characters WHERE auth_ticket = @ticket LIMIT 1");
if (Row != null)
{
UserId = (uint)Row["id"];
LogName = (string)Row["username"];
RemoveTicket(MySqlClient, (uint)Row["id"], RemoteAddress);
}
// Check if ticket was OK + Check for user id bans
if (UserId <= 0)
{
mFailedLoginCount++;
Output.WriteLine("Login from " + RemoteAddress + " rejected: invalid SSO ticket.");
return 0;
}
if (ModerationBanManager.IsUserIdBlacklisted(UserId))
{
mFailedLoginCount++;
Output.WriteLine("Login from " + RemoteAddress + " rejected: blacklisted IP address.");
return 0;
}
// Disconnect any previous sessions for this account
if (SessionManager.ContainsCharacterId(UserId))
{
Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);
SessionManager.StopSession(TargetSession.Id);
}
// Mark as a successful login and continue
Output.WriteLine("User " + LogName + " (ID " + UserId + ") has logged in from " + RemoteAddress + ".");
MySqlClient.ExecuteNonQuery("UPDATE characters SET online = '1' WHERE id = " + UserId + " LIMIT 1");
mSuccessfulLoginCount++;
return UserId;
}
}