Microsoft Visual Studio C++ 6.0 Batch Queue Item

  1. Start Microsoft Visual Studio C++ 6.0 and select File->New.
  2. Select ATL COM AppWizard, enter a project name and click OK.
    screenshot
  3. Click Finish and then OK.
    screenshot
  4. Right click on the project and select New ATL Object
  5. Select Simple Object and press next.
    screenshot
  6. Enter a short name for your batch queue item creator object and press select the Attributes tab.
    screenshot
  7. Select Free Threading Model and press OK.
    screenshot
  8. In the class view right click on your batch queue item creator object, select Implement Interface and then press OK.
  9. Select TestScriptRunner 5.0 Type Library(5.0) in the Available type libraries and press OK.
    screenshot
  10. Select IBatchQueueCreator in the interfaces box and press OK.
    screenshot
  11. In the project file view right click on the project and select add files to project and add BatchQueueItem.h and BatchQueueItem.cpp from the Test Script Runner install directory (usually C:\Program Files\Ideal Systems Consultancy Ltd\Test Script Runner).
  12. Right click on the project and select settings.
  13. In the settings for box select All Configurations.
  14. Open the C/C++ tab, select the pre-processor category, add the Test Script Runner install directory to the Additional Include Directories box.
    screenshot
  15. In the Category select C++ Language and enable exception handling then press OK.
    screenshot
  16. In the project class view right click on the project and select New Class.
  17. In the class type box select generic type, enter a name for your batch queue item object, add BatchQueueItem in the Base class(es) box and press OK.
    screenshot
  18. Open the batch queue item object header file and add the code below before the class definition replacing DemoBatchQueueItem with the name of your batch queue item class: -
         class DemoBatchQueueItem;
         typedef CComObject<DemoBatchQueueItem> CComObjectDemoBatchQueueItem;
        
  19. Also within the class add the method: -
         virtual bool execute();
        
  20. Open the batch queue item object source file and add :BatchQueueItemr(<your batch queue item object description>,"<version>") to the constructor. In this case this will be :-
         BatchQueueItem("Demo Batch Queue Item","1.0")
        
  21. Open your Batch Queue Item Creator header and implement the four functions get_Version, create, get_NumberOfFileTypes and get_FileType. Below is the demo implementation for these. Please note you can create multiple batch queue items from the single creator object and you need to add a #include statement to each batch queue item object.
         STDMETHOD(get_Version)(BSTR * pVal)
         {
             if (pVal == NULL)
             {
                 return E_POINTER;
             }
             *pVal = CComBSTR("1.0").Detach();
             return S_OK;
         }
         STDMETHOD(create)(ULONG Index, IBatchQueueItem * * pVal)
         {
             if (pVal == NULL)
             {
                 return E_POINTER;
             }
             if (Index == 0)
             {
                 CComObjectDemoBatchQueueItem *temp;
                 CComObjectDemoBatchQueueItem::CreateInstance(&temp);
                 temp->AddRef();
                 *pVal = temp;
                 return S_OK;
             }
             return E_INVALIDARG;
         }
         STDMETHOD(get_NumberOfFileTypes)(ULONG * pVal)
         {
             if (pVal == NULL)
             {
                 return E_POINTER;
             }
             *pVal = 1;
             return S_OK;
         }
         STDMETHOD(get_FileType)(ULONG Index, BSTR * pVal)
         {
             if (pVal == NULL)
             {
                 return E_POINTER;
             }
             if (Index == 0)
             {
                 *pVal = CComBSTR("bqdemo").Detach ();
                 return S_OK;
             }
             return E_INVALIDARG;
         } 
        
  22. Compile the code and then select the program identifier from the registry file for your tester creator and add this to the system via the Admin->Add Batch Item Creator command. The program identifier for the demo batch queue item is: -
         DemoBatch_CPP_6_0.DemoBatchQueueItemCreator
        
  23. To Debug your batch queue item plug-in simply run the debugger and select PlugInRunner.exe (located in Test Script Runner install directory) as the Executable For Debug Session and press OK when informed that there are no debug symbols. Add break points in your action code and run a batch queue.

Please note that when you wish to compile your plug-in for release you may find that you have an unresolved external symbol _main. If this is the case remove the pre-processor definition _ATL_MIN_CRT (Project Settings->C/C++ Tab, Pre-processor Category - Pre-processor Definitions) then recompile.

If you wish to add logging information to your batch queue item object you can call the log method at any point. All logging entries from configuration to sever will be displayed in the logger view window and in the log file. If you wish to add debug log entries then use levels finest, finer and fine levels and change the logging level via the Logging->Set Logging Level option.

You can download the demo plug-in at: - http://www.TestScriptRunner.com/zipfiles/VCPP_6_0_DemoBatchQueueItem.zip.