admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Quintiq file version 2.0
#parent: #root
Method PTF_CheckClientStatusByScript (
  LibPTF_TestScript script,
  Number executedsessions,
  Number reqsessions,
  output Number executingsessions_o,
  output String endtime_o,
  output Boolean alldone_o
) id:Method_LibPTF_pnlTestController_PTF_CheckClientStatusByScript
{
  #keys: '[104342.0.777090175]'
  Body:
  [*
    // Checks the PTF execution status of a single script and perform some post-PTF execution routine for individual script when the script has been executed successfully
    
    columnDelimiter     := LibPTF_Util::PTFLogFileColumnDelimiter(); 
    user                := script.User();
    resultfiles         := OS::ScanDirectory( this.PTF_GetResultLogPath(), LibPTF::FileExtEndResult() );
    resultfilecount     := this.PTF_GetFileCountFromResultLog( user, LibPTF::FileExtEndResult() )
    tempfilecount       := this.PTF_GetFileCountFromResultLog( user, LibPTF::FileExtTempResult() )
    timeoutbooting      := executedsessions - ( resultfilecount + tempfilecount );
    executingsessions_o := timeoutbooting + tempfilecount;
    
    
    if( resultfilecount < reqsessions )
    {
      alldone_o := false;
      if( executedsessions > 0 )
      {
        endtime_o := this.PTF_GetCurrentDatetime();
      }
    }
    else
    {
      scriptfullpath := this.PTF_GetScriptPath() + script.User() + "_" + script.Project() + LibPTF::FileExtRunningScript();
    
      // Check if UI logging is required
      if( script.LoggingOptions() = "Full"
          and OS::IsFile( scriptfullpath )
        )
      {
        // Create execution result and result line object
        traverse( resultfiles, Elements, result )
        {
          fileuser := "";
          clientid := "";
          this.PTF_GetInfoFromResultLogPath( fileuser, clientid, result );
    
          if( fileuser.ToUpper() = user.ToUpper() )
          {
            file := OSFile::Construct();
            file.Open( result, "Read", true );
            scriptresult := file.ReadTextToEnd();
            file.Close();
    
            totalduration := Duration::Zero();
            if( scriptresult.TrimBoth().Length() > 0 )
            {
              totalduration := [Duration]this.PTF_GetTotalDurationFromResultLines( scriptresult )
            }
            execresult := LibPTF_ExecResult::Create( script,
                                                     [Number]clientid,
                                                     totalduration ,
                                                     fileuser
                                                   );
    
            traverse( scriptresult.Tokenize( String::NewLine() ), Elements, line )
            {
              if( line.Length() > 0 )
              {
                linebycol       := line.Tokenize( columnDelimiter );
                starttime       := linebycol.Element( 1 ).TrimBoth();
                endtime         := linebycol.Element( 2 ).TrimBoth();
                overallduration := [Number]linebycol.Element( 3 ).TrimBoth();
                actualduration  := [Number]linebycol.Element( 4 ).TrimBoth();
                action          := linebycol.Element( 5 );
                isRunSuccess    := [Boolean]linebycol.Element( 6 ).TrimBoth();
                information     := linebycol.Element( 7 ).TrimBoth();
    
                LibPTF_ExecResultLine::Create( execresult,
                                               action,
                                               overallduration,
                                               actualduration,
                                               this.PTF_ConvertStringToDateTime( starttime ),
                                               this.PTF_ConvertStringToDateTime( endtime ),
                                               isRunSuccess,
                                               information
                                             );
              }
            }
    
          } // end if of fileuser check
        } // end of traversing result file logs
      } // end if of logging option
    
      // SUCCESSFULLY finishes the test script execution, REMOVE QRUNSCRIPT files
      OS::RemoveFile( scriptfullpath );
    } // end of else block
  *]
}