diff --git a/ProgramServerMTD/CMakeLists.txt b/ProgramServerMTD/CMakeLists.txt index a8c2a74..cbd2254 100644 --- a/ProgramServerMTD/CMakeLists.txt +++ b/ProgramServerMTD/CMakeLists.txt @@ -51,3 +51,9 @@ target_include_directories(ServerMTD PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../LibIn target_include_directories(ServerMTD PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../LibInstructorsAndTrainees/tasks) target_include_directories(ServerMTD PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../LibInstructorsAndTrainees/widgets) target_include_directories(ServerMTD PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../LibInstructorsAndTrainees/specialmessagebox) +if(PROJECT_TYPE_DEBUG) + target_link_directories(ServerMTD PUBLIC ${REPO_PATH}/BUILDS/Debug64/LibInstructorsAndTrainees) +else() + target_link_directories(ServerMTD PUBLIC ${REPO_PATH}/BUILDS/Release64/LibInstructorsAndTrainees) +endif() +target_link_libraries(ServerMTD PRIVATE libInstructorsAndTrainees.dll) diff --git a/ProgramServerMTD/main.cpp b/ProgramServerMTD/main.cpp index 231509a..6240721 100644 --- a/ProgramServerMTD/main.cpp +++ b/ProgramServerMTD/main.cpp @@ -1,10 +1,50 @@ #include "mainwindow.h" #include +//#include +#include +#include "specialmessagebox.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); + + + // Уникальное имя для идентификации процесса + const QString sharedMemKey = "ServerMTD_sharedMemKey"; + + // Создание объекта общей памяти + QSharedMemory sharedMemory(sharedMemKey); + + // Попытка прикрепления к существующему сегменту + bool isRunningAlready = false; + if (sharedMemory.attach(QSharedMemory::ReadWrite)) + { + qWarning() << "App ServerMTD is running already!"; + + QTranslator qtLanguageTranslator; + qtLanguageTranslator.load(QString("translations/RRJServer_") + "ru_RU", "."); + qApp->installTranslator(&qtLanguageTranslator); + //QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("App ServerMTD is running already!")); + SpecMsgBox::CriticalClose(nullptr, QObject::tr("App ") + QObject::tr("Maintenance training device RRJ-95NEW-100 Server") + QObject::tr(" is running already!")); + isRunningAlready = true; + } else + { + // Приложения ещё нет, создаём сегмент памяти + if (!sharedMemory.create(1)) + { + qCritical() << "Error create shared memory!"; + return 1; + } + } + + if (isRunningAlready) + return 1; + + // Освобождаем общую память при завершении работы приложения + QObject::connect(qApp, &QCoreApplication::aboutToQuit, + [&]() { sharedMemory.detach(); }); + MainWindow w; w.show(); //Закоментировать, если нужно, чтобы по-умолчанию было свернуто в трее! return a.exec(); diff --git a/translations/RRJServer_ru_RU.qm b/translations/RRJServer_ru_RU.qm index 76bba9d..b64d0f9 100644 Binary files a/translations/RRJServer_ru_RU.qm and b/translations/RRJServer_ru_RU.qm differ diff --git a/translations/RRJServer_ru_RU.ts b/translations/RRJServer_ru_RU.ts index 80300cd..0c7d139 100644 --- a/translations/RRJServer_ru_RU.ts +++ b/translations/RRJServer_ru_RU.ts @@ -1304,100 +1304,100 @@ Delete it anyway? - + none нет - + The file could not be opened Файл не может быть открыт - + Instructor authorization. Авторизация инструктора. - + Instructor deauthorization Деавторизация инструктора - + Error! Ошибка! - + Server blocked! Сервер заблокирован! - + Instructor authorization is temporarily unavailable. Авторизация инструктора временно недоступна. - + Try again later. Попробуйте позже. - + Database error! Ошибка базы данных! - + The user is archived! Пользователь является архивным! - + The user is already logged in! Пользователь уже в сети! - + Login or password error! Ошибка логина или пароля! - + The server is not available! Сервер недоступен! - + Connection attempt Попытка соединения - - + + connected подключен - + blocked заблокирован - + not connected не подключен - + Server settings have been changed. Please reconnect to the server. Настройки сервера были изменены. Пожалуйста, переподключитесь к серверу. - + Instructor authorization Авторизация инструктора @@ -1638,26 +1638,49 @@ Please reconnect to the server. FIM + + + The trainee was removed! + Обучаемый удален! + + + + The trainee was archived! + Обучаемый заархивирован! + + + + QObject + + + Error + Ошибка + + + + App ServerMTD is running already! + Программа ServerMTD уже запущена! + RecognizeSystem - + The file could not be opened Файл не может быть открыт - + You cannot delete the basic version! Вы не можете удалить базовую версию! - + You cannot delete the active version Вы не можете удалить активную версию - + This name already exists Это имя уже существует @@ -1750,76 +1773,76 @@ Please reconnect to the server. Ошибка PostgreSQL! - + Server is started! Сервер запущен! - + Server is stoped! Сервер остановлен! - + Settings file could not be opened: Файл настроек не открыт: - + Database settings have been changed. The server will be restarted. Настройки Базы Данных были изменены. Сервер будет перезапущен. - + The file could not be opened Файл не может быть открыт - - + + Database connection error! Ошибка подключения Базы данных! - + Database connection OK! База данных подключена! - + started запущен - + locked заблокирован - + stoped остановлен - + connected подключена - + not connected не подключен - + No Client files found! Файлы клиента не найдены! - + * check Application for the presence of a folder with a build * check SharedData for a folder with the base version and the name base * проверьте Application на наличие папки со сборкой