Merge branch 'master' of http://git.vdk2ch.ru:3000/RakVhalate/2chBackAPI into master
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simple_Not 2022-10-20 11:17:13 +10:00
commit 63330d5fc0
6 changed files with 105 additions and 6 deletions

35
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,35 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/NeDvachAPI.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

41
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/NeDvachAPI.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/NeDvachAPI.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/NeDvachAPI.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class TestPostingController : ControllerBase
{
[HttpPost]
public int Area(int altitude , int height)
{
//DBchat.SendPost(ReceivedPost);
return altitude+height;
}
}
}

View File

@ -5,7 +5,6 @@ namespace NeDvachAPI
public class DBchat public class DBchat
{ {
// Obtain connection string information from the portal // Obtain connection string information from the portal
//
private static string Host = "postgres.vdk2ch.ru"; private static string Host = "postgres.vdk2ch.ru";
private static string User = "postgres"; private static string User = "postgres";
private static string DBname = "postgres"; private static string DBname = "postgres";
@ -34,7 +33,13 @@ namespace NeDvachAPI
conn.Open(); 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
(SELECT post_id, substring(post,1,200)
FROM dvach
ORDER BY post_id
DESC limit 10)
subquery ORDER BY post_id ASC", conn))
{ {
var reader = command.ExecuteReader(); var reader = command.ExecuteReader();
@ -113,8 +118,9 @@ namespace NeDvachAPI
Console.Out.WriteLine("Opening connection"); Console.Out.WriteLine("Opening connection");
conn.Open(); conn.Open();
using (var command = new NpgsqlCommand("INSERT INTO dvach " + using (var command = new NpgsqlCommand(@"
"(post_id, post) VALUES (DEFAULT, @postText)", conn)) INSERT INTO dvach " + @"(post_id, post)
VALUES (DEFAULT, @postText)", conn))
{ {
command.Parameters.AddWithValue("postText", postToSend.Text); command.Parameters.AddWithValue("postText", postToSend.Text);

View File

@ -1,7 +1,7 @@
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Debug",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Debug",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },