first commit
This commit is contained in:
18
test/qxClientServer/CMakeLists.txt
Normal file
18
test/qxClientServer/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxClientServer LANGUAGES CXX)
|
||||
|
||||
include(../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
add_subdirectory(qxService/qxServiceClient)
|
||||
add_subdirectory(qxService/qxServiceServer)
|
||||
add_subdirectory(qxClient)
|
||||
add_subdirectory(qxServer)
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxClientServer project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
70
test/qxClientServer/qxClient/CMakeLists.txt
Normal file
70
test/qxClientServer/qxClient/CMakeLists.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxClient 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/qxClient.ui
|
||||
)
|
||||
|
||||
if(COMMAND qt_wrap_ui)
|
||||
qt_wrap_ui(UIS_HDRS ${UIS})
|
||||
else() # (COMMAND qt_wrap_ui)
|
||||
qt5_wrap_ui(UIS_HDRS ${UIS})
|
||||
endif() # (COMMAND qt_wrap_ui)
|
||||
|
||||
add_executable(qxClient ${SRCS} ${HEADERS} ${UIS_HDRS})
|
||||
|
||||
target_compile_definitions(qxClient PRIVATE -D_BUILDING_QX_CLIENT)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxClient PRIVATE ./include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxClient ${QX_LIBRARIES} Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets QxOrm qxServiceClient)
|
||||
|
||||
set_target_properties(qxClient 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(qxClient PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxClient project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
7
test/qxClientServer/qxClient/debug/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/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/qxClient/include/export.h
Normal file
20
test/qxClientServer/qxClient/include/export.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _QX_CLIENT_EXPORT_H_
|
||||
#define _QX_CLIENT_EXPORT_H_
|
||||
|
||||
#include "../../qxService/include/export.h"
|
||||
|
||||
#ifdef _BUILDING_QX_CLIENT
|
||||
#define QX_CLIENT_DLL_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _BUILDING_QX_CLIENT
|
||||
#define QX_CLIENT_DLL_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _BUILDING_QX_CLIENT
|
||||
|
||||
#ifdef _BUILDING_QX_CLIENT
|
||||
#define QX_REGISTER_HPP_QX_CLIENT QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_CLIENT QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // _BUILDING_QX_CLIENT
|
||||
#define QX_REGISTER_HPP_QX_CLIENT QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_CLIENT QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif // _BUILDING_QX_CLIENT
|
||||
|
||||
#endif // _QX_CLIENT_EXPORT_H_
|
||||
56
test/qxClientServer/qxClient/include/main_dlg.h
Normal file
56
test/qxClientServer/qxClient/include/main_dlg.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _QX_CLIENT_MAIN_DLG_H_
|
||||
#define _QX_CLIENT_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_qxClient.h"
|
||||
|
||||
#include "../../qxService/include/business_object/user.h"
|
||||
#include "../../qxService/include/business_object/user_search.h"
|
||||
|
||||
class main_dlg : public QWidget, private Ui::dlgClient
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
qx::service::QxClientAsync_ptr m_pDateTimeAsync; // To retrieve current server date-time without blocking GUI (async transaction)
|
||||
|
||||
public:
|
||||
|
||||
main_dlg(QWidget * parent = NULL) : QWidget(parent), Ui::dlgClient() { main_dlg::init(); }
|
||||
virtual ~main_dlg() { ; }
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
void updateLastTransactionLog(qx::service::QxTransaction_ptr transaction);
|
||||
void fillUser(user_ptr user);
|
||||
user_ptr fileUser();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void onClickBtnDateTime();
|
||||
void onClickBtnDateTimeAsync();
|
||||
void onClickBtnAddUser();
|
||||
void onClickBtnUpdateUser();
|
||||
void onClickBtnRemoveUser();
|
||||
void onClickBtnRemoveAllUsers();
|
||||
void onClickBtnFetchUser();
|
||||
void onClickBtnGetAllUsers();
|
||||
void onClickBtnSearchUsers();
|
||||
void onDateTimeAsyncFinished();
|
||||
void onUpdateServerConnection();
|
||||
|
||||
};
|
||||
|
||||
#endif // _QX_CLIENT_MAIN_DLG_H_
|
||||
9
test/qxClientServer/qxClient/include/precompiled.h
Normal file
9
test/qxClientServer/qxClient/include/precompiled.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _QX_CLIENT_PRECOMPILED_HEADER_H_
|
||||
#define _QX_CLIENT_PRECOMPILED_HEADER_H_
|
||||
|
||||
#include <QxOrm.h>
|
||||
#include <QxServices.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#endif // _QX_CLIENT_PRECOMPILED_HEADER_H_
|
||||
7
test/qxClientServer/qxClient/qt/moc/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/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
|
||||
7
test/qxClientServer/qxClient/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/qt/rcc/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
|
||||
448
test/qxClientServer/qxClient/qt/ui/qxClient.ui
Normal file
448
test/qxClientServer/qxClient/qt/ui/qxClient.ui
Normal file
@@ -0,0 +1,448 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>dlgClient</class>
|
||||
<widget class="QWidget" name="dlgClient">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>541</width>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>541</width>
|
||||
<height>371</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>541</width>
|
||||
<height>371</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>qxClient</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="grpServerInfos">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>10</y>
|
||||
<width>301</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Server infos transaction</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnDateTime">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>121</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get Server DateTime</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get Server DateTime</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnDateTime_Async">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get Server DateTime Async</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get Server DateTime Async</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpTransaction">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>170</y>
|
||||
<width>521</width>
|
||||
<height>191</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>501</width>
|
||||
<height>161</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 class="QGroupBox" name="grpUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>521</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>User transaction</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnGetAllUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get All Users</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get All</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnAddUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>51</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnUpdateUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Update User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRemoveUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRemoveAllUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove All Users</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove All</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnFetchUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>20</y>
|
||||
<width>71</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Fetch User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fetch</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="lineUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>501</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblId">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ID :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblFirstName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>First Name</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First Name :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblLastName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Last Name</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Last Name :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblBirthDate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>60</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Birthdate</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Birthdate :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtId">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtFirstName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>First Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtLastName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Last Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtBirthDate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Birthdate</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnSearchUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Search Users</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpServerConnection">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>211</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Server connection</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="lblIp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ip</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ip :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblPort">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Port :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinPort">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>20</y>
|
||||
<width>51</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtIp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ip</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>127.0.0.1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
7
test/qxClientServer/qxClient/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/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
|
||||
39
test/qxClientServer/qxClient/qxClient.pro
Normal file
39
test/qxClientServer/qxClient/qxClient.pro
Normal file
@@ -0,0 +1,39 @@
|
||||
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_CLIENT
|
||||
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 = qxClientd
|
||||
LIBS += -l"QxOrmd"
|
||||
LIBS += -l"qxServiceClientd"
|
||||
} else {
|
||||
TARGET = qxClient
|
||||
LIBS += -l"QxOrm"
|
||||
LIBS += -l"qxServiceClient"
|
||||
} # 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/qxClient.ui
|
||||
7
test/qxClientServer/qxClient/release/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/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/qxClient/src/main.cpp
Normal file
22
test/qxClientServer/qxClient/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();
|
||||
}
|
||||
223
test/qxClientServer/qxClient/src/main_dlg.cpp
Normal file
223
test/qxClientServer/qxClient/src/main_dlg.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include <QtGui/qcursor.h>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtWidgets/qmessagebox.h>
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtGui/qmessagebox.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
|
||||
#include "../include/main_dlg.h"
|
||||
|
||||
#include "../../qxService/include/service/server_infos.h"
|
||||
#include "../../qxService/include/service/user_service.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
#define QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT "dd/MM/yyyy"
|
||||
|
||||
void main_dlg::init()
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
QObject::connect(btnDateTime, SIGNAL(clicked()), this, SLOT(onClickBtnDateTime()));
|
||||
QObject::connect(btnDateTime_Async, SIGNAL(clicked()), this, SLOT(onClickBtnDateTimeAsync()));
|
||||
QObject::connect(btnAddUser, SIGNAL(clicked()), this, SLOT(onClickBtnAddUser()));
|
||||
QObject::connect(btnUpdateUser, SIGNAL(clicked()), this, SLOT(onClickBtnUpdateUser()));
|
||||
QObject::connect(btnRemoveUser, SIGNAL(clicked()), this, SLOT(onClickBtnRemoveUser()));
|
||||
QObject::connect(btnRemoveAllUser, SIGNAL(clicked()), this, SLOT(onClickBtnRemoveAllUsers()));
|
||||
QObject::connect(btnFetchUser, SIGNAL(clicked()), this, SLOT(onClickBtnFetchUser()));
|
||||
QObject::connect(btnGetAllUser, SIGNAL(clicked()), this, SLOT(onClickBtnGetAllUsers()));
|
||||
QObject::connect(btnSearchUser, SIGNAL(clicked()), this, SLOT(onClickBtnSearchUsers()));
|
||||
QObject::connect(txtIp, SIGNAL(editingFinished()), this, SLOT(onUpdateServerConnection()));
|
||||
QObject::connect(spinPort, SIGNAL(editingFinished()), this, SLOT(onUpdateServerConnection()));
|
||||
|
||||
txtBirthDate->setText(QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
txtBirthDate->setToolTip(QString("Birthdate : ") + QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
txtIp->setText("127.0.0.1");
|
||||
spinPort->setValue(7694);
|
||||
onUpdateServerConnection();
|
||||
}
|
||||
|
||||
void main_dlg::updateLastTransactionLog(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", " "));
|
||||
qx_bool bMsgReturn = transaction->getMessageReturn();
|
||||
if (! bMsgReturn.getValue() && ! bMsgReturn.getDesc().isEmpty())
|
||||
{ QMessageBox::warning(this, "qxClient - transaction error", bMsgReturn.getDesc()); }
|
||||
}
|
||||
|
||||
void main_dlg::fillUser(user_ptr user)
|
||||
{
|
||||
if (! user) { return; }
|
||||
txtId->setText(QString::number(user->id));
|
||||
txtFirstName->setText(user->first_name);
|
||||
txtLastName->setText(user->last_name);
|
||||
txtBirthDate->setText(user->birth_date.toString(QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT));
|
||||
}
|
||||
|
||||
user_ptr main_dlg::fileUser()
|
||||
{
|
||||
user_ptr user_to_file = user_ptr(new user());
|
||||
user_to_file->id = txtId->text().toLong();
|
||||
user_to_file->first_name = txtFirstName->text();
|
||||
user_to_file->last_name = txtLastName->text();
|
||||
user_to_file->birth_date = QDateTime::fromString(txtBirthDate->text(), QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
return user_to_file;
|
||||
}
|
||||
|
||||
void main_dlg::onUpdateServerConnection()
|
||||
{
|
||||
qx::service::QxConnect::getSingleton()->setIp(txtIp->text());
|
||||
qx::service::QxConnect::getSingleton()->setPort(spinPort->value());
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnDateTime()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create service and call method to retrieve current server date-time
|
||||
server_infos service;
|
||||
service.get_current_date_time();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnDateTimeAsync()
|
||||
{
|
||||
if (m_pDateTimeAsync) { qDebug("[QxOrm] '%s' transaction is already running", "server_infos::get_current_date_time"); return; }
|
||||
// Create service and call method to retrieve current server date-time (async mode)
|
||||
server_infos_ptr service = server_infos_ptr(new server_infos());
|
||||
m_pDateTimeAsync.reset(new qx::service::QxClientAsync());
|
||||
QObject::connect(m_pDateTimeAsync.get(), SIGNAL(finished()), this, SLOT(onDateTimeAsyncFinished()));
|
||||
m_pDateTimeAsync->setService(service, "get_current_date_time");
|
||||
m_pDateTimeAsync->start();
|
||||
}
|
||||
|
||||
void main_dlg::onDateTimeAsyncFinished()
|
||||
{
|
||||
if (! m_pDateTimeAsync || ! m_pDateTimeAsync->getService()) { return; }
|
||||
updateLastTransactionLog(m_pDateTimeAsync->getService()->getTransaction());
|
||||
m_pDateTimeAsync.reset();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnAddUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user to add
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->user = fileUser();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.insert();
|
||||
// If transaction is ok => display user with new id added to database
|
||||
user_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->user : user_ptr());
|
||||
if (output) { fillUser(output); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnUpdateUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user to update
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->user = fileUser();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.update();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnRemoveUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user id to remove
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->id = txtId->text().toLong();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.remove();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnRemoveAllUsers()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create service to call
|
||||
user_service service;
|
||||
service.remove_all();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnFetchUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user id to fetch
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->id = txtId->text().toLong();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.fetch_by_id();
|
||||
// If transaction is ok => display user fetched on GUI
|
||||
user_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->user : user_ptr());
|
||||
if (output) { fillUser(output); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnGetAllUsers()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create service to call
|
||||
user_service service;
|
||||
service.fetch_all();
|
||||
// If transaction is ok => display in a message box the number of users fetched from database
|
||||
list_of_users_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->list_of_users : list_of_users_ptr());
|
||||
if (output) { QMessageBox::information(this, "qxClient - get all users", "database contains '" + QString::number(output->size()) + "' user(s)."); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnSearchUsers()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create criteria to search users
|
||||
user_search_ptr criteria = user_search_ptr(new user_search());
|
||||
criteria->first_name = txtFirstName->text();
|
||||
criteria->last_name = txtLastName->text();
|
||||
criteria->birth_date = QDateTime::fromString(txtBirthDate->text(), QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
// Create input parameters with criteria to search users
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->criteria = criteria;
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.get_by_criteria();
|
||||
// If transaction is ok => display in a message box the number of users fetched from database
|
||||
list_of_users_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->list_of_users : list_of_users_ptr());
|
||||
if (output) { QMessageBox::information(this, "qxClient - search users", "database contains '" + QString::number(output->size()) + "' user(s) with input criteria."); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
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);
|
||||
}
|
||||
7
test/qxClientServer/qxService/debug/debug_client/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/debug/debug_client/.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
|
||||
7
test/qxClientServer/qxService/debug/debug_server/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/debug/debug_server/.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
|
||||
23
test/qxClientServer/qxService/include/business_object/user.h
Normal file
23
test/qxClientServer/qxService/include/business_object/user.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _QX_SERVICE_BO_USER_H_
|
||||
#define _QX_SERVICE_BO_USER_H_
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user
|
||||
{
|
||||
public:
|
||||
// -- contructor, virtual destructor
|
||||
user() : id(0) { ; }
|
||||
virtual ~user() { ; }
|
||||
// -- properties
|
||||
long id;
|
||||
QString first_name;
|
||||
QString last_name;
|
||||
QDateTime birth_date;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<user> user_ptr;
|
||||
typedef qx::QxCollection<long, user_ptr> list_of_users;
|
||||
typedef std::shared_ptr<list_of_users> list_of_users_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_BO_USER_H_
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _QX_SERVICE_BO_USER_SEARCH_H_
|
||||
#define _QX_SERVICE_BO_USER_SEARCH_H_
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_search
|
||||
{
|
||||
public:
|
||||
// -- contructor, virtual destructor
|
||||
user_search() { ; }
|
||||
virtual ~user_search() { ; }
|
||||
// -- properties
|
||||
QString first_name;
|
||||
QString last_name;
|
||||
QDateTime birth_date;
|
||||
// -- methods
|
||||
bool empty() const
|
||||
{ return (first_name.isEmpty() && last_name.isEmpty() && ! birth_date.isValid()); }
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_search, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<user_search> user_search_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_BO_USER_SEARCH_H_
|
||||
25
test/qxClientServer/qxService/include/dao/user_manager.h
Normal file
25
test/qxClientServer/qxService/include/dao/user_manager.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _QX_SERVICE_MODE_CLIENT
|
||||
#ifndef _QX_SERVICE_USER_MANAGER_H_
|
||||
#define _QX_SERVICE_USER_MANAGER_H_
|
||||
|
||||
#include "../../include/business_object/user.h"
|
||||
#include "../../include/business_object/user_search.h"
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_manager
|
||||
{
|
||||
public:
|
||||
user_manager() { user_manager::init_database(); }
|
||||
~user_manager() { ; }
|
||||
QSqlError insert(user_ptr p);
|
||||
QSqlError update(user_ptr p);
|
||||
QSqlError remove(user_ptr p);
|
||||
QSqlError remove_all();
|
||||
QSqlError fetch_by_id(user_ptr p);
|
||||
QSqlError fetch_all(list_of_users_ptr lst);
|
||||
QSqlError get_by_criteria(user_search_ptr criteria, list_of_users_ptr lst);
|
||||
private:
|
||||
static void init_database();
|
||||
};
|
||||
|
||||
#endif // _QX_SERVICE_USER_MANAGER_H_
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
18
test/qxClientServer/qxService/include/export.h
Normal file
18
test/qxClientServer/qxService/include/export.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _QX_SERVICE_EXPORT_H_
|
||||
#define _QX_SERVICE_EXPORT_H_
|
||||
|
||||
#ifdef _BUILDING_QX_SERVICE
|
||||
#define QX_SERVICE_DLL_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _BUILDING_QX_SERVICE
|
||||
#define QX_SERVICE_DLL_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _BUILDING_QX_SERVICE
|
||||
|
||||
#ifdef _BUILDING_QX_SERVICE
|
||||
#define QX_REGISTER_HPP_QX_SERVICE QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_SERVICE QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // _BUILDING_QX_SERVICE
|
||||
#define QX_REGISTER_HPP_QX_SERVICE QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_SERVICE QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif // _BUILDING_QX_SERVICE
|
||||
|
||||
#endif // _QX_SERVICE_EXPORT_H_
|
||||
9
test/qxClientServer/qxService/include/precompiled.h
Normal file
9
test/qxClientServer/qxService/include/precompiled.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _QX_SERVICE_PRECOMPILED_HEADER_H_
|
||||
#define _QX_SERVICE_PRECOMPILED_HEADER_H_
|
||||
|
||||
#include <QxOrm.h>
|
||||
#include <QxServices.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#endif // _QX_SERVICE_PRECOMPILED_HEADER_H_
|
||||
34
test/qxClientServer/qxService/include/service/server_infos.h
Normal file
34
test/qxClientServer/qxService/include/service/server_infos.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _QX_SERVICE_SERVER_INFOS_H_
|
||||
#define _QX_SERVICE_SERVER_INFOS_H_
|
||||
|
||||
/* -- Service Input Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT server_infos_input : public qx::service::IxParameter
|
||||
{ QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(server_infos_input); };
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(server_infos_input, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<server_infos_input> server_infos_input_ptr;
|
||||
|
||||
/* -- Service Output Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT server_infos_output : public qx::service::IxParameter
|
||||
{ public: QDateTime current_date_time; QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(server_infos_output); };
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(server_infos_output, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<server_infos_output> server_infos_output_ptr;
|
||||
|
||||
/* -- Service Definition -- */
|
||||
|
||||
typedef qx::service::QxService<server_infos_input, server_infos_output> server_infos_base_class;
|
||||
class QX_SERVICE_DLL_EXPORT server_infos : public server_infos_base_class
|
||||
{
|
||||
public:
|
||||
server_infos() : server_infos_base_class("server_infos") { ; }
|
||||
virtual ~server_infos() { ; }
|
||||
void get_current_date_time();
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(server_infos, qx::service::IxService, 0)
|
||||
typedef std::shared_ptr<server_infos> server_infos_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_SERVER_INFOS_H_
|
||||
56
test/qxClientServer/qxService/include/service/user_service.h
Normal file
56
test/qxClientServer/qxService/include/service/user_service.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _QX_SERVICE_USER_SERVICE_H_
|
||||
#define _QX_SERVICE_USER_SERVICE_H_
|
||||
|
||||
#include "../../include/business_object/user.h"
|
||||
#include "../../include/business_object/user_search.h"
|
||||
|
||||
/* -- Service Input Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_service_input : public qx::service::IxParameter
|
||||
{
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(user_service_input);
|
||||
public:
|
||||
user_service_input() : id(0) { ; }
|
||||
virtual ~user_service_input() { ; }
|
||||
long id;
|
||||
user_ptr user;
|
||||
user_search_ptr criteria;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_service_input, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<user_service_input> user_service_input_ptr;
|
||||
|
||||
/* -- Service Output Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_service_output : public qx::service::IxParameter
|
||||
{
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(user_service_output);
|
||||
public:
|
||||
user_ptr user;
|
||||
list_of_users_ptr list_of_users;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_service_output, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<user_service_output> user_service_output_ptr;
|
||||
|
||||
/* -- Service Definition -- */
|
||||
|
||||
typedef qx::service::QxService<user_service_input, user_service_output> user_service_base_class;
|
||||
class QX_SERVICE_DLL_EXPORT user_service : public user_service_base_class
|
||||
{
|
||||
public:
|
||||
user_service() : user_service_base_class("user_service") { ; }
|
||||
virtual ~user_service() { ; }
|
||||
void insert();
|
||||
void update();
|
||||
void remove();
|
||||
void remove_all();
|
||||
void fetch_by_id();
|
||||
void fetch_all();
|
||||
void get_by_criteria();
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_service, qx::service::IxService, 0)
|
||||
typedef std::shared_ptr<user_service> user_service_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_USER_SERVICE_H_
|
||||
7
test/qxClientServer/qxService/qt/moc/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/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
|
||||
7
test/qxClientServer/qxService/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/qt/rcc/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
|
||||
7
test/qxClientServer/qxService/qt/ui/include/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/qt/ui/include/.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
|
||||
7
test/qxClientServer/qxService/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/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
|
||||
37
test/qxClientServer/qxService/qxService.pri
Normal file
37
test/qxClientServer/qxService/qxService.pri
Normal file
@@ -0,0 +1,37 @@
|
||||
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 = lib
|
||||
CONFIG += dll
|
||||
DEFINES += _BUILDING_QX_SERVICE
|
||||
INCLUDEPATH += ../../../../QxOrm/include/
|
||||
DESTDIR = ../../../../QxOrm/test/_bin/
|
||||
LIBS += -L"../../../../QxOrm/lib"
|
||||
|
||||
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
|
||||
PRECOMPILED_HEADER = ./include/precompiled.h
|
||||
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -l"QxOrmd"
|
||||
} else {
|
||||
LIBS += -l"QxOrm"
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
HEADERS += ./include/precompiled.h
|
||||
HEADERS += ./include/export.h
|
||||
HEADERS += ./include/service/server_infos.h
|
||||
HEADERS += ./include/service/user_service.h
|
||||
HEADERS += ./include/business_object/user.h
|
||||
HEADERS += ./include/business_object/user_search.h
|
||||
HEADERS += ./include/dao/user_manager.h
|
||||
|
||||
SOURCES += ./src/service/server_infos.cpp
|
||||
SOURCES += ./src/service/user_service.cpp
|
||||
SOURCES += ./src/business_object/user.cpp
|
||||
SOURCES += ./src/business_object/user_search.cpp
|
||||
SOURCES += ./src/dao/user_manager.cpp
|
||||
SOURCES += ./src/main.cpp
|
||||
11
test/qxClientServer/qxService/qxServiceClient.pro
Normal file
11
test/qxClientServer/qxService/qxServiceClient.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
include(./qxService.pri)
|
||||
|
||||
DEFINES += _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
OBJECTS_DIR = ./debug/debug_client/
|
||||
TARGET = qxServiceClientd
|
||||
} else {
|
||||
OBJECTS_DIR = ./release/release_client/
|
||||
TARGET = qxServiceClient
|
||||
} # CONFIG(debug, debug|release)
|
||||
64
test/qxClientServer/qxService/qxServiceClient/CMakeLists.txt
Normal file
64
test/qxClientServer/qxService/qxServiceClient/CMakeLists.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxServiceClient LANGUAGES CXX)
|
||||
|
||||
include(../../../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
../include/precompiled.h
|
||||
../include/export.h
|
||||
../include/service/server_infos.h
|
||||
../include/service/user_service.h
|
||||
../include/business_object/user.h
|
||||
../include/business_object/user_search.h
|
||||
../include/dao/user_manager.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
../src/service/server_infos.cpp
|
||||
../src/service/user_service.cpp
|
||||
../src/business_object/user.cpp
|
||||
../src/business_object/user_search.cpp
|
||||
../src/dao/user_manager.cpp
|
||||
../src/main.cpp
|
||||
)
|
||||
|
||||
add_library(qxServiceClient SHARED ${SRCS} ${HEADERS})
|
||||
|
||||
target_compile_definitions(qxServiceClient PRIVATE -D_BUILDING_QX_SERVICE -D_QX_SERVICE_MODE_CLIENT)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxServiceClient PRIVATE ../include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxServiceClient ${QX_LIBRARIES} QxOrm)
|
||||
|
||||
set_target_properties(qxServiceClient 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"
|
||||
)
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxServiceClient project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
9
test/qxClientServer/qxService/qxServiceServer.pro
Normal file
9
test/qxClientServer/qxService/qxServiceServer.pro
Normal file
@@ -0,0 +1,9 @@
|
||||
include(./qxService.pri)
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
OBJECTS_DIR = ./debug/debug_server/
|
||||
TARGET = qxServiceServerd
|
||||
} else {
|
||||
OBJECTS_DIR = ./release/release_server/
|
||||
TARGET = qxServiceServer
|
||||
} # CONFIG(debug, debug|release)
|
||||
64
test/qxClientServer/qxService/qxServiceServer/CMakeLists.txt
Normal file
64
test/qxClientServer/qxService/qxServiceServer/CMakeLists.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxServiceServer LANGUAGES CXX)
|
||||
|
||||
include(../../../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
../include/precompiled.h
|
||||
../include/export.h
|
||||
../include/service/server_infos.h
|
||||
../include/service/user_service.h
|
||||
../include/business_object/user.h
|
||||
../include/business_object/user_search.h
|
||||
../include/dao/user_manager.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
../src/service/server_infos.cpp
|
||||
../src/service/user_service.cpp
|
||||
../src/business_object/user.cpp
|
||||
../src/business_object/user_search.cpp
|
||||
../src/dao/user_manager.cpp
|
||||
../src/main.cpp
|
||||
)
|
||||
|
||||
add_library(qxServiceServer SHARED ${SRCS} ${HEADERS})
|
||||
|
||||
target_compile_definitions(qxServiceServer PRIVATE -D_BUILDING_QX_SERVICE)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxServiceServer PRIVATE ../include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxServiceServer ${QX_LIBRARIES} QxOrm)
|
||||
|
||||
set_target_properties(qxServiceServer 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"
|
||||
)
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxServiceServer project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
7
test/qxClientServer/qxService/release/release_client/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/release/release_client/.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
|
||||
7
test/qxClientServer/qxService/release/release_server/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/release/release_server/.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
|
||||
17
test/qxClientServer/qxService/src/business_object/user.cpp
Normal file
17
test/qxClientServer/qxService/src/business_object/user.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/business_object/user.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(user)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<user> & t)
|
||||
{
|
||||
t.id(& user::id, "id");
|
||||
|
||||
t.data(& user::first_name, "first_name");
|
||||
t.data(& user::last_name, "last_name");
|
||||
t.data(& user::birth_date, "birth_date");
|
||||
}}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/business_object/user_search.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_search)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<user_search> & t)
|
||||
{
|
||||
t.data(& user_search::first_name, "first_name");
|
||||
t.data(& user_search::last_name, "last_name");
|
||||
t.data(& user_search::birth_date, "birth_date");
|
||||
}}
|
||||
90
test/qxClientServer/qxService/src/dao/user_manager.cpp
Normal file
90
test/qxClientServer/qxService/src/dao/user_manager.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/dao/user_manager.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void user_manager::init_database()
|
||||
{
|
||||
static QMutex mutex;
|
||||
static bool bInitDone = false;
|
||||
if (bInitDone) { return; }
|
||||
QMutexLocker locker(& mutex);
|
||||
if (bInitDone) { return; }
|
||||
bInitDone = true;
|
||||
|
||||
QFile::remove("./user.db");
|
||||
qx::QxSqlDatabase::getSingleton()->setDriverName("QSQLITE");
|
||||
qx::QxSqlDatabase::getSingleton()->setDatabaseName("user.db");
|
||||
qx::QxSqlDatabase::getSingleton()->setHostName("localhost");
|
||||
qx::QxSqlDatabase::getSingleton()->setUserName("root");
|
||||
qx::QxSqlDatabase::getSingleton()->setPassword("");
|
||||
qx::dao::create_table<user>();
|
||||
}
|
||||
|
||||
QSqlError user_manager::insert(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot insert user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->first_name.trimmed().isEmpty()) { return QSqlError("cannot insert user : 'first_name' is required", "", QSqlError::UnknownError); }
|
||||
if (p->last_name.trimmed().isEmpty()) { return QSqlError("cannot insert user : 'last_name' is required", "", QSqlError::UnknownError); }
|
||||
return qx::dao::insert(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::update(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot update user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->id == 0) { return QSqlError("cannot update user : 'id' is required", "", QSqlError::UnknownError); }
|
||||
if (p->first_name.trimmed().isEmpty()) { return QSqlError("cannot update user : 'first_name' is required", "", QSqlError::UnknownError); }
|
||||
if (p->last_name.trimmed().isEmpty()) { return QSqlError("cannot update user : 'last_name' is required", "", QSqlError::UnknownError); }
|
||||
if (! qx::dao::exist(p)) { return QSqlError("cannot update user : user doesn't exist in database", "", QSqlError::UnknownError); }
|
||||
return qx::dao::update(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::remove(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot remove user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->id == 0) { return QSqlError("cannot remove user : 'id' is required", "", QSqlError::UnknownError); }
|
||||
if (! qx::dao::exist(p)) { return QSqlError("cannot remove user : user doesn't exist in database", "", QSqlError::UnknownError); }
|
||||
return qx::dao::delete_by_id(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::remove_all()
|
||||
{
|
||||
return qx::dao::delete_all<user>();
|
||||
}
|
||||
|
||||
QSqlError user_manager::fetch_by_id(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot fetch user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->id == 0) { return QSqlError("cannot fetch user : 'id' is required", "", QSqlError::UnknownError); }
|
||||
if (! qx::dao::exist(p)) { return QSqlError("cannot fetch user : user doesn't exist in database", "", QSqlError::UnknownError); }
|
||||
return qx::dao::fetch_by_id(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::fetch_all(list_of_users_ptr lst)
|
||||
{
|
||||
return qx::dao::fetch_all(lst);
|
||||
}
|
||||
|
||||
QSqlError user_manager::get_by_criteria(user_search_ptr criteria, list_of_users_ptr lst)
|
||||
{
|
||||
if (! criteria) { return QSqlError("cannot search users : invalid criteria (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (criteria->empty()) { return fetch_all(lst); }
|
||||
|
||||
QString sql = "WHERE ";
|
||||
if (! criteria->first_name.isEmpty()) { sql += "user.first_name LIKE :first_name AND "; }
|
||||
if (! criteria->last_name.isEmpty()) { sql += "user.last_name LIKE :last_name AND "; }
|
||||
if (criteria->birth_date.isValid()) { sql += "user.birth_date = :birth_date AND "; }
|
||||
sql = sql.left(sql.count() - 5); // Remove last " AND "
|
||||
|
||||
qx::QxSqlQuery query(sql);
|
||||
if (! criteria->first_name.isEmpty()) { query.bind(":first_name", criteria->first_name); }
|
||||
if (! criteria->last_name.isEmpty()) { query.bind(":last_name", criteria->last_name); }
|
||||
if (criteria->birth_date.isValid()) { query.bind(":birth_date", criteria->birth_date); }
|
||||
|
||||
return qx::dao::fetch_by_query(query, lst);
|
||||
}
|
||||
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
20
test/qxClientServer/qxService/src/main.cpp
Normal file
20
test/qxClientServer/qxService/src/main.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern "C"
|
||||
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReservedt */)
|
||||
{
|
||||
(void)hInstance;
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_PROCESS_ATTACH\n"); break;
|
||||
case DLL_PROCESS_DETACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_PROCESS_DETACH\n"); break;
|
||||
case DLL_THREAD_ATTACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_THREAD_ATTACH\n"); break;
|
||||
case DLL_THREAD_DETACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_THREAD_DETACH\n"); break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // _MSC_VER
|
||||
42
test/qxClientServer/qxService/src/service/server_infos.cpp
Normal file
42
test/qxClientServer/qxService/src/service/server_infos.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/service/server_infos.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(server_infos_input)
|
||||
QX_REGISTER_CPP_QX_SERVICE(server_infos_output)
|
||||
QX_REGISTER_CPP_QX_SERVICE(server_infos)
|
||||
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(server_infos_input)
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(server_infos_output)
|
||||
|
||||
namespace qx {
|
||||
|
||||
template <> void register_class(QxClass<server_infos_input> & t)
|
||||
{ Q_UNUSED(t); }
|
||||
|
||||
template <> void register_class(QxClass<server_infos_output> & t)
|
||||
{ t.data(& server_infos_output::current_date_time, "current_date_time"); }
|
||||
|
||||
template <> void register_class(QxClass<server_infos> & t)
|
||||
{ t.fct_0<void>(std::mem_fn(& server_infos::get_current_date_time), "get_current_date_time"); } // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
|
||||
|
||||
} // namespace qx
|
||||
|
||||
#ifdef _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void server_infos::get_current_date_time()
|
||||
{ qx::service::execute_client(this, "get_current_date_time"); }
|
||||
|
||||
#else // _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void server_infos::get_current_date_time()
|
||||
{
|
||||
server_infos_output_ptr output = server_infos_output_ptr(new server_infos_output());
|
||||
output->current_date_time = QDateTime::currentDateTime();
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
133
test/qxClientServer/qxService/src/service/user_service.cpp
Normal file
133
test/qxClientServer/qxService/src/service/user_service.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/service/user_service.h"
|
||||
|
||||
#include "../../include/dao/user_manager.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_service_input)
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_service_output)
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_service)
|
||||
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(user_service_input)
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(user_service_output)
|
||||
|
||||
namespace qx {
|
||||
|
||||
template <> void register_class(QxClass<user_service_input> & t)
|
||||
{
|
||||
t.data(& user_service_input::id, "id");
|
||||
t.data(& user_service_input::user, "user");
|
||||
t.data(& user_service_input::criteria, "criteria");
|
||||
}
|
||||
|
||||
template <> void register_class(QxClass<user_service_output> & t)
|
||||
{
|
||||
t.data(& user_service_output::user, "user");
|
||||
t.data(& user_service_output::list_of_users, "list_of_users");
|
||||
}
|
||||
|
||||
template <> void register_class(QxClass<user_service> & t)
|
||||
{
|
||||
t.fct_0<void>(std::mem_fn(& user_service::insert), "insert"); // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
|
||||
t.fct_0<void>(std::mem_fn(& user_service::update), "update");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::remove), "remove");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::remove_all), "remove_all");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::fetch_by_id), "fetch_by_id");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::fetch_all), "fetch_all");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::get_by_criteria), "get_by_criteria");
|
||||
}
|
||||
|
||||
} // namespace qx
|
||||
|
||||
#ifdef _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void user_service::insert() { qx::service::execute_client(this, "insert"); }
|
||||
void user_service::update() { qx::service::execute_client(this, "update"); }
|
||||
void user_service::remove() { qx::service::execute_client(this, "remove"); }
|
||||
void user_service::remove_all() { qx::service::execute_client(this, "remove_all"); }
|
||||
void user_service::fetch_by_id() { qx::service::execute_client(this, "fetch_by_id"); }
|
||||
void user_service::fetch_all() { qx::service::execute_client(this, "fetch_all"); }
|
||||
void user_service::get_by_criteria() { qx::service::execute_client(this, "get_by_criteria"); }
|
||||
|
||||
#else // _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void user_service::insert()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::insert()'"); return; }
|
||||
QSqlError err = user_manager().insert(input->user);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->user = input->user;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
void user_service::update()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::update()'"); return; }
|
||||
QSqlError err = user_manager().update(input->user);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); }
|
||||
else { setMessageReturn(true); }
|
||||
}
|
||||
|
||||
void user_service::remove()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::remove()'"); return; }
|
||||
user_ptr user_tmp = user_ptr(new user());
|
||||
user_tmp->id = input->id;
|
||||
QSqlError err = user_manager().remove(user_tmp);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); }
|
||||
else { setMessageReturn(true); }
|
||||
}
|
||||
|
||||
void user_service::remove_all()
|
||||
{
|
||||
QSqlError err = user_manager().remove_all();
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); }
|
||||
else { setMessageReturn(true); }
|
||||
}
|
||||
|
||||
void user_service::fetch_by_id()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::fetch_by_id()'"); return; }
|
||||
user_ptr user_output = user_ptr(new user());
|
||||
user_output->id = input->id;
|
||||
QSqlError err = user_manager().fetch_by_id(user_output);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->user = user_output;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
void user_service::fetch_all()
|
||||
{
|
||||
list_of_users_ptr list_of_users_output = list_of_users_ptr(new list_of_users());
|
||||
QSqlError err = user_manager().fetch_all(list_of_users_output);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->list_of_users = list_of_users_output;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
void user_service::get_by_criteria()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::get_by_criteria()'"); return; }
|
||||
list_of_users_ptr list_of_users_output = list_of_users_ptr(new list_of_users());
|
||||
QSqlError err = user_manager().get_by_criteria(input->criteria, list_of_users_output);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->list_of_users = list_of_users_output;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
4
test/qxClientServer/qxService/tools/build_debug.bat
Normal file
4
test/qxClientServer/qxService/tools/build_debug.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceClient.pro"
|
||||
nmake debug
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceServer.pro"
|
||||
nmake debug
|
||||
4
test/qxClientServer/qxService/tools/build_release.bat
Normal file
4
test/qxClientServer/qxService/tools/build_release.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceClient.pro"
|
||||
nmake release
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceServer.pro"
|
||||
nmake release
|
||||
4
test/qxClientServer/qxService/tools/clean_debug.bat
Normal file
4
test/qxClientServer/qxService/tools/clean_debug.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
cd "./debug/"
|
||||
del /F /S /Q "./*.*"
|
||||
cd "../"
|
||||
del /F /S /Q "./vc90.pdb"
|
||||
2
test/qxClientServer/qxService/tools/clean_release.bat
Normal file
2
test/qxClientServer/qxService/tools/clean_release.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
cd "./release/"
|
||||
del /F /S /Q "./*.*"
|
||||
Reference in New Issue
Block a user