effectprocess 추가
git-svn-id: svn://192.168.0.12/source@306 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -20,7 +20,9 @@ SOURCES += main.cpp \
|
|||||||
sutilfunction.cpp \
|
sutilfunction.cpp \
|
||||||
sresultsender.cpp \
|
sresultsender.cpp \
|
||||||
seffectprocess.cpp \
|
seffectprocess.cpp \
|
||||||
snaverblog.cpp
|
snaverblog.cpp \
|
||||||
|
seffectstatistics.cpp \
|
||||||
|
snaverblogprocess.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
swebpage.h \
|
swebpage.h \
|
||||||
@@ -29,4 +31,5 @@ HEADERS += \
|
|||||||
sutilfunction.h \
|
sutilfunction.h \
|
||||||
seffectprocess.h \
|
seffectprocess.h \
|
||||||
seffectstatistics.h \
|
seffectstatistics.h \
|
||||||
snaverblog.h
|
snaverblog.h \
|
||||||
|
snaverblogprocess.h
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.3.0, 2016-10-27T19:07:05. -->
|
<!-- Written by QtCreator 3.3.0, 2016-10-28T18:38:52. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
<value type="int">0</value>
|
<value type="int">2</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">EffectProcess</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">EffectProcess</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/source/EffectProcess/EffectProcess.pro</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/source/EffectProcess/EffectProcess.pro</value>
|
||||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">"naver" "blog" "656563516" "http://blog.naver.com/mymisunzzzz/220737293892"</value>
|
||||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">EffectProcess.pro</value>
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">EffectProcess.pro</value>
|
||||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.1 MSVC2013 64bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.1 MSVC2013 64bit</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.1 MSVC2013 64bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.1 MSVC2013 64bit</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{481b3484-407d-4ae0-ba41-458f5e9d2bf2}</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{481b3484-407d-4ae0-ba41-458f5e9d2bf2}</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
@@ -595,15 +595,16 @@
|
|||||||
<value type="int">13</value>
|
<value type="int">13</value>
|
||||||
<value type="int">14</value>
|
<value type="int">14</value>
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">EffectProcess</value>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
|
||||||
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/source/EffectProcess/EffectProcess.pro</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">"naver" "blog" "656563516" "http://blog.naver.com/mymisunzzzz/220737293892"</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">EffectProcess.pro</value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
@@ -781,15 +782,16 @@
|
|||||||
<value type="int">13</value>
|
<value type="int">13</value>
|
||||||
<value type="int">14</value>
|
<value type="int">14</value>
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">EffectProcess</value>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
|
||||||
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/source/EffectProcess/EffectProcess.pro</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">"naver" "blog" "656563516" "http://blog.naver.com/mymisunzzzz/220737293892"</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">EffectProcess.pro</value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
@@ -967,15 +969,16 @@
|
|||||||
<value type="int">13</value>
|
<value type="int">13</value>
|
||||||
<value type="int">14</value>
|
<value type="int">14</value>
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">EffectProcess</value>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
|
||||||
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/source/EffectProcess/EffectProcess.pro</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">"naver" "blog" "656563516" "http://blog.naver.com/mymisunzzzz/220737293892"</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">EffectProcess.pro</value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
|||||||
@@ -1,35 +1,37 @@
|
|||||||
#include <QCoreApplication>
|
#include <QApplication>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "seffectprocess.h"
|
||||||
|
#include "snaverblogprocess.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace
|
std::shared_ptr<SEffectProcess>
|
||||||
|
getProcess(const QString& _platform_name, const QString& _platform_form,
|
||||||
|
const QString& _event_code, const QString& _url)
|
||||||
{
|
{
|
||||||
const QString DBNAME = "database";
|
if (_platform_name.trimmed() == "naver" && _platform_form.trimmed() == "blog")
|
||||||
|
return std::shared_ptr<SEffectProcess>(new SNaverBlogProcess(_platform_name, _platform_form, _event_code, _url));
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setApplicationName(QString("Chrome"));
|
a.setApplicationName(QString("Chrome"));
|
||||||
a.setApplicationVersion(QString("53.0.2785.143"));
|
a.setApplicationVersion(QString("53.0.2785.143"));
|
||||||
|
|
||||||
QSettings settings(QString("effect.ini"), QSettings::IniFormat);
|
if (argc != 5)
|
||||||
settings.setIniCodec("UTF-8");
|
{
|
||||||
settings.beginGroup("database");
|
std::cout << "x!@#!@#!@#e010!@#checkArgument";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
QString strHostname = settings.value("host", "182.162.171.147").toString();
|
std::shared_ptr<SEffectProcess> process = getProcess(argv[1], argv[2], argv[3], argv[4]);
|
||||||
QString strUsername = settings.value("user", "admin").toString();
|
|
||||||
QString strPassword = settings.value("pass", "admin123").toString();
|
|
||||||
QString strDBName = settings.value("name", "bigbird").toString();
|
|
||||||
|
|
||||||
settings.endGroup();
|
process->run(argv[4]);
|
||||||
|
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", DBNAME);
|
|
||||||
db.setHostName(strHostname);
|
|
||||||
db.setUserName(strUsername);
|
|
||||||
db.setPassword(strPassword);
|
|
||||||
db.setDatabaseName(strDBName);
|
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,70 @@
|
|||||||
#include "seffectprocess.h"
|
#include "seffectprocess.h"
|
||||||
#include "sutilclass.h"
|
#include "sutilclass.h"
|
||||||
#include "sutilfunction.h"
|
#include "sutilfunction.h"
|
||||||
|
#include <QDebug>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const QString SEPERATOR = "!@#";
|
const QString SEPERATOR = "!@#";
|
||||||
}
|
}
|
||||||
|
|
||||||
SEffectProcess::SEffectProcess(const QString& _platform_name, const QString& _platform_form,
|
SEffectProcess::SEffectProcess(const QString& _platform_name, const QString& _platform_form,
|
||||||
const QString& _event_code, const QString& _url)
|
const QString& _event_code, const QString& _url): m_pResultSender(new SResultSender)
|
||||||
{
|
{
|
||||||
m_pParam[E_PARAM_URL] = _url;
|
m_pParam[E_PARAM_URL] = _url;
|
||||||
m_pParam[E_PARAM_EVENT_CODE] = _event_code;
|
m_pParam[E_PARAM_EVENT_CODE] = _event_code;
|
||||||
m_pParam[E_PARAM_PLATFORM_FORM] = _platform_form;
|
m_pParam[E_PARAM_PLATFORM_FORM] = _platform_form;
|
||||||
m_pParam[E_PARAM_PLATFORM_NAME] = _platform_name;
|
m_pParam[E_PARAM_PLATFORM_NAME] = _platform_name;
|
||||||
|
initConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SEffectProcess::eventCode()
|
||||||
|
{
|
||||||
|
return m_pParam[E_PARAM_EVENT_CODE].toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SEffectProcess::slotOk()
|
void SEffectProcess::slotOk()
|
||||||
{
|
{
|
||||||
|
qDebug() << "slotOk";
|
||||||
std::cout << 'o' << SEPERATOR.toStdString() << m_pParam[E_PARAM_EVENT_CODE].toStdString() <<
|
std::cout << 'o' << SEPERATOR.toStdString() << m_pParam[E_PARAM_EVENT_CODE].toStdString() <<
|
||||||
SEPERATOR.toStdString() << m_pParam[E_PARAM_URL].toStdString();
|
SEPERATOR.toStdString() << m_pParam[E_PARAM_URL].toStdString();
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SEffectProcess::slotError(E_ERROR_CODE _error, const QString &_msg)
|
void SEffectProcess::slotError(E_ERROR_CODE _error, const QString& _msg)
|
||||||
{
|
{
|
||||||
|
qDebug() << "slotError";
|
||||||
|
qDebug() << _msg;
|
||||||
std::cout << 'x' << SEPERATOR.toStdString() << m_pParam[E_PARAM_EVENT_CODE].toStdString()
|
std::cout << 'x' << SEPERATOR.toStdString() << m_pParam[E_PARAM_EVENT_CODE].toStdString()
|
||||||
<< SEPERATOR.toStdString() << m_pParam[E_PARAM_URL].toStdString() << EnumErrorCodetostrErrorCode(_error).toStdString()
|
<< SEPERATOR.toStdString() << m_pParam[E_PARAM_URL].toStdString()
|
||||||
|
<< SEPERATOR.toStdString() << EnumErrorCodetostrErrorCode(_error).toStdString()
|
||||||
<< SEPERATOR.toStdString() << _msg.toStdString();
|
<< SEPERATOR.toStdString() << _msg.toStdString();
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SEffectProcess::slotDataOk(const EffectData& _data)
|
||||||
|
{
|
||||||
|
qDebug() << "slotDataOk";
|
||||||
|
State_s1_effect result = processData(_data);
|
||||||
|
qDebug() << "slotDataOK asdf";
|
||||||
|
if (send(result))
|
||||||
|
slotOk();
|
||||||
|
/*
|
||||||
|
else
|
||||||
|
slotError(E_ERROR_CODE::DB_UNKNOWN_ERROR, "");
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void SEffectProcess::initConnect()
|
||||||
|
{
|
||||||
|
QObject::connect(&(*m_pResultSender), &SResultSender::signalError,
|
||||||
|
this, &SEffectProcess::slotError);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SEffectProcess::send(const State_s1_effect& _result)
|
||||||
|
{
|
||||||
|
return m_pResultSender->send(_result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "sutilclass.h"
|
#include "sutilclass.h"
|
||||||
|
#include "sresultsender.h"
|
||||||
|
|
||||||
enum E_PARAM
|
enum E_PARAM
|
||||||
{
|
{
|
||||||
@@ -13,6 +14,7 @@ enum E_PARAM
|
|||||||
E_PARAM_MAX
|
E_PARAM_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EffectData;
|
||||||
|
|
||||||
class SEffectProcess:public QObject
|
class SEffectProcess:public QObject
|
||||||
{
|
{
|
||||||
@@ -21,16 +23,29 @@ class SEffectProcess:public QObject
|
|||||||
public:
|
public:
|
||||||
SEffectProcess(const QString& _platform_name, const QString& _platform_form,
|
SEffectProcess(const QString& _platform_name, const QString& _platform_form,
|
||||||
const QString& _event_code, const QString& _url);
|
const QString& _event_code, const QString& _url);
|
||||||
virtual void run() = 0;
|
virtual void run(const QString& _url) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual State_s1_effect processData(const EffectData& _data) = 0;
|
||||||
|
bool send(const State_s1_effect& _result);
|
||||||
|
int eventCode();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotOk();
|
void slotOk();
|
||||||
void slotError(E_ERROR_CODE _error, const QString& _msg);
|
void slotError(E_ERROR_CODE _error, const QString& _msg);
|
||||||
|
void slotDataOk(const EffectData& _data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initConnect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_pParam[E_PARAM_MAX];
|
QString m_pParam[E_PARAM_MAX];
|
||||||
|
std::unique_ptr<SResultSender> m_pResultSender;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // SEFFECTPROCESS
|
#endif // SEFFECTPROCESS
|
||||||
|
|
||||||
|
|||||||
72
EffectProcess/seffectstatistics.cpp
Normal file
72
EffectProcess/seffectstatistics.cpp
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#include "seffectstatistics.h"
|
||||||
|
#include <QSet>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
int getReplyCount(const EffectData& _data)
|
||||||
|
{
|
||||||
|
QSet<QString> set_id;
|
||||||
|
foreach (const DataForm& row, _data.reply)
|
||||||
|
{
|
||||||
|
if (_data.body.data[ARTICLE_ID].trimmed() != row.data[ARTICLE_ID].trimmed())
|
||||||
|
set_id.insert(row.data[ARTICLE_ID].trimmed());
|
||||||
|
}
|
||||||
|
return set_id.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getlikeCount(const EffectData& _data)
|
||||||
|
{
|
||||||
|
//qDebug() << "getlikeCount:" << _data.body.data[REPLY_URL];
|
||||||
|
return _data.body.data[REPLY_URL].toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getViewCount(const EffectData& _data)
|
||||||
|
{
|
||||||
|
return _data.body.data[ARTICLE_HIT].trimmed().replace(",","").toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getViewBuzz(const EffectData& _data)
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString getReplyBuzz(const EffectData& _data)
|
||||||
|
{
|
||||||
|
QMap<QDate, int> mapDate;
|
||||||
|
|
||||||
|
QDate firstDate = QDateTime::fromString(_data.body.data[ARTICLE_DATE].trimmed().replace("T", " ").replace(".","-").replace("- "," "), "yyyy-MM-dd hh:mm:ss").date();
|
||||||
|
QDate lastDate = QDate::currentDate();
|
||||||
|
/*
|
||||||
|
qDebug() << _data.body.data[ARTICLE_DATE];
|
||||||
|
qDebug() << "firstDate:" << firstDate.toString("yyyy-MM-dd");
|
||||||
|
qDebug() << "lastDate:" << lastDate.toString("yyyy-MM-dd");
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (QDate date = firstDate; date <= lastDate; date = date.addDays(1))
|
||||||
|
{
|
||||||
|
mapDate.insert(date, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (auto &row, _data.reply)
|
||||||
|
{
|
||||||
|
QDate date = QDateTime::fromString(row.data[ARTICLE_DATE].trimmed().replace("T", " ").replace(".","-").replace("- "," "), "yyyy-MM-dd hh:mm:ss").date();
|
||||||
|
if (!mapDate.contains(date))
|
||||||
|
//mapDate.insert(date, 0);
|
||||||
|
continue;
|
||||||
|
mapDate[date]++;
|
||||||
|
}
|
||||||
|
QJsonObject jObj;
|
||||||
|
for (auto iter = mapDate.cbegin(); iter != mapDate.cend(); ++iter)
|
||||||
|
{
|
||||||
|
jObj[iter.key().toString("yyyyMMdd")] = iter.value();
|
||||||
|
}
|
||||||
|
QJsonDocument jDoc(jObj);
|
||||||
|
QString result = jDoc.toJson();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1,5 +1,22 @@
|
|||||||
#ifndef SEFFECTSTATISTICS
|
#ifndef SEFFECTSTATISTICS
|
||||||
#define SEFFECTSTATISTICS
|
#define SEFFECTSTATISTICS
|
||||||
|
#include "sutilclass.h"
|
||||||
|
|
||||||
|
|
||||||
|
int getReplyCount(const EffectData& _data);
|
||||||
|
|
||||||
|
|
||||||
|
int getlikeCount(const EffectData& _data);
|
||||||
|
|
||||||
|
|
||||||
|
int getViewCount(const EffectData& _data);
|
||||||
|
|
||||||
|
|
||||||
|
QString getViewBuzz(const EffectData& _data);
|
||||||
|
|
||||||
|
|
||||||
|
QString getReplyBuzz(const EffectData& _data);
|
||||||
|
|
||||||
|
|
||||||
#endif // SEFFECTSTATISTICS
|
#endif // SEFFECTSTATISTICS
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <QChar>
|
#include <QChar>
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const int TIME = 4000;//4 second
|
const int TIME = 3000;//3 second
|
||||||
}
|
}
|
||||||
|
|
||||||
QWebElement Find(const QWebElement& _FindElement, const QString& _strElement = "",
|
QWebElement Find(const QWebElement& _FindElement, const QString& _strElement = "",
|
||||||
@@ -78,28 +78,40 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SNaverBlog::SNaverBlog(std::shared_ptr<QWebPage> _page):m_pWebPage(_page),
|
SNaverBlog::SNaverBlog(std::shared_ptr<SWebPage> _page):m_pWebPage(_page),
|
||||||
m_eMode(E_CRAWL_MODE::BODY), m_bReplyProcessed(false), m_bBodyProcessed(false),
|
m_eMode(E_CRAWL_MODE::BODY), m_bReplyProcessed(false), m_bBodyProcessed(false),
|
||||||
//m_bReplyProcessing(false), m_bBodyProcessing(false),
|
//m_bReplyProcessing(false), m_bBodyProcessing(false),
|
||||||
m_pNetworkRequest(new QNetworkRequest), m_nBodyRetry(3)
|
m_pNetworkRequest(new QNetworkRequest), m_nBodyRetry(3)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (!_page)
|
if (!_page)
|
||||||
_page = std::make_shared<QWebPage>(new QWebPage);
|
m_pWebPage = std::make_shared<SWebPage>(new SWebPage);
|
||||||
|
|
||||||
initConnect();
|
initConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNaverBlog::initConnect()
|
void SNaverBlog::initConnect()
|
||||||
{
|
{
|
||||||
QObject::connect(&(*m_pWebPage), &QWebPage::loadFinished,
|
QObject::connect(&(*m_pWebPage), &SWebPage::loadFinished,
|
||||||
this, &SNaverBlog::slotLoadFinished);
|
this, &SNaverBlog::slotLoadFinished);
|
||||||
|
QObject::connect(&(*m_pWebPage), &SWebPage::signalAlert,
|
||||||
|
this, &SNaverBlog::slotAlert);
|
||||||
|
QObject::connect(&(*m_pWebPage), &SWebPage::loadProgress,
|
||||||
|
[](int n){ qDebug() << n; });
|
||||||
|
QObject::connect(&(*m_pWebPage), &SWebPage::loadStarted,
|
||||||
|
[](){ qDebug() << "loadstart"; });
|
||||||
|
|
||||||
m_pWebPage->settings()->setAttribute(QWebSettings::AutoLoadImages, false);
|
m_pWebPage->settings()->setAttribute(QWebSettings::AutoLoadImages, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SNaverBlog::slotAlert(const QString& msg)
|
||||||
|
{
|
||||||
|
emit signalError(E_ERROR_CODE::DELETED_URL_ERROR, msg);
|
||||||
|
}
|
||||||
|
|
||||||
void SNaverBlog::go(const QString &_url, E_CRAWL_MODE _mode)
|
void SNaverBlog::go(const QString &_url, E_CRAWL_MODE _mode)
|
||||||
{
|
{
|
||||||
|
qDebug() << _url;
|
||||||
m_eMode = _mode;
|
m_eMode = _mode;
|
||||||
QUrl url(_url.trimmed());
|
QUrl url(_url.trimmed());
|
||||||
if (_mode == E_CRAWL_MODE::BODY)
|
if (_mode == E_CRAWL_MODE::BODY)
|
||||||
@@ -108,47 +120,66 @@ void SNaverBlog::go(const QString &_url, E_CRAWL_MODE _mode)
|
|||||||
if (url.scheme().isEmpty())
|
if (url.scheme().isEmpty())
|
||||||
url.setScheme("http");
|
url.setScheme("http");
|
||||||
|
|
||||||
|
QNetworkRequest requests;
|
||||||
|
requests.setUrl(url);
|
||||||
|
requests.setRawHeader("Accept-Language",
|
||||||
|
"ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4,zh-CN;q=0.2,zh;q=0.2");
|
||||||
|
m_pWebPage->mainFrame()->load(requests);
|
||||||
|
/*
|
||||||
m_pNetworkRequest->setUrl(url);
|
m_pNetworkRequest->setUrl(url);
|
||||||
m_pNetworkRequest->setRawHeader(
|
m_pNetworkRequest->setRawHeader(
|
||||||
"Accept-Language",
|
"Accept-Language",
|
||||||
"ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4,zh-CN;q=0.2,zh;q=0.2"
|
"ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4,zh-CN;q=0.2,zh;q=0.2"
|
||||||
);
|
);
|
||||||
m_pWebPage->mainFrame()->load(*m_pNetworkRequest);
|
m_pWebPage->mainFrame()->load(*m_pNetworkRequest);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNaverBlog::slotLoadFinished(bool ok)
|
void SNaverBlog::slotLoadFinished(bool ok)
|
||||||
{
|
{
|
||||||
|
qDebug() << "slotLoadFinished";
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
signalError(E_ERROR_CODE::UNKNOWN_ERROR, "UnkownError/BlockError/ProxyError");
|
signalError(E_ERROR_CODE::UNKNOWN_ERROR, "UnkownError/BlockError/ProxyError");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
qDebug() << "slotLoadFinished";
|
||||||
switch(m_eMode)
|
switch(m_eMode)
|
||||||
{
|
{
|
||||||
case E_CRAWL_MODE::BODY:
|
case E_CRAWL_MODE::BODY:
|
||||||
{
|
{
|
||||||
Lock lock(&m_mutexBody);
|
Lock lock(&m_mutexBody);
|
||||||
|
|
||||||
if (m_bBodyProcessed)
|
if (m_bBodyProcessed)
|
||||||
return;
|
return;
|
||||||
|
qDebug() << "body loadfinished";
|
||||||
|
|
||||||
m_efData.body = getBody();
|
m_efData.body = getBody();
|
||||||
if (!check(m_efData.body) && m_nBodyRetry-- > 0)
|
if (!check(m_efData.body) && m_nBodyRetry-- > 0)
|
||||||
{
|
{
|
||||||
QTimer::singleShot(TIME, this, SLOT(slotLoadFinished(bool)));
|
//QTimer::singleShot(TIME, this, SLOT(slotLoadFinished(bool)));
|
||||||
|
QTimer::singleShot(TIME, [&](){ slotLoadFinished(true);});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << m_efData.body.data[ARTICLE_ID];
|
||||||
|
qDebug() << m_efData.body.data[ARTICLE_URL];
|
||||||
|
qDebug() << m_efData.body.data[ARTICLE_PROFILE];
|
||||||
|
qDebug() << m_efData.body.data[ARTICLE_NICKNAME];
|
||||||
|
qDebug() << m_efData.body.data[ARTICLE_HIT];
|
||||||
|
qDebug() << m_efData.body.data[REPLY_URL];
|
||||||
|
qDebug() << m_efData.body.data[ARTICLE_TITLE];
|
||||||
m_bBodyProcessed = true;
|
m_bBodyProcessed = true;
|
||||||
break;
|
qDebug() << "body loadfinished";
|
||||||
|
qDebug() << makeReplyUrl(m_strUrl);
|
||||||
|
go(makeReplyUrl(m_strUrl), E_CRAWL_MODE::REPLY);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case E_CRAWL_MODE::REPLY:
|
case E_CRAWL_MODE::REPLY:
|
||||||
{
|
{
|
||||||
Lock lock(&m_mutexReply);
|
Lock lock(&m_mutexReply);
|
||||||
|
|
||||||
if (m_bReplyProcessed)
|
if (m_bReplyProcessed)
|
||||||
return;
|
return;
|
||||||
|
qDebug() << "reply loadfinished";
|
||||||
|
|
||||||
m_efData.reply = getReply();
|
m_efData.reply = getReply();
|
||||||
m_bReplyProcessed = true;
|
m_bReplyProcessed = true;
|
||||||
@@ -213,7 +244,10 @@ DataForm SNaverBlog::getBody()
|
|||||||
|
|
||||||
bool SNaverBlog::check(const DataForm &_data)
|
bool SNaverBlog::check(const DataForm &_data)
|
||||||
{
|
{
|
||||||
return true;
|
if (_data.data[ARTICLE_PROFILE].isEmpty() || _data.data[REPLY_URL].isEmpty())
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SNaverBlog::check(const QVector<DataForm> &_data)
|
bool SNaverBlog::check(const QVector<DataForm> &_data)
|
||||||
@@ -224,9 +258,157 @@ bool SNaverBlog::check(const QVector<DataForm> &_data)
|
|||||||
QVector<DataForm> SNaverBlog::getReply()
|
QVector<DataForm> SNaverBlog::getReply()
|
||||||
{
|
{
|
||||||
QVector<DataForm> data;
|
QVector<DataForm> data;
|
||||||
|
QWebFrame* frame = m_pWebPage->mainFrame();
|
||||||
|
|
||||||
|
QWebElement group = Find(frame->documentElement(),"ul","id","commentList");
|
||||||
|
QWebElementCollection elements = group.findAll("li");
|
||||||
|
QString strParent,strDate,strNick,strComm,strUrl,strId;
|
||||||
|
QStringList strList = m_strUrl.split("/");
|
||||||
|
QString strCommUrl;
|
||||||
|
for (int i=0; i < strList.size() - 1; i++)
|
||||||
|
strUrl += strList.at(i) + "/";
|
||||||
|
|
||||||
|
{
|
||||||
|
int nStartIdPos = m_strUrl.indexOf("blogId=") + QString("blogId=").size();
|
||||||
|
int nEndIdPos = m_strUrl.indexOf('&', nStartIdPos);
|
||||||
|
strUrl += m_strUrl.mid(nStartIdPos, nEndIdPos - nStartIdPos) + '/';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int nStartIdPos = m_strUrl.indexOf("logNo=") + QString("logNo=").size();
|
||||||
|
int nEndIdPos = m_strUrl.indexOf('&', nStartIdPos);
|
||||||
|
strUrl += m_strUrl.mid(nStartIdPos, nEndIdPos - nStartIdPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
int nCount=0;
|
||||||
|
foreach (QWebElement element, elements)
|
||||||
|
{
|
||||||
|
if (element.attribute("class") == "_countableComment ")
|
||||||
|
{
|
||||||
|
strNick = strParent = GetSafeUtf(Find(element,"a","class","nick pcol2").toPlainText());
|
||||||
|
strDate = Find(element,"span","class","date fil5 pcol2").toPlainText();
|
||||||
|
strComm = Find(element,"dd","class","comm pcol2").toPlainText();
|
||||||
|
|
||||||
|
strCommUrl = Find(element,"a","class","nick pcol2").attribute("href");
|
||||||
|
if(strCommUrl.left(QString("http://blog.naver.com").length()).compare("http://blog.naver.com") == 0)
|
||||||
|
strId = strCommUrl.split("/").at(3).trimmed();
|
||||||
|
if(strCommUrl.right(QString("blog.me").length()).compare("blog.me") == 0)
|
||||||
|
strId = strCommUrl.split("/").at(2).split(".").at(0).trimmed();
|
||||||
|
if(strCommUrl.left(1) == "/")
|
||||||
|
{
|
||||||
|
QStringList strList = strCommUrl.split("&");
|
||||||
|
foreach(QString str, strList)
|
||||||
|
{
|
||||||
|
if(str.left(3) == "id=")
|
||||||
|
{
|
||||||
|
strId = str.right(str.length() - 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
strComm = GetSafeUtf(strComm);
|
||||||
|
if (strComm.isEmpty()== false)
|
||||||
|
{
|
||||||
|
strComm.replace("'","\\'");
|
||||||
|
strComm.replace("\"","\\\"");
|
||||||
|
strComm = strComm.trimmed();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int nStartIdPos = m_strUrl.indexOf("blogId=") + QString("blogId=").size();
|
||||||
|
int nEndIdPos = m_strUrl.indexOf('&', nStartIdPos);
|
||||||
|
DataForm form;
|
||||||
|
form.data[ARTICLE_URL] = strUrl.toUtf8();
|
||||||
|
form.data[ARTICLE_ID] = strId.trimmed().toUtf8();
|
||||||
|
form.data[PLATFORM_ID] = m_strUrl.mid(nStartIdPos, nEndIdPos - nStartIdPos);
|
||||||
|
form.data[ARTICLE_NICKNAME] = strNick.toUtf8();
|
||||||
|
form.data[ARTICLE_DATA] = strComm.toUtf8();
|
||||||
|
form.data[ARTICLE_DATE] = strDate.toUtf8();
|
||||||
|
form.data[REPLY_URL] = m_strUrl.toUtf8();
|
||||||
|
form.data[ARTICLE_ORDER] = QString::number(nCount++);
|
||||||
|
data.append(form);
|
||||||
|
/*
|
||||||
|
query.bindValue(":URL", strUrl.toUtf8());
|
||||||
|
query.bindValue(":PLATFORMID",m_strUrl.mid(nStartIdPos, nEndIdPos - nStartIdPos));
|
||||||
|
query.bindValue(":NICK",strNick.toUtf8());
|
||||||
|
query.bindValue(":DATA",strComm.toUtf8());
|
||||||
|
query.bindValue(":DATE",strDate.toUtf8());
|
||||||
|
query.bindValue(":URLREPLY",m_strUrl.toUtf8());
|
||||||
|
query.bindValue(":ROWNUM",(nCount++));
|
||||||
|
|
||||||
|
if (query.exec()==false)
|
||||||
|
cout << "error : " << query.lastError().text().toStdString();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (element.attribute("class") == "reply _countableComment ")
|
||||||
|
{
|
||||||
|
strNick = Find(element,"a","class","nick pcol2").toPlainText();
|
||||||
|
strDate = Find(element,"span","class","date fil5 pcol2").toPlainText();
|
||||||
|
QWebElement subElement = Find(element,"dd","class","comm pcol2");
|
||||||
|
QString subNick = Find(subElement,"a","class","nick pcol2").toPlainText();
|
||||||
|
strComm = subElement.toPlainText();
|
||||||
|
|
||||||
|
strCommUrl = Find(element,"a","class","nick pcol2").attribute("href");
|
||||||
|
if(strCommUrl.left(QString("http://blog.naver.com").length()).compare("http://blog.naver.com") == 0)
|
||||||
|
strId = strCommUrl.split("/").at(3).trimmed();
|
||||||
|
if(strCommUrl.right(QString("blog.me").length()).compare("blog.me") == 0)
|
||||||
|
strId = strCommUrl.split("/").at(2).split(".").at(0).trimmed();
|
||||||
|
if(strCommUrl.left(1) == "/")
|
||||||
|
{
|
||||||
|
QStringList strList = strCommUrl.split("&");
|
||||||
|
foreach(QString str, strList)
|
||||||
|
{
|
||||||
|
if(str.left(3) == "id=")
|
||||||
|
{
|
||||||
|
strId = str.right(str.length() - 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(subNick.isEmpty() == false)
|
||||||
|
strComm = strComm.right(strComm.size()-subNick.size()-1);
|
||||||
|
|
||||||
|
if (strComm.isEmpty() == false)
|
||||||
|
{
|
||||||
|
strComm = GetSafeUtf(strComm);
|
||||||
|
strComm.replace("'","\\'");
|
||||||
|
strComm.replace("\"","\\\"");
|
||||||
|
strComm = strComm.trimmed();
|
||||||
|
|
||||||
|
int nStartIdPos = m_strUrl.indexOf("blogId=") + QString("blogId=").size();
|
||||||
|
int nEndIdPos = m_strUrl.indexOf('&', nStartIdPos);
|
||||||
|
DataForm form;
|
||||||
|
form.data[ARTICLE_ID] = strId;
|
||||||
|
|
||||||
|
form.data[ARTICLE_URL] = strUrl.toUtf8();
|
||||||
|
form.data[PLATFORM_ID] = m_strUrl.mid(nStartIdPos, nEndIdPos - nStartIdPos);
|
||||||
|
form.data[ARTICLE_NICKNAME] = strNick.toUtf8();
|
||||||
|
form.data[ARTICLE_DATA] = strComm.toUtf8();
|
||||||
|
form.data[ARTICLE_DATE] = strDate.toUtf8();
|
||||||
|
form.data[ARTICLE_PARENT] = strParent.toUtf8();
|
||||||
|
form.data[REPLY_URL] = m_strUrl.toUtf8();
|
||||||
|
form.data[ARTICLE_ORDER] = QString::number(nCount++);
|
||||||
|
|
||||||
|
data.append(form);
|
||||||
|
/*
|
||||||
|
query.bindValue(":URL",strUrl.toUtf8());
|
||||||
|
query.bindValue(":PLATFORMID",m_strUrl.mid(nStartIdPos, nEndIdPos - nStartIdPos));
|
||||||
|
query.bindValue(":NICK",strNick.toUtf8());
|
||||||
|
query.bindValue(":DATA",strComm.toUtf8());
|
||||||
|
query.bindValue(":DATE",strDate.toUtf8());
|
||||||
|
query.bindValue(":PARENT",strParent.toUtf8());
|
||||||
|
query.bindValue(":URLREPLY",m_strUrl.toUtf8());
|
||||||
|
query.bindValue(":ROWNUM",(nCount++));
|
||||||
|
if (query.exec()==false)
|
||||||
|
{
|
||||||
|
cout << "error : " << query.lastError().text().toStdString();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +483,7 @@ void SNaverBlog::getBody(QWebFrame *frame, DataForm &_data)
|
|||||||
if(_data.data[ARTICLE_NICKNAME].length() == 0)
|
if(_data.data[ARTICLE_NICKNAME].length() == 0)
|
||||||
_data.data[ARTICLE_NICKNAME] = _data.data[ARTICLE_ID];
|
_data.data[ARTICLE_NICKNAME] = _data.data[ARTICLE_ID];
|
||||||
|
|
||||||
image = Find(profile,"img","alt","프로필 이미지");
|
image = Find(profile,"img","alt","ÇÁ·ÎÇÊ À̹ÌÁö");
|
||||||
strProfile = Find(profile, "p", "class", "caption align").toPlainText().trimmed();
|
strProfile = Find(profile, "p", "class", "caption align").toPlainText().trimmed();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,44 +3,10 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "sutilclass.h"
|
#include "sutilclass.h"
|
||||||
#include <QWebPage>
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include "swebpage.h"
|
||||||
|
|
||||||
enum E_COLUMN
|
|
||||||
{
|
|
||||||
PLATFORM_NAME = 0,
|
|
||||||
PLATFORM_FORM,
|
|
||||||
PLATFORM_TITLE,
|
|
||||||
ARTICLE_FORM,
|
|
||||||
ARTICLE_PARENT,
|
|
||||||
ARTICLE_ID,
|
|
||||||
ARTICLE_NICKNAME,
|
|
||||||
ARTICLE_TITLE,
|
|
||||||
ARTICLE_DATA,
|
|
||||||
ARTICLE_URL,
|
|
||||||
ARTICLE_HIT,
|
|
||||||
ARTICLE_DATE,
|
|
||||||
ARTICLE_ORDER,
|
|
||||||
ARTICLE_PROFILE,
|
|
||||||
ARTICLE_PROFILEURL,
|
|
||||||
PLATFORM_ID,
|
|
||||||
KEYWORD_ID,
|
|
||||||
REPLY_URL,
|
|
||||||
ETC,
|
|
||||||
TOTAL_COUNT,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DataForm
|
|
||||||
{
|
|
||||||
QString data[TOTAL_COUNT];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EffectData
|
|
||||||
{
|
|
||||||
DataForm body;
|
|
||||||
QVector<DataForm> reply;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class E_CRAWL_MODE
|
enum class E_CRAWL_MODE
|
||||||
{
|
{
|
||||||
@@ -53,7 +19,7 @@ class SNaverBlog: public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SNaverBlog(std::shared_ptr<QWebPage> _page = nullptr);
|
explicit SNaverBlog(std::shared_ptr<SWebPage> _page = nullptr);
|
||||||
void go(const QString& _url, E_CRAWL_MODE _mode = E_CRAWL_MODE::BODY);
|
void go(const QString& _url, E_CRAWL_MODE _mode = E_CRAWL_MODE::BODY);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -69,16 +35,21 @@ signals:
|
|||||||
void signalDataOk(const EffectData& _data);
|
void signalDataOk(const EffectData& _data);
|
||||||
void signalError(E_ERROR_CODE _error, const QString& _msg);
|
void signalError(E_ERROR_CODE _error, const QString& _msg);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotLoadFinished(bool ok = true);
|
void slotLoadFinished(bool ok = true);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotAlert(const QString& msg);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QWebPage> m_pWebPage;
|
std::shared_ptr<SWebPage> m_pWebPage;
|
||||||
std::unique_ptr<QNetworkRequest> m_pNetworkRequest;
|
std::unique_ptr<QNetworkRequest> m_pNetworkRequest;
|
||||||
E_CRAWL_MODE m_eMode;
|
E_CRAWL_MODE m_eMode;
|
||||||
|
bool m_bReplyProcessed;
|
||||||
|
|
||||||
bool m_bBodyProcessed;
|
bool m_bBodyProcessed;
|
||||||
bool m_bReplyProcessed;
|
|
||||||
QMutex m_mutexBody;
|
QMutex m_mutexBody;
|
||||||
QMutex m_mutexReply;
|
QMutex m_mutexReply;
|
||||||
/*
|
/*
|
||||||
|
|||||||
34
EffectProcess/snaverblogprocess.cpp
Normal file
34
EffectProcess/snaverblogprocess.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include "snaverblogprocess.h"
|
||||||
|
#include "seffectstatistics.h"
|
||||||
|
#include <QDebug>
|
||||||
|
SNaverBlogProcess::SNaverBlogProcess(const QString& _platform_name, const QString& _platform_form,
|
||||||
|
const QString& _event_code, const QString& _url):
|
||||||
|
SEffectProcess(_platform_name, _platform_form, _event_code, _url), m_pSNaverBlog(new SNaverBlog)
|
||||||
|
{
|
||||||
|
connect(&(*m_pSNaverBlog), &SNaverBlog::signalDataOk, this, &SNaverBlogProcess::slotDataOk);
|
||||||
|
}
|
||||||
|
|
||||||
|
State_s1_effect SNaverBlogProcess::processData(const EffectData& _data)
|
||||||
|
{
|
||||||
|
State_s1_effect result;
|
||||||
|
|
||||||
|
result.event_num = eventCode();
|
||||||
|
qDebug() << result.event_num;
|
||||||
|
|
||||||
|
result.likecount = getlikeCount(_data);
|
||||||
|
qDebug() << result.likecount;
|
||||||
|
result.replybuzz = getReplyBuzz(_data);
|
||||||
|
qDebug() << "replybuzz";
|
||||||
|
result.viewcount = getViewCount(_data);
|
||||||
|
qDebug() << result.viewcount;
|
||||||
|
|
||||||
|
result.replycount = getReplyCount(_data);
|
||||||
|
|
||||||
|
qDebug() << result.replycount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SNaverBlogProcess::run(const QString& _url)
|
||||||
|
{
|
||||||
|
m_pSNaverBlog->go(_url);
|
||||||
|
}
|
||||||
25
EffectProcess/snaverblogprocess.h
Normal file
25
EffectProcess/snaverblogprocess.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef SNAVERBLOGPROCESS
|
||||||
|
#define SNAVERBLOGPROCESS
|
||||||
|
|
||||||
|
#include "seffectprocess.h"
|
||||||
|
#include "snaverblog.h"
|
||||||
|
|
||||||
|
class SNaverBlogProcess: public SEffectProcess
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SNaverBlogProcess(const QString& _platform_name, const QString& _platform_form,
|
||||||
|
const QString& _event_code, const QString& _url);
|
||||||
|
void run(const QString& _url) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual State_s1_effect processData(const EffectData& _data) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<SNaverBlog> m_pSNaverBlog;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SNAVERBLOGPROCESS
|
||||||
|
|
||||||
@@ -4,6 +4,9 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QDebug>
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const QString SEPERATOR = "!@#";
|
const QString SEPERATOR = "!@#";
|
||||||
@@ -45,19 +48,19 @@ bool SResultSender::send(const State_s1_effect& _result)
|
|||||||
|
|
||||||
if (!db.open())
|
if (!db.open())
|
||||||
{
|
{
|
||||||
emit error(E_ERROR_CODE::DB_OPEN_ERROR, db.lastError().text());
|
emit signalError(E_ERROR_CODE::DB_OPEN_ERROR, db.lastError().text());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBContainer container(db);
|
DBContainer container(db);
|
||||||
|
|
||||||
QString strQuery = "delete from stats_s1_effect where eventcode = " + QString::number(_result.event_num);
|
QString strQuery = "delete from stats_s1_effect where event_num = " + QString::number(_result.event_num);
|
||||||
|
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
|
|
||||||
if (!query.exec(strQuery))
|
if (!query.exec(strQuery))
|
||||||
{
|
{
|
||||||
emit error(E_ERROR_CODE::DB_QUERY_ERROR, query.lastError().text() + SEPERATOR + query.lastQuery());
|
emit signalError(E_ERROR_CODE::DB_QUERY_ERROR, query.lastError().text() + "\n" + query.lastQuery());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +81,9 @@ bool SResultSender::send(const State_s1_effect& _result)
|
|||||||
|
|
||||||
if (!query.exec())
|
if (!query.exec())
|
||||||
{
|
{
|
||||||
emit error(E_ERROR_CODE::DB_QUERY_ERROR, query.lastError().text() + SEPERATOR + query.lastQuery());
|
qDebug() << "insert error";
|
||||||
|
|
||||||
|
emit signalError(E_ERROR_CODE::DB_QUERY_ERROR, query.lastError().text() + "\n" + query.lastQuery());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,23 +5,6 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "sutilclass.h"
|
#include "sutilclass.h"
|
||||||
|
|
||||||
struct State_s1_effect
|
|
||||||
{
|
|
||||||
int event_num;
|
|
||||||
QString view_buzz;
|
|
||||||
QString replybuzz;
|
|
||||||
int replycount;
|
|
||||||
int likecount;
|
|
||||||
int viewcount;
|
|
||||||
int interactioncount;
|
|
||||||
int reachcount;
|
|
||||||
int engagementcount;
|
|
||||||
State_s1_effect():event_num(0),replycount(0),likecount(0),viewcount(0),
|
|
||||||
interactioncount(0),reachcount(0),engagementcount(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SResultSender: public QObject
|
class SResultSender: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -30,7 +13,7 @@ public:
|
|||||||
bool send(const State_s1_effect& _result);
|
bool send(const State_s1_effect& _result);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(E_ERROR_CODE _error, const QString& _error_msg);
|
void signalError(E_ERROR_CODE _error, const QString& _error_msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ enum class E_CRAWL_STATE:unsigned short
|
|||||||
NO
|
NO
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class E_ERROR_CODE:unsigned short
|
enum class E_ERROR_CODE
|
||||||
{
|
{
|
||||||
DB_OPEN_ERROR = 0,
|
DB_OPEN_ERROR = 0,
|
||||||
DB_FULL_ERROR,
|
DB_FULL_ERROR,
|
||||||
@@ -161,6 +161,58 @@ enum E_LOG_COLUMN
|
|||||||
ERROR_MSG
|
ERROR_MSG
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum E_COLUMN
|
||||||
|
{
|
||||||
|
PLATFORM_NAME = 0,
|
||||||
|
PLATFORM_FORM,
|
||||||
|
PLATFORM_TITLE,
|
||||||
|
ARTICLE_FORM,
|
||||||
|
ARTICLE_PARENT,
|
||||||
|
ARTICLE_ID,
|
||||||
|
ARTICLE_NICKNAME,
|
||||||
|
ARTICLE_TITLE,
|
||||||
|
ARTICLE_DATA,
|
||||||
|
ARTICLE_URL,
|
||||||
|
ARTICLE_HIT,
|
||||||
|
ARTICLE_DATE,
|
||||||
|
ARTICLE_ORDER,
|
||||||
|
ARTICLE_PROFILE,
|
||||||
|
ARTICLE_PROFILEURL,
|
||||||
|
PLATFORM_ID,
|
||||||
|
KEYWORD_ID,
|
||||||
|
REPLY_URL,
|
||||||
|
ETC,
|
||||||
|
TOTAL_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DataForm
|
||||||
|
{
|
||||||
|
QString data[TOTAL_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EffectData
|
||||||
|
{
|
||||||
|
DataForm body;
|
||||||
|
QVector<DataForm> reply;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct State_s1_effect
|
||||||
|
{
|
||||||
|
int event_num;
|
||||||
|
QString view_buzz;
|
||||||
|
QString replybuzz;
|
||||||
|
int replycount;
|
||||||
|
int likecount;
|
||||||
|
int viewcount;
|
||||||
|
int interactioncount;
|
||||||
|
int reachcount;
|
||||||
|
int engagementcount;
|
||||||
|
State_s1_effect():event_num(0),replycount(0),likecount(0),viewcount(0),
|
||||||
|
interactioncount(0),reachcount(0),engagementcount(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SUTILCLASS
|
#endif // SUTILCLASS
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ void messageBoxError(const QString &title, const QString &body)
|
|||||||
|
|
||||||
QString errorCodeToString(E_ERROR_CODE _error_code)
|
QString errorCodeToString(E_ERROR_CODE _error_code)
|
||||||
{
|
{
|
||||||
if (0 <= static_cast<int>(_error_code) &&
|
if ((0 <= static_cast<int>(_error_code)) &&
|
||||||
static_cast<int>(_error_code) < static_cast<int>(E_ERROR_CODE::MAX))
|
(static_cast<int>(_error_code) < static_cast<int>(E_ERROR_CODE::MAX)))
|
||||||
return ERROR_MESSAGE[static_cast<int>(_error_code)];
|
return ERROR_MESSAGE[static_cast<int>(_error_code)];
|
||||||
else
|
else
|
||||||
return ERROR_MESSAGE[static_cast<int>(E_ERROR_CODE::UNKNOWN_ERROR)];
|
return ERROR_MESSAGE[static_cast<int>(E_ERROR_CODE::UNKNOWN_ERROR)];
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "swebpage.h"
|
#include "swebpage.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <QDebug>
|
||||||
SWebPage::SWebPage(QObject *parent): QWebPage(parent)
|
SWebPage::SWebPage(QObject *parent): QWebPage(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -8,5 +8,33 @@ SWebPage::SWebPage(QObject *parent): QWebPage(parent)
|
|||||||
|
|
||||||
void SWebPage::javaScriptAlert(QWebFrame *frame, const QString &msg)
|
void SWebPage::javaScriptAlert(QWebFrame *frame, const QString &msg)
|
||||||
{
|
{
|
||||||
|
qDebug() << "alert";
|
||||||
emit signalAlert(msg);
|
emit signalAlert(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SWebPage::javaScriptConfirm(QWebFrame *frame, const QString &msg)
|
||||||
|
{
|
||||||
|
qDebug() << "confirm";
|
||||||
|
emit signalAlert(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SWebPage::javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID)
|
||||||
|
{
|
||||||
|
qDebug() << "console";
|
||||||
|
emit signalAlert(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SWebPage::javaScriptPrompt(QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result)
|
||||||
|
{
|
||||||
|
qDebug() << "prompt";
|
||||||
|
emit signalAlert(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWebPage * SWebPage::createWindow(WebWindowType type)
|
||||||
|
{
|
||||||
|
qDebug() << "createwindow";
|
||||||
|
emit signalAlert("???");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void javaScriptAlert(QWebFrame * frame, const QString & msg) override;
|
void javaScriptAlert(QWebFrame * frame, const QString & msg) override;
|
||||||
//bool javaScriptConfirm(QWebFrame * frame, const QString & msg){}
|
bool javaScriptConfirm(QWebFrame * frame, const QString & msg) override;
|
||||||
|
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
||||||
|
bool javaScriptPrompt(QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result);
|
||||||
|
QWebPage * createWindow(WebWindowType type);
|
||||||
signals:
|
signals:
|
||||||
void signalAlert(const QString& msg);
|
void signalAlert(const QString& msg);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.3.0, 2016-10-27T19:07:05. -->
|
<!-- Written by QtCreator 3.3.0, 2016-10-28T13:07:39. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
<value type="int">3</value>
|
<value type="int">0</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.0 MinGW 32bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.0 MinGW 32bit</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.0 MinGW 32bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.0 MinGW 32bit</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.win32_mingw491_kit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.win32_mingw491_kit</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.3.0, 2016-10-05T15:40:28. -->
|
<!-- Written by QtCreator 3.3.0, 2016-10-28T13:07:39. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
Reference in New Issue
Block a user