Skip to content

Commit

Permalink
Merge pull request #54 from csthenry/dev
Browse files Browse the repository at this point in the history
已优化所有可优化项,或许是今年最后一个版本,诸多不顺,未来再见...
  • Loading branch information
csthenry authored Feb 21, 2023
2 parents fb1690b + 7dfb012 commit d90ed9b
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 90 deletions.
4 changes: 2 additions & 2 deletions MagicLightAssistant.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2023-02-18T15:17:26.8751705Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-02-21T13:06:43.7108611Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2023-02-18T15:17:27.0389119Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-02-21T13:06:43.8451300Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>
27 changes: 23 additions & 4 deletions activitymanagework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,33 @@ ActivityManageWork::ActivityManageWork(QObject *parent)
db_service.addDatabase(DB, "ActivityManageWork_DB");
db_service.addDatabase(DB_SECOND, "ActivityManageWork_DB_SECOND");

DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
DB.open();
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
if (isDisplay)
{
tabModel->select();
memberTabModel->select();
}
else
if(DB.isOpen())
DB.close();
});
heartBeat->start(MYSQL_TIME_OUT);
}

ActivityManageWork::~ActivityManageWork()
{
DB.close();
heartBeat->stop();
if(DB.isOpen())
DB.close();
}

void ActivityManageWork::working()
{
if (!DB.isOpen())
DB.open();
isDisplay = true;
tabModel->setTable("magic_activity");
tabModel->setSort(tabModel->fieldIndex("joinDate"), Qt::DescendingOrder);
tabModel->setEditStrategy(QSqlTableModel::OnRowChange);
Expand Down Expand Up @@ -73,8 +89,11 @@ void ActivityManageWork::updateActStatus()
qDebug() << "当前待新增的总学时:" + QString::number(curScore);
}

void ActivityManageWork::homeWorking()
void ActivityManageWork::homeWorking()//已废弃
{
if (!DB.isOpen())
DB.open();
isDisplay = true;
QDateTime m_curDateTime = QDateTime::fromSecsSinceEpoch(service::getWebTime()); //获取网络时间
QString curDateTime = m_curDateTime.toString("yyyy-MM-dd hh:mm:ss");
tabModel->clear();
Expand Down
2 changes: 2 additions & 0 deletions activitymanagework.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class ActivityManageWork : public QObject
void setType(int t);
void setFilter(int flag, const QString& filter);
float getCurScore();
bool isDisplay = false; //当前页正在展示

private:
QTimer *heartBeat;
float curScore = 0;
int type; //1为活动页面,2为活动管理页面
QString uid; //用于统计当前用户已完成活动
Expand Down
22 changes: 19 additions & 3 deletions attendmanagework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,33 @@ AttendManageWork::AttendManageWork(QObject *parent) : QObject(parent)
db_service.addDatabase(DB, "AttendManageWork_DB");
db_service.addDatabase(DB_SECOND, "AttendManageWork_DB_SECOND");

DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
DB.open();
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
if (isDisplay)
{
userModel->select();
attendModel->select();
}
else
if (DB.isOpen())
DB.close();
});
heartBeat->start(MYSQL_TIME_OUT);
}

AttendManageWork::~AttendManageWork()
{
DB.close();
heartBeat->stop();
if (DB.isOpen())
DB.close();
}

void AttendManageWork::working()
{
if (!DB.isOpen())
DB.open();
isDisplay = true;
//使用relationalModel时,这数据库不能关闭,否则外键的映射就没办法操作了...早知道不用relationalModel了,数据库连接很难管理...
userModel->setTable("magic_users");
userModel->setSort(userModel->fieldIndex("uid"), Qt::AscendingOrder); //升序排列
Expand Down
2 changes: 2 additions & 0 deletions attendmanagework.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AttendManageWork : public QObject
void setCombox(QComboBox* group, QComboBox* department);
void dataOperate(int type);
void setFilter(int type, const QString& filter);
bool isDisplay = false;
QSqlDatabase getDB();
private:
service db_service;
Expand All @@ -34,6 +35,7 @@ class AttendManageWork : public QObject
QSqlDatabase DB, DB_SECOND;
QStringList comboxItems_group, comboxItems_department;
QSqlRelationalTableModel *userModel, *attendModel;
QTimer* heartBeat;
void getComboxItems();
signals:
void attendManageWorkFinished();
Expand Down
22 changes: 19 additions & 3 deletions attendwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,30 @@ AttendWork::AttendWork(QObject *parent) : QObject(parent)
db_service.addDatabase(DB, "AttendWork_DB");
db_service.addDatabase(DB_SECOND, "AttendWork_DB_SECOND");

DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
DB.open();
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
if (isDisplay)
relTableModel->select();
else
if (DB.isOpen())
DB.close();
});
heartBeat->start(MYSQL_TIME_OUT);
}

