本文整理汇总了C#中SqlCommand.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.Execute方法的具体用法?C# SqlCommand.Execute怎么用?C# SqlCommand.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlCommand
的用法示例。
在下文中一共展示了SqlCommand.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Room
public Room(RoomInfo roomInfo)
{
RoomInfo = roomInfo;
IsActive = true;
_settings = RoomSettings.Get(RoomInfo.ShortName);
if (_settings == null)
{
_settings = new RoomSettings
{
Room = RoomInfo.ShortName,
Bans = new HashSet<string>(),
Mods = new HashSet<string>()
};
_settings.Insert();
}
_history = new LinkedList<HistoryLine>();
var cmd = new SqlCommand("SELECT * FROM rohbot.chathistory WHERE chat=lower(:chat) ORDER BY date DESC LIMIT 100;");
cmd["chat"] = RoomInfo.ShortName;
foreach (var line in cmd.Execute().Reverse().Select(r => HistoryLine.Read(r)))
{
_history.AddLast(line);
}
_showLinkTitles = (RoomInfo["LinkTitles"] ?? "").ToLower() == "true";
IsWhitelisted = (RoomInfo["Whitelist"] ?? "").ToLower() == "true";
IsHidden = (RoomInfo["Hidden"] ?? "").ToLower() == "true";
IsPrivate = (RoomInfo["Private"] ?? "").ToLower() == "true";
IsLogging = (RoomInfo["Logging"] ?? "true").ToLower() == "true";
ShowWebStates = (RoomInfo["WebStates"] ?? "true").ToLower() == "true";
DisableBanning = (RoomInfo["DisableBanning"] ?? "").ToLower() == "true";
}
示例2: Handle
public override void Handle(Connection connection)
{
if (Program.DelayManager.AddAndCheck(connection, DelayManager.Database))
return;
if (connection.Session == null)
{
connection.SendSysMessage("You need to be logged in to do that.");
return;
}
if (!connection.Session.IsInRoom(Target))
{
connection.SendSysMessage("You are not in that room.");
return;
}
var room = Program.RoomManager.Get(Target);
if (room == null)
{
connection.SendSysMessage("Room does not exist.");
return;
}
if (room.IsPrivate && room.IsBanned(connection.Session.Account.Name))
return;
List<HistoryLine> lines;
if (Util.DateTimeFromTimestamp(AfterDate) < (DateTime.UtcNow - Util.MaximumHistoryRequest))
{
lines = new List<HistoryLine>();
}
else
{
var cmd = new SqlCommand("SELECT * FROM rohbot.chathistory WHERE chat=lower(:chat) AND date<:afterdate ORDER BY date DESC LIMIT 100;");
cmd["chat"] = Target;
cmd["afterdate"] = AfterDate;
lines = cmd.Execute().Select(r => (HistoryLine)HistoryLine.Read(r)).ToList();
lines.Reverse();
}
if (lines.Count == 0)
lines.Add(new ChatLine(0, Target, "Steam", Program.Settings.PersonaName, "0", "", "No additional history is available.", false));
var history = new ChatHistory
{
ShortName = room.RoomInfo.ShortName,
Requested = true,
Lines = lines
};
connection.Send(history);
}
示例3: Handle
public override void Handle(Session session)
{
if (Program.DelayManager.AddAndCheck(session, 2.5))
return;
var room = Program.RoomManager.Get(session.Room);
if (room == null)
{
session.SendSysMessage("Room does not exist.");
return;
}
if (room.IsPrivate)
{
if (session.Account == null || room.IsBanned(session.Account.Name))
return;
}
List<HistoryLine> lines;
if (Util.DateTimeFromUnixTimestamp(AfterDate) > DateTime.UtcNow.AddDays(-7))
{
var cmd = new SqlCommand("SELECT * FROM rohbot.chathistory WHERE chat=lower(:chat) AND date<:afterdate ORDER BY date DESC LIMIT 100;");
cmd["chat"] = session.Room;
cmd["afterdate"] = AfterDate;
lines = cmd.Execute().Select(r => (HistoryLine)HistoryLine.Read(r)).Reverse().ToList();
}
else
{
lines = new List<HistoryLine>();
}
var history = new ChatHistory
{
Name = room.RoomInfo.Name,
ShortName = room.RoomInfo.ShortName,
Requested = true,
Lines = lines
};
session.Send(history);
}
示例4: Get
public static RoomSettings Get(string room)
{
var cmd = new SqlCommand("SELECT * FROM rohbot.roomsettings WHERE lower(room)=lower(:room);");
cmd["room"] = room;
var row = cmd.Execute().FirstOrDefault();
return row == null ? null : new RoomSettings(row);
}