79 lines
1.7 KiB
C++
79 lines
1.7 KiB
C++
/*
|
|
* DeleteWorkflowCmd.cpp
|
|
*
|
|
* Created on: 2012-10-16
|
|
* Author: dev
|
|
*/
|
|
|
|
#include "DeleteWorkflowCmd.h"
|
|
#include "PaiObject.h"
|
|
#include "ConsoleGUIService.h"
|
|
#include "Log.h"
|
|
#include "SaveHelper.h"
|
|
#include "PaiSurvey.h"
|
|
#include "PaiWorkflowMaster.h"
|
|
#include "PaiMessageBox.h"
|
|
|
|
using namespace pai::gui;
|
|
namespace pai
|
|
{
|
|
DeleteWorkflowCmd::DeleteWorkflowCmd(pai::objectmodel::PaiObject* pObject, QUndoCommand *parent)
|
|
:QUndoCommand(parent)
|
|
{
|
|
m_pObject = pObject;
|
|
}
|
|
|
|
DeleteWorkflowCmd::~DeleteWorkflowCmd()
|
|
{
|
|
}
|
|
|
|
void DeleteWorkflowCmd::undo()
|
|
{
|
|
}
|
|
|
|
void DeleteWorkflowCmd::redo()
|
|
{
|
|
DeleteWorkflow();
|
|
}
|
|
|
|
void DeleteWorkflowCmd::DeleteWorkflow()
|
|
{
|
|
if (m_pObject == NULL)
|
|
{
|
|
return;
|
|
}
|
|
//做删除操作
|
|
QString strErrMsg;
|
|
if (m_pObject->Erase(&strErrMsg))//从数据库删除
|
|
{
|
|
if(SaveHelper::GetSurveyByWfDBID(m_pObject->GetDBID()))
|
|
{
|
|
pai::objectmodel::PaiObject *pParent = SaveHelper::GetSurveyByWfDBID(m_pObject->GetDBID())
|
|
->GetMaster(QUuid(pai::objectmodel::PaiWorkflowMaster::GetTypeIDString()));
|
|
if(pParent)
|
|
{
|
|
pParent->RemoveChild(m_pObject, true);//从内存树删除并通知数据树
|
|
}
|
|
|
|
pai::objectmodel::PaiObject *pShadowObject = GetObjectModelService()->GetObject(m_pObject->GetDBID());
|
|
if (pShadowObject != NULL)
|
|
{
|
|
pParent = pShadowObject->GetParent();
|
|
if(pParent)
|
|
{
|
|
pParent->RemoveChild(pShadowObject, true);//从内存树删除并通知数据树
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
PaiMessageBox::Critical(NULL, QObject::tr("Error!"), strErrMsg);
|
|
pai::log::Error(_FLF(QObject::tr("QUndoCommand::ShowMessage ").toStdString()+strErrMsg.toStdString()));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|