zoukankan      html  css  js  c++  java
  • (OK) cBPM-CentOS—wrapped by fastcgi—files—executing commands

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

    
        <!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
    
    ");
                //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", "
    Usage:
    "
                    "    CriteriaToolsExecutor <WorkflowName> [NrExecution]
    
    "
                    "This program invokes criteria workflow engine and execute <WorkflowName>
    "
                    "Options:
    "
                    "    NrExecution        the number of process execution. Default is 1
    ");
        /*
            cout << "
    Usage:
    "
                    "    CriteriaToolsExecutor <WorkflowName> [NrExecution]
    
    "
                    "This program invokes criteria workflow engine and execute <WorkflowName>
    "
                    "Options:
    "
                    "    NrExecution        the number of process execution. Default is 1
    "
            << 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:
    
    "
                        "1: Criteria session initialization (only one time)
    "
                        "    ----- for each process (begin) -----
    "
                        "2: Create process instance from template
    "
                        "3: Execute process instance just created
    "
                        "    ----- for each process (end) -----
    "
                        "4: Querying for activity pending
    "
                        "5: close criteria session
    
    ");
    
        /*
            cout << "The program will perform the following steps:
    
    "
                        "1: Criteria session initialization (only one time)
    "
                        "    ----- for each process (begin) -----
    "
                        "2: Create process instance from template
    "
                        "3: Execute process instance just created
    "
                        "    ----- for each process (end) -----
    "
                        "4: Querying for activity pending
    "
                        "5: close criteria session
    
    ";
        */
            //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
    ", "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.
    ", 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
    ", "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
    ", "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 ]
    ", 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 ]
    ", 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 ]
    ", response->sMsg);
                    //cout << "Create process instance [KO]. Err[" << response->sMsg << "]" << endl;
                }
    
    
            }
    
            //ztg alter, use fcgi, not use cout, instead of using printf
            printf("%s
    ", "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 ]
    ", lWorkflowRunning);
                    //cout << "WorkflowRunning[" << lWorkflowRunning << "]" << endl;
                }
                else
                {
                    //ztg alter, use fcgi, not use cout, instead of using printf
                    printf("Error retreiving RunningWorkflow.Err[ %s ]
    ", 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
    ", tExecutionTimer.getTicks());
            //cout << "Execution Time(ms): " << tExecutionTimer.getTicks() << endl;
    
            //ztg alter, use fcgi, not use cout, instead of using printf
            printf("%s
    ", "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
    ", "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
    ", "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 ]
    ", response->sMsg);
                //cout << "Terminating [KO].Err[" << response->sMsg << "]" << endl;
            }
        //
    
            return 0;
        }
    
    



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

  • 相关阅读:
    比较汇编指令 LEA 和 MOV(转载)
    整数的所有不同分割数目非递归算法
    解决vim终端下的错位问题
    busybox源码剖析(2)pwd.c
    寻找脚码2013年2月24日
    busybox源码剖析(3)cat.c
    找出没有相邻的1的二进制数的个数2013年2月17日
    iOS6开发关于集合视图UICollectionView的相关文章:
    iOS 6 开发应用集合视图(UICollectionView)使用xib文件创建集合视图单元格
    iOS6开发应用集合视图(UICollectionView)创建基于Storyboard的集合视图应用程序
  • 原文地址:https://www.cnblogs.com/ztguang/p/12647030.html
Copyright © 2011-2022 走看看