mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +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);
|
await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
DynamicParameters parameters = new DynamicParameters();
|
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.Add("url", feed.OriginalUrl ?? string.Empty);
|
{
|
||||||
parameters.Add("title", feed.Title ?? string.Empty);
|
Parameters =
|
||||||
parameters.Add("categoryId", feed.CategoryId ?? string.Empty);
|
{
|
||||||
parameters.Add("feedType", feed.FeedType ?? string.Empty);
|
new SqliteParameter("Url", feed.OriginalUrl ?? string.Empty),
|
||||||
parameters.Add("description", feed.Description ?? string.Empty);
|
new SqliteParameter("Title", feed.Title ?? string.Empty),
|
||||||
parameters.Add("language", feed.Language ?? string.Empty);
|
new SqliteParameter("CategoryId", feed.CategoryId ?? string.Empty),
|
||||||
parameters.Add("copyright", feed.Copyright ?? string.Empty);
|
new SqliteParameter("FeedType", feed.FeedType ?? string.Empty),
|
||||||
parameters.Add("publicationDate", feed.PublicationDate?.ToUnixTimeMilliseconds() ?? 0);
|
new SqliteParameter("Description", feed.Description ?? string.Empty),
|
||||||
parameters.Add("lastUpdated", feed.LastUpdated?.ToUnixTimeMilliseconds() ?? 0);
|
new SqliteParameter("Language", feed.Language ?? string.Empty),
|
||||||
parameters.Add("categories", feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty);
|
new SqliteParameter("Copyright", feed.Copyright ?? string.Empty),
|
||||||
parameters.Add("imageUrl", feed.ImageUrl ?? string.Empty);
|
new SqliteParameter("PublicationDate", feed.PublicationDate?.ToUnixTimeMilliseconds() ?? 0),
|
||||||
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);
|
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)",
|
/*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
|
new
|
||||||
{
|
{
|
||||||
|
@ -101,8 +106,8 @@ namespace SharpRss
|
||||||
Categories = feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty,
|
Categories = feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty,
|
||||||
ImageUrl = feed.ImageUrl ?? string.Empty
|
ImageUrl = feed.ImageUrl ?? string.Empty
|
||||||
});*/
|
});*/
|
||||||
if (affected == 0)
|
/*if (affected == 0)
|
||||||
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);
|
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);*/
|
||||||
}
|
}
|
||||||
public static async Task<HashSet<FeedModel>> GetFeedsAsync(string[]? categoryIds = null)
|
public static async Task<HashSet<FeedModel>> GetFeedsAsync(string[]? categoryIds = null)
|
||||||
{
|
{
|
||||||
|
@ -140,20 +145,23 @@ namespace SharpRss
|
||||||
await using SqliteTransaction dbTransaction = dbc.BeginTransaction();
|
await using SqliteTransaction dbTransaction = dbc.BeginTransaction();
|
||||||
foreach (FeedItemModel item in items)
|
foreach (FeedItemModel item in items)
|
||||||
{
|
{
|
||||||
DynamicParameters parameters = new DynamicParameters();
|
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.Add("id", item.Id ?? string.Empty);
|
{
|
||||||
parameters.Add("feedurl", item.FeedUrl ?? string.Empty);
|
Parameters =
|
||||||
parameters.Add("read", item.Read.ToString());
|
{
|
||||||
parameters.Add("description", item.Description ?? string.Empty);
|
new SqliteParameter("Id", item.Id ?? string.Empty),
|
||||||
parameters.Add("link", item.Link ?? string.Empty);
|
new SqliteParameter("FeedUrl", item.FeedUrl ?? string.Empty),
|
||||||
parameters.Add("lastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0);
|
new SqliteParameter("Read", item.Read.ToString()),
|
||||||
parameters.Add("publishingDate", item.PublishingDate?.ToUnixTimeMilliseconds() ?? 0);
|
new SqliteParameter("Description", item.Description ?? string.Empty),
|
||||||
parameters.Add("authors", item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty);
|
new SqliteParameter("Link", item.Link ?? string.Empty),
|
||||||
parameters.Add("categories", item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty);
|
new SqliteParameter("LastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
|
||||||
parameters.Add("content", item.Content ?? string.Empty);
|
new SqliteParameter("PublishingDate", item.PublishingDate?.ToUnixTimeMilliseconds() ?? 0),
|
||||||
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)",
|
new SqliteParameter("Authors", item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty),
|
||||||
parameters,
|
new SqliteParameter("Categories", item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty),
|
||||||
transaction: dbTransaction);
|
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)",
|
/*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,
|
transaction: dbTransaction,
|
||||||
param: new
|
param: new
|
||||||
|
@ -169,7 +177,7 @@ namespace SharpRss
|
||||||
Categories = item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty,
|
Categories = item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty,
|
||||||
Content = item.Content ?? string.Empty
|
Content = item.Content ?? string.Empty
|
||||||
});*/
|
});*/
|
||||||
totalAffected += affected;
|
totalAffected += exec;
|
||||||
}
|
}
|
||||||
dbTransaction.Commit();
|
dbTransaction.Commit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user