first commit
This commit is contained in:
76
test/qxClientServer/qxServer/CMakeLists.txt
Normal file
76
test/qxClientServer/qxServer/CMakeLists.txt
Normal file
@@ -0,0 +1,76 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxServer LANGUAGES CXX)
|
||||
|
||||
include(../../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Sql Gui Widgets REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
./include/precompiled.h
|
||||
./include/export.h
|
||||
./include/main_dlg.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
./src/main_dlg.cpp
|
||||
./src/main.cpp
|
||||
)
|
||||
|
||||
set(UIS
|
||||
./qt/ui/qxServer.ui
|
||||
)
|
||||
|
||||
set(QRCS
|
||||
./qt/rcc/_qxServer.qrc
|
||||
)
|
||||
|
||||
if(COMMAND qt_wrap_ui)
|
||||
qt_wrap_ui(UIS_HDRS ${UIS})
|
||||
qt_add_resources(QRCS_HDRS ${QRCS})
|
||||
else() # (COMMAND qt_wrap_ui)
|
||||
qt5_wrap_ui(UIS_HDRS ${UIS})
|
||||
qt5_add_resources(QRCS_HDRS ${QRCS})
|
||||
endif() # (COMMAND qt_wrap_ui)
|
||||
|
||||
add_executable(qxServer ${SRCS} ${HEADERS} ${UIS_HDRS} ${QRCS_HDRS})
|
||||
|
||||
target_compile_definitions(qxServer PRIVATE -D_BUILDING_QX_SERVER)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxServer PRIVATE ./include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxServer ${QX_LIBRARIES} Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets QxOrm qxServiceServer)
|
||||
|
||||
set_target_properties(qxServer PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
)
|
||||
|
||||
set_target_properties(qxServer PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxServer project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
7
test/qxClientServer/qxServer/debug/.gitignore
vendored
Normal file
7
test/qxClientServer/qxServer/debug/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
20
test/qxClientServer/qxServer/include/export.h
Normal file
20
test/qxClientServer/qxServer/include/export.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _QX_SERVER_EXPORT_H_
|
||||
#define _QX_SERVER_EXPORT_H_
|
||||
|
||||
#include "../../qxService/include/export.h"
|
||||
|
||||
#ifdef _BUILDING_QX_SERVER
|
||||
#define QX_SERVER_DLL_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _BUILDING_QX_SERVER
|
||||
#define QX_SERVER_DLL_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _BUILDING_QX_SERVER
|
||||
|
||||
#ifdef _BUILDING_QX_SERVER
|
||||
#define QX_REGISTER_HPP_QX_SERVER QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_SERVER QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // _BUILDING_QX_SERVER
|
||||
#define QX_REGISTER_HPP_QX_SERVER QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_SERVER QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif // _BUILDING_QX_SERVER
|
||||
|
||||
#endif // _QX_SERVER_EXPORT_H_
|
||||
47
test/qxClientServer/qxServer/include/main_dlg.h
Normal file
47
test/qxClientServer/qxServer/include/main_dlg.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _QX_SERVER_MAIN_DLG_H_
|
||||
#define _QX_SERVER_MAIN_DLG_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef _QX_NO_PRECOMPILED_HEADER
|
||||
#ifndef Q_MOC_RUN
|
||||
#include "../include/precompiled.h" // Need to include precompiled header for the generated moc file
|
||||
#endif // Q_MOC_RUN
|
||||
#endif // _QX_NO_PRECOMPILED_HEADER
|
||||
|
||||
#include "../qt/ui/include/ui_qxServer.h"
|
||||
|
||||
class main_dlg : public QWidget, private Ui::dlgServer
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
qx::service::QxThreadPool_ptr m_pThreadPool; // Server thread pool to receive all requests
|
||||
qx::QxDaoAsync m_daoAsync; // To test to run queries in a different thread
|
||||
|
||||
public:
|
||||
|
||||
main_dlg(QWidget * parent = NULL) : QWidget(parent), Ui::dlgServer() { main_dlg::init(); }
|
||||
virtual ~main_dlg() { ; }
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
void loadServices();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void onClickStartStop();
|
||||
void onCboIndexChanged(int index);
|
||||
void onError(const QString & err, qx::service::QxTransaction_ptr transaction);
|
||||
void onServerIsRunning(bool bIsRunning, qx::service::QxServer * pServer);
|
||||
void onTransactionFinished(qx::service::QxTransaction_ptr transaction);
|
||||
void onQueryFinished(const QSqlError & daoError, qx::dao::detail::QxDaoAsyncParams_ptr pDaoParams);
|
||||
|
||||
};
|
||||
|
||||
#endif // _QX_SERVER_MAIN_DLG_H_
|
||||
9
test/qxClientServer/qxServer/include/precompiled.h
Normal file
9
test/qxClientServer/qxServer/include/precompiled.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _QX_SERVER_PRECOMPILED_HEADER_H_
|
||||
#define _QX_SERVER_PRECOMPILED_HEADER_H_
|
||||
|
||||
#include <QxOrm.h>
|
||||
#include <QxServices.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#endif // _QX_SERVER_PRECOMPILED_HEADER_H_
|
||||
7
test/qxClientServer/qxServer/qt/moc/.gitignore
vendored
Normal file
7
test/qxClientServer/qxServer/qt/moc/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
1
test/qxClientServer/qxServer/qt/rcc/_qxServer.qrc
Normal file
1
test/qxClientServer/qxServer/qt/rcc/_qxServer.qrc
Normal file
@@ -0,0 +1 @@
|
||||
<RCC version="1.0">
|
||||
BIN
test/qxClientServer/qxServer/qt/rcc/run.png
Normal file
BIN
test/qxClientServer/qxServer/qt/rcc/run.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
test/qxClientServer/qxServer/qt/rcc/stop.png
Normal file
BIN
test/qxClientServer/qxServer/qt/rcc/stop.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 796 B |
325
test/qxClientServer/qxServer/qt/ui/qxServer.ui
Normal file
325
test/qxClientServer/qxServer/qt/ui/qxServer.ui
Normal file
@@ -0,0 +1,325 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>dlgServer</class>
|
||||
<widget class="QWidget" name="dlgServer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>552</width>
|
||||
<height>392</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>552</width>
|
||||
<height>392</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>552</width>
|
||||
<height>392</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>qxServer</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="grpError">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>310</y>
|
||||
<width>531</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Log last server error</string>
|
||||
</property>
|
||||
<widget class="QPlainTextEdit" name="txtError">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>511</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>170</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>170</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>112</red>
|
||||
<green>111</green>
|
||||
<blue>113</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpServerParams">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>531</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Server parameters</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="lblThreadCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>15</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Thread Count</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Thread Count :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblSerializationType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Serialization Type</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Serialization Type :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cboSerializationType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>50</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Serialization Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblPortNumber">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Port Number</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Port Number :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinPortNumber">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>20</y>
|
||||
<width>51</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Port Number</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="chkCompressData">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>40</y>
|
||||
<width>101</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Compress Data</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Compress Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnStartStop">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>20</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Server /
|
||||
Stop Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="lineServerParams">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>10</y>
|
||||
<width>3</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="imgIsRunning">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>20</y>
|
||||
<width>71</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>[ is running ? ]</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinThreadCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>15</y>
|
||||
<width>51</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Thread Count</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="chkEncryptData">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>55</y>
|
||||
<width>101</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Encrypt Data</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Encrypt Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpTransaction">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>531</width>
|
||||
<height>201</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Log last client-server reply-request transaction</string>
|
||||
</property>
|
||||
<widget class="QPlainTextEdit" name="txtTransaction">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>511</width>
|
||||
<height>171</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
7
test/qxClientServer/qxServer/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxServer/qt/ui/src/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
41
test/qxClientServer/qxServer/qxServer.pro
Normal file
41
test/qxClientServer/qxServer/qxServer.pro
Normal file
@@ -0,0 +1,41 @@
|
||||
include(../../../QxOrm.pri)
|
||||
|
||||
!contains(DEFINES, _QX_ENABLE_QT_NETWORK) {
|
||||
error(unable to use QxOrm QxService module : please define _QX_ENABLE_QT_NETWORK compilation option in QxOrm.pri configuration file)
|
||||
} # !contains(DEFINES, _QX_ENABLE_QT_NETWORK)
|
||||
|
||||
TEMPLATE = app
|
||||
DEFINES += _BUILDING_QX_SERVER
|
||||
INCLUDEPATH += ../../../../QxOrm/include/
|
||||
DESTDIR = ../../../../QxOrm/test/_bin/
|
||||
|
||||
QT += gui
|
||||
greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets }
|
||||
|
||||
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
|
||||
PRECOMPILED_HEADER = ./include/precompiled.h
|
||||
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
|
||||
|
||||
LIBS += -L"../../../../QxOrm/lib"
|
||||
LIBS += -L"../../../../QxOrm/test/_bin"
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = qxServerd
|
||||
LIBS += -l"QxOrmd"
|
||||
LIBS += -l"qxServiceServerd"
|
||||
} else {
|
||||
TARGET = qxServer
|
||||
LIBS += -l"QxOrm"
|
||||
LIBS += -l"qxServiceServer"
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
HEADERS += ./include/precompiled.h
|
||||
HEADERS += ./include/export.h
|
||||
HEADERS += ./include/main_dlg.h
|
||||
|
||||
SOURCES += ./src/main_dlg.cpp
|
||||
SOURCES += ./src/main.cpp
|
||||
|
||||
FORMS += ./qt/ui/qxServer.ui
|
||||
|
||||
RESOURCES += ./qt/rcc/_qxServer.qrc
|
||||
7
test/qxClientServer/qxServer/release/.gitignore
vendored
Normal file
7
test/qxClientServer/qxServer/release/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
22
test/qxClientServer/qxServer/src/main.cpp
Normal file
22
test/qxClientServer/qxServer/src/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtGui/qapplication.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
|
||||
#include "../include/precompiled.h"
|
||||
#include "../include/main_dlg.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
main_dlg dlg;
|
||||
dlg.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
132
test/qxClientServer/qxServer/src/main_dlg.cpp
Normal file
132
test/qxClientServer/qxServer/src/main_dlg.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/main_dlg.h"
|
||||
|
||||
#include "../../qxService/include/service/server_infos.h"
|
||||
#include "../../qxService/include/dao/user_manager.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void main_dlg::init()
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
QObject::connect(btnStartStop, SIGNAL(clicked()), this, SLOT(onClickStartStop()));
|
||||
QObject::connect(cboSerializationType, SIGNAL(currentIndexChanged(int)), this, SLOT(onCboIndexChanged(int)));
|
||||
QObject::connect((& m_daoAsync), SIGNAL(queryFinished(const QSqlError &, qx::dao::detail::QxDaoAsyncParams_ptr)), this, SLOT(onQueryFinished(const QSqlError &, qx::dao::detail::QxDaoAsyncParams_ptr)));
|
||||
|
||||
cboSerializationType->addItem("0- serialization_binary", QVariant((int)qx::service::QxConnect::serialization_binary));
|
||||
cboSerializationType->addItem("1- serialization_xml", QVariant((int)qx::service::QxConnect::serialization_xml));
|
||||
cboSerializationType->addItem("2- serialization_text", QVariant((int)qx::service::QxConnect::serialization_text));
|
||||
cboSerializationType->addItem("3- serialization_portable_binary", QVariant((int)qx::service::QxConnect::serialization_portable_binary));
|
||||
cboSerializationType->addItem("4- serialization_wide_binary", QVariant((int)qx::service::QxConnect::serialization_wide_binary));
|
||||
cboSerializationType->addItem("5- serialization_wide_xml", QVariant((int)qx::service::QxConnect::serialization_wide_xml));
|
||||
cboSerializationType->addItem("6- serialization_wide_text", QVariant((int)qx::service::QxConnect::serialization_wide_text));
|
||||
cboSerializationType->addItem("7- serialization_polymorphic_binary", QVariant((int)qx::service::QxConnect::serialization_polymorphic_binary));
|
||||
cboSerializationType->addItem("8- serialization_polymorphic_xml", QVariant((int)qx::service::QxConnect::serialization_polymorphic_xml));
|
||||
cboSerializationType->addItem("9- serialization_polymorphic_text", QVariant((int)qx::service::QxConnect::serialization_polymorphic_text));
|
||||
cboSerializationType->addItem("10- serialization_qt", QVariant((int)qx::service::QxConnect::serialization_qt));
|
||||
cboSerializationType->addItem("11- serialization_json", QVariant((int)qx::service::QxConnect::serialization_json));
|
||||
cboSerializationType->setCurrentIndex(cboSerializationType->findData(QVariant((int)qx::service::QxConnect::getSingleton()->getSerializationType())));
|
||||
|
||||
spinPortNumber->setValue(7694);
|
||||
spinThreadCount->setValue(qx::service::QxConnect::getSingleton()->getThreadCount());
|
||||
onServerIsRunning(false, NULL);
|
||||
onClickStartStop();
|
||||
}
|
||||
|
||||
void main_dlg::loadServices()
|
||||
{
|
||||
// Required to be sure to load all services dll : create a dummy service for each dll
|
||||
// It is also possible to create a 'plugin system' to load services
|
||||
server_infos dummy_01; Q_UNUSED(dummy_01);
|
||||
}
|
||||
|
||||
void main_dlg::onClickStartStop()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
if (m_pThreadPool)
|
||||
{
|
||||
m_pThreadPool.reset();
|
||||
txtError->setPlainText("");
|
||||
txtTransaction->setPlainText("");
|
||||
onServerIsRunning(false, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
qx::service::QxConnect::getSingleton()->setPort(spinPortNumber->value());
|
||||
qx::service::QxConnect::getSingleton()->setThreadCount(spinThreadCount->value());
|
||||
qx::service::QxConnect::getSingleton()->setSerializationType((qx::service::QxConnect::serialization_type)(cboSerializationType->itemData(cboSerializationType->currentIndex()).toInt()));
|
||||
qx::service::QxConnect::getSingleton()->setCompressData(chkCompressData->isChecked());
|
||||
qx::service::QxConnect::getSingleton()->setEncryptData(chkEncryptData->isChecked());
|
||||
|
||||
m_pThreadPool.reset(new qx::service::QxThreadPool());
|
||||
QObject::connect(m_pThreadPool.get(), SIGNAL(error(const QString &, qx::service::QxTransaction_ptr)), this, SLOT(onError(const QString &, qx::service::QxTransaction_ptr)));
|
||||
QObject::connect(m_pThreadPool.get(), SIGNAL(serverIsRunning(bool, qx::service::QxServer *)), this, SLOT(onServerIsRunning(bool, qx::service::QxServer *)));
|
||||
QObject::connect(m_pThreadPool.get(), SIGNAL(transactionFinished(qx::service::QxTransaction_ptr)), this, SLOT(onTransactionFinished(qx::service::QxTransaction_ptr)));
|
||||
m_pThreadPool->start();
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onCboIndexChanged(int index)
|
||||
{
|
||||
if (index < 0) { cboSerializationType->setToolTip(""); }
|
||||
else { cboSerializationType->setToolTip(cboSerializationType->itemText(cboSerializationType->currentIndex())); }
|
||||
|
||||
// To test to run queries in a different thread : see 'onQueryFinished()' method to see the result
|
||||
if (cboSerializationType->count() <= 1) { return; }
|
||||
user_manager dummy; Q_UNUSED(dummy); // To init database parameters
|
||||
qx_query query = "SELECT * FROM user";
|
||||
m_daoAsync.asyncCallQuery(query);
|
||||
}
|
||||
|
||||
void main_dlg::onServerIsRunning(bool bIsRunning, qx::service::QxServer * pServer)
|
||||
{
|
||||
Q_UNUSED(pServer);
|
||||
imgIsRunning->setText("");
|
||||
imgIsRunning->setPixmap(bIsRunning ? QPixmap(":/run") : QPixmap(":/stop"));
|
||||
btnStartStop->setText(bIsRunning ? "Stop Server" : "Start Server");
|
||||
|
||||
spinPortNumber->setEnabled(! bIsRunning);
|
||||
spinThreadCount->setEnabled(! bIsRunning);
|
||||
cboSerializationType->setEnabled(! bIsRunning);
|
||||
chkCompressData->setEnabled(! bIsRunning);
|
||||
chkEncryptData->setEnabled(! bIsRunning);
|
||||
}
|
||||
|
||||
void main_dlg::onError(const QString & err, qx::service::QxTransaction_ptr transaction)
|
||||
{
|
||||
if (err.isEmpty()) { txtError->setPlainText(""); return; }
|
||||
QString errText = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm") + " : " + err;
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
if (transaction) { errText += QString("\r\n\r\n") + qx::serialization::xml::to_string(* transaction); }
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
if (transaction) { errText += QString("\r\n\r\n") + transaction->getInfos(); }
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
txtError->setPlainText(errText.replace("\t", " "));
|
||||
}
|
||||
|
||||
void main_dlg::onTransactionFinished(qx::service::QxTransaction_ptr transaction)
|
||||
{
|
||||
if (! transaction) { txtTransaction->setPlainText(""); return; }
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
QString text = qx::serialization::xml::to_string(* transaction);
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
QString text = transaction->getInfos();
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
txtTransaction->setPlainText(text.replace("\t", " "));
|
||||
}
|
||||
|
||||
void main_dlg::onQueryFinished(const QSqlError & daoError, qx::dao::detail::QxDaoAsyncParams_ptr pDaoParams)
|
||||
{
|
||||
if (! pDaoParams) { return; }
|
||||
qx::QxSqlQuery query = pDaoParams->query;
|
||||
if (! daoError.isValid()) { /* ... */ }
|
||||
// If the async query is associated to a simple object, just use 'pDaoParams->pInstance' method
|
||||
qx::IxPersistable_ptr ptr = pDaoParams->pInstance;
|
||||
// If the async query is associated to a list of objects, just use 'pDaoParams->pListOfInstances' method
|
||||
qx::IxPersistableCollection_ptr lst = pDaoParams->pListOfInstances;
|
||||
// etc...
|
||||
Q_UNUSED(query); Q_UNUSED(ptr); Q_UNUSED(lst);
|
||||
}
|
||||
Reference in New Issue
Block a user