----------------------------下面针对cBPM
[root@localhost html]# gedit /root/.bashrc
[root@localhost html]# gedit /etc/profile
末尾添加:
---------------------------------
export WF_HOME=/etc/nginx/html
export CRITERIA_HOME=/etc/nginx/html
---------------------------------
[root@localhost criteria-lin]# gedit ./src/Criteria/Criteria.WorkflowEngine/WAPI/WAPI.cpp
-------------------------
使用绝对路径, 如下。因为 代码里面不能 解析 ${CRITERIA_HOME}。 权宜之计。
//ztg alter path
//String sWfHome = System::getEnvironmentVariable("${CRITERIA_HOME}");
//String sWfHome = "/opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor";
String sWfHome = "/etc/nginx/html";
//ztg alter path
//string sDirectory = bOS::CoreSystem::System::expandEnvironmentStrings ("${WF_HOME}");
//String sDirectory = "/opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor";
String sDirectory = "/etc/nginx/html";
-------------------------
[root@localhost html]# gedit database/Criteria.xml
-------------------------
使用绝对路径, 如下。因为 代码里面不能 解析 ${CRITERIA_HOME}。 权宜之计。
/etc/nginx/html/database/processTemplate
而非:
${CRITERIA_HOME}/database/processTemplate
-------------------------
[root@localhost html]# gedit database/processTemplate/TestNotePad.xml
-------------------------
?NoteResult?@gedit@%FileName1%
修改为
?NoteResult?@touch@%FileName1%
FileName1 ——> /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/notepad.txt
-------------------------
[root@localhost html]# cp /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer .
[root@localhost html]# cp -a /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/database/ .
[root@localhost html]# export WF_HOME=/etc/nginx/html; export CRITERIA_HOME=/etc/nginx/html
[root@localhost html]# spawn-fcgi -a 127.0.0.1 -p 8088 -f /etc/nginx/html/executer
[root@localhost html]# ./executer TestNotePad
[root@localhost html]# lsof executer
+++++++++++++++++++++++++++++++++++++++++
[root@localhost html]# gedit /root/.bashrc
[root@localhost html]# gedit /etc/profile
末尾添加:
---------------------------------
export WF_HOME=/etc/nginx/html
export CRITERIA_HOME=/etc/nginx/html
---------------------------------
[root@localhost criteria-lin]# gedit ./src/Criteria/Criteria.WorkflowEngine/WAPI/WAPI.cpp
-------------------------
使用绝对路径, 如下。因为 代码里面不能 解析 ${CRITERIA_HOME}。 权宜之计。
//ztg alter path
//String sWfHome = System::getEnvironmentVariable("${CRITERIA_HOME}");
//String sWfHome = "/opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor";
String sWfHome = "/etc/nginx/html";
//ztg alter path
//string sDirectory = bOS::CoreSystem::System::expandEnvironmentStrings ("${WF_HOME}");
//String sDirectory = "/opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor";
String sDirectory = "/etc/nginx/html";
-------------------------
[root@localhost html]# gedit database/Criteria.xml
-------------------------
使用绝对路径, 如下。因为 代码里面不能 解析 ${CRITERIA_HOME}。 权宜之计。
/etc/nginx/html/database/processTemplate
而非:
${CRITERIA_HOME}/database/processTemplate
-------------------------
[root@localhost html]# gedit database/processTemplate/TestNotePad.xml
-------------------------
?NoteResult?@gedit@%FileName1%
修改为
?NoteResult?@touch@%FileName1%
FileName1 ——> /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/notepad.txt
-------------------------
[root@localhost html]# cp /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer .
[root@localhost html]# cp -a /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/database/ .
[root@localhost html]# export WF_HOME=/etc/nginx/html; export CRITERIA_HOME=/etc/nginx/html
[root@localhost html]# spawn-fcgi -a 127.0.0.1 -p 8088 -f /etc/nginx/html/executer
[root@localhost html]# ./executer TestNotePad
[root@localhost html]# lsof executer
+++++++++++++++++++++++++++++++++++++++++
[root@localhost html]# gedit index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="cbpm.js"></script>
</head>
<body>
<div id="loginContent" class="container">
<div id="loginResult" style="display:none;">
</div>
<form id="loginForm" name="loginForm" method="post" action="">
<fieldset>
<legend>Enter information</legend>
<p>
<label for="processname">Process name</label>
<br />
<input type="text" id="processname" name="processname" class="text" size="20" />
</p>
<p>
<button type="submit" class="button positive">
start
</button>
</p>
</fieldset>
</form>
</div>
</body>
</html>
+++++++++++++++++++++++++++++++++++++++++
[root@localhost html]# gedit cbpm.js
$(document).ready(function(){
$("form#loginForm").submit(function() { // loginForm is submitted
var processname = $('#processname').attr('value'); // get first name
//var name = $('#name').attr('value'); // get name
//if (processname && name) { // values are not empty
if (processname) { // values are not empty
$.ajax({
type: "GET",
url: "/executer.cgi", // URL of the Perl script
// send processname and name as parameters to the Perl script
//data: "processname=" + processname,
data: processname,
// script call was *not* successful
error: function() {
alert("script call was not successful");
},
// script call was successful
// perl_data should contain the string returned by the Perl script
success: function(perl_data){
alert("Your name is: " + perl_data)
}
});
}
else {
$('div#loginResult').text("Enter your name");
$('div#loginResult').addClass("error");
}
$('div#loginResult').fadeIn();
return false;
});
});
executer ——> /opt/cBPM/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer
+++++++++++++++++++++++++++++++++++++++++
/opt/cBPM/criteria-lin/src/Criteria/Criteria.Tools/Criteria.Tools.Executor/src/main.cpp
#include "bOSString.h"
#include "bOSStringBuffer.h"
using namespace bOS::CoreString;
#include "Tracer.h"
#include "bOSTimer.h"
#include "WAPI.h"
#include "WAPIActivity.h"
#include "WAPIWorkItem.h"
#include "WAPIProcess.h"
#include "Activity.h"
//ztg add, use fcgi
#include "fcgi_stdio.h"
//ztg add, use fcgi
int main_fcgi( char* proc_name, int argc=2);
//ztg add, use fcgi
int main(void)
{
//main_fcgi("TestNotePad");
//*
while (FCGI_Accept() >= 0) {
char *proc_name = getenv("QUERY_STRING");
printf("Content type: text/html\n\n");
//printf("%s",proc_name);
//main_fcgi("TestNotePad");
main_fcgi(proc_name);
} //*/
}
static void usage()
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s", "\nUsage:\n"
" CriteriaToolsExecutor <WorkflowName> [NrExecution]\n\n"
"This program invokes criteria workflow engine and execute <WorkflowName>\n"
"Options:\n"
" NrExecution the number of process execution. Default is 1\n");
/*
cout << "\nUsage:\n"
" CriteriaToolsExecutor <WorkflowName> [NrExecution]\n\n"
"This program invokes criteria workflow engine and execute <WorkflowName>\n"
"Options:\n"
" NrExecution the number of process execution. Default is 1\n"
<< endl;
*/
}
//ztg alter, use fcgi
//int main(int argc, char* argv[])
int main_fcgi( char* proc_name, int argc)
{
if ( argc == 1 )
{
usage();
exit(1);
}
String sWorkflowName;
if ( argc >= 2 )
{
//ztg alter, use fcgi
//sWorkflowName = argv[1];
sWorkflowName = proc_name;
}
unsigned int uiSize =1;
if ( argc == 3 )
{
//ztg del, use fcgi
//uiSize = atoi(argv[2]);
}
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s", "The program will perform the following steps:\n\n"
"1: Criteria session initialization (only one time)\n"
" ----- for each process (begin) -----\n"
"2: Create process instance from template\n"
"3: Execute process instance just created\n"
" ----- for each process (end) -----\n"
"4: Querying for activity pending\n"
"5: close criteria session\n\n");
/*
cout << "The program will perform the following steps:\n\n"
"1: Criteria session initialization (only one time)\n"
" ----- for each process (begin) -----\n"
"2: Create process instance from template\n"
"3: Execute process instance just created\n"
" ----- for each process (end) -----\n"
"4: Querying for activity pending\n"
"5: close criteria session\n\n";
*/
//ztg del, use fcgi
//cout << "Press a Key for beginning................................................" << endl;
//getchar();
Response* response = new Response();
response->iCode= 0;
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "Criteria session Initialization.....(look at Executor trace file)");
//cout << "Criteria session Initialization.....(look at Executor trace file)" << endl;
CM_SETTING_TO("Executor", 7);
InitSession(response);
if ( response->iCode != 0 )
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("Criteria session Initialization [KO].Error[ %s ]. Exit.\n", response->sMsg);
//cout << "Criteria session Initialization [KO].Error[" << response->sMsg << "]. Exit." << endl;
exit(2);
}
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "Criteria session Initialization [OK]");
//cout << "Criteria session Initialization [OK]" << endl;
bOS::Utils::Timer tExecutionTimer;
tExecutionTimer.start();
char* lProcessId = new char[50];
//char* acRet = NULL;
StringBuffer outputSimplified;
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "Create process instance from template");
//cout << "Create process instance from template" << endl;
for ( unsigned int i=0; i<uiSize; i++)
{
bOS::Utils::Timer tTot;
bOS::Utils::Timer tCreate;
bOS::Utils::Timer tStart;
tTot.start();
tCreate.start();
createWorkflowProcess((char*)sWorkflowName.c_str(), lProcessId, response);
tCreate.stop();
if ( response->iCode == 0 )
{
//cout << "Create process instance [OK]. Process Instance Id[" << lProcessId << "]" << endl;
tStart.start();
startProcessInSynchWay(lProcessId, response);
tStart.stop();
tTot.stop();
if ( response->iCode == 0 )
{
//cout << "Execute process instance [OK]. Process Instance Id[" << lProcessId << "] just started" << endl;
//ztg alter, use fcgi, not use cout, instead of using printf
printf("[ %u ] Process [ %d ] [ %d ] [ %d ] [ %d ]\n", i, lProcessId, tCreate.getTicks(), tStart.getTicks(), tTot.getTicks());
//cout << "[" << i << "] Process [" << lProcessId << "] [" << tCreate.getTicks() << "] [" << tStart.getTicks() << "] [" << tTot.getTicks() << "]" << endl;
}
else
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("Execute process instance [KO]. Process Instance Id[ %s ]\n", lProcessId);
//cout << "Execute process instance [KO]. Process Instance Id[" << lProcessId << "] not started" << endl;
}
}
else
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("Create process instance [KO]. Err[ %s ]\n", response->sMsg);
//cout << "Create process instance [KO]. Err[" << response->sMsg << "]" << endl;
}
}
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "Querying for activity pending");
//cout << "Querying for activity pending" << endl;
unsigned long lWorkflowRunning=0;
do
{
lWorkflowRunning= getNumberRunningWorkflow(response);
if ( response->iCode == 0 )
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("WorkflowRunning[ %lu ]\n", lWorkflowRunning);
//cout << "WorkflowRunning[" << lWorkflowRunning << "]" << endl;
}
else
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("Error retreiving RunningWorkflow.Err[ %s ]\n", response->sMsg);
//cout << "Error retreiving RunningWorkflow.Err[" << response->sMsg << "]" << endl;
}
}
while ( lWorkflowRunning > 0);
tExecutionTimer.stop();
//ztg alter, use fcgi, not use cout, instead of using printf
printf("Execution Time(ms): %d\n", tExecutionTimer.getTicks());
//cout << "Execution Time(ms): " << tExecutionTimer.getTicks() << endl;
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "Press a Key for terminating................................................");
//cout << "Press a Key for terminating................................................" << endl;
//getchar();
//ztg add sleep()
//sleep(2);
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "EndSession.......");
//cout << "EndSession......." << endl;
response->iCode = 0;
EndSession(response);
if ( response->iCode == 0 )
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("%s\n", "Session Terminated [OK]");
//cout << "Session Terminated [OK]" << endl;
}
else
{
//ztg alter, use fcgi, not use cout, instead of using printf
printf("Terminating [KO].Err[ %s ]\n", response->sMsg);
//cout << "Terminating [KO].Err[" << response->sMsg << "]" << endl;
}
//
return 0;
}
+++++++++++++++++++++++++++++++++++++++++