From cda1ab21494c27dc66303cc7eb5a11b9c2a6bb28 Mon Sep 17 00:00:00 2001 From: Professional Date: Sat, 22 Mar 2025 00:48:10 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B0=D1=80=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Program.cs | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Program.cs b/Program.cs index 2b03799..769d94a 100644 --- a/Program.cs +++ b/Program.cs @@ -1762,7 +1762,26 @@ class Program { await connection.OpenAsync(); - // Проверяем, существует ли таблица Reports + // Сначала создаем таблицу Reports, если её не существует + var createTableCommand = connection.CreateCommand(); + createTableCommand.CommandText = + @" + CREATE TABLE IF NOT EXISTS Reports ( + Id INTEGER PRIMARY KEY AUTOINCREMENT, + ChatId INTEGER NOT NULL, + Priority TEXT NOT NULL, + Room TEXT NOT NULL, + Description TEXT NOT NULL, + ReporterName TEXT NOT NULL, + DateCreated DATETIME DEFAULT CURRENT_TIMESTAMP, + Status TEXT DEFAULT 'ожидает', + AdminId INTEGER DEFAULT 0 + ); + "; + await createTableCommand.ExecuteNonQueryAsync(); + Log.Information("Таблица Reports успешно создана (если её не было)."); + + // Проверяем, существует ли таблица Reports и добавляем недостающие столбцы var checkTableCommand = connection.CreateCommand(); checkTableCommand.CommandText = "PRAGMA table_info(Reports);"; var tableInfo = await checkTableCommand.ExecuteReaderAsync(); @@ -1809,25 +1828,6 @@ class Program } } - // Создаем таблицу Reports, если её не существует - var createTableCommand = connection.CreateCommand(); - createTableCommand.CommandText = - @" - CREATE TABLE IF NOT EXISTS Reports ( - Id INTEGER PRIMARY KEY AUTOINCREMENT, - ChatId INTEGER NOT NULL, - Priority TEXT NOT NULL, - Room TEXT NOT NULL, - Description TEXT NOT NULL, - ReporterName TEXT NOT NULL, - DateCreated DATETIME DEFAULT CURRENT_TIMESTAMP, - Status TEXT DEFAULT 'ожидает', - AdminId INTEGER DEFAULT 0 - ); - "; - await createTableCommand.ExecuteNonQueryAsync(); - Log.Information("Таблица Reports успешно создана (если её не было)."); - // Создаем таблицу администраторов await CreateAdminsTableIfNotExists(); } @@ -1838,6 +1838,7 @@ class Program } } + private static Dictionary userReportSteps = new Dictionary(); private static Dictionary userReports = new Dictionary();