Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6660210
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: Android平台

2015-11-22 22:13:11

----------------------------下面针对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 index.html

点击(此处)折叠或打开

  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <script type="text/javascript" src=""></script>
  5.     <script type="text/javascript" src="cbpm.js"></script>
  6.   </head>
  7.   <body>
  8.     <div id="loginContent" class="container">
  9.         <div id="loginResult" style="display:none;">
  10.         </div>
  11.         <form id="loginForm" name="loginForm" method="post" action="">
  12.         <fieldset>
  13.             <legend>Enter information</legend>
  14.             <p>
  15.             <label for="processname">Process name</label>
  16.             <br />
  17.             <input type="text" id="processname" name="processname" class="text" size="20" />
  18.             </p>
  19.             <p>
  20.             <button type="submit" class="button positive">
  21.              start
  22.             </button>
  23.             </p>
  24.         </fieldset>
  25.         </form>
  26.     </div>
  27.   </body>
  28. </html>


+++++++++++++++++++++++++++++++++++++++++

[root@localhost html]# gedit cbpm.js


点击(此处)折叠或打开

  1. $(document).ready(function(){
  2.   $("form#loginForm").submit(function() { // loginForm is submitted


  3. var processname = $('#processname').attr('value'); // get first name
  4. //var name = $('#name').attr('value'); // get name

  5. //if (processname && name) { // values are not empty
  6. if (processname) { // values are not empty
  7.     $.ajax({
  8.         type: "GET",
  9.         url: "/executer.cgi", // URL of the Perl script

  10.         // send processname and name as parameters to the Perl script
  11.         //data: "processname=" + processname,
  12.         data: processname,

  13.         // script call was *not* successful
  14.         error: function() {
  15.             alert("script call was not successful");
  16.         },

  17.         // script call was successful
  18.         // perl_data should contain the string returned by the Perl script
  19.         success: function(perl_data){
  20.             alert("Your name is: " + perl_data)
  21.         }
  22.     });
  23. }

  24. else {
  25.   $('div#loginResult').text("Enter your name");
  26.   $('div#loginResult').addClass("error");
  27. }

  28. $('div#loginResult').fadeIn();
  29. return false;
  30.   });
  31. });

 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

