did some
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
rak 2022-12-01 21:40:53 +10:00
parent 800a8ee1b9
commit c5063b8c04
2 changed files with 2 additions and 54 deletions

View File

@ -1,21 +1,13 @@
using NeDvachAPI.Models;
using Npgsql;
using static System.Net.Mime.MediaTypeNames;
namespace NeDvachAPI.DBControllers
{
public class DBchat
{
// Obtain connection string information from the portal
public static List<Post> PostsList(string boardName, int thread)
{
// Build connection string using parameters from portal
//Post[] posts = new Post[10];
List<Post> posts = new List<Post>();
//int postCount = 0;
string received = "";
string connString =
string.Format(
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
@ -30,17 +22,6 @@ namespace NeDvachAPI.DBControllers
conn.Open();
// using ( var command = new NpgsqlCommand(@"
// SELECT * FROM
// (SELECT post_id, substring(post,1,200)
// FROM dvach
// ORDER BY post_id DESC
// limit 10
// )
// subquery
// ORDER BY post_id ASC", conn) )
using (var command = new NpgsqlCommand($@"
SELECT * FROM
(
@ -55,13 +36,6 @@ namespace NeDvachAPI.DBControllers
var reader = command.ExecuteReader();
while (reader.Read())
{
//received +=(
//string.Format(
//"#{0}: {1}" + "\n",
// reader.GetInt32(0).ToString(),
//reader.GetString(1)
//)
//);
Post receivedPost = new()
{
Id = reader.GetInt32(0),
@ -71,8 +45,6 @@ namespace NeDvachAPI.DBControllers
};
posts.Add(receivedPost);
//posts[postCount] = receivedPost;
//postCount++;
}
reader.Close();
}
@ -82,10 +54,7 @@ namespace NeDvachAPI.DBControllers
public static List<Post> ThreadsList(string boardName)
{
// Build connection string using parameters from portal
//Post[] posts = new Post[10];
List<Post> posts = new List<Post>();
//int postCount = 0;
string received = "";
string connString =
string.Format(
@ -102,16 +71,6 @@ namespace NeDvachAPI.DBControllers
conn.Open();
// using ( var command = new NpgsqlCommand(@"
// SELECT * FROM
// (SELECT post_id, substring(post,1,200)
// FROM dvach
// ORDER BY post_id DESC
// limit 10
// )
// subquery
// ORDER BY post_id ASC", conn) )
using (var command = new NpgsqlCommand($@"
SELECT * FROM
(
@ -127,13 +86,6 @@ namespace NeDvachAPI.DBControllers
var reader = command.ExecuteReader();
while (reader.Read())
{
//received +=(
//string.Format(
//"#{0}: {1}" + "\n",
// reader.GetInt32(0).ToString(),
//reader.GetString(1)
//)
//);
Post receivedPost = new()
{
Id = reader.GetInt32(0),
@ -145,8 +97,6 @@ namespace NeDvachAPI.DBControllers
};
posts.Add(receivedPost);
//posts[postCount] = receivedPost;
//postCount++;
}
reader.Close();
}
@ -223,7 +173,6 @@ namespace NeDvachAPI.DBControllers
command.Parameters.AddWithValue("postImgUrl", postToSend.ImgURL);
command.Parameters.AddWithValue("threadId", postToSend.Thread_Id);
command.Parameters.AddWithValue("ip", postToSend.Ip);
//command.Parameters.AddWithValue("postTimeStamp", DateTime.Now.ToString("dd/MM/yyyy HH:mm"));
int nRows = command.ExecuteNonQuery();
Console.Out.WriteLine("Добавлен пост с текстом " + postToSend.Text + " номером " + 22);
}
@ -244,7 +193,6 @@ namespace NeDvachAPI.DBControllers
using (var conn = new NpgsqlConnection(connString))
{
//Console.Out.WriteLine("Opening connection");
conn.Open();
using (var command = new NpgsqlCommand(@"

View File

@ -11,8 +11,8 @@ builder.Services.AddCors(setup =>
setup.AddDefaultPolicy(policyBuilder =>
{
policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("GET", "POST").WithHeaders("*");
//policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
//policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("GET", "POST").WithHeaders("*");
policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
});
});