aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Activity/ActivityRepository.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-20 15:32:24 -0500
committerGitHub <noreply@github.com>2016-11-20 15:32:24 -0500
commit2ea0f7c545879b7bde976a783d923c0078003bf2 (patch)
tree15991ef523281ee1577b685616d22fc9953c13f9 /Emby.Server.Implementations/Activity/ActivityRepository.cs
parentaf7de0a35346270e5cca7c6998e1608dfdcf9d1d (diff)
parent24dc91160d33e9b1ea8edd1f4262b8ecb14db930 (diff)
Merge pull request #2297 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Activity/ActivityRepository.cs')
-rw-r--r--Emby.Server.Implementations/Activity/ActivityRepository.cs62
1 files changed, 40 insertions, 22 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs
index 8f64f04db..d730e420a 100644
--- a/Emby.Server.Implementations/Activity/ActivityRepository.cs
+++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs
@@ -57,18 +57,21 @@ namespace Emby.Server.Implementations.Activity
{
connection.RunInTransaction(db =>
{
- var commandText = "replace into ActivityLogEntries (Id, Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
-
- db.Execute(commandText,
- entry.Id.ToGuidParamValue(),
- entry.Name,
- entry.Overview,
- entry.ShortOverview,
- entry.Type,
- entry.ItemId,
- entry.UserId,
- entry.Date.ToDateTimeParamValue(),
- entry.Severity.ToString());
+ using (var statement = db.PrepareStatement("replace into ActivityLogEntries (Id, Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity) values (@Id, @Name, @Overview, @ShortOverview, @Type, @ItemId, @UserId, @DateCreated, @LogSeverity)"))
+ {
+ statement.TryBind("@Id", entry.Id.ToGuidParamValue());
+ statement.TryBind("@Name", entry.Name);
+
+ statement.TryBind("@Overview", entry.Overview);
+ statement.TryBind("@ShortOverview", entry.ShortOverview);
+ statement.TryBind("@Type", entry.Type);
+ statement.TryBind("@ItemId", entry.ItemId);
+ statement.TryBind("@UserId", entry.UserId);
+ statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue());
+ statement.TryBind("@LogSeverity", entry.Severity.ToString());
+
+ statement.MoveNext();
+ }
});
}
}
@@ -81,19 +84,16 @@ namespace Emby.Server.Implementations.Activity
using (var connection = CreateConnection(true))
{
var commandText = BaseActivitySelectText;
-
var whereClauses = new List<string>();
- var paramList = new List<object>();
if (minDate.HasValue)
{
- whereClauses.Add("DateCreated>=?");
- paramList.Add(minDate.Value.ToDateTimeParamValue());
+ whereClauses.Add("DateCreated>=@DateCreated");
}
var whereTextWithoutPaging = whereClauses.Count == 0 ?
- string.Empty :
- " where " + string.Join(" AND ", whereClauses.ToArray());
+ string.Empty :
+ " where " + string.Join(" AND ", whereClauses.ToArray());
if (startIndex.HasValue && startIndex.Value > 0)
{
@@ -119,13 +119,31 @@ namespace Emby.Server.Implementations.Activity
commandText += " LIMIT " + limit.Value.ToString(_usCulture);
}
- var totalRecordCount = connection.Query("select count (Id) from ActivityLogEntries" + whereTextWithoutPaging, paramList.ToArray()).SelectScalarInt().First();
-
var list = new List<ActivityLogEntry>();
- foreach (var row in connection.Query(commandText, paramList.ToArray()))
+ using (var statement = connection.PrepareStatement(commandText))
{
- list.Add(GetEntry(row));
+ if (minDate.HasValue)
+ {
+ statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
+ }
+
+ foreach (var row in statement.ExecuteQuery())
+ {
+ list.Add(GetEntry(row));
+ }
+ }
+
+ int totalRecordCount;
+
+ using (var statement = connection.PrepareStatement("select count (Id) from ActivityLogEntries" + whereTextWithoutPaging))
+ {
+ if (minDate.HasValue)
+ {
+ statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
+ }
+
+ totalRecordCount = statement.ExecuteQuery().SelectScalarInt().First();
}
return new QueryResult<ActivityLogEntry>()