AttendWork::~AttendWork()
{
DB.close();
heartBeat->stop();
if (DB.isOpen())
DB.close();
}

void AttendWork::working()
{
if (!DB.isOpen())
DB.open();
isDisplay = true;
relTableModel->setTable("magic_attendance");
relTableModel->setSort(relTableModel->fieldIndex("today"), Qt::DescendingOrder); //时间降序排列
relTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit); //手动提交
Expand Down Expand Up @@ -48,6 +61,9 @@ void AttendWork::working()

void AttendWork::homeChartWorking()
{
if (!DB.isOpen())
DB.open();
isDisplay = true;
relTableModel->setTable("magic_attendance");
relTableModel->setSort(relTableModel->fieldIndex("today"), Qt::DescendingOrder); //时间降序排列
relTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit); //手动提交
Expand Down
2 changes: 2 additions & 0 deletions attendwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AttendWork : public QObject
QJsonArray getWeekMyWorkTime();
QJsonArray getWeekAllWorkStatus();
QJsonArray getWeekWorkMem();
bool isDisplay = false;
private slots:
void submitAll(int type); //1代表签到,0代表签退
private:
Expand All @@ -41,6 +42,7 @@ private slots:
QSqlDatabase DB, DB_SECOND;
QSqlRelationalTableModel *relTableModel;
QJsonArray weekMyWorkTime, weekAllWorkStatus, weekWorkMem;
QTimer* heartBeat;
signals:
void attendWorkFinished();
void attendDone(bool);
Expand Down
4 changes: 2 additions & 2 deletions checkupdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

checkUpdate::checkUpdate()
{
CurVersion = "1.2.0.0"; //在此处定义软件当前版本
AutoUpdateToolVersion = 11200; //自动更新工具识别版本
CurVersion = "1.2.8.0"; //在此处定义软件当前版本
AutoUpdateToolVersion = 11280; //自动更新工具识别版本
writeVersion();
}
checkUpdate::~checkUpdate()
Expand Down
22 changes: 19 additions & 3 deletions groupmanagework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,33 @@ GroupManageWork::GroupManageWork(QObject *parent) : QObject(parent)
db_service.addDatabase(DB, "GroupManageWork_DB");
db_service.addDatabase(DB_SECOND, "GroupManageWork_DB_SECOND");

DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
DB.open();
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
if (isDisplay)
{
groupModel->select();
departmentModel->select();
}
else
if (DB.isOpen())
DB.close();
});
heartBeat->start(MYSQL_TIME_OUT);
}

GroupManageWork::~GroupManageWork()
{
DB.close();
heartBeat->stop();
if (DB.isOpen())
DB.close();
}

void GroupManageWork::working()
{
if (!DB.isOpen())
DB.open();
isDisplay = true;
groupModel->setTable("magic_group");
groupModel->setSort(groupModel->fieldIndex("group_id"), Qt::AscendingOrder); //升序排列
groupModel->setEditStrategy(QSqlTableModel::OnManualSubmit); //手动提交
Expand Down
2 changes: 2 additions & 0 deletions groupmanagework.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class GroupManageWork : public QObject
void setDepartmentModel(QSqlTableModel* department);
void submitAll(int type); //1代表提交用户组model,0为部门
void fixUser(int type, const QString& removedId);
bool isDisplay = false;
private:
service db_service;
QSqlDatabase DB, DB_SECOND;
QSqlTableModel *groupModel, *departmentModel;
QTimer* heartBeat;

signals:
void groupManageWorkFinished();
Expand Down
Loading

0 comments on commit d90ed9b

Please sign in to comment.