Quintiq file version 2.0
#parent: #root
Method PTF_ExecuteTest (
  structured[LibPTF_TestScript] testscripts
) id:Method_LibPTF_pnlTestController_PTF_ExecuteTest
{
  #keys: '[105690.0.201964467]'
  Body:
  [*
    // Execute the selected test scripts
    rowDelimiter    := LibPTF_Util::StringListRowDelimiter();     
    columnDelimiter := LibPTF_Util::StringListColumnDelimiter();
    
    validtestscripts := selectset( testscripts,
                                   Elements,
                                   script,
                                   true,
                                   script.IsScriptValid()
                                 );
    
    nrtotal   := testscripts.Size();
    nrvalid   := validtestscripts.Size();
    nrinvalid := nrtotal - nrvalid;
    message   := "There are " + [String]nrinvalid + " invalid test script(s)." + String::NewLine() + String::NewLine()
                 + "Do you want to execute the other " + [String]nrvalid + " valid test script(s)?";
    
    // If all scripts valid or user continues to execute other valid scripts
    if( nrvalid = nrtotal
        or MessageBox::Warning( this, message, '&Yes|&No', 1 ) = 0 )
    {
      //Logs a line in log file as an indication of the beginning of a PTF run
      LibPTF::LogRunStarted();
                                                      
      resultLogFileName := this.PTF_GetResultLogFileName();                                                  
      
      this.vhResultLogFolder().Value( resultLogFileName )
      OS::CreateDirectory( LibPTF_pnlTestController.PTF_GetResultLogPath() );
      this.gt().Enabled( true );
    
      //execute only valid testscript
      ts := validtestscripts.Copy();
      dhSelectedScripts.Data( &ts );
    
      str := "";
    
      traverse( dhSelectedScripts.Data(), Elements, script )
      {
        str := str + script.User() + columnDelimiter
                   + [String]script.TotalNrOfSessions() + columnDelimiter
                   + [String]script.NrOfSimultaneousSessions() + columnDelimiter
                   + "0" + columnDelimiter
                   + "0" + columnDelimiter
                   + [String]script.TotalNrOfSessions() + columnDelimiter
                   + "N/A" + columnDelimiter
                   + "N/A" + columnDelimiter
                   + "N/A" + columnDelimiter
                   + [String]script.Offset() + rowDelimiter ;
      }
    
      lstExecutionTestScript.Strings( str.SubString( 0, str.Length() - 1 ) );
    
    
      
      // Set labels text in panel test controller (start,end,duration)
      now := DateTime::Now();
      nowAsString := LibPTF_pnlTestController.PTF_ConvertDateTimeToString( now );    
      lblStartTime.Text( nowAsString );
      lblEndTime.Text( "N/A" );
      lblDurationTime.Text( "N/A" );
      
      LibPTF_pnlTestController.PTF_GenerateBatchFile();  
    
      // Assign LastTestStartTime attribute and current client timezone offset and timezone ID labels
      // Purpose: For update datetime string value when client timezone is changed (ONLY for timezone mode)
      LibPTF_pnlTestController.PTF_GetPTF().LastTestStartTime( now ); 
      lblClientTimezoneOffset.Text( LibPTF_pnlTestController.PTF_GetClientTimeZoneOffset() );
      lblLastClientTimeZone.Text( Application::SessionTimeZone().ID() );
    }
  *]
}
