Process Pool Demo: Difference between revisions

Updated for DF v20.0
m (Changed web property to regular property)
(Updated for DF v20.0)
Line 2: Line 2:


The code for it is as follows and you can download the zip file from this link: [[File:ProcPoolDemo.zip]].
The code for it is as follows and you can download the zip file from this link: [[File:ProcPoolDemo.zip]].
(Note: now modified to work with DataFlex 20.0 as well as DataFlex 19.1... and possibly prior versions as well - no guarantees though. I have only tested with 19.1 and 20.0.)


<source lang="dataflex">
<source lang="dataflex">
Line 12: Line 14:
Use cWebSpacer.pkg
Use cWebSpacer.pkg
Use cWebList.pkg
Use cWebList.pkg
Use cWebColumn.pkg
Use cWebLabel.pkg
Use cWebLabel.pkg
Use cRegistry.pkg
Use cRegistry.pkg
Use cIniFile.pkg
Use Flexml.pkg
Define PROCESS_VM_READ          for |CI$0010
Define PROCESS_QUERY_INFORMATION for |CI$0400
   
   
Define PROCESS_VM_READ              for |CI$0010
Define PROCESS_QUERY_INFORMATION    for |CI$0400
Define KEY_WOW64_64KEY              for |CI$0100
// Wrap all these in #IFNDEF/#ENDIF blocks to avoid any conflicts
// Wrap all these in #IFNDEF/#ENDIF blocks to avoid any conflicts
// with the same things already defined in the application
// with the same things already defined in the application
Line 198: Line 203:
     Delegate Set phoDefaultView to Self
     Delegate Set phoDefaultView to Self
      
      
    // Work out the web application name from the WebServiceDispatcher.wo
//    // Work out the web application name from the WebServiceDispatcher.wo
    // file in AppHTML, which we treat like a .ini file
//    // file in AppHTML, which we treat like a .ini file
//    Function WebAppName Returns String
//        Handle hoIni
//        String sName
//       
//        Get Create (RefClass(cIniFile)) to hoIni
//        Set psFileName of hoIni to ;
//            (psAppHtmlPath(phoWorkspace(ghoApplication)) + ;
//            "\WebServiceDispatcher.wso")
//        Get ReadString of hoIni "WebService" "Application" "" to sName
//        Send Destroy of hoIni
//        Function_Return sName
//    End_Function
   
    // Work out the web application name from the web.config
    // file in AppHTML, which we read into an XML object
     Function WebAppName Returns String
     Function WebAppName Returns String
         Handle hoIni
         Handle hoXml hoElem
         String sName
         String sName
        Boolean bOK
          
          
         Get Create (RefClass(cIniFile)) to hoIni
         Get Create (RefClass(cXMLDOMDocument)) to hoXml
         Set psFileName of hoIni to ;
         Set psDocumentName of hoXml to ;
             (psAppHtmlPath(phoWorkspace(ghoApplication)) + ;
             (psAppHtmlPath(phoWorkspace(ghoApplication)) + "\web.config")
            "\WebServiceDispatcher.wso")
         Get LoadXMLDocument of hoXml to bOK
         Get ReadString of hoIni "WebService" "Application" "" to sName
        Get FindNode of hoXml "configuration/location/system.webServer/dataflexHttpModule" to hoElem
         Send Destroy of hoIni
        Get AttributeValue of hoElem "application" to sName
         Send Destroy of hoElem
        Send Destroy of hoXml
         Function_Return sName
         Function_Return sName
     End_Function
     End_Function
Line 304: Line 327:
     Object oReg is a cRegistry
     Object oReg is a cRegistry
         Set phRootKey to HKEY_LOCAL_MACHINE
         Set phRootKey to HKEY_LOCAL_MACHINE
         Set pfAccessRights to Key_Read
         Set pfAccessRights to (KEY_WOW64_64KEY ior KEY_READ)
       
       
         Function BaseKey Returns String
         Function BaseKey Returns String
             String[] asParts
             String[] asParts
           
           
             Move "SOFTWARE"                to asParts[0]
             Move "SOFTWARE"                to asParts[0]
             Move "Data Access Worldwide"    to asParts[1]
             Move "Data Access Worldwide"    to asParts[1]
Line 316: Line 339:
             Move "Web Applications"        to asParts[5]
             Move "Web Applications"        to asParts[5]
              
              
             // If it is a 64-bit machine:
             // If it is a 64-bit machine and running on a DF version PRIOR to 20
             If (KeyExists(Self, "SOFTWARE\Wow6432Node")) ;
            // Insert "Wow6432Node just after "SOFTWARE":
             If (KeyExists(Self, "SOFTWARE\Wow6432Node") and ;
                (Number(C_DFVersion) < 20)) ;
                 Move (InsertInArray(asParts, 1, "Wow6432Node")) to asParts
                 Move (InsertInArray(asParts, 1, "Wow6432Node")) to asParts
              
              
Line 327: Line 352:
             Integer iVal
             Integer iVal
             String  sKey
             String  sKey
           
 
             Move (BaseKey(Self) + "\" + sApp)  to sKey
             Move (BaseKey(Self) + "\" + sApp)  to sKey
           
             Get KeyExists sKey                  to bOK
             Get KeyExists sKey                  to bOK
   
             If not bOK ;
             If not bOK ;
                 Function_Return 0
                 Function_Return 0
              
              
             Get OpenKey sKey to bOK
             Get OpenKey sKey to bOK
           
             If not bOK ;
             If not bOK ;
                 Function_Return 0
                 Function_Return 0
               
           
             Move (ReadDWord(Self, sVal)) to iVal
             Move (ReadDWord(Self, sVal)) to iVal
             Send CloseKey
             Send CloseKey
Line 424: Line 448:
                     Set psLabel to "Current Pool:"
                     Set psLabel to "Current Pool:"
                 End_Object
                 End_Object
               
               
             End_Object
             End_Object