home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / ENTRPRIS / APE / AECLIENT / CLIENT.CLS < prev    next >
Encoding:
Visual Basic class definition  |  1996-12-04  |  37.7 KB  |  862 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = 0   'False
  4. END
  5. Attribute VB_Name = "Client"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Attribute VB_Description = "Provides interface for configuring, starting, and stopping APE tests."
  11. Option Explicit
  12.  
  13. Public Enum APECallbackNotificationConstants
  14.     apeCallbackModeRegisterEveryRequest = giUSE_PASSED_CALLBACK
  15.     apeCallbackModeRegisterOnce = giUSE_DEFAULT_CALLBACK
  16.     apeCallbackModeUseRaiseEvent = giRETURN_BY_SYNC_EVENT
  17. End Enum
  18.  
  19. Public Enum APEDatasetTypeConstants
  20.     apeDatasetTypeArray = giCONTAINER_TYPE_VARRAY
  21.     apeDatasetTypeCollection = giCONTAINER_TYPE_VCOLLECTION
  22. End Enum
  23.  
  24. Public Enum APEServiceTaskConstants
  25.     apeServiceTaskDoNotUseProcessor = giUSE_PROCESSOR_NEVER
  26.     apeServiceTaskAlwaysUseProcessor = giUSE_PROCESSOR_ALWAYS
  27.     apeServiceTaskForPercentUseProcessor = giUSE_PROCESSOR_PERCENTAGE
  28.     apeServiceTaskReadDatabase = giREAD_DATABASE
  29.     apeServiceTaskWriteDatabase = giWRITE_DATABASE
  30.     apeservicetaskReadWriteDatabase = giREADWRITE_DATABASE
  31. End Enum
  32.  
  33. 'Private class level variables
  34. Private mbFirstClientOnMachine As Boolean   'If true, this is the first Client application
  35.                                             'started on this machine
  36. '*****************
  37. 'Public Properties
  38. '*****************
  39.  
  40. Public Property Set Explorer(ByVal oExplorer As APEInterfaces.Manager)
  41. Attribute Explorer.VB_Description = "Set the Manager object that the Client will use to notify test completion."
  42.     '-------------------------------------------------------------------------
  43.     'Purpose:   To give the client a reference to AEManager.Explorer
  44.     'IN:
  45.     '   [oExplorer]
  46.     '           must be valid reference to a AEManager.Explorer class object
  47.     'Effects:
  48.     '   [goExplorer]
  49.     '           Set equal to parameter
  50.     '-------------------------------------------------------------------------
  51.     Set goExplorer = oExplorer
  52. End Property
  53.  
  54. Public Property Get MachineName() As String
  55. Attribute MachineName.VB_Description = "Returns the computer name that the Client is instanciated on."
  56.     'Get the local computer name
  57.     Dim l As Long
  58.     Dim s As String
  59.     s = Space$(255)
  60.     l = GetComputerName(s, 255)
  61.     l = InStr(s, vbNullChar)
  62.     s = Left$(s, l - 1)
  63.     MachineName = s
  64. End Property
  65.  
  66. Public Property Let ConnectionAddress(ByVal sAddress As String)
  67. Attribute ConnectionAddress.VB_Description = "Set the network address for the location of the APE server."
  68.     '-------------------------------------------------------------------------
  69.     'Purpose:   The netaddress used for remote connections
  70.     'Effects:
  71.     '   [gsConnectionAddress]
  72.     '           Set equal to parameter
  73.     '-------------------------------------------------------------------------
  74.     gsConnectionAddress = sAddress
  75. End Property
  76.  
  77. Public Property Get ConnectionAddress() As String
  78.     ConnectionAddress = gsConnectionAddress
  79. End Property
  80.  
  81. Public Property Let ConnectionProtocol(ByVal sProtocol As String)
  82. Attribute ConnectionProtocol.VB_Description = "Sets the protocol to be used for Remote Automation connections."
  83.     '-------------------------------------------------------------------------
  84.     'Purpose:   The RPC protocol to use for all remote connections.
  85.     'Effects:
  86.     '   [gsConnectionProtocol]
  87.     '           Set equal to parameter
  88.     '-------------------------------------------------------------------------
  89.     gsConnectionProtocol = sProtocol
  90. End Property
  91.  
  92. Public Property Get ConnectionProtocol() As String
  93.     ConnectionProtocol = gsConnectionProtocol
  94. End Property
  95.  
  96. Public Property Let ConnectionAuthentication(ByVal lAuthentication As Long)
  97. Attribute ConnectionAuthentication.VB_Description = "Sets the authentication level to be used for Remote Automation connections."
  98.     '-------------------------------------------------------------------------
  99.     'Purpose:   The RPC authenticaion to enforce for all remote connections.
  100.     'Effects:
  101.     '   [gsConnectionAuthentication]
  102.     '           Set equal to parameter
  103.     '-------------------------------------------------------------------------
  104.     glConnectionAuthentication = lAuthentication
  105. End Property
  106.  
  107. Public Property Get ConnectionAuthentication() As Long
  108.     ConnectionAuthentication = glConnectionAuthentication
  109. End Property
  110.  
  111. Public Property Let ConnectionRemote(ByVal bRemote As Boolean)
  112. Attribute ConnectionRemote.VB_Description = "Determines if the Client will connect to a remote APE server or to a local APE server."
  113.     '-------------------------------------------------------------------------
  114.     'Purpose:   If true server is remote and ConnectionAddress, ConnectionProtocol,
  115.     '           ConnectionNetOLE, and ConnectionAuthentication apply
  116.     'Effects:
  117.     '   [gsConnectionRemote]
  118.     '           Set equal to parameter
  119.     '-------------------------------------------------------------------------
  120.     gbConnectionRemote = bRemote
  121. End Property
  122.  
  123. Public Property Get ConnectionRemote() As Boolean
  124.     ConnectionRemote = gbConnectionRemote
  125. End Property
  126.  
  127. Public Property Let ConnectionNetOLE(ByVal bNetOLE As Boolean)
  128. Attribute ConnectionNetOLE.VB_Description = "Determines if the Client will use DCOM to connect to the APE server."
  129.     '-------------------------------------------------------------------------
  130.     'Purpose:   If true use NetOLE (DCOM) for remote connection, instead of
  131.     '           Remote Automation
  132.     'Effects:
  133.     '   [gsConnectionNetOLE]
  134.     '           Set equal to parameter
  135.     '-------------------------------------------------------------------------
  136.     gbConnectionNetOLE = bNetOLE
  137. End Property
  138.  
  139. Public Property Get ConnectionNetOLE() As Boolean
  140.     ConnectionNetOLE = gbConnectionNetOLE
  141. End Property
  142.  
  143. Public Property Let ID(ByVal lID As Long)
  144. Attribute ID.VB_Description = "Sets and returns the Client ID for Client management."
  145.     '-------------------------------------------------------------------------
  146.     'Purpose:   Unique ID for the client in this test.  ID is used to seperate
  147.     '           Clients log records and differentiate title bars
  148.     'Effects:
  149.     '   [glClientID]
  150.     '           Set equal to parameter
  151.     '-------------------------------------------------------------------------
  152.     glClientID = lID
  153. End Property
  154.  
  155. Public Property Get ID() As Long
  156.     ID = glClientID
  157. End Property
  158.  
  159. Public Property Let Model(ByVal lModel As Long)
  160. Attribute Model.VB_Description = "Determines what test model the Client will perform."
  161.     '-------------------------------------------------------------------------
  162.     'Purpose:   'What model to use for this test.
  163.     '               0 or giMODEL_QUEUE - Queue Management
  164.     '               2 or gimodel_direct - Direct Instanciation
  165.     'Effects:
  166.     '   [glModel]
  167.     '           Set equal to parameter
  168.     '-------------------------------------------------------------------------
  169.     glModel = lModel
  170. End Property
  171.  
  172. Public Property Get Model() As Long
  173.     Model = glModel
  174. End Property
  175.  
  176. Public Property Let Show(ByVal bShow As Boolean)
  177. Attribute Show.VB_Description = "Determines if the Client will show a form."
  178.     '-------------------------------------------------------------------------
  179.     'Purpose:   If true, show the Client's U/I
  180.     'Effects:
  181.     '   [gbShow]
  182.     '           Set equal to parameter
  183.     '   [frmClient.Visible]
  184.     '           Set equal to parameter
  185.     '-------------------------------------------------------------------------
  186.     frmClient.Visible = bShow
  187.     gbShow = bShow
  188.     If bShow Then
  189.         'Update values on U/I
  190.         With frmClient
  191.             .lblCallsMade.Caption = 0
  192.             .lblCallsReturned.Caption = 0
  193.             .lblCallsMade.Refresh
  194.             .lblCallsReturned.Refresh
  195.         End With
  196.     End If
  197. End Property
  198.  
  199. Public Property Get Show() As Boolean
  200.     Show = gbShow
  201. End Property
  202.  
  203. Public Property Let Log(ByVal bLog As Boolean)
  204. Attribute Log.VB_Description = "Determines if the Client logs its events and errors."
  205.     '-------------------------------------------------------------------------
  206.     'Purpose:   If true, log events in the Client
  207.     'Effects:
  208.     '   [gbLog]
  209.     '           Set equal to parameter
  210.     '-------------------------------------------------------------------------
  211.     gbLog = bLog
  212. End Property
  213.  
  214. Public Property Get Log() As Boolean
  215.     Log = gbLog
  216. End Property
  217.  
  218. Public Property Let CallbackMode(ByVal lCallbackMode As APECallbackNotificationConstants)
  219. Attribute CallbackMode.VB_Description = "Determines what Callback mode that will be used."
  220.     '-------------------------------------------------------------------------
  221.     'Purpose:   Determines if and how client receives results from
  222.     '           services requested from QueueManager
  223.     '           see "Callback mode keys" in modAEConstants
  224.     'Effects:
  225.     '   [glCallbackMode]
  226.     '           Set equal to parameter
  227.     '-------------------------------------------------------------------------
  228.     Select Case lCallbackMode
  229.         Case giUSE_DEFAULT_CALLBACK, giUSE_PASSED_CALLBACK, giRETURN_BY_SYNC_EVENT
  230.             glCallbackMode = lCallbackMode
  231.         Case Else
  232.             'Default callback mode
  233.             glCallbackMode = giUSE_PASSED_CALLBACK
  234.     End Select
  235. End Property
  236.  
  237. Public Property Get CallbackMode() As APECallbackNotificationConstants
  238.     CallbackMode = glCallbackMode
  239. End Property
  240.  
  241. 'How many Kb should the log collection be allowed to take
  242. 'before it is cached to a temporary file?
  243. 'If zero, the log is not cached to a file.
  244. Public Property Let LogThreshold(ByVal lKB As Long)
  245. Attribute LogThreshold.VB_Description = "Sets the log threshold in kilobytes that determines when log records are written to a file and purged from memory."
  246.     '-------------------------------------------------------------------------
  247.     'Purpose:   Client uses the LogThreshold property to determine how many
  248.     '           kilobytes should be held in memory before writing to a file
  249.     '           and emptying log record array.
  250.     'Effects:   [glLogThreshold]
  251.     '               Becomes equal to the passed parameter
  252.     '           [glLogThresholdRecs]
  253.     '               Becomes an estimated number of records equivalent
  254.     '-------------------------------------------------------------------------
  255.     On Error Resume Next
  256.     glLogThreshold = lKB
  257.     glLogThresholdRecs = lKB * giLOG_RECORD_KILOBYTES
  258. End Property
  259.  
  260. Public Property Get LogThreshold() As Long
  261.     LogThreshold = glLogThreshold
  262. End Property
  263.  
  264. Public Property Let PreLoadServices(ByVal bPreLoad As Boolean)
  265. Attribute PreLoadServices.VB_Description = "Determines if LoadServiceObject will be called on a directly instantiated AEWorker.Worker object before beginning the test."
  266.     '-------------------------------------------------------------------------
  267.     'Purpose:   If true, call the Worker's PreLoadService method before
  268.     '           starting test
  269.     'Effects:
  270.     '   [gbPreloadServices]
  271.     '           Set equal to parameter
  272.     '-------------------------------------------------------------------------
  273.     gbPreloadServices = bPreLoad
  274. End Property
  275.  
  276. Public Property Get PreLoadServices() As Boolean
  277.     PreLoadServices = gbPreloadServices
  278. End Property
  279.  
  280. Public Property Let PersistentServices(ByVal bPersistent As Boolean)
  281. Attribute PersistentServices.VB_Description = "Sets the value that is used to set the PersistentServices property of a directly instantiated AEWorker.Worker object."
  282.     '-------------------------------------------------------------------------
  283.     'Purpose:   Sets the Worker's PersistentServices property
  284.     'Effects:
  285.     '   [gbPersistentServices]
  286.     '           Set equal to parameter
  287.     '-------------------------------------------------------------------------
  288.     gbPersistentServices = bPersistent
  289. End Property
  290.  
  291. Public Property Get PersistentServices() As Boolean
  292.     PersistentServices = gbPersistentServices
  293. End Property
  294.  
  295. Public Property Let LogWorker(ByVal bLog As Boolean)
  296. Attribute LogWorker.VB_Description = "Sets the value that is used to set the Log property of a directly instantiated AEWorker.Worker object."
  297.     '-------------------------------------------------------------------------
  298.     'Purpose:   Sets the Worker's Log property
  299.     'Effects:
  300.     '   [gbLogWorker]
  301.     '           Set equal to parameter
  302.     '-------------------------------------------------------------------------
  303.     gbLogWorker = bLog
  304. End Property
  305.  
  306. Public Property Get LogWorker() As Boolean
  307.     Log = gbLogWorker
  308. End Property
  309. Public Property Let EarlyBindServices(ByVal bEarlyBind As Boolean)
  310. Attribute EarlyBindServices.VB_Description = "Sets the value that is used to set the EarlyBindServices property of a directly instantiated AEWorker.Worker object."
  311.     '-------------------------------------------------------------------------
  312.     'Purpose:   Sets the Worker's EarlyBindServices property
  313.     'Effects:
  314.     '   [gbEarlyBindServices]
  315.     '           Set equal to parameter
  316.     '-------------------------------------------------------------------------
  317.     gbEarlyBindServices = bEarlyBind
  318. End Property
  319.  
  320. Public Property Get EarlyBindServices() As Boolean
  321.     EarlyBindServices = gbEarlyBindServices
  322. End Property
  323.  
  324. '************************
  325. 'Public Methods
  326. '************************
  327.  
  328. Function GetStatistics() As Variant
  329. Attribute GetStatistics.VB_Description = "Returns a variant array of test statistics."
  330.     '-------------------------------------------------------------------------
  331.     'Purpose:   Get the all summary status from the client.
  332.     'Return:    Returns a single dimension long array in which
  333.     '           element 0 = number of calls, 1 = Begin Milliseonds,
  334.     '           and 2 = End Milliseconds
  335.     '-------------------------------------------------------------------------
  336.     'Returns statistical data for Explorer computation
  337.     Dim lReturn(giSTAT_ARRAY_DIMENSION) As Long
  338.     lReturn(giNUM_CALLS_ELEMENT) = glCallsMade
  339.     lReturn(giBEGIN_TICKS_ELEMENT) = glFirstServiceTick
  340.     lReturn(giEND_TICKS_ELEMENT) = glLastCallbackTick
  341.     GetStatistics = lReturn()
  342. End Function
  343.  
  344. Public Function GetRecords() As Variant
  345. Attribute GetRecords.VB_Description = "Returns a variant array of log records."
  346.     '-------------------------------------------------------------------------
  347.     'Purpose:   Use to retrieve all of the log records created by the client
  348.     '           Keep calling until, it does not return a variant array
  349.     'Return:    Returns a two dimension array in which
  350.     '           the first four elements of the first dimension
  351.     '           are Component(string), ServiceID(Long),Comment(string),
  352.     '           and Milliseconds(long) respectively
  353.     '           the second dimension represents the number of log records
  354.     '           User Defined Types can not be returned from public
  355.     '           procedures of public classes
  356.     'Effects:   [gaLog]
  357.     '               Redimensioned after calling GetRecords to not have empty
  358.     '               records at the end
  359.     '           [glLastAddedRecord]
  360.     '               becomes equal to giNO_RECORDS
  361.     '-------------------------------------------------------------------------
  362.     
  363.     GetWrittenLog
  364.     'Trim the array to only send the filled elements
  365.     If glLastAddedRecord >= 0 Then
  366.         If UBound(gaLog, 2) <> glLastAddedRecord Then ReDim Preserve gaLog(giLOG_ARRAY_DIMENSION_ONE, glLastAddedRecord)
  367.         GetRecords = gaLog()
  368.         'Setting the glLastAddedRecord flag to giNO_RECORD will cause
  369.         'Write log to ignore records on the next call
  370.         glLastAddedRecord = giNO_RECORD
  371.     Else
  372.         GetRecords = Null
  373.     End If
  374. End Function
  375.  
  376. Public Sub StartTest(Optional ByVal lStartDelay As Long = -1)
  377. Attribute StartTest.VB_Description = "Starts a test."
  378.     '-------------------------------------------------------------------------
  379.     'Purpose:   Tells the client to start its Test
  380.     'IN:
  381.     '   [lStartDelay]
  382.     '           If present it will be used as the timer interval so the start test
  383.     '           can be delayed.  If missing, a default will be used.
  384.     'Assumes:   All properties have already been set
  385.     'Effects:
  386.     '   [gbRunCompleteProcedure]
  387.     '           becomes false
  388.     '   [tmrStartTest]
  389.     '           becomes enabled
  390.     '-------------------------------------------------------------------------
  391.     Dim s As String
  392.     
  393.     If gbTestInProcess Then Exit Sub
  394.     s = LoadResString(giSTART_TEST)
  395.     If gbLog Then AddLogRecord 0, s, GetTickCount(), False
  396.     DisplayStatus s
  397.     'Start timer and release the calling program.  When trmStarTest
  398.     'get's its first event it will set its inteval to 0 and call
  399.     'RunTest.
  400.     gbRunCompleteProcedure = False
  401.     With frmClient.tmrStartTest
  402.         If lStartDelay <= 0 Then lStartDelay = giDEFAULT_TIMER_INTERVAL
  403.         .Interval = lStartDelay
  404.         .Enabled = True
  405.     End With
  406.     Exit Sub
  407. End Sub
  408.  
  409.  
  410. Public Sub StopTest()
  411. Attribute StopTest.VB_Description = "Ends a test."
  412.     '-------------------------------------------------------------------------
  413.     'Purpose:   Tells the client to Stop its Test
  414.     '-------------------------------------------------------------------------
  415.     gStopTest
  416. End Sub
  417.  
  418. Public Sub SetSendData(ByVal lContainerType As APEDatasetTypeConstants, ByVal lRowSize As Long, _
  419.                             Optional ByVal bRandomizeRowSize As Variant, Optional ByVal lRowSizeMin As Variant, _
  420.                             Optional ByVal lRowSizeMax As Variant, _
  421.                             Optional ByVal lNumRows As Variant, Optional ByVal bRandomizeNumRows As Variant, _
  422.                             Optional ByVal lNumRowsMin As Variant, Optional ByVal lNumRowsMax As Variant)
  423. Attribute SetSendData.VB_Description = "Determines the type and size of data that will be passed with Service Requests."
  424.     '-------------------------------------------------------------------------
  425.     'Purpose:   Set all of the parameter for data being passed
  426.     '           in with the Service Request from the client.
  427.     'In:
  428.     '   [lContainerType]
  429.     '           A code specifying the type of data to send with the Service
  430.     '           Request.  See modAECon.bas for constants
  431.     '   [lRowSize]
  432.     '           The size of the row in bytes
  433.     '   [bRandomizeRowSize]
  434.     '           If true Client will pick a random RowSize for every Service
  435.     '           Request.  lRowSizeMin will become the Lower bound of the range
  436.     '           and lRowSizeMax will become the upper bound.
  437.     '   [lRowSizeMin]
  438.     '           Required if bRandomizeRowSize is true
  439.     '   [lRowSizemax]
  440.     '           Required if bRandomizeRowSize is true
  441.     '   [lNumRows]
  442.     '           The number of rows of data to send with the Service Request
  443.     '   [bRandomizeNumRows
  444.     '           If true Client will pick a random NumRows for every Service
  445.     '           Request.  lNumRowsMin will become the Lower bound of the range
  446.     '           and lNumRowsMax will become the upper bound.
  447.     '   [lNumRowsMin]
  448.     '           Required if bRandomizeNumRows is true
  449.     '   [lNumRowsMax]
  450.     '           Required if bRandomizeNumRows is true
  451.     'Effects:
  452.     '   [gudtSendNumRows]
  453.     '           becomes value of lNumRows
  454.     '   [gudtSendRowSize]
  455.     '           becomes value of lRowSize
  456.     '   [glSendContainerType]
  457.     '           becomes value of lContainerType
  458.     '-------------------------------------------------------------------------
  459.     glSendContainerType = lContainerType
  460.     With gudtSendRowSize
  461.         .SpecificValue = lRowSize
  462.         If IsMissing(bRandomizeRowSize) Then .Random = False Else .Random = CBool(bRandomizeRowSize)
  463.         If .Random Then
  464.             If IsMissing(lRowSizeMin) Or IsMissing(lRowSizeMax) Then
  465.                 GoTo SetSendData_InvalidParameter
  466.             Else
  467.                 .LowerValue = lRowSizeMin
  468.                 .UpperValue = lRowSizeMax
  469.             End If
  470.         End If
  471.     End With
  472.                 
  473.     With gudtSendNumRows
  474.         If Not IsMissing(lNumRows) Then .SpecificValue = lNumRows
  475.         If IsMissing(bRandomizeNumRows) Then .Random = False Else .Random = CBool(bRandomizeNumRows)
  476.         If .Random Then
  477.             If IsMissing(lNumRowsMin) Or IsMissing(lNumRowsMax) Then
  478.                 GoTo SetSendData_InvalidParameter
  479.             Else
  480.                 .LowerValue = lRowSizeMin
  481.                 .UpperValue = lRowSizeMax
  482.             End If
  483.         End If
  484.     End With
  485.     Exit Sub
  486. SetSendData_InvalidParameter:
  487.     Err.Raise giREQUIRED_PARAMETER_IS_MISSING + vbObjectError, , LoadResString(giREQUIRED_PARAMETER_IS_MISSING)
  488. End Sub
  489.  
  490. Public Sub SetReceiveData(ByVal lContainerType As APEDatasetTypeConstants, ByVal lRowSize As Long, _
  491.                             Optional ByVal bRandomizeRowSize As Variant, Optional ByVal lRowSizeMin As Variant, _
  492.                             Optional ByVal lRowSizeMax As Variant, _
  493.                             Optional ByVal lNumRows As Variant, Optional ByVal bRandomizeNumRows As Variant, _
  494.                             Optional ByVal lNumRowsMin As Variant, Optional ByVal lNumRowsMax As Variant)
  495. Attribute SetReceiveData.VB_Description = "Determines the type and size of data that will be returned as Service Request results. "
  496.     '-------------------------------------------------------------------------
  497.     'Purpose:   Set all of the parameter for data being passed
  498.     '           to the client as results of the Service Request.
  499.     'In:
  500.     '   [lContainerType]
  501.     '           A code specifying the type of data to return from the Service
  502.     '           Request.  See modAECon.bas for constants
  503.     '   [lRowSize]
  504.     '           The size of the row in bytes
  505.     '   [bRandomizeRowSize]
  506.     '           If true Client will pick a random RowSize for every Service
  507.     '           Request.  lRowSizeMin will become the Lower bound of the range
  508.     '           and lRowSizeMax will become the upper bound.
  509.     '   [lRowSizeMin]
  510.     '           Required if bRandomizeRowSize is true
  511.     '   [lRowSizemax]
  512.     '           Required if bRandomizeRowSize is true
  513.     '   [lNumRows]
  514.     '           The number of rows of data to return from the Service Request
  515.     '   [bRandomizeNumRows
  516.     '           If true Client will pick a random NumRows for every Service
  517.     '           Request.  lNumRowsMin will become the Lower bound of the range
  518.     '           and lNumRowsMax will become the upper bound.
  519.     '   [lNumRowsMin]
  520.     '           Required if bRandomize NumRows is true
  521.     '   [lNumRowsMax]
  522.     '           Required if bRandomizeNumRows is true
  523.     'Effects:
  524.     '   [gudtSendNumRows]
  525.     '           becomes value of lNumRows
  526.     '   [gudtSendRowSize]
  527.     '           becomes value of lRowSize
  528.     '   [glSendContainerType]
  529.     '           becomes value of lContainerType
  530.     '-------------------------------------------------------------------------
  531.     glReceiveContainerType = lContainerType
  532.     With gudtReceiveRowSize
  533.         .SpecificValue = lRowSize
  534.         If IsMissing(bRandomizeRowSize) Then .Random = False Else .Random = CBool(bRandomizeRowSize)
  535.         If .Random Then
  536.             If IsMissing(lRowSizeMin) Or IsMissing(lRowSizeMax) Then
  537.                 GoTo SetReceiveData_InvalidParameter
  538.             Else
  539.                 .LowerValue = lRowSizeMin
  540.                 .UpperValue = lRowSizeMax
  541.             End If
  542.         End If
  543.     End With
  544.                 
  545.     With gudtReceiveNumRows
  546.         If Not IsMissing(lNumRows) Then .SpecificValue = lNumRows
  547.         If IsMissing(bRandomizeNumRows) Then .Random = False Else .Random = CBool(bRandomizeNumRows)
  548.         If .Random Then
  549.             If IsMissing(lNumRowsMin) Or IsMissing(lNumRowsMax) Then
  550.                 GoTo SetReceiveData_InvalidParameter
  551.             Else
  552.                 .LowerValue = lRowSizeMin
  553.                 .UpperValue = lRowSizeMax
  554.             End If
  555.         End If
  556.     End With
  557.     Exit Sub
  558. SetReceiveData_InvalidParameter:
  559.     Err.Raise giREQUIRED_PARAMETER_IS_MISSING + vbObjectError, , LoadResString(giREQUIRED_PARAMETER_IS_MISSING)
  560. End Sub
  561.  
  562. Public Sub SetProperties(ByVal bShow As Boolean, Optional ByVal bLog As Variant, Optional ByVal lID As Variant, Optional ByVal lModel As Variant, _
  563.                         Optional ByVal lLogThreshold As Variant, Optional ByVal iCallbackMode As Variant)
  564. Attribute SetProperties.VB_Description = "Sets the Client related properties in one method call."
  565.     '-------------------------------------------------------------------------
  566.     'Purpose:   To set the Client properties in one method call
  567.     'Effects:   Sets the following properties to parameter values
  568.     '           Show, Log, Model, NumberOfCalls, WaitPeriod, ServiceCommand,
  569.     '           ServiceMilliseconds, UseProcessor, LogThreshold, UseDefaultCallback
  570.     '-------------------------------------------------------------------------
  571.     Me.Show = bShow
  572.     If Not IsMissing(bLog) Then gbLog = bLog
  573.     If Not IsMissing(lID) Then Me.ID = lID
  574.     If Not IsMissing(lModel) Then glModel = lModel
  575.     If Not IsMissing(lLogThreshold) Then Me.LogThreshold = lLogThreshold
  576.     If Not IsMissing(iCallbackMode) Then CallbackMode = iCallbackMode
  577. End Sub
  578.  
  579. Public Sub SetTestDuration(Optional ByVal lNumberOfCalls As Variant, _
  580.                            Optional ByVal lNumberOfMilliseconds As Variant)
  581. Attribute SetTestDuration.VB_Description = "Sets how long a test will last in number of calls or number of milliseconds."
  582.     '-------------------------------------------------------------------------
  583.     'Purpose:   The the parameters effecting the TestDuration
  584.     'In:        If no parameters are present then the test will continue
  585.     '           until interupted by the Stop test method.
  586.     '   [lNumberOfCalls]
  587.     '           If present, the test duration will last for a number of
  588.     '           calls specified by this parameter
  589.     '   [lNumberOfMilliseconds]
  590.     '           If present and lNumberOfCalls is missing, the test duration
  591.     '           will last for the number of milliseconds specified by this
  592.     '           parameter.
  593.     '-------------------------------------------------------------------------
  594.     If Not IsMissing(lNumberOfCalls) Then
  595.         giTestDurationMode = giTEST_DURATION_CALLS
  596.         glNumberOfCalls = lNumberOfCalls
  597.     ElseIf Not IsMissing(lNumberOfMilliseconds) Then
  598.         giTestDurationMode = giTEST_DURATION_TICKS
  599.         glTestDurationInTicks = lNumberOfMilliseconds
  600.     Else
  601.         giTestDurationMode = giTEST_DURATION_CONTINUE
  602.     End If
  603. End Sub
  604.  
  605. Public Sub SetWaitPeriod(ByVal lMilliseconds As Long, Optional ByVal bRandom As Variant, _
  606.                             Optional ByVal lMillisecondsMin As Variant, _
  607.                             Optional ByVal lMillisecondsMax As Variant)
  608. Attribute SetWaitPeriod.VB_Description = "Sets how long the Client will wait between submitting Service Requests in milliseconds."
  609.     '-------------------------------------------------------------------------
  610.     'Purpose:   Specifies how many Milliseconds to wait between each call
  611.     'Effects:
  612.     '   [gudtWaitPeriod]
  613.     '           Set equal to parameter
  614.     '-------------------------------------------------------------------------
  615.     With gudtWaitPeriod
  616.         .SpecificValue = lMilliseconds
  617.         If IsMissing(bRandom) Then .Random = False Else .Random = CBool(bRandom)
  618.         If .Random Then
  619.             If IsMissing(lMillisecondsMin) Or IsMissing(lMillisecondsMax) Then
  620.                 GoTo SetWaitPeriod_InvalidParameter
  621.             Else
  622.                 .LowerValue = lMillisecondsMin
  623.                 .UpperValue = lMillisecondsMax
  624.             End If
  625.         End If
  626.     End With
  627.     Exit Sub
  628. SetWaitPeriod_InvalidParameter:
  629.     Err.Raise giREQUIRED_PARAMETER_IS_MISSING + vbObjectError, , LoadResString(giREQUIRED_PARAMETER_IS_MISSING)
  630. End Sub
  631.  
  632. Public Sub SetTaskDuration(ByVal lMilliseconds As Long, Optional ByVal bRandom As Variant, _
  633.                             Optional ByVal lMillisecondsMin As Variant, _
  634.                             Optional ByVal lMillisecondsMax As Variant)
  635. Attribute SetTaskDuration.VB_Description = "Sets how long the default service object's task will execute in milliseconds."
  636.     With gudtTaskDuration
  637.         .SpecificValue = lMilliseconds
  638.         If IsMissing(bRandom) Then .Random = False Else .Random = CBool(bRandom)
  639.         If .Random Then
  640.             If IsMissing(lMillisecondsMin) Or IsMissing(lMillisecondsMax) Then
  641.                 GoTo SetTaskDuration_InvalidParameter
  642.             Else
  643.                 .LowerValue = lMillisecondsMin
  644.                 .UpperValue = lMillisecondsMax
  645.             End If
  646.         End If
  647.     End With
  648.     Exit Sub
  649. SetTaskDuration_InvalidParameter:
  650.     Err.Raise giREQUIRED_PARAMETER_IS_MISSING + vbObjectError, , LoadResString(giREQUIRED_PARAMETER_IS_MISSING)
  651. End Sub
  652.  
  653. Public Sub SetServiceTask(ByVal lServiceTask As APEServiceTaskConstants, Optional ByVal iServiceTaskPercent As Variant)
  654. Attribute SetServiceTask.VB_Description = "Sets the task that the default service will execute."
  655.     '-------------------------------------------------------------------------
  656.     'Purpose:   To instruct Client what task to require from AEService.Service
  657.     'Effects:
  658.     '   [glServiceTask]
  659.     '           Set equal to parameter
  660.     '-------------------------------------------------------------------------
  661.     glServiceTask = lServiceTask
  662.     If lServiceTask = giUSE_PROCESSOR_PERCENTAGE Then
  663.         'second parameter is required
  664.         If IsMissing(iServiceTaskPercent) Then
  665.             GoTo SetUseProcessor_InvalidParameter
  666.         Else
  667.             giUseProcPercent = iServiceTaskPercent
  668.         End If
  669.     End If
  670.     Exit Sub
  671.     
  672. SetUseProcessor_InvalidParameter:
  673.     Err.Raise giREQUIRED_PARAMETER_IS_MISSING + vbObjectError, , LoadResString(giREQUIRED_PARAMETER_IS_MISSING)
  674. End Sub
  675.  
  676. Public Sub SetServiceCommand(ByVal bUseDefaultService As Boolean, Optional ByVal sName As Variant)
  677. Attribute SetServiceCommand.VB_Description = "Determines if the default Service object or a custom service object will be used."
  678.     '-------------------------------------------------------------------------
  679.     'Purpose:   Specifies what ProgID to and command to use for Service
  680.     '           requests
  681.     'IN:
  682.     '   [bUseDefaultService]
  683.     '           If true use default service, else use require following parameter
  684.     '           as service command
  685.     '   [sName]
  686.     '           Required if bUseDefaultService is False
  687.     '           Ex: "Library.Class.Method"
  688.     'Effects:
  689.     '   [gsServiceCommand]
  690.     '           Set equal to parameter
  691.     '-------------------------------------------------------------------------
  692.     gbUseDefaultService = bUseDefaultService
  693.     If Not bUseDefaultService Then
  694.         If IsMissing(sName) Then
  695.             GoTo SetServiceCommand_InvalidParameter
  696.         ElseIf VarType(sName) <> vbString Then
  697.             GoTo SetServiceCommand_InvalidParameter
  698.         Else
  699.             gsServiceCommand = sName
  700.         End If
  701.     End If
  702.     Exit Sub
  703. SetServiceCommand_InvalidParameter:
  704.     Err.Raise giREQUIRED_PARAMETER_IS_MISSING + vbObjectError, , LoadResString(giREQUIRED_PARAMETER_IS_MISSING)
  705. End Sub
  706.  
  707. Public Sub SetWorkerProperties(ByVal bLog As Boolean, Optional ByVal bEarlyBindServices As Variant, _
  708.         Optional ByVal bPersistentServices As Variant, Optional ByVal bPreloadServices As Variant)
  709. Attribute SetWorkerProperties.VB_Description = "Sets all Worker related properties in one method call."
  710.     '-------------------------------------------------------------------------
  711.     'Purpose:   To set the Worker properties in one method call
  712.     'Effects:   Sets the following properties to parameter values
  713.     '           ShowWorker, LogWorker, EarlyBindServices, PersistentServices
  714.     '           PreloadServices
  715.     '-------------------------------------------------------------------------
  716.     gbLogWorker = bLog
  717.     If Not IsMissing(bEarlyBindServices) Then gbEarlyBindServices = bEarlyBindServices
  718.     If Not IsMissing(bPersistentServices) Then PersistentServices = bPersistentServices
  719.     If Not IsMissing(bPreloadServices) Then gbPreloadServices = bPreloadServices
  720.  
  721. End Sub
  722.  
  723. Public Sub SetConnectionProperties(ByVal bRemote As Boolean, Optional ByVal bNetOLE As Variant, _
  724.         Optional ByVal sAddress As Variant, Optional ByVal sProtocol As Variant, _
  725.         Optional ByVal lAuthentication As Variant)
  726. Attribute SetConnectionProperties.VB_Description = "Sets the connection properties in one method call."
  727.     '-------------------------------------------------------------------------
  728.     'Purpose:   To set the Connection Settings that the Client will use to
  729.     '           connect to a remote Worker
  730.     'In:
  731.     '   [bRemote]
  732.     '           If true connect to a remote Worker instead of a local one
  733.     '   [bNetOLE]
  734.     '           If true use NetOLE (DCOM) instead of Remote Automation
  735.     '   [sAddress]
  736.     '           Machine name to connect to
  737.     '   [sProtocol]
  738.     '           Protocol sequence to use when connecting to remote objects
  739.     '   [lAuthentication]
  740.     '           Authentication level to use
  741.     'Effects:   The following globals are set to the value of the corresponding
  742.     '           parameters:
  743.     '           gbConnectionRemote, gbConnectionNetOLE, gsConnectionAddress
  744.     '           gsConnectionProtocol, glConnectionAuthentication
  745.     '-------------------------------------------------------------------------
  746.     gbConnectionRemote = bRemote
  747.     If Not IsMissing(bNetOLE) Then gbConnectionNetOLE = bNetOLE
  748.     If Not IsMissing(sAddress) Then gsConnectionAddress = sAddress
  749.     If Not IsMissing(sProtocol) Then gsConnectionProtocol = sProtocol
  750.     If Not IsMissing(lAuthentication) Then glConnectionAuthentication = lAuthentication
  751.         
  752. End Sub
  753.  
  754. '******************
  755. 'Private Procedures
  756. '******************
  757.  
  758. Private Sub RestoreLocalConnSettings()
  759.     '-------------------------------------------------------------------------
  760.     'Purpose:       If this AEClient was the first client created on the local
  761.     '               machine, restores the Connections Settings of the Worker and
  762.     '               the QueueMgr to local.  Settings need to be restored to
  763.     '               local incase machine is used as a server in another session.
  764.     '-------------------------------------------------------------------------
  765.     Dim iResult As Integer
  766.     'Called by Class_Terminate
  767.     
  768.     If mbFirstClientOnMachine Then
  769.         iResult = goRegClass.SetAutoServerSettings(False, "AEWorker.Worker")
  770.         iResult = goRegClass.SetAutoServerSettings(False, "AEQueueMgr.Queue")
  771.         iResult = goRegClass.SetAutoServerSettings(False, "AEPoolMgr.Pool")
  772.     End If
  773. End Sub
  774.  
  775. Private Sub Class_Initialize()
  776.     On Error GoTo Class_InitializeError
  777.     '-------------------------------------------------------------------------
  778.     'Purpose:   If this is the first instanciation
  779.     '           Put the Client in a "Ready" state.  Load RacReg, set property
  780.     '           defaults
  781.     'Effects:
  782.     '   [glInstances]
  783.     '           increments it by one
  784.     '-------------------------------------------------------------------------
  785.     'Keep track of the number of instances
  786.     'to responsd to the first instancing
  787.     glInstances = glInstances + 1
  788.     If glInstances = 1 Then
  789.         If Not App.PrevInstance Then mbFirstClientOnMachine = True
  790.         'Make sure we don't get a timeout when starting OLE server across the net.
  791.         App.OleServerBusyRaiseError = True
  792.         App.OleServerBusyTimeout = 10000
  793.         'Create Objects
  794.         Set goRegClass = New RacReg.RegClass
  795.         
  796.         Set gcServices = New Collection
  797.         glLastAddedRecord = giNO_RECORD
  798.         'Get a temp file name
  799.         gsTempFile = GetTempFile
  800.         'Default Properties and variables
  801.         glModel = giMODEL_QUEUE
  802.         gbTestInProcess = False
  803.         glSendContainerType = giCONTAINER_TYPE_VARRAY
  804.         glReceiveContainerType = giCONTAINER_TYPE_VARRAY
  805.         gsServiceCommand = gsSERVICE_LIB_CLASS & "." & gsSERVICE_DONT_USE_PROCESSOR
  806.         glServiceTask = giUSE_PROCESSOR_NEVER
  807.         gbShow = True
  808.         gbLog = True
  809.         glModel = giMODEL_QUEUE
  810.         glCallsMade = 0
  811.         gbShow = True
  812.         gbLog = True
  813.         gbLogWorker = True
  814.         glLogThreshold = 0
  815.         'Set status flags
  816.         gbStopping = False
  817.     End If
  818.     Exit Sub
  819. Class_InitializeError:
  820.     LogError Err
  821.     Resume Next
  822. End Sub
  823.  
  824. Private Sub Class_Terminate()
  825.     '-------------------------------------------------------------------------
  826.     'Purpose:   If the last reference to the Client is destroyed
  827.     '           Close the Client
  828.     'Effects:
  829.     '           Restore Local connection settings
  830.     '           Run gStopTest
  831.     '           Delete Temporary file
  832.     '   [glInstances]
  833.     '           decrements it by one
  834.     '-------------------------------------------------------------------------
  835.     On Error GoTo Class_TerminateError
  836.     glInstances = glInstances - 1
  837.     If glInstances <= 0 Then
  838.         'There is one internal reference to the Client class in the form module.  So,
  839.         'we need to terminate when glInstances = 1 not 0.
  840.         'Call gStopTest so that Services are cancelled
  841.         'and set flag for shut down after Services are cancelled
  842.         RestoreLocalConnSettings
  843.         Close   'close in case getting logs was canceled
  844.         Kill gsTempFile
  845.         gbShutDown = True
  846.         gStopTest
  847.         Set goExplorer = Nothing
  848.     End If
  849.     Exit Sub
  850. Class_TerminateError:
  851.     Select Case Err.Number
  852.         Case ERR_FILE_NOT_FOUND
  853.             'There is no file to kill
  854.             Resume Next
  855.         Case Else
  856.             LogError Err
  857.             Resume Next
  858.     End Select
  859. End Sub
  860.  
  861.  
  862.