点击(此处)折叠或打开

  1. #include "bOSString.h"
  2. #include "bOSStringBuffer.h"
  3. using namespace bOS::CoreString;

  4. #include "Tracer.h"

  5. #include "bOSTimer.h"

  6. #include "WAPI.h"
  7. #include "WAPIActivity.h"
  8. #include "WAPIWorkItem.h"
  9. #include "WAPIProcess.h"

  10. #include "Activity.h"

  11. //ztg add, use fcgi
  12. #include "fcgi_stdio.h"

  13. //ztg add, use fcgi
  14. int main_fcgi( char* proc_name, int argc=2);
  15. //ztg add, use fcgi
  16. int main(void)
  17. {
  18.     //main_fcgi("TestNotePad");
  19.     //*
  20.     while (FCGI_Accept() >= 0) {

  21.         char *proc_name = getenv("QUERY_STRING");

  22.         printf("Content type: text/html\n\n");
  23.         //printf("%s",proc_name);
  24.         //main_fcgi("TestNotePad");
  25.         main_fcgi(proc_name);

  26.     } //*/
  27. }



  28. static void usage()
  29. {
  30.     //ztg alter, use fcgi, not use cout, instead of using printf
  31.     printf("%s", "\nUsage:\n"
  32.             "    CriteriaToolsExecutor [NrExecution]\n\n"
  33.             "This program invokes criteria workflow engine and execute \n"
  34.             "Options:\n"
  35.             "    NrExecution        the number of process execution. Default is 1\n");
  36. /*
  37.     cout << "\nUsage:\n"
  38.             "    CriteriaToolsExecutor [NrExecution]\n\n"
  39.             "This program invokes criteria workflow engine and execute \n"
  40.             "Options:\n"
  41.             "    NrExecution        the number of process execution. Default is 1\n"
  42.     << endl;
  43. */
  44. }


  45. //ztg alter, use fcgi
  46. //int main(int argc, char* argv[])
  47. int main_fcgi( char* proc_name, int argc)
  48. {
  49.     if ( argc == 1 )
  50.     {
  51.         usage();
  52.         exit(1);
  53.     }

  54.     String sWorkflowName;
  55.     if ( argc >= 2 )
  56.     {
  57.      //ztg alter, use fcgi
  58.         //sWorkflowName = argv[1];
  59.         sWorkflowName = proc_name;
  60.     }

  61.     unsigned int uiSize =1;
  62.     if ( argc == 3 )
  63.     {
  64.      //ztg del, use fcgi
  65.         //uiSize = atoi(argv[2]);
  66.     }

  67.     //ztg alter, use fcgi, not use cout, instead of using printf
  68.     printf("%s", "The program will perform the following steps:\n\n"
  69.                 "1: Criteria session initialization (only one time)\n"
  70.                 "    ----- for each process (begin) -----\n"
  71.                 "2: Create process instance from template\n"
  72.                 "3: Execute process instance just created\n"
  73.                 "    ----- for each process (end) -----\n"
  74.                 "4: Querying for activity pending\n"
  75.                 "5: close criteria session\n\n");

  76. /*
  77.     cout << "The program will perform the following steps:\n\n"
  78.                 "1: Criteria session initialization (only one time)\n"
  79.                 "    ----- for each process (begin) -----\n"
  80.                 "2: Create process instance from template\n"
  81.                 "3: Execute process instance just created\n"
  82.                 "    ----- for each process (end) -----\n"
  83.                 "4: Querying for activity pending\n"
  84.                 "5: close criteria session\n\n";
  85. */
  86.     //ztg del, use fcgi
  87.     //cout << "Press a Key for beginning................................................" << endl;
  88.     //getchar();

  89.     Response* response = new Response();
  90.     response->iCode= 0;

  91.     //ztg alter, use fcgi, not use cout, instead of using printf
  92.     printf("%s\n", "Criteria session Initialization.....(look at Executor trace file)");
  93.     //cout << "Criteria session Initialization.....(look at Executor trace file)" << endl;

  94.     CM_SETTING_TO("Executor", 7);
  95.     InitSession(response);
  96.     if ( response->iCode != 0 )
  97.     {
  98.         //ztg alter, use fcgi, not use cout, instead of using printf
  99.         printf("Criteria session Initialization [KO].Error[ %s ]. Exit.\n", response->sMsg);
  100.         //cout << "Criteria session Initialization [KO].Error[" << response->sMsg << "]. Exit." << endl;
  101.         exit(2);
  102.     }
  103.     //ztg alter, use fcgi, not use cout, instead of using printf
  104.     printf("%s\n", "Criteria session Initialization [OK]");
  105.     //cout << "Criteria session Initialization [OK]" << endl;

  106.     bOS::Utils::Timer tExecutionTimer;
  107.     tExecutionTimer.start();

  108.     char* lProcessId = new char[50];
  109.     //char* acRet = NULL;

  110.     StringBuffer outputSimplified;

  111.     //ztg alter, use fcgi, not use cout, instead of using printf
  112.     printf("%s\n", "Create process instance from template");
  113.     //cout << "Create process instance from template" << endl;
  114.     for ( unsigned int i=0; i<uiSize; i++)
  115.     {
  116.         bOS::Utils::Timer tTot;
  117.         bOS::Utils::Timer tCreate;
  118.         bOS::Utils::Timer tStart;

  119.         tTot.start();

  120.         tCreate.start();
  121.         createWorkflowProcess((char*)sWorkflowName.c_str(), lProcessId, response);
  122.         tCreate.stop();

  123.         if ( response->iCode == 0 )
  124.         {
  125.             //cout << "Create process instance [OK]. Process Instance Id[" << lProcessId << "]" << endl;
  126.             tStart.start();
  127.             startProcessInSynchWay(lProcessId, response);
  128.             tStart.stop();
  129.             tTot.stop();

  130.             if ( response->iCode == 0 )
  131.             {
  132.                 //cout << "Execute process instance [OK]. Process Instance Id[" << lProcessId << "] just started" << endl;

  133.                 //ztg alter, use fcgi, not use cout, instead of using printf
  134.                 printf("[ %u ] Process [ %d ] [ %d ] [ %d ] [ %d ]\n", i, lProcessId, tCreate.getTicks(), tStart.getTicks(), tTot.getTicks());
  135.                 //cout << "[" << i << "] Process [" << lProcessId << "] [" << tCreate.getTicks() << "] [" << tStart.getTicks() << "] [" << tTot.getTicks() << "]" << endl;
  136.             }
  137.             else
  138.             {
  139.                 //ztg alter, use fcgi, not use cout, instead of using printf
  140.                 printf("Execute process instance [KO]. Process Instance Id[ %s ]\n", lProcessId);
  141.                 //cout << "Execute process instance [KO]. Process Instance Id[" << lProcessId << "] not started" << endl;
  142.             }
  143.         }
  144.         else
  145.         {
  146.             //ztg alter, use fcgi, not use cout, instead of using printf
  147.             printf("Create process instance [KO]. Err[ %s ]\n", response->sMsg);
  148.             //cout << "Create process instance [KO]. Err[" << response->sMsg << "]" << endl;
  149.         }


  150.     }

  151.     //ztg alter, use fcgi, not use cout, instead of using printf
  152.     printf("%s\n", "Querying for activity pending");
  153.     //cout << "Querying for activity pending" << endl;

  154.     unsigned long lWorkflowRunning=0;
  155.     do
  156.     {
  157.         lWorkflowRunning= getNumberRunningWorkflow(response);
  158.         if ( response->iCode == 0 )
  159.         {
  160.             //ztg alter, use fcgi, not use cout, instead of using printf
  161.             printf("WorkflowRunning[ %lu ]\n", lWorkflowRunning);
  162.             //cout << "WorkflowRunning[" << lWorkflowRunning << "]" << endl;
  163.         }
  164.         else
  165.         {
  166.             //ztg alter, use fcgi, not use cout, instead of using printf
  167.             printf("Error retreiving RunningWorkflow.Err[ %s ]\n", response->sMsg);
  168.             //cout << "Error retreiving RunningWorkflow.Err[" << response->sMsg << "]" << endl;
  169.         }
  170.     }
  171.     while ( lWorkflowRunning > 0);

  172.     tExecutionTimer.stop();

  173.     //ztg alter, use fcgi, not use cout, instead of using printf
  174.     printf("Execution Time(ms): %d\n", tExecutionTimer.getTicks());
  175.     //cout << "Execution Time(ms): " << tExecutionTimer.getTicks() << endl;

  176.     //ztg alter, use fcgi, not use cout, instead of using printf
  177.     printf("%s\n", "Press a Key for terminating................................................");
  178.     //cout << "Press a Key for terminating................................................" << endl;
  179.     //getchar();
  180.     //ztg add sleep()
  181.     //sleep(2);


  182.     //ztg alter, use fcgi, not use cout, instead of using printf
  183.     printf("%s\n", "EndSession.......");
  184.     //cout << "EndSession......." << endl;

  185.     response->iCode = 0;
  186.     EndSession(response);
  187.     if ( response->iCode == 0 )
  188.     {
  189.         //ztg alter, use fcgi, not use cout, instead of using printf
  190.         printf("%s\n", "Session Terminated [OK]");
  191.         //cout << "Session Terminated [OK]" << endl;
  192.     }
  193.     else
  194.     {
  195.         //ztg alter, use fcgi, not use cout, instead of using printf
  196.         printf("Terminating [KO].Err[ %s ]\n", response->sMsg);
  197.         //cout << "Terminating [KO].Err[" << response->sMsg << "]" << endl;
  198.     }
  199. //

  200.     return 0;
  201. }


+++++++++++++++++++++++++++++++++++++++++



阅读(910) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~