mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2024-11-09 23:44:20 +01:00
Fixed queries. TODO: Test dapper version!
This commit is contained in:
parent
2a4d20682e
commit
a17b2a7ebf
|
@ -73,7 +73,32 @@ namespace SharpRss
|
|||
{
|
||||
await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
|
||||
dbc.Open();
|
||||
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)
|
||||
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 =
|
||||
{
|
||||
|
@ -81,6 +106,7 @@ namespace SharpRss
|
|||
new SqliteParameter("Title", feed.Title ?? string.Empty),
|
||||
new SqliteParameter("CategoryId", feed.CategoryId ?? string.Empty),
|
||||
new SqliteParameter("FeedType", feed.FeedType ?? string.Empty),
|
||||
new SqliteParameter("FeedVersion", feed.FeedVersion ?? string.Empty),
|
||||
new SqliteParameter("Description", feed.Description ?? string.Empty),
|
||||
new SqliteParameter("Language", feed.Language ?? string.Empty),
|
||||
new SqliteParameter("Copyright", feed.Copyright ?? string.Empty),
|
||||
|
@ -98,6 +124,7 @@ namespace SharpRss
|
|||
Title = feed.Title ?? string.Empty,
|
||||
CategoryId = feed.CategoryId ?? string.Empty,
|
||||
FeedType = feed.FeedType ?? string.Empty,
|
||||
FeedVersion = feed.FeedVersion ?? string.Empty,
|
||||
Description = feed.Description ?? string.Empty,
|
||||
Language = feed.Language ?? string.Empty,
|
||||
Copyright = feed.Copyright ?? string.Empty,
|
||||
|
@ -105,8 +132,8 @@ namespace SharpRss
|
|||
LastUpdated = feed.LastUpdated?.ToUnixTimeMilliseconds() ?? 0,
|
||||
Categories = feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty,
|
||||
ImageUrl = feed.ImageUrl ?? string.Empty
|
||||
});*/
|
||||
/*if (affected == 0)
|
||||
});
|
||||
if (affected == 0)
|
||||
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);*/
|
||||
}
|
||||
public static async Task<HashSet<FeedModel>> GetFeedsAsync(string[]? categoryIds = null)
|
||||
|
@ -145,13 +172,15 @@ namespace SharpRss
|
|||
await using SqliteTransaction dbTransaction = dbc.BeginTransaction();
|
||||
foreach (FeedItemModel item in items)
|
||||
{
|
||||
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)
|
||||
await using SqliteCommand cmd = new SqliteCommand(@"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)", 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("Title", item.Title),
|
||||
new SqliteParameter("Description", item.Description ?? string.Empty),
|
||||
new SqliteParameter("Link", item.Link ?? string.Empty),
|
||||
new SqliteParameter("LastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
|
||||
|
@ -162,13 +191,15 @@ namespace SharpRss
|
|||
}
|
||||
};
|
||||
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,
|
||||
param: new
|
||||
{
|
||||
Id = item.Id ?? string.Empty,
|
||||
FeedUrl = item.FeedUrl ?? string.Empty,
|
||||
Read = item.Read.ToString(),
|
||||
Title = item.Title ?? string.Empty,
|
||||
Description = item.Description ?? string.Empty,
|
||||
Link = item.Link ?? string.Empty,
|
||||
LastUpdated = item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0,
|
||||
|
@ -176,8 +207,8 @@ namespace SharpRss
|
|||
Authors = item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty,
|
||||
Categories = item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty,
|
||||
Content = item.Content ?? string.Empty
|
||||
});*/
|
||||
totalAffected += exec;
|
||||
});
|
||||
totalAffected += affected;*/
|
||||
}
|
||||
dbTransaction.Commit();
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user