📄 awflow.cpp
字号:
#include "stdafx.h"
#include "global.h"
#include "HopeKingDatabase.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
void WINAPI CommDllCallBack(DWORD dwHandle,int id,void * Buffer,int iBufferLen)
{
if(((CAsynWorker * )dwHandle)->IsValid()){
gDllGlobalManager.GetBus()->SetCommDllStatus(dwHandle,id,Buffer,iBufferLen);
}
}
void CAWFlow::OnRegisterBaseStyle()
{
CBaseFlow::OnRegisterBaseStyle();
}
#define FlowSleepTimerId 'FSTI'
#define FlowWaitTimerOut 'FWTO'
#define FlowCmdTimerSet 'FCTS'
#define FLOWLOCKID 'FLID'
void WINAPI SetDataCallBack(DWORD dwHandle,int id,void * Buffer,int iBufferLen);
COMMANDRESULT CAWFlow::SetPause(DWORD dwPauseCommand)
{
if(m_dwPauseCommand!=0xffffffff){
// TRACE("something error with serPause() and FunctionReturn();\n");
}
m_dwPauseCommand=dwPauseCommand;
if(m_iFlowTimeOutSec>0){
m_iErrorCode=0;
int iSec=m_iFlowTimeOutSec*1000/TIME_ELEAPS;
AddTime(iSec,FlowWaitTimerOut,false,false,false);
}
return LINE_PAUSE;
}
CAWFlow * CAWFlow::GetNewFlow(int)
{
CAWFlow * p=new CAWFlow();
return p;
}
COMMANDRESULT CAWFlow::DefaultParse(DWORD dwCommand,UniVar * pdwCommandList,int iNum)
{
PreSetCmd(dwCommand);
switch(dwCommand){
case APIBUSSendCommandEx ://dword dwSenderObject,dword dwCommand,ROAD int irode=0xffffffff,HKEY int hkey=0,TIMER int itime=0xffffffff,...
{
m_iErrorCode=0;
CUniMsg um;
um.SetMessage((DWORD)0,(DWORD)pdwCommandList[0],NULL,(CAsynWorker *)(int)pdwCommandList[1],(DWORD)pdwCommandList[2],MSG_COMMAND);
for(int i=6;i<iNum;i++){
um.Add(pdwCommandList[i]);
}
SetPause(APIBUSSendCommandEx);
if(!SendMsg(m_dwFlowCommadnIDent,&um,(int)pdwCommandList[3],(void *)(int)pdwCommandList[4],(int)pdwCommandList[5])){
m_iErrorCode=-23000;
m_dwFlowCommadnIDent=0xffffffff;
TRACE("send command continue\n");
return SetContinue();
}
TRACE("send command pause\n");
return LINE_PAUSE;
}
break;
case APIBUSSendEventEx ://dword dwSenderObject,dword dwCommand,WAITOBJ dword wobj=0,WAITCMD dword wcmd=0,WAITTYPE dword wtype=0,ROAD int irode=0xffffffff,HKEY int hkey=0,...
{
m_iErrorCode=0;
if(!(DWORD)pdwCommandList[2]){
m_iErrorCode=-1;
return SetContinue();
}
if(!(DWORD)pdwCommandList[1]){
AddCommand(FALSE,(DWORD)pdwCommandList[2],(DWORD)pdwCommandList[1],0,0,0,iNum-9,pdwCommandList+9);
return SetContinue();
}
CUniMsg um;
um.SetMessage((DWORD)0,(DWORD)pdwCommandList[0],NULL,(CAsynWorker *)(int)pdwCommandList[1],(DWORD)pdwCommandList[2],MSG_EVENT);
if((int)(um.m_pReceivor)==-1)
um.m_pReceivor=this;
for(int i=9;i<iNum;i++){
um.Add(pdwCommandList[i]);
}
if((int)pdwCommandList[4]==0){
if(!SendMsg(&um,(int)pdwCommandList[7],(void *)(int)pdwCommandList[8],-1))
m_iErrorCode=-23000;
return SetContinue();
}
else{
m_dwFlowWaitMach=(int)pdwCommandList[3];
m_iFlowWaitObject=(int)pdwCommandList[4];
m_iFlowWaitCommand=(int)pdwCommandList[5];
m_iFlowWaitType=(int)pdwCommandList[6];
SetPause(APIBUSSendEventEx);
SendMsg(&um,(int)pdwCommandList[7],(void *)(int)pdwCommandList[8],-1);
return LINE_PAUSE;
}
}
break;
case APIBUSSendRespEx ://dword dwSenderObject,dword dwCommand,WAITOBJ dword wobj=0,WAITCMD dword wcmd=0,WAITTYPE dword wtype=0,ROAD int irode=0xffffffff,...
{
m_iErrorCode=0;
CUniMsg um;
um.SetMessage((DWORD)0,(DWORD)pdwCommandList[0],NULL,(CAsynWorker *)(int)pdwCommandList[1],(DWORD)pdwCommandList[2],MSG_RESPONSE);
for(int i=8;i<iNum;i++){
um.Add(pdwCommandList[i]);
}
if((int)pdwCommandList[4]==0){
if(!SendMsg(&um,(int)pdwCommandList[7],NULL,-1))
m_iErrorCode=-23000;
return SetContinue();
}
else{
m_dwFlowWaitMach=(int)pdwCommandList[3];
m_iFlowWaitObject=(int)pdwCommandList[4];
m_iFlowWaitCommand=(int)pdwCommandList[5];
m_iFlowWaitType=(int)pdwCommandList[6];
SetPause(APIBUSSendRespEx);
if(!SendMsg(&um,(int)pdwCommandList[7],NULL,-1)){
m_iErrorCode=-23000;
return SetContinue();
}
return LINE_PAUSE;
}
}
break;
case APIBUSSetTimeOut ://int iSec
m_iFlowTimeOutSec=(int)pdwCommandList[0];
break;
case APIBUSCancelTimeOut ://int iSec
m_iFlowTimeOutSec=0;
break;
case APIBUSLockOwn ://int & buss,int ASYN asyn=1
{
pdwCommandList[0]=(int)LockWorker(FLOWLOCKID);
if(!(pdwCommandList[0].uv.iv)&&(int)pdwCommandList[1]){
ApplyWorkerLock(FLOWLOCKID);
return SetPause(APIBUSLockOwn);
}
}
break;
case APIBUSUnLockOwn ://int key
UnlockWorker((void *)(int)pdwCommandList[0]);
m_dwPauseCommand=0xffffffff;
break;
case APIBUSGetAllCommandParam:
{
for(int i=0;m_pCurMsg&&i<iNum&&i<m_pCurMsg->GetSize();i++){
pdwCommandList[i]=m_pCurMsg->m_pTV[i];
}
}
break;
case APIBUSGetCurrentCommandParam ://int idx,datablock 0 & param
{
int idx=pdwCommandList[0];
if(m_pCurMsg){
if(idx>=0&&idx<m_pCurMsg->GetSize()){
pdwCommandList[1]=m_pCurMsg->GetAt(idx);
}
else {
m_iErrorCode=-24001;
pdwCommandList[1]=-1;
TRACE("error idx:%ld,%ld",idx,m_pCurMsg->GetSize());
}
}
else{
m_iErrorCode=-24001;
pdwCommandList[1]=-1;
TRACE("-2");
}
}
break;
case APIBUSGetCommandParamNum ://int & num
if(m_pCurMsg)
pdwCommandList[0]=m_pCurMsg->GetSize();
else
pdwCommandList[0]=0;
break;
case APIBUSGetCommand ://dword & CommandHandle, dword & ApplyObject,dword & CommandType, WAIT int wait=0
{
pdwCommandList[0]=0;
pdwCommandList[1]=0;
pdwCommandList[2]=0;
return GetCommand(pdwCommandList,(INT )pdwCommandList[3]);
}
case APIBUSAddTimeOutMessage ://int timeout,dword object,TIMEID int timeid=0 TFlag int tflag=1
{
if((int)pdwCommandList[3]){
AddTime(
(int)pdwCommandList[0]*1000/TIME_ELEAPS,
FlowCmdTimerSet+(int)pdwCommandList[1],
false,
((BOOL)pdwCommandList[2])?true:false,
false);
}
else{
AddTime(
(int)pdwCommandList[0],
FlowCmdTimerSet+(int)pdwCommandList[1],
false,
((BOOL)pdwCommandList[2])?true:false,
false);
}
}
break;
case APIBUSCancelTimeOutMessage ://TIMEID int timeid=0
{
CancelTime(FlowCmdTimerSet+(int)pdwCommandList[0]);
}
break;
case APIBUSFlowSleep ://int iSec
{
if((int)pdwCommandList[1]){
int iSec=(int)pdwCommandList[0];
AddTime(iSec,FlowSleepTimerId,false,false,false);
}
else {
int iSec=(int)(pdwCommandList[0])*1000/TIME_ELEAPS;
AddTime(iSec,FlowSleepTimerId,false,false,false);
}
return SetPause(APIBUSFlowSleep);
}
case APIBUSFlowEdau :// 0x00f00020 //ALIS string szAlis='dacs',string szFunction,int & iRetCode,...
{
m_iErrorCode=0;
if(!m_pBus||iNum<7){
m_iErrorCode=-1;
return SetContinue();
}
CUniMsg um;
if(!m_pBus->m_dwRemoteEdauMod){
if(!m_pBus->m_pEdauDllProxy){
m_iErrorCode=-1;
return SetContinue();
}
um.SetMessage(NULL,m_pBus->m_pEdauDllProxy,CMD_TASK_RUNTASK,MSG_COMMAND);
um.Add(pdwCommandList[0]);
um.Add(pdwCommandList[1]);
um.Add(pdwCommandList[2]);
for(int i=7;i<iNum;i++)
um.Add(pdwCommandList[i]);
COMMANDRESULT ret=SetPause(APIBUSFlowEdau);
SendMsg(m_dwFlowCommadnIDent,&um,3,NULL,-1);
return ret;
}
else{
um.SetMessage(GetModId(),m_pBus->m_dwRemoteEdauMod,this,NULL,CMD_TASK_RUNTASK,MSG_COMMAND);
um.Add(pdwCommandList[0]);
um.Add(pdwCommandList[1]);
um.Add(pdwCommandList[2]);
for(int i=7;i<iNum;i++)
um.Add(pdwCommandList[i]);
COMMANDRESULT ret=SetPause(APIBUSFlowEdau);
SendMsg(m_dwFlowCommadnIDent,&um,3,NULL,50);
return ret;
}
}
break;
case APIBUSExcuteOdbc :// //CHAN int iChannel=0,string szFunction,int & iRetCode,...
{
if(!m_pBus||iNum<7){
m_iErrorCode=-1;
return SetContinue();
}
if(!m_pBus->m_dwRemoteOdbcMod){
if(!m_pBus->m_pOdbc){
m_iErrorCode=-1;
return SetContinue();
}
CHopeKingDatabase * pDbs=NULL;
if((int)pdwCommandList[0]==-1){
pDbs=m_pBus->m_pOdbc->GetDefault();
}
else{
if(pdwCommandList[0].IsString()){
pDbs=(CHopeKingDatabase * )m_pBus->m_pOdbc->GetOdbc((LPCTSTR)pdwCommandList[0]);
}
else{
pDbs=(CHopeKingDatabase * )(int)pdwCommandList[0];
}
}
if(pDbs->IsValid()){
m_iErrorCode=0;
CUniMsg um;
um.SetMessage(NULL,pDbs,CMD_TASK_RUNTASK,MSG_COMMAND);
um.Add(pdwCommandList[0]);
um.Add(pdwCommandList[1]);
um.Add(pdwCommandList[2]);
for(int i=7;i<iNum;i++)
um.Add(pdwCommandList[i]);
COMMANDRESULT ret=SetPause(APIBUSExcuteOdbc);
SendMsg(m_dwFlowCommadnIDent,&um,3,NULL,-1);
return ret;
}
else{
m_iErrorCode=-25021;
return SetContinue();
}
}
else{
m_iErrorCode=0;
CUniMsg um;
um.SetMessage(GetModId(),m_pBus->m_dwRemoteOdbcMod,this,NULL,CMD_TASK_RUNTASK,MSG_COMMAND);
um.Add(pdwCommandList[0]);
um.Add(pdwCommandList[1]);
um.Add(pdwCommandList[2]);
for(int i=7;i<iNum;i++)
um.Add(pdwCommandList[i]);
COMMANDRESULT ret=SetPause(APIBUSExcuteOdbc);
SendMsg(m_dwFlowCommadnIDent,&um,3,(HANDLE)1,50);
return ret;
}
}
break;
case APIBUSAsynDllCall ://0x00f10021 //dword lhandle,dword thandle,string name,CALLRET int cret,FUNCRET int fret...
{
if(!m_pBus||!m_pBus->m_pEdauDllProxy||iNum<5){
m_iErrorCode=-1;
return SetContinue();
}
m_iErrorCode=0;
CUniMsg um;
um.SetMessage(NULL,m_pBus->m_pEdauDllProxy,CMD_TASK_DLLPROXY,MSG_COMMAND);
for(int i=0;i<iNum;i++)
um.Add(pdwCommandList[i]);
COMMANDRESULT ret=SetPause(APIBUSAsynDllCall);
SendMsg(m_dwFlowCommadnIDent,&um,3,NULL,-1);
return ret;
}
break;
case APIBUSReleaseFlow ://0x00f20002 //int id
{
if(!(DWORD)pdwCommandList[1]||(DWORD)pdwCommandList[1]==GetModId()){
if((int)pdwCommandList[0]){
CAWFlow * pFlow=(CAWFlow * )(GetRegisterObject((int)pdwCommandList[0]));
if(pFlow->IsValid()){
if((int)pdwCommandList[2]){
if(!pFlow->m_bRelease){
pFlow->m_bRelease=TRUE;
m_pBus->UnRegister(pFlow);
try{
pFlow->ExitFlow();
delete pFlow;
}
catch(...){
TRACE("Release error,run flow\n");
}
}
}
else{
if(!SendEvent(0,pFlow,EVENT_SET_CLOSE_FLOW_EVENT)){
if(!pFlow->m_bRelease){
pFlow->m_bRelease=TRUE;
m_pBus->UnRegister(pFlow);
try{
pFlow->ExitFlow();
delete pFlow;
}
catch(...){
TRACE("Release error,run flow\n");
}
}
return SetContinue();
}
else{
return SetPause(APIBUSReleaseFlow);
}
}
}
}
else{
m_bRelease=TRUE;
if(m_pCreator->IsValid()){
SendEvent(m_pCreator,EVT_WORKERFLOW_RELEASE,NULL,-1,UniVar((int)this),InValidVar);
return LINE_END;
}
else{
m_pBus->UnRegister(this);
if(m_bAutoDelete)
delete this;
return LINE_END;
}
}
}
else{
//remote release
}
}
break;
case APIBUSCreateNewFlow ://0x00f20000 //string flown,...
{
if((DWORD)pdwCommandList[2]==0||(DWORD)pdwCommandList[2]==GetModId()){
CAWFlow * pFlow=GetNewFlow(pdwCommandList[0]);
pdwCommandList[0]=0;
if(pFlow){
pFlow->SetBus(m_pBus);
if(pFlow->CreateFlow((LPSTR)pdwCommandList[5])){
m_dwFlowCreateId=(DWORD)pdwCommandList[1];
m_pBus->Register((int)pdwCommandList[1],pFlow);
pFlow->SetFlowDescripe((LPSTR)pdwCommandList[5]);
if((LPSTR)pdwCommandList[5]){
pFlow->m_bBoolCanTrace=TRUE;
if(gDllGlobalManager.m_pGlobalApi){
gDllGlobalManager.m_pGlobalApi->CanTraceFlow(pFlow);
}
}
pFlow->m_pCreator=this;
pFlow->m_dwCreateMod=(DWORD)pdwCommandList[2];
if((DWORD)pdwCommandList[3])
pFlow->AddExprObj(this,(DWORD)pdwCommandList[3],(DWORD)pdwCommandList[4],0);
pFlow->OnCreate();
pFlow->BStart(iNum-6,pdwCommandList+6);
pdwCommandList[0]=1;
break;
}
else{
delete pFlow;
}
}
pdwCommandList[0]=0;
}
else {
// remote create
}
}
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -