mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 12:54:20 +01:00
Somehow the sql command parameters are broken...
This commit is contained in:
parent
3e49e2ebf1
commit
2a4d20682e
|
@ -73,19 +73,24 @@ namespace SharpRss
|
|||
{
|
||||
await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
|
||||
dbc.Open();
|
||||
DynamicParameters parameters = new DynamicParameters();
|
||||
parameters.Add("url", feed.OriginalUrl ?? string.Empty);
|
||||
parameters.Add("title", feed.Title ?? string.Empty);
|
||||
parameters.Add("categoryId", feed.CategoryId ?? string.Empty);
|
||||
parameters.Add("feedType", feed.FeedType ?? string.Empty);
|
||||
parameters.Add("description", feed.Description ?? string.Empty);
|
||||
parameters.Add("language", feed.Language ?? string.Empty);
|
||||
parameters.Add("copyright", feed.Copyright ?? string.Empty);
|
||||
parameters.Add("publicationDate", feed.PublicationDate?.ToUnixTimeMilliseconds() ?? 0);
|
||||
parameters.Add("lastUpdated", feed.LastUpdated?.ToUnixTimeMilliseconds() ?? 0);
|
||||
parameters.Add("categories", feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty);
|
||||
parameters.Add("imageUrl", feed.ImageUrl ?? string.Empty);
|
||||
int affected = await dbc.ExecuteAsync("INSERT OR REPLACE INTO feed (url, title, category_id, feed_type, feed_version, description, language, copyright, publication_date, last_updated, categories, image_url) VALUES (@url, @title, @categoryId, @feedType, @feedVersion, @description, @language, @copyright, @publicationDate, @lastUpdated, @categories, @imageUrl)", param: parameters);
|
||||
await using SqliteCommand cmd = new SqliteCommand("INSERT OR REPLACE INTO feed (url, title, category_id, feed_type, feed_version, description, language, copyright, publication_date, last_updated, categories, image_url) VALUES (@Url, @Title, @CategoryId, @FeedType, @FeedVersion, @Description, @Language, @Copyright, @PublicationDate, @LastUpdated, @Categories, @ImageUrl)", dbc)
|
||||
{
|
||||
Parameters =
|
||||
{
|
||||
new SqliteParameter("Url", feed.OriginalUrl ?? string.Empty),
|
||||
new SqliteParameter("Title", feed.Title ?? string.Empty),
|
||||
new SqliteParameter("CategoryId", feed.CategoryId ?? string.Empty),
|
||||
new SqliteParameter("FeedType", feed.FeedType ?? string.Empty),
|
||||
new SqliteParameter("Description", feed.Description ?? string.Empty),
|
||||
new SqliteParameter("Language", feed.Language ?? string.Empty),
|
||||
new SqliteParameter("Copyright", feed.Copyright ?? string.Empty),
|
||||
new SqliteParameter("PublicationDate", feed.PublicationDate?.ToUnixTimeMilliseconds() ?? 0),
|
||||
new SqliteParameter("LastUpdated", feed.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
|
||||
new SqliteParameter("Categories", feed.Categories != null && feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty),
|
||||
new SqliteParameter("ImageUrl", feed.ImageUrl ?? string.Empty)
|
||||
}
|
||||
};
|
||||
int exec = await cmd.ExecuteNonQueryAsync();
|
||||
/*int affected = await dbc.ExecuteAsync("INSERT OR REPLACE INTO feed (url, title, category_id, feed_type, feed_version, description, language, copyright, publication_date, last_updated, categories, image_url) VALUES (@Url, @Title, @CategoryId, @FeedType, @FeedVersion, @Description, @language, @Copyright, @PublicationDate, @LastUpdated, @Categories, @ImageUrl)",
|
||||
new
|
||||
{
|
||||
|
@ -101,8 +106,8 @@ namespace SharpRss
|
|||
Categories = feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty,
|
||||
ImageUrl = feed.ImageUrl ?? string.Empty
|
||||
});*/
|
||||
if (affected == 0)
|
||||
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);
|
||||
/*if (affected == 0)
|
||||
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);*/
|
||||
}
|
||||
public static async Task<HashSet<FeedModel>> GetFeedsAsync(string[]? categoryIds = null)
|
||||
{
|
||||
|
@ -140,20 +145,23 @@ namespace SharpRss
|
|||
await using SqliteTransaction dbTransaction = dbc.BeginTransaction();
|
||||
foreach (FeedItemModel item in items)
|
||||
{
|
||||
DynamicParameters parameters = new DynamicParameters();
|
||||
parameters.Add("id", item.Id ?? string.Empty);
|
||||
parameters.Add("feedurl", item.FeedUrl ?? string.Empty);
|
||||
parameters.Add("read", item.Read.ToString());
|
||||
parameters.Add("description", item.Description ?? string.Empty);
|
||||
parameters.Add("link", item.Link ?? string.Empty);
|
||||
parameters.Add("lastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0);
|
||||
parameters.Add("publishingDate", item.PublishingDate?.ToUnixTimeMilliseconds() ?? 0);
|
||||
parameters.Add("authors", item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty);
|
||||
parameters.Add("categories", item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty);
|
||||
parameters.Add("content", item.Content ?? string.Empty);
|
||||
int affected = await dbc.ExecuteAsync("INSERT OR REPLACE INTO feed_item (id, feed_url, read, title, description, link, last_updated, publishing_date, authors, categories, content) VALUES (@id, @feedUrl, @read, @title, @description, @link, @lastUpdated, @publishingDate, @authors, @categories, @content)",
|
||||
parameters,
|
||||
transaction: dbTransaction);
|
||||
await using SqliteCommand cmd = new SqliteCommand("INSERT OR REPLACE INTO feed (url, title, category_id, feed_type, feed_version, description, language, copyright, publication_date, last_updated, categories, image_url) VALUES (@Url, @Title, @CategoryId, @FeedType, @FeedVersion, @Description, @language, @Copyright, @PublicationDate, @LastUpdated, @Categories, @ImageUrl)", dbc, dbTransaction)
|
||||
{
|
||||
Parameters =
|
||||
{
|
||||
new SqliteParameter("Id", item.Id ?? string.Empty),
|
||||
new SqliteParameter("FeedUrl", item.FeedUrl ?? string.Empty),
|
||||
new SqliteParameter("Read", item.Read.ToString()),
|
||||
new SqliteParameter("Description", item.Description ?? string.Empty),
|
||||
new SqliteParameter("Link", item.Link ?? string.Empty),
|
||||
new SqliteParameter("LastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
|
||||
new SqliteParameter("PublishingDate", item.PublishingDate?.ToUnixTimeMilliseconds() ?? 0),
|
||||
new SqliteParameter("Authors", item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty),
|
||||
new SqliteParameter("Categories", item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty),
|
||||
new SqliteParameter("Content", item.Content ?? string.Empty)
|
||||
}
|
||||
};
|
||||
int exec = await cmd.ExecuteNonQueryAsync();
|
||||
/*int affected = await dbc.ExecuteAsync("INSERT OR REPLACE INTO feed_item (id, feed_url, read, title, description, link, last_updated, publishing_date, authors, categories, content) VALUES (@Id, @FeedUrl, @Read, @Title, Description, @Link, @LastUpdated, @PublishingDate, @Authors, @Categories, @Content)",
|
||||
transaction: dbTransaction,
|
||||
param: new
|
||||
|
@ -169,7 +177,7 @@ namespace SharpRss
|
|||
Categories = item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty,
|
||||
Content = item.Content ?? string.Empty
|
||||
});*/
|
||||
totalAffected += affected;
|
||||
totalAffected += exec;
|
||||
}
|
||||
dbTransaction.Commit();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user