| 2263 |
kivins |
1 |
//---------------------------------------------------------------------------
|
|
|
2 |
|
|
|
3 |
#pragma warn -com
|
|
|
4 |
#include <LoggingMacros.h>
|
|
|
5 |
#pragma warn +com
|
|
|
6 |
|
|
|
7 |
#include <vcl.h>
|
|
|
8 |
#pragma hdrstop
|
|
|
9 |
|
|
|
10 |
#include "stdio.h"
|
|
|
11 |
#include "io.h"
|
|
|
12 |
#include "dir.h"
|
|
|
13 |
#include "RunTests.h"
|
|
|
14 |
#include "Utilities.h"
|
|
|
15 |
|
|
|
16 |
#define MASSUDWriter "MASSUDWriter"
|
|
|
17 |
|
|
|
18 |
#define ADV_PROGRESS_BAR
|
|
|
19 |
//#define STORE_IN_DATABASE
|
|
|
20 |
#define STORE_PAYLOAD
|
|
|
21 |
#define INITIALISETXNSTRUCTURE
|
|
|
22 |
|
|
|
23 |
//---------------------------------------------------------------------------
|
|
|
24 |
#pragma package(smart_init)
|
|
|
25 |
#pragma link "Grids_ts"
|
|
|
26 |
#pragma link "TSDBGrid"
|
|
|
27 |
#pragma link "TSGrid"
|
|
|
28 |
#pragma link "AdvProgressBar"
|
|
|
29 |
#pragma resource "*.dfm"
|
|
|
30 |
TRunTestsForm *RunTestsForm;
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
//---------------------------------------------------------------------------
|
|
|
34 |
/**
|
|
|
35 |
* Process paint message.
|
|
|
36 |
*/
|
|
|
37 |
void ProcessPaintMessages( HWND Handle )
|
|
|
38 |
{
|
|
|
39 |
MSG msg;
|
|
|
40 |
while ( PeekMessage( &msg, Handle, WM_PAINT, WM_PAINT, PM_REMOVE ) )
|
|
|
41 |
{
|
|
|
42 |
DispatchMessage( &msg );
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
//---------------------------------------------------------------------------
|
|
|
48 |
__fastcall TRunTestsForm::TRunTestsForm(TComponent* Owner)
|
|
|
49 |
: TForm(Owner)
|
|
|
50 |
{
|
|
|
51 |
}
|
|
|
52 |
//---------------------------------------------------------------------------
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Get the collection of schemas and find our schema in that collection.
|
|
|
56 |
*/
|
|
|
57 |
|
|
|
58 |
const bool TRunTestsForm::findSchema( vector< AnsiString > & xmlSchemas,
|
|
|
59 |
TXMLSchema & schema,
|
|
|
60 |
const AnsiString & currentProject,
|
|
|
61 |
const int & currentIteration )
|
|
|
62 |
{
|
|
|
63 |
vector< string > schemas;
|
|
|
64 |
if ( schema.GetSchemas( schemas ) )
|
|
|
65 |
{
|
|
|
66 |
AnsiString theSchema;
|
|
|
67 |
for ( vector< string >::iterator what = schemas.begin();
|
|
|
68 |
what != schemas.end();
|
|
|
69 |
++what )
|
|
|
70 |
{
|
|
|
71 |
theSchema = what->c_str();
|
|
|
72 |
|
|
|
73 |
if ( theSchema.Pos( MASSUDWriter ) == 1 )
|
|
|
74 |
{
|
|
|
75 |
xmlSchemas.push_back( theSchema );
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
string handle;
|
|
|
81 |
for ( vector< AnsiString >::iterator where = xmlSchemas.begin();
|
|
|
82 |
where != xmlSchemas.end();
|
|
|
83 |
++where )
|
|
|
84 |
{
|
|
|
85 |
handle = where->c_str();
|
|
|
86 |
|
|
|
87 |
vector< string > schema_structures;
|
|
|
88 |
string project;
|
|
|
89 |
string majorversion;
|
|
|
90 |
|
|
|
91 |
schema.GetAttributeProperty( handle, "project", project );
|
|
|
92 |
|
|
|
93 |
if ( currentProject.UpperCase() == AnsiString( project.c_str() ).UpperCase() )
|
|
|
94 |
{
|
|
|
95 |
schema.GetAttributeProperty( handle, "majorversion", majorversion );
|
|
|
96 |
|
|
|
97 |
if ( currentIteration == atoi( majorversion.c_str() ) )
|
|
|
98 |
{
|
|
|
99 |
return ( true );
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
return ( false );
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
//---------------------------------------------------------------------------
|
|
|
109 |
/**
|
|
|
110 |
* Build the transaction map for faster lookup.
|
|
|
111 |
*/
|
|
|
112 |
|
|
|
113 |
void TRunTestsForm::buildTranactionMap( TXNIndexMap & transactions,
|
|
|
114 |
const AnsiString & currentProject,
|
|
|
115 |
const int & currentIteration )
|
|
|
116 |
{
|
|
|
117 |
TADOQuery * query = 0;
|
|
|
118 |
try
|
|
|
119 |
{
|
|
|
120 |
query = new TADOQuery( this );
|
|
|
121 |
query->Connection = Data_Module->IntegrationDBConnection;
|
|
|
122 |
|
|
|
123 |
AnsiString sql_statement;
|
|
|
124 |
sql_statement.sprintf(
|
|
|
125 |
"SELECT "
|
|
|
126 |
"NAME, "
|
|
|
127 |
"UDTYPE, "
|
|
|
128 |
"UDSUBTYPE "
|
|
|
129 |
"FROM "
|
|
|
130 |
"MASS_TXNS "
|
|
|
131 |
"WHERE "
|
|
|
132 |
"PROJECTCODE=\'%s\' AND "
|
|
|
133 |
"ITERATION=%d ",
|
|
|
134 |
currentProject.c_str(),
|
|
|
135 |
currentIteration );
|
|
|
136 |
|
|
|
137 |
query->SQL->Text = sql_statement;
|
|
|
138 |
query->Open();
|
|
|
139 |
|
|
|
140 |
unsigned short udtype = 0;
|
|
|
141 |
unsigned short udsubtype = 0;
|
|
|
142 |
unsigned int udindex = 0;
|
|
|
143 |
while ( !query->Eof )
|
|
|
144 |
{
|
|
|
145 |
udtype = query->FieldByName( "UDTYPE" )->AsInteger;
|
|
|
146 |
udsubtype = query->FieldByName( "UDSUBTYPE" )->AsInteger;
|
|
|
147 |
udindex = ( udtype << 16 ) + udsubtype;
|
|
|
148 |
|
|
|
149 |
transactions.insert( TXNIndexPair(
|
|
|
150 |
udindex,
|
|
|
151 |
query->FieldByName( "NAME" )->AsString ) );
|
|
|
152 |
|
|
|
153 |
query->Next();
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
__finally
|
|
|
157 |
{
|
|
|
158 |
delete query;
|
|
|
159 |
query = 0;
|
|
|
160 |
}
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
//---------------------------------------------------------------------------
|
|
|
165 |
/**
|
|
|
166 |
* Substitute any macros with the appropriate value.
|
|
|
167 |
*/
|
|
|
168 |
AnsiString & TRunTestsForm::substituteMacro( AnsiString & value, const unsigned short & udType )
|
|
|
169 |
{
|
|
|
170 |
if ( value == "@ACCOUNTTYPE" )
|
|
|
171 |
{
|
|
|
172 |
int accountFormat = 0;
|
|
|
173 |
switch ( udType )
|
|
|
174 |
{
|
|
|
175 |
case 1: // Card
|
|
|
176 |
accountFormat = 2;
|
|
|
177 |
break;
|
|
|
178 |
case 2: // Application
|
|
|
179 |
accountFormat = 1;
|
|
|
180 |
break;
|
|
|
181 |
case 3: // Product
|
|
|
182 |
accountFormat = 3;
|
|
|
183 |
break;
|
|
|
184 |
case 4: // Other
|
|
|
185 |
accountFormat = 4;
|
|
|
186 |
break;
|
|
|
187 |
case 5: // Audit
|
|
|
188 |
accountFormat = 4;
|
|
|
189 |
break;
|
|
|
190 |
case 6: // Event
|
|
|
191 |
accountFormat = 4;
|
|
|
192 |
break;
|
|
|
193 |
case 7: // Project
|
|
|
194 |
accountFormat = 4;
|
|
|
195 |
break;
|
|
|
196 |
} // switch
|
|
|
197 |
|
|
|
198 |
value.sprintf( "%d", accountFormat );
|
|
|
199 |
}
|
|
|
200 |
return ( value );
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
//---------------------------------------------------------------------------
|
|
|
205 |
/**
|
|
|
206 |
* Evaluate to true when the given value is a macro, and to false otherwise.
|
|
|
207 |
*/
|
|
|
208 |
const bool TRunTestsForm::isMacro( const string & value )
|
|
|
209 |
{
|
|
|
210 |
return ( value == "@ACCOUNTTYPE" );
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
//---------------------------------------------------------------------------
|
|
|
215 |
/**
|
|
|
216 |
* Build the header that we use as the basis for prefixing each transaction
|
|
|
217 |
* when prefixing is required.
|
|
|
218 |
*/
|
|
|
219 |
|
|
|
220 |
void TRunTestsForm::buildHeader( string & handle,
|
|
|
221 |
TXMLSchema & schema,
|
|
|
222 |
vector< pair< string, string > > & macros,
|
|
|
223 |
const AnsiString & currentProject,
|
|
|
224 |
const int & currentIteration )
|
|
|
225 |
{
|
|
|
226 |
const char * headerStructure = "SysHdr_t";
|
|
|
227 |
|
|
|
228 |
TADOQuery * query = 0;
|
|
|
229 |
try
|
|
|
230 |
{
|
|
|
231 |
try
|
|
|
232 |
{
|
|
|
233 |
if ( schema.Create( headerStructure, currentIteration, handle, 0 ) )
|
|
|
234 |
{
|
|
|
235 |
query = new TADOQuery( this );
|
|
|
236 |
query->Connection = Data_Module->IntegrationDBConnection;
|
|
|
237 |
|
|
|
238 |
AnsiString sqlStatement;
|
|
|
239 |
sqlStatement.sprintf(
|
|
|
240 |
"SELECT "
|
|
|
241 |
"* "
|
|
|
242 |
"FROM "
|
|
|
243 |
"TXNHDR_VALUES "
|
|
|
244 |
"WHERE "
|
|
|
245 |
"PROJECT_CODE=\'%s\' AND "
|
|
|
246 |
"ITERATION=%d ",
|
|
|
247 |
currentProject.c_str(),
|
|
|
248 |
currentIteration );
|
|
|
249 |
|
|
|
250 |
query->SQL->Text = sqlStatement;
|
|
|
251 |
query->Open();
|
|
|
252 |
|
|
|
253 |
string fieldName;
|
|
|
254 |
string fieldValue;
|
|
|
255 |
string attributePath;
|
|
|
256 |
string valuemap;
|
|
|
257 |
|
|
|
258 |
while ( !query->Eof )
|
|
|
259 |
{
|
|
|
260 |
fieldName = query->FieldByName( "FIELDNAME" )->AsString.c_str();
|
|
|
261 |
fieldValue = query->FieldByName( "FIELDVALUE" )->AsString.c_str();
|
|
|
262 |
|
|
|
263 |
if ( !isMacro( fieldValue ) )
|
|
|
264 |
{
|
|
|
265 |
attributePath = handle + "." + fieldName;
|
|
|
266 |
m_XMLSchema->GetAttributeProperty( attributePath, "valuemap", valuemap );
|
|
|
267 |
|
|
|
268 |
if ( valuemap.empty() )
|
|
|
269 |
{
|
|
|
270 |
// string fieldDatatype;
|
|
|
271 |
// schema.GetAttributeProperty( attributePath, "datatype", fieldDatatype );
|
|
|
272 |
|
|
|
273 |
if ( fieldValue[ 0 ] == '-' )
|
|
|
274 |
{
|
|
|
275 |
schema.SetAttributeValue( handle, fieldName.c_str(), atoi( fieldValue.c_str() ) );
|
|
|
276 |
}
|
|
|
277 |
else
|
|
|
278 |
{
|
|
|
279 |
schema.SetAttributeValue( handle, fieldName.c_str(), fieldValue.c_str());
|
|
|
280 |
}
|
|
|
281 |
}
|
|
|
282 |
else
|
|
|
283 |
{
|
|
|
284 |
if ( ( fieldValue[ 0 ] >= '0' && fieldValue[ 0 ] <= '9' ) ||
|
|
|
285 |
( fieldValue[ 0 ] == '-' && fieldValue[ 1 ] >= '0' && fieldValue[ 1 ] <= '9' ) )
|
|
|
286 |
{
|
|
|
287 |
schema.SetAttributeValue( handle, fieldName.c_str(), atoi( fieldValue.c_str() ) );
|
|
|
288 |
}
|
|
|
289 |
else
|
|
|
290 |
{
|
|
|
291 |
schema.SetAttributeValue( handle, fieldName.c_str(), fieldValue.c_str());
|
|
|
292 |
}
|
|
|
293 |
}
|
|
|
294 |
}
|
|
|
295 |
else
|
|
|
296 |
{
|
|
|
297 |
macros.push_back( std::pair< std::string, std::string >(
|
|
|
298 |
fieldName,
|
|
|
299 |
fieldValue ) );
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
query->Next();
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
query->Close();
|
|
|
306 |
}
|
|
|
307 |
else
|
|
|
308 |
{
|
|
|
309 |
MessageDlg( "Failed to create header structure",
|
|
|
310 |
mtError,
|
|
|
311 |
TMsgDlgButtons() << mbOK,
|
|
|
312 |
|
|
|
313 |
MTHROW( std::runtime_error, \
|
|
|
314 |
"Cannot create \"" \
|
|
|
315 |
<< headerStructure \
|
|
|
316 |
<< "\", version " \
|
|
|
317 |
<< currentIteration \
|
|
|
318 |
<< '.' );
|
|
|
319 |
}
|
|
|
320 |
}
|
|
|
321 |
catch ( ... )
|
|
|
322 |
{
|
|
|
323 |
if ( !handle.empty() )
|
|
|
324 |
{
|
|
|
325 |
schema.Destroy( handle );
|
|
|
326 |
handle = "";
|
|
|
327 |
}
|
|
|
328 |
throw;
|
|
|
329 |
}
|
|
|
330 |
}
|
|
|
331 |
__finally
|
|
|
332 |
{
|
|
|
333 |
delete query;
|
|
|
334 |
query = 0;
|
|
|
335 |
}
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
//---------------------------------------------------------------------------
|
|
|
340 |
/**
|
|
|
341 |
* Replace the given macros.
|
|
|
342 |
*/
|
|
|
343 |
void TRunTestsForm::substituteMacros(
|
|
|
344 |
string & handle,
|
|
|
345 |
TXMLSchema & schema,
|
|
|
346 |
const vector< pair< string, string > > & macros,
|
|
|
347 |
const unsigned short & udType )
|
|
|
348 |
{
|
|
|
349 |
AnsiString value;
|
|
|
350 |
for ( vector< pair< string, string > >::const_iterator
|
|
|
351 |
where = macros.begin();
|
|
|
352 |
where != macros.end();
|
|
|
353 |
++where )
|
|
|
354 |
{
|
|
|
355 |
schema.SetAttributeValue(
|
|
|
356 |
handle,
|
|
|
357 |
where->first.c_str(),
|
|
|
358 |
substituteMacro( value = where->second.c_str(), udType ).c_str() );
|
|
|
359 |
}
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
//---------------------------------------------------------------------------
|
|
|
365 |
/**
|
|
|
366 |
* Load transaction parameters.
|
|
|
367 |
*/
|
|
|
368 |
void TRunTestsForm::loadParameters( IterationParams & parameters,
|
|
|
369 |
const int & testScenario,
|
|
|
370 |
const int & transactionSpecification )
|
|
|
371 |
{
|
|
|
372 |
TADOQuery * query = 0;
|
|
|
373 |
|
|
|
374 |
try
|
|
|
375 |
{
|
|
|
376 |
AnsiString sql_statement;
|
|
|
377 |
sql_statement.sprintf(
|
|
|
378 |
"SELECT "
|
|
|
379 |
"FIELDNAME, "
|
|
|
380 |
"SUBSCRIPT, "
|
|
|
381 |
"FIELDVALUE "
|
|
|
382 |
"FROM "
|
|
|
383 |
"TXNSPEC_VALUES "
|
|
|
384 |
"WHERE "
|
|
|
385 |
"TESTSCENARIO_NO=%d AND "
|
|
|
386 |
"TXNSPEC_NO=%d AND "
|
|
|
387 |
"( FIELDVALUE IS NOT NULL OR FIELDVALUE<>\'\')",
|
|
|
388 |
testScenario,
|
|
|
389 |
transactionSpecification );
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
query = new TADOQuery( 0 );
|
|
|
393 |
query->Connection = Data_Module->IntegrationDBConnection;
|
|
|
394 |
query->SQL->Text = sql_statement;
|
|
|
395 |
|
|
|
396 |
query->Open();
|
|
|
397 |
AnsiString field;
|
|
|
398 |
while ( !query->Eof )
|
|
|
399 |
{
|
|
|
400 |
|
|
|
401 |
if ( query->FieldByName( "SUBSCRIPT" )->AsInteger == 0 )
|
|
|
402 |
{
|
|
|
403 |
field = query->FieldByName( "FIELDNAME" )->AsString;
|
|
|
404 |
}
|
|
|
405 |
else
|
|
|
406 |
{
|
|
|
407 |
field.sprintf( "%s.%d",
|
|
|
408 |
query->FieldByName( "FIELDNAME" )->AsString.c_str(),
|
|
|
409 |
query->FieldByName( "SUBSCRIPT" )->AsInteger );
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
parameters.insert(
|
|
|
413 |
IterationParamsPair(
|
|
|
414 |
field.c_str(),
|
|
|
415 |
query->FieldByName( "FIELDVALUE" )->AsString.c_str() ) );
|
|
|
416 |
|
|
|
417 |
query->Next();
|
|
|
418 |
}
|
|
|
419 |
}
|
|
|
420 |
__finally
|
|
|
421 |
{
|
|
|
422 |
delete query;
|
|
|
423 |
query = 0;
|
|
|
424 |
}
|
|
|
425 |
}
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
//---------------------------------------------------------------------------
|
|
|
429 |
/**
|
|
|
430 |
* Get the value of the key assigned last to the named table.
|
|
|
431 |
*/
|
|
|
432 |
const unsigned int getLastAssignedSk( TADOConnection * database, const char * tableName )
|
|
|
433 |
{
|
|
|
434 |
unsigned int value = 0;
|
|
|
435 |
AnsiString sqlQuery;
|
|
|
436 |
TADOQuery * query = 0;
|
|
|
437 |
|
|
|
438 |
try
|
|
|
439 |
{
|
|
|
440 |
query = new TADOQuery( 0 );
|
|
|
441 |
query->Connection = database;
|
|
|
442 |
|
|
|
443 |
AnsiString sequenceName;
|
|
|
444 |
sequenceName.sprintf( "%s_SK", tableName );
|
|
|
445 |
|
|
|
446 |
sqlQuery.sprintf(
|
|
|
447 |
"SELECT FN_SEQ_CURRVAL( \'%s\' ) FROM DUAL",
|
|
|
448 |
sequenceName );
|
|
|
449 |
query->SQL->Text = sqlQuery;
|
|
|
450 |
query->Open();
|
|
|
451 |
value = query->Fields->Fields[ 0 ]->AsInteger;
|
|
|
452 |
}
|
|
|
453 |
__finally
|
|
|
454 |
{
|
|
|
455 |
query->Close();
|
|
|
456 |
delete query;
|
|
|
457 |
}
|
|
|
458 |
|
|
|
459 |
return value;
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
//---------------------------------------------------------------------------
|
|
|
464 |
/**
|
|
|
465 |
* Create an instance of the given scenario, and evaluate to its key.
|
|
|
466 |
*/
|
|
|
467 |
void createScenario( TADOConnection * database, int & key, const unsigned int & testScenario )
|
|
|
468 |
{
|
|
|
469 |
TADOQuery * query = 0;
|
|
|
470 |
|
|
|
471 |
try
|
|
|
472 |
{
|
|
|
473 |
query = new TADOQuery( 0 );
|
|
|
474 |
query->Connection = database;
|
|
|
475 |
|
|
|
476 |
AnsiString sqlQuery;
|
|
|
477 |
sqlQuery.sprintf(
|
|
|
478 |
"INSERT INTO GENERATED_SCENARIO( TEST_SCENARIO_FK ) VALUES ( %u )",
|
|
|
479 |
testScenario );
|
|
|
480 |
|
|
|
481 |
query->SQL->Text = sqlQuery;
|
|
|
482 |
query->ExecSQL();
|
|
|
483 |
|
|
|
484 |
key = getLastAssignedSk( database, "GENERATED_SCENARIO" );
|
|
|
485 |
}
|
|
|
486 |
__finally
|
|
|
487 |
{
|
|
|
488 |
query->Close();
|
|
|
489 |
delete query;
|
|
|
490 |
}
|
|
|
491 |
}
|
|
|
492 |
|
|
|
493 |
|
|
|
494 |
//---------------------------------------------------------------------------
|
|
|
495 |
/**
|
|
|
496 |
* Create a batch for the given scenario instance, and evaluate to its key.
|
|
|
497 |
*/
|
|
|
498 |
void createBatch( TADOConnection * database, int & key, const unsigned int & number, const int & scenario )
|
|
|
499 |
{
|
|
|
500 |
TADOQuery * query = 0;
|
|
|
501 |
|
|
|
502 |
try
|
|
|
503 |
{
|
|
|
504 |
query = new TADOQuery( 0 );
|
|
|
505 |
query->Connection = database;
|
|
|
506 |
|
|
|
507 |
AnsiString sqlQuery;
|
|
|
508 |
sqlQuery.sprintf(
|
|
|
509 |
"INSERT INTO GENERATED_BATCH( GENERATED_SCENARIO_FK, SEQUENCE_NUMBER ) VALUES ( %d, %u )",
|
|
|
510 |
scenario,
|
|
|
511 |
number );
|
|
|
512 |
|
|
|
513 |
query->SQL->Text = sqlQuery;
|
|
|
514 |
query->ExecSQL();
|
|
|
515 |
|
|
|
516 |
key = getLastAssignedSk( database, "GENERATED_BATCH" );
|
|
|
517 |
}
|
|
|
518 |
__finally
|
|
|
519 |
{
|
|
|
520 |
query->Close();
|
|
|
521 |
delete query;
|
|
|
522 |
}
|
|
|
523 |
}
|
|
|
524 |
|
|
|
525 |
|
|
|
526 |
//---------------------------------------------------------------------------
|
|
|
527 |
/**
|
|
|
528 |
* Create a transaction for the given batch and transaction specification,
|
|
|
529 |
* and evaluate to its key.
|
|
|
530 |
*/
|
|
|
531 |
void createTransaction( TADOConnection * database,
|
|
|
532 |
int & key,
|
|
|
533 |
const int & batch,
|
|
|
534 |
const int & transactionSpecification,
|
|
|
535 |
TMemoryStream * payload )
|
|
|
536 |
{
|
|
|
537 |
TADOQuery * query = 0;
|
|
|
538 |
|
|
|
539 |
try
|
|
|
540 |
{
|
|
|
541 |
query = new TADOQuery( 0 );
|
|
|
542 |
query->Connection = database;
|
|
|
543 |
|
|
|
544 |
/**
|
|
|
545 |
* This is a strange way of going about inserting a row, but it
|
|
|
546 |
* seems to be the only one that works with Oracle.
|
|
|
547 |
*/
|
|
|
548 |
query->SQL->Text = "SELECT * FROM GENERATED_TRANSACTION";
|
|
|
549 |
query->Open();
|
|
|
550 |
query->Append();
|
|
|
551 |
|
|
|
552 |
query->FieldByName( "GENERATED_BATCH_FK" )->AsInteger = batch;
|
|
|
553 |
query->FieldByName( "TRANSACTION_SPECIFICATION_FK" )->AsInteger = transactionSpecification;
|
|
|
554 |
|
|
|
555 |
TBlobField *blob = dynamic_cast< TBlobField * >( query->FieldByName( "PAYLOAD" ) );
|
|
|
556 |
if ( blob )
|
|
|
557 |
{
|
|
|
558 |
blob->LoadFromStream( payload );
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
query->Post();
|
|
|
562 |
|
|
|
563 |
key = getLastAssignedSk( database, "GENERATED_TRANSACTION" );
|
|
|
564 |
}
|
|
|
565 |
__finally
|
|
|
566 |
{
|
|
|
567 |
query->Close();
|
|
|
568 |
delete query;
|
|
|
569 |
}
|
|
|
570 |
}
|
|
|
571 |
|
|
|
572 |
|
|
|
573 |
//---------------------------------------------------------------------------
|
|
|
574 |
/**
|
|
|
575 |
* Generate the given transaction.
|
|
|
576 |
*/
|
|
|
577 |
void TRunTestsForm::generateScenario( const unsigned int & testscenario_no,
|
|
|
578 |
TXNIndexMap & mass_txns,
|
|
|
579 |
const bool & isTds,
|
|
|
580 |
string & headerHandle,
|
|
|
581 |
TransactionSchedule & transactionSchedule,
|
|
|
582 |
const vector< pair< string, string > > & macros,
|
|
|
583 |
const unsigned int & repeatCount,
|
|
|
584 |
const unsigned int & total,
|
|
|
585 |
const int & batchSk )
|
|
|
586 |
{
|
|
|
587 |
TMemoryStream * payload = 0;
|
|
|
588 |
|
|
|
589 |
try
|
|
|
590 |
{
|
|
|
591 |
payload = new TMemoryStream();
|
|
|
592 |
|
|
|
593 |
bool txngen_error = false;
|
|
|
594 |
#ifdef STORE_IN_DATABASE
|
|
|
595 |
int transactionSk = 0;
|
|
|
596 |
#endif
|
|
|
597 |
for ( TransactionSchedule::iterator
|
|
|
598 |
transaction = transactionSchedule.begin();
|
|
|
599 |
!txngen_error && transaction != transactionSchedule.end();
|
|
|
600 |
++transaction )
|
|
|
601 |
{
|
|
|
602 |
payload->Clear();
|
|
|
603 |
#if 1
|
|
|
604 |
// If this is a TDS then prefix with a SysHdr_t
|
|
|
605 |
if ( isTds ) // TDS
|
|
|
606 |
{
|
|
|
607 |
substituteMacros( headerHandle, *m_XMLSchema, macros, transaction->second->getUdType() );
|
|
|
608 |
|
|
|
609 |
const string streamtype = "XDR";
|
|
|
610 |
const string stream_args;
|
|
|
611 |
void * stream = 0;
|
|
|
612 |
unsigned int stream_size = 0;
|
|
|
613 |
|
|
|
614 |
if ( m_XMLSchema->Serialise( headerHandle, streamtype, stream_args, stream, stream_size, 0, 0, 0 ) )
|
|
|
615 |
{
|
|
|
616 |
payload->Write( stream, stream_size );
|
|
|
617 |
}
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
#ifdef INITIALISETXNSTRUCTURE
|
|
|
621 |
// Initialise our transaction artefact with its parameters
|
|
|
622 |
if ( InitialiseTxnStructure(
|
|
|
623 |
transaction->second->getHandle(),
|
|
|
624 |
0,
|
|
|
625 |
transaction->second->getIterationParameters() ) )
|
|
|
626 |
#endif
|
|
|
627 |
{
|
|
|
628 |
// If we have initialised the Txn successfully then Serialise the outcome
|
|
|
629 |
|
|
|
630 |
const string streamtype = "XDR";
|
|
|
631 |
const string stream_args;
|
|
|
632 |
void * stream = 0;
|
|
|
633 |
unsigned int stream_size = 0;
|
|
|
634 |
|
|
|
635 |
if ( m_XMLSchema->Serialise(
|
|
|
636 |
transaction->second->getHandle(),
|
|
|
637 |
streamtype,
|
|
|
638 |
stream_args,
|
|
|
639 |
stream,
|
|
|
640 |
stream_size,
|
|
|
641 |
0,
|
|
|
642 |
0,
|
|
|
643 |
|
|
|
644 |
{
|
|
|
645 |
payload->Write( stream, stream_size );
|
|
|
646 |
#ifdef STORE_IN_DATABASE
|
|
|
647 |
createTransaction(
|
|
|
648 |
Data_Module->IntegrationDBConnection,
|
|
|
649 |
transactionSk,
|
|
|
650 |
batchSk,
|
|
|
651 |
transaction->first,
|
|
|
652 |
payload );
|
|
|
653 |
#endif
|
|
|
654 |
}
|
|
|
655 |
else
|
|
|
656 |
{
|
|
|
657 |
AnsiString msg;
|
|
|
658 |
msg.sprintf(
|
|
|
659 |
"Failed to serialise txn \'%s\' for \'%s\'",
|
|
|
660 |
transaction->second->getName().c_str(),
|
|
|
661 |
m_testcase.c_str() );
|
|
|
662 |
|
|
|
663 |
MessageDlg(msg, mtError, TMsgDlgButtons() << mbOK, 0);
|
|
|
664 |
|
|
|
665 |
txngen_error = true;
|
|
|
666 |
}
|
|
|
667 |
}
|
|
|
668 |
#ifdef INITIALISETXNSTRUCTURE
|
|
|
669 |
else
|
|
|
670 |
{
|
|
|
671 |
txngen_error = true;
|
|
|
672 |
}
|
|
|
673 |
#endif
|
|
|
674 |
#endif
|
|
|
675 |
} // while
|
|
|
676 |
}
|
|
|
677 |
__finally
|
|
|
678 |
{
|
|
|
679 |
delete payload;
|
|
|
680 |
payload = 0;
|
|
|
681 |
}
|
|
|
682 |
}
|
|
|
683 |
|
|
|
684 |
|
|
|
685 |
//---------------------------------------------------------------------------
|
|
|
686 |
/**
|
|
|
687 |
* Read the transaction schedule for the given test scenario.
|
|
|
688 |
*/
|
|
|
689 |
void TRunTestsForm::readTransactionSchedule( TADOConnection * database,
|
|
|
690 |
TXMLSchema & schema,
|
|
|
691 |
const int & currentIteration,
|
|
|
692 |
TXNIndexMap & massTransactions,
|
|
|
693 |
const int & testScenario,
|
|
|
694 |
TransactionSchedule & transactionSchedule )
|
|
|
695 |
{
|
|
|
696 |
TADOQuery * query = 0;
|
|
|
697 |
try
|
|
|
698 |
{
|
|
|
699 |
query = new TADOQuery( 0 );
|
|
|
700 |
query->Connection = database;
|
|
|
701 |
|
|
|
702 |
AnsiString sqlQuery;
|
|
|
703 |
sqlQuery.sprintf(
|
|
|
704 |
"SELECT "
|
|
|
705 |
"TXNSPEC_NO, "
|
|
|
706 |
"UDTYPE, "
|
|
|
707 |
"UDSUBTYPE "
|
|
|
708 |
"FROM "
|
|
|
709 |
"TRANSACTION_SPECIFICATION "
|
|
|
710 |
"WHERE "
|
|
|
711 |
"TESTSCENARIO_NO=%d "
|
|
|
712 |
"ORDER BY "
|
|
|
713 |
"SEQ_NO",
|
|
|
714 |
testScenario );
|
|
|
715 |
|
|
|
716 |
query->SQL->Text = sqlQuery;
|
|
|
717 |
|
|
|
718 |
pair< TransactionSchedule::iterator, bool > where;
|
|
|
719 |
int transactionSpecification = 0;
|
|
|
720 |
unsigned short udType = 0;
|
|
|
721 |
unsigned short udSubtype = 0;
|
|
|
722 |
TransactionArtefact * transactionArtefact = 0;
|
|
|
723 |
string handle;
|
|
|
724 |
TXNIndexMap::iterator transaction;
|
|
|
725 |
string structureName;
|
|
|
726 |
|
|
|
727 |
for ( query->Open(); !query->Eof; query->Next() )
|
|
|
728 |
{
|
|
|
729 |
transactionSpecification = query->FieldByName( "TXNSPEC_NO" )->AsInteger;
|
|
|
730 |
udType = query->FieldByName( "UDTYPE" )->AsInteger;
|
|
|
731 |
udSubtype = query->FieldByName( "UDSUBTYPE" )->AsInteger;
|
|
|
732 |
|
|
|
733 |
// Resolve the UD type and subtype into a structure name.
|
|
|
734 |
transaction = massTransactions.find( ( udType << 16 ) + udSubtype );
|
|
|
735 |
if ( transaction != massTransactions.end() )
|
|
|
736 |
{
|
|
|
737 |
structureName = transaction->second.c_str();
|
|
|
738 |
|
|
|
739 |
where = transactionSchedule.insert(
|
|
|
740 |
TransactionSchedule::value_type( transactionSpecification, 0 ) );
|
|
|
741 |
if ( where.second )
|
|
|
742 |
{
|
|
|
743 |
try
|
|
|
744 |
{
|
|
|
745 |
transactionArtefact = new TransactionArtefact(
|
|
|
746 |
schema,
|
|
|
747 |
structureName,
|
|
|
748 |
udType );
|
|
|
749 |
|
|
|
750 |
if ( schema.Create( "",
|
|
|
751 |
structureName.c_str(),
|
|
|
752 |
currentIteration,
|
|
|
753 |
handle,
|
|
|
754 |
|
|
|
755 |
{
|
|
|
756 |
where.first->second = transactionArtefact;
|
|
|
757 |
transactionArtefact->setHandle( handle );
|
|
|
758 |
}
|
|
|
759 |
else
|
|
|
760 |
{
|
|
|
761 |
MTHROW( std::runtime_error, \
|
|
|
762 |
"Cannot create structure \"" \
|
|
|
763 |
<< structureName \
|
|
|
764 |
<< "\" for iteration " \
|
|
|
765 |
<< currentIteration \
|
|
|
766 |
<< '.' );
|
|
|
767 |
}
|
|
|
768 |
|
|
|
769 |
loadParameters(
|
|
|
770 |
transactionArtefact->getIterationParameters(),
|
|
|
771 |
testScenario,
|
|
|
772 |
transactionSpecification );
|
|
|
773 |
}
|
|
|
774 |
catch ( ... )
|
|
|
775 |
{
|
|
|
776 |
delete transactionArtefact;
|
|
|
777 |
transactionArtefact = 0;
|
|
|
778 |
|
|
|
779 |
transactionSchedule.erase( where.first );
|
|
|
780 |
|
|
|
781 |
throw;
|
|
|
782 |
}
|
|
|
783 |
}
|
|
|
784 |
else
|
|
|
785 |
{
|
|
|
786 |
MTHROW( std::runtime_error, \
|
|
|
787 |
"Cannot cache handle for structure \"" \
|
|
|
788 |
<< structureName \
|
|
|
789 |
<< "\"." );
|
|
|
790 |
}
|
|
|
791 |
}
|
|
|
792 |
else
|
|
|
793 |
{
|
|
|
794 |
MTHROW( std::runtime_error, \
|
|
|
795 |
"Cannot find structure for UD type " \
|
|
|
796 |
<< udType \
|
|
|
797 |
<< ", subtype " \
|
|
|
798 |
<< udSubtype \
|
|
|
799 |
<< '.' );
|
|
|
800 |
}
|
|
|
801 |
}
|
|
|
802 |
}
|
|
|
803 |
__finally
|
|
|
804 |
{
|
|
|
805 |
query->Close();
|
|
|
806 |
delete query;
|
|
|
807 |
}
|
|
|
808 |
}
|
|
|
809 |
|
|
|
810 |
|
|
|
811 |
//---------------------------------------------------------------------------
|
|
|
812 |
/**
|
|
|
813 |
* Generate the given test case.
|
|
|
814 |
*/
|
|
|
815 |
void TRunTestsForm::generateTestCase( void )
|
|
|
816 |
{
|
|
|
817 |
#ifdef ADV_PROGRESS_BAR
|
|
|
818 |
m_progressBar->Show();
|
|
|
819 |
m_progressBar->Position = 0;
|
|
|
820 |
#else
|
|
|
821 |
m_progressBarOld->Show();
|
|
|
822 |
m_progressBarOld->Position = 0;
|
|
|
823 |
#endif
|
|
|
824 |
|
|
|
825 |
const bool isTds = ( GenerationTargetComboBox->ItemIndex == 1 );
|
|
|
826 |
|
|
|
827 |
TransactionSchedule transactionSchedule;
|
|
|
828 |
|
|
|
829 |
TADOQuery * query = 0;
|
|
|
830 |
try
|
|
|
831 |
{
|
|
|
832 |
const bool foundSchema = findSchema(
|
|
|
833 |
m_xml_schemas,
|
|
|
834 |
*m_XMLSchema,
|
|
|
835 |
m_currentproject,
|
|
|
836 |
m_currentiteration );
|
|
|
837 |
|
|
|
838 |
// Did we find the Target XML Writer Schema ?
|
|
|
839 |
if ( foundSchema )
|
|
|
840 |
{
|
|
|
841 |
/**
|
|
|
842 |
* When we need a header, then create the header that we'll
|
|
|
843 |
* prepend to every transaction. Macros are evaluated later,
|
|
|
844 |
* so we need to remember them until then.
|
|
|
845 |
*/
|
|
|
846 |
string headerHandle;
|
|
|
847 |
vector< pair< string, string > > macros;
|
|
|
848 |
if ( isTds )
|
|
|
849 |
{
|
|
|
850 |
buildHeader(
|
|
|
851 |
headerHandle,
|
|
|
852 |
*m_XMLSchema,
|
|
|
853 |
macros,
|
|
|
854 |
m_currentproject,
|
|
|
855 |
m_currentiteration );
|
|
|
856 |
}
|
|
|
857 |
|
|
|
858 |
Data_Module->IntegrationDBConnection->BeginTrans();
|
|
|
859 |
|
|
|
860 |
AnsiString sql_statement;
|
|
|
861 |
|
|
|
862 |
query = new TADOQuery( this );
|
|
|
863 |
query->Connection = Data_Module->IntegrationDBConnection;
|
|
|
864 |
|
|
|
865 |
// Build a MASS Txn Map for fast lookup
|
|
|
866 |
TXNIndexMap mass_txns;
|
|
|
867 |
buildTranactionMap( mass_txns, m_currentproject, m_currentiteration );
|
|
|
868 |
|
|
|
869 |
// Process ALL TestScenarios, in order, for this TestCase
|
|
|
870 |
|
|
|
871 |
bool txngen_error = false;
|
|
|
872 |
|
|
|
873 |
sql_statement="";
|
|
|
874 |
sql_statement.sprintf("select testscenario_no,testcase_seqno,name,repeat_count,batch_size "
|
|
|
875 |
"from test_scenarios "
|
|
|
876 |
"where project_code='%s' and iteration=%d "
|
|
|
877 |
"and testcase_id='%s' "
|
|
|
878 |
"order by testcase_seqno",
|
|
|
879 |
m_currentproject.c_str(),
|
|
|
880 |
m_currentiteration,
|
|
|
881 |
m_testcase.c_str());
|
|
|
882 |
|
|
|
883 |
query->SQL->Text = sql_statement;
|
|
|
884 |
|
|
|
885 |
/**
|
|
|
886 |
* First, we traverse the result set to scope out the work that
|
|
|
887 |
* we're about to embark upon. We use this as an indication of
|
|
|
888 |
* progress.
|
|
|
889 |
*/
|
|
|
890 |
query->Open();
|
|
|
891 |
unsigned int total = 0;
|
|
|
892 |
unsigned int count = 0;
|
|
|
893 |
while ( !query->Eof )
|
|
|
894 |
{
|
|
|
895 |
total += ( !query->FieldByName("REPEAT_COUNT")->IsNull
|
|
|
896 |
? query->FieldByName("REPEAT_COUNT")->AsInteger
|
|
|
897 |
: 1 );
|
|
|
898 |
query->Next();
|
|
|
899 |
}
|
|
|
900 |
query->Close();
|
|
|
901 |
|
|
|
902 |
/**
|
|
|
903 |
* Now we traverse the result set to actually do the work.
|
|
|
904 |
*/
|
|
|
905 |
query->Open();
|
|
|
906 |
TDateTime beginning = TDateTime::CurrentDateTime();
|
|
|
907 |
TDateTime now = TDateTime::CurrentDateTime();
|
|
|
908 |
TDateTime update = TDateTime::CurrentDateTime();
|
|
|
909 |
const TDateTime step( 0, 0, 2, 500 );
|
|
|
910 |
double duration;
|
|
|
911 |
double estimate;
|
|
|
912 |
double scale = 0.0;
|
|
|
913 |
AnsiString progress;
|
|
|
914 |
|
|
|
915 |
#ifdef STORE_IN_DATABASE
|
|
|
916 |
int scenarioSk = 0;
|
|
|
917 |
#endif
|
|
|
918 |
int batchSk = 0;
|
|
|
919 |
int batchNumber = 0;
|
|
|
920 |
unsigned int batchLength = 0;
|
|
|
921 |
while ( !txngen_error && !query->Eof )
|
|
|
922 |
{
|
|
|
923 |
const unsigned int testscenario_no = query->FieldByName( "TESTSCENARIO_NO" )->AsInteger;
|
|
|
924 |
const unsigned int repeatCount = ( !query->FieldByName( "REPEAT_COUNT" )->IsNull
|
|
|
925 |
? query->FieldByName("REPEAT_COUNT")->AsInteger
|
|
|
926 |
: 1 );
|
|
|
927 |
const unsigned int batchSize = ( !query->FieldByName( "BATCH_SIZE" )->IsNull
|
|
|
928 |
? query->FieldByName("batch_size")->AsInteger
|
|
|
929 |
: 1 );
|
|
|
930 |
const AnsiString name = query->FieldByName("NAME")->AsString.c_str();
|
|
|
931 |
|
|
|
932 |
AnsiString testcase_desc;
|
|
|
933 |
testcase_desc.sprintf("(%d) %s",
|
|
|
934 |
query->FieldByName("TESTCASE_SEQNO")->AsInteger,
|
|
|
935 |
name.c_str()
|
|
|
936 |
);
|
|
|
937 |
|
|
|
938 |
readTransactionSchedule(
|
|
|
939 |
Data_Module->IntegrationDBConnection,
|
|
|
940 |
*m_XMLSchema,
|
|
|
941 |
m_currentiteration,
|
|
|
942 |
mass_txns,
|
|
|
943 |
testscenario_no,
|
|
|
944 |
transactionSchedule );
|
|
|
945 |
batchNumber = 1;
|
|
|
946 |
batchLength = 0;
|
|
|
947 |
#ifdef STORE_IN_DATABASE
|
|
|
948 |
createScenario(
|
|
|
949 |
Data_Module->IntegrationDBConnection,
|
|
|
950 |
scenarioSk,
|
|
|
951 |
testscenario_no );
|
|
|
952 |
createBatch(
|
|
|
953 |
Data_Module->IntegrationDBConnection,
|
|
|
954 |
batchSk,
|
|
|
955 |
batchNumber,
|
|
|
956 |
scenarioSk );
|
|
|
957 |
#endif
|
|
|
958 |
// TTreeNode *testcase_node = TestCaseTxnTreeView->Items->AddObject(NULL, testcase_desc, (void *)testscenario_no);
|
|
|
959 |
|
|
|
960 |
/**
|
|
|
961 |
* Determine the set of Transaction Specifications for the ordered
|
|
|
962 |
* set of test scenarios
|
|
|
963 |
*/
|
|
|
964 |
for ( unsigned int i=0; i<repeatCount; ++i )
|
|
|
965 |
{
|
|
|
966 |
if ( batchLength >= batchSize )
|
|
|
967 |
{
|
|
|
968 |
++batchNumber;
|
|
|
969 |
batchLength = 1;
|
|
|
970 |
|
|
|
971 |
#ifdef STORE_IN_DATABASE
|
|
|
972 |
createBatch(
|
|
|
973 |
Data_Module->IntegrationDBConnection,
|
|
|
974 |
batchSk,
|
|
|
975 |
batchNumber,
|
|
|
976 |
scenarioSk );
|
|
|
977 |
#endif
|
|
|
978 |
}
|
|
|
979 |
else
|
|
|
980 |
{
|
|
|
981 |
++batchLength;
|
|
|
982 |
}
|
|
|
983 |
generateScenario(
|
|
|
984 |
testscenario_no,
|
|
|
985 |
mass_txns,
|
|
|
986 |
isTds,
|
|
|
987 |
headerHandle,
|
|
|
988 |
transactionSchedule,
|
|
|
989 |
macros,
|
|
|
990 |
repeatCount,
|
|
|
991 |
total,
|
|
|
992 |
batchSk );
|
|
|
993 |
++count;
|
|
|
994 |
|
|
|
995 |
now = TDateTime::CurrentDateTime();
|
|
|
996 |
if ( now - update >= step )
|
|
|
997 |
{
|
|
|
998 |
scale = double( total ) / double( count );
|
|
|
999 |
duration = now - beginning;
|
|
|
1000 |
estimate = ( duration * scale ) - duration;
|
|
|
1001 |
StatusBar->Panels->Items[0]->Text = "rt Estimated Time Remaining: " + TDateTime( estimate ).FormatString( "tt" );
|
|
|
1002 |
|
|
|
1003 |
progress.sprintf( "Count: %d, avg: %f ms/t",
|
|
|
1004 |
count,
|
|
|
1005 |
( duration / count ) * 24 * 60 * 60 * 1000 );
|
|
|
1006 |
StatusBar->Panels->Items[1]->Text = progress;
|
|
|
1007 |
|
|
|
1008 |
ProcessPaintMessages( StatusBar->Handle );
|
|
|
1009 |
|
|
|
1010 |
update = now;
|
|
|
1011 |
}
|
|
|
1012 |
#ifdef ADV_PROGRESS_BAR
|
|
|
1013 |
if ( m_progressBar->Position != int( count / double( total ) * 100.0 ) )
|
|
|
1014 |
{
|
|
|
1015 |
m_progressBar->Position = int( count / double( total ) * 100.0 );
|
|
|
1016 |
}
|
|
|
1017 |
#else
|
|
|
1018 |
m_progressBarOld->Position = count / double( total ) * 100.0;
|
|
|
1019 |
#endif
|
|
|
1020 |
}
|
|
|
1021 |
|
|
|
1022 |
query->Next();
|
|
|
1023 |
} // while
|
|
|
1024 |
|
|
|
1025 |
StatusBar->Panels->Items[0]->Text = "";
|
|
|
1026 |
StatusBar->Panels->Items[1]->Text = "";
|
|
|
1027 |
|
|
|
1028 |
if (!txngen_error)
|
|
|
1029 |
{
|
|
|
1030 |
Data_Module->IntegrationDBConnection->CommitTrans();
|
|
|
1031 |
}
|
|
|
1032 |
}
|
|
|
1033 |
else
|
|
|
1034 |
{
|
|
|
1035 |
AnsiString msg;
|
|
|
1036 |
|
|
|
1037 |
msg.sprintf("Failed to locate XML for %s (%s) Iteration: %d\nPlease verify XMLSchema.ini",
|
|
|
1038 |
MASSUDWriter,
|
|
|
1039 |
m_currentproject.c_str(),
|
|
|
1040 |
m_currentiteration
|
|
|
1041 |
);
|
|
|
1042 |
|
|
|
1043 |
MessageDlg(msg.c_str(),
|
|
|
1044 |
mtError, TMsgDlgButtons() << mbOK, 0);
|
|
|
1045 |
}
|
|
|
1046 |
}
|
|
|
1047 |
__finally
|
|
|
1048 |
{
|
|
|
1049 |
delete query;
|
|
|
1050 |
query = 0;
|
|
|
1051 |
|
|
|
1052 |
if (Data_Module->IntegrationDBConnection->InTransaction)
|
|
|
1053 |
{
|
|
|
1054 |
Data_Module->IntegrationDBConnection->RollbackTrans();
|
|
|
1055 |
}
|
|
|
1056 |
|
|
|
1057 |
// Clear the transaction schedule.
|
|
|
1058 |
for ( TransactionSchedule::iterator where = transactionSchedule.begin();
|
|
|
1059 |
where != transactionSchedule.end();
|
|
|
1060 |
++where )
|
|
|
1061 |
{
|
|
|
1062 |
delete where->second;
|
|
|
1063 |
where->second = 0;
|
|
|
1064 |
}
|
|
|
1065 |
transactionSchedule.clear();
|
|
|
1066 |
|
|
|
1067 |
#ifdef ADV_PROGRESS_BAR
|
|
|
1068 |
m_progressBar->Hide();
|
|
|
1069 |
#else
|
|
|
1070 |
m_progressBarOld->Hide();
|
|
|
1071 |
#endif
|
|
|
1072 |
}
|
|
|
1073 |
}
|
|
|
1074 |
|
|
|
1075 |
|
|
|
1076 |
//---------------------------------------------------------------------------
|
|
|
1077 |
void __fastcall TRunTestsForm::GenerateTransactionsClick(TObject *Sender)
|
|
|
1078 |
{
|
|
|
1079 |
const TCursor Save_Cursor = Screen->Cursor;
|
|
|
1080 |
Screen->Cursor = crHourGlass;
|
|
|
1081 |
|
|
|
1082 |
try
|
|
|
1083 |
{
|
|
|
1084 |
TestCaseTxnTreeView->Items->Clear();
|
|
|
1085 |
generateTestCase();
|
|
|
1086 |
MWARNING( "TODO: rebuild tree view." );
|
|
|
1087 |
}
|
|
|
1088 |
__finally
|
|
|
1089 |
{
|
|
|
1090 |
Screen->Cursor = Save_Cursor;
|
|
|
1091 |
}
|
|
|
1092 |
}
|
|
|
1093 |
|
|
|
1094 |
|
|
|
1095 |
//---------------------------------------------------------------------------
|
|
|
1096 |
bool __fastcall TRunTestsForm::InitialiseTxnStructure(const string &structure_handle, int subscript, IterationParams &structure_params)
|
|
|
1097 |
{
|
|
|
1098 |
vector<string> structure_attributes;
|
|
|
1099 |
vector<string>::iterator s_itr;
|
|
|
1100 |
// AnsiString sql_statement;
|
|
|
1101 |
bool noerror = true;
|
|
|
1102 |
|
|
|
1103 |
m_XMLSchema->GetAttributes(structure_handle, structure_attributes);
|
|
|
1104 |
|
|
|
1105 |
s_itr = structure_attributes.begin();
|
|
|
1106 |
while ( noerror && (s_itr != structure_attributes.end()) )
|
|
|
1107 |
{
|
|
|
1108 |
string elementtype;
|
|
|
1109 |
string attr_handle = (*s_itr);
|
|
|
1110 |
|
|
|
1111 |
m_XMLSchema->GetAttributeProperty(attr_handle, "type", elementtype);
|
|
|
1112 |
|
|
|
1113 |
if (elementtype == "field")
|
|
|
1114 |
{
|
|
|
1115 |
string datatype;
|
|
|
1116 |
|
|
|
1117 |
m_XMLSchema->GetAttributeProperty(attr_handle, "datatype", datatype);
|
|
|
1118 |
|
|
|
1119 |
if (datatype == "Struct")
|
|
|
1120 |
{
|
|
|
1121 |
noerror = InitialiseTxnStructure(attr_handle, subscript, structure_params);
|
|
|
1122 |
}
|
|
|
1123 |
else
|
|
|
1124 |
{
|
|
|
1125 |
string fieldname;
|
|
|
1126 |
string tagvalue;
|
|
|
1127 |
string xpath;
|
|
|
1128 |
|
|
|
1129 |
m_XMLSchema->GetAttributeProperty(attr_handle, "tag", tagvalue);
|
|
|
1130 |
|
|
|
1131 |
if (tagvalue.length() > 0)
|
|
|
1132 |
{
|
|
|
1133 |
m_XMLSchema->GetAttributeProperty(attr_handle, "name", fieldname);
|
|
|
1134 |
|
|
|
1135 |
AnsiString fieldid;
|
|
|
1136 |
|
|
|
1137 |
if (subscript == 0)
|
|
|
1138 |
{
|
|
|
1139 |
fieldid = fieldname.c_str();
|
|
|
1140 |
}
|
|
|
1141 |
else
|
|
|
1142 |
{
|
|
|
1143 |
fieldid.sprintf("%s.%d", fieldname.c_str(), subscript);
|
|
|
1144 |
}
|
|
|
1145 |
|
|
|
1146 |
IterationParams::iterator f_itr = structure_params.find(fieldid.c_str());
|
|
|
1147 |
|
|
|
1148 |
if (f_itr != structure_params.end())
|
|
|
1149 |
{
|
|
|
1150 |
string fieldvalue = (*f_itr).second;
|
|
|
1151 |
string valuemap;
|
|
|
1152 |
|
|
|
1153 |
m_XMLSchema->GetAttributeProperty(attr_handle, "valuemap", valuemap);
|
|
|
1154 |
if (valuemap.empty())
|
|
|
1155 |
{
|
|
|
1156 |
if (fieldvalue[0] == '-')
|
|
|
1157 |
{
|
|
|
1158 |
int int_value = atoi( fieldvalue.c_str() );
|
|
|
1159 |
|
|
|
1160 |
m_XMLSchema->SetAttributeValue(attr_handle, "", int_value);
|
|
|
1161 |
}
|
|
|
1162 |
else
|
|
|
1163 |
if (m_XMLSchema->SetAttributeValue(attr_handle, "", fieldvalue.c_str()) == false)
|
|
|
1164 |
{
|
|
|
1165 |
AnsiString msg;
|
|
|
1166 |
msg.sprintf("Failed to initialise attribute '%s' to (%s) DataType: %s\n"
|
|
|
1167 |
"Continue ?",
|
|
|
1168 |
fieldname.c_str(), fieldvalue.c_str(),
|
|
|
1169 |
datatype.c_str());
|
|
|
1170 |
|
|
|
1171 |
if (MessageDlg(msg, mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrNo)
|
|
|
1172 |
{
|
|
|
1173 |
noerror = false;
|
|
|
1174 |
}
|
|
|
1175 |
}
|
|
|
1176 |
}
|
|
|
1177 |
else
|
|
|
1178 |
{
|
|
|
1179 |
if ( (fieldvalue[0] == '-') || (fieldvalue[0] >='0' && fieldvalue[0] <='9') )
|
|
|
1180 |
{
|
|
|
1181 |
int int_value = atoi( fieldvalue.c_str() );
|
|
|
1182 |
|
|
|
1183 |
if (m_XMLSchema->SetAttributeValue(attr_handle, "", int_value) == false)
|
|
|
1184 |
{
|
|
|
1185 |
AnsiString msg;
|
|
|
1186 |
msg.sprintf("Failed to initialise attribute '%s' to (%s) DataType: %s\n"
|
|
|
1187 |
"Continue ?",
|
|
|
1188 |
fieldname.c_str(), fieldvalue.c_str(),
|
|
|
1189 |
datatype.c_str());
|
|
|
1190 |
|
|
|
1191 |
if (MessageDlg(msg, mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrNo)
|
|
|
1192 |
{
|
|
|
1193 |
noerror = false;
|
|
|
1194 |
}
|
|
|
1195 |
}
|
|
|
1196 |
}
|
|
|
1197 |
else
|
|
|
1198 |
{
|
|
|
1199 |
if (m_XMLSchema->SetAttributeValue(attr_handle, "", fieldvalue.c_str()) == false)
|
|
|
1200 |
{
|
|
|
1201 |
AnsiString msg;
|
|
|
1202 |
msg.sprintf("Failed to initialise attribute '%s' to (%s) DataType: %s\n"
|
|
|
1203 |
"Continue ?",
|
|
|
1204 |
fieldname.c_str(), fieldvalue.c_str(),
|
|
|
1205 |
datatype.c_str());
|
|
|
1206 |
|
|
|
1207 |
if (MessageDlg(msg, mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrNo)
|
|
|
1208 |
{
|
|
|
1209 |
noerror = false;
|
|
|
1210 |
}
|
|
|
1211 |
}
|
|
|
1212 |
}
|
|
|
1213 |
}
|
|
|
1214 |
}
|
|
|
1215 |
}
|
|
|
1216 |
}
|
|
|
1217 |
}
|
|
|
1218 |
else
|
|
|
1219 |
if (elementtype == "repeat")
|
|
|
1220 |
{
|
|
|
1221 |
string refcountfield;
|
|
|
1222 |
string maxOccursStr;
|
|
|
1223 |
string refcountAttribute;
|
|
|
1224 |
|
|
|
1225 |
m_XMLSchema->GetAttributeProperty(attr_handle, "refcountfield", refcountfield);
|
|
|
1226 |
|
|
|
1227 |
if (!refcountfield.empty())
|
|
|
1228 |
{
|
|
|
1229 |
string refcountAttribute = structure_handle+"."+refcountfield;
|
|
|
1230 |
|
|
|
1231 |
m_XMLSchema->GetAttributeProperty(refcountAttribute, "max", maxOccursStr);
|
|
|
1232 |
}
|
|
|
1233 |
|
|
|
1234 |
if (maxOccursStr.empty())
|
|
|
1235 |
{
|
|
|
1236 |
m_XMLSchema->GetAttributeProperty(attr_handle, "maxOccurs", maxOccursStr);
|
|
|
1237 |
}
|
|
|
1238 |
|
|
|
1239 |
int maxOccurs = atoi(maxOccursStr.c_str());
|
|
|
1240 |
|
|
|
1241 |
// Limit to 100 elements
|
|
|
1242 |
if (maxOccurs > 100)
|
|
|
1243 |
{
|
|
|
1244 |
maxOccurs = 100;
|
|
|
1245 |
}
|
|
|
1246 |
|
|
|
1247 |
string refcount_value;
|
|
|
1248 |
m_XMLSchema->GetAttributeValue(structure_handle, refcountfield, refcount_value);
|
|
|
1249 |
|
|
|
1250 |
string repeat_name;
|
|
|
1251 |
m_XMLSchema->GetAttributeProperty(attr_handle, "name", repeat_name);
|
|
|
1252 |
|
|
|
1253 |
if (!refcount_value.empty())
|
|
|
1254 |
{
|
|
|
1255 |
maxOccurs = atoi(refcount_value.c_str());
|
|
|
1256 |
}
|
|
|
1257 |
m_XMLSchema->SetAttributeValue(structure_handle, refcountfield, maxOccurs);
|
|
|
1258 |
|
|
|
1259 |
for (int occurrence=1; occurrence<=maxOccurs; occurrence++)
|
|
|
1260 |
{
|
|
|
1261 |
string repeat_attribute_handle;
|
|
|
1262 |
AnsiString temp;
|
|
|
1263 |
|
|
|
1264 |
temp.sprintf("%s.%d",
|
|
|
1265 |
attr_handle.c_str(),
|
|
|
1266 |
occurrence);
|
|
|
1267 |
|
|
|
1268 |
repeat_attribute_handle = temp.c_str();
|
|
|
1269 |
|
|
|
1270 |
noerror = InitialiseTxnStructure(repeat_attribute_handle, occurrence, structure_params);
|
|
|
1271 |
} // for (int i=1; i<=occurrence; i++)
|
|
|
1272 |
}
|
|
|
1273 |
|
|
|
1274 |
s_itr++;
|
|
|
1275 |
} // while
|
|
|
1276 |
|
|
|
1277 |
return noerror;
|
|
|
1278 |
}
|
|
|
1279 |
|
|
|
1280 |
//---------------------------------------------------------------------------
|
|
|
1281 |
|
|
|
1282 |
|
|
|
1283 |
void TRunTestsForm::ShowForm(const AnsiString &testcase, const AnsiString &testname, const AnsiString &project, int currentiteration, const AnsiString &user_gen_dir, TXMLSchema *XMLSchema)
|
|
|
1284 |
{
|
|
|
1285 |
m_currentproject = project;
|
|
|
1286 |
m_currentiteration = currentiteration;
|
|
|
1287 |
m_XMLSchema = XMLSchema;
|
|
|
1288 |
m_testcase = testcase;
|
|
|
1289 |
m_user_gen_dir = user_gen_dir;
|
|
|
1290 |
|
|
|
1291 |
TestCaseTitle->Caption = testname;
|
|
|
1292 |
|
|
|
1293 |
ShowModal();
|
|
|
1294 |
}
|
|
|
1295 |
|
|
|
1296 |
//---------------------------------------------------------------------------
|
|
|
1297 |
|
|
|
1298 |
void __fastcall TRunTestsForm::TestCaseTxnTreeViewChange(TObject *Sender,
|
|
|
1299 |
TTreeNode *Node)
|
|
|
1300 |
{
|
|
|
1301 |
if (Node->Level == 1)
|
|
|
1302 |
{
|
|
|
1303 |
TADOQuery *query = new TADOQuery(this);
|
|
|
1304 |
query->Connection = Data_Module->IntegrationDBConnection;
|
|
|
1305 |
|
|
|
1306 |
int testscenario_no = (int)(Node->Parent->Data);
|
|
|
1307 |
int txnspec_no = (int)(Node->Data);
|
|
|
1308 |
|
|
|
1309 |
AnsiString sql_statement;
|
|
|
1310 |
|
|
|
1311 |
sql_statement.sprintf("SELECT PAYLOAD FROM TRANSACTION_SPECIFICATION "
|
|
|
1312 |
"WHERE TESTSCENARIO_NO=%d AND TXNSPEC_NO=%d",
|
|
|
1313 |
testscenario_no,
|
|
|
1314 |
txnspec_no);
|
|
|
1315 |
|
|
|
1316 |
query->SQL->Text = sql_statement;
|
|
|
1317 |
query->Open();
|
|
|
1318 |
|
|
|
1319 |
if (query->RecordCount == 1)
|
|
|
1320 |
{
|
|
|
1321 |
TStream* payload_stream = query->CreateBlobStream(query->FieldByName("PAYLOAD"), bmRead);
|
|
|
1322 |
unsigned int payload_size = payload_stream->Size;
|
|
|
1323 |
void* payload = malloc(payload_size);
|
|
|
1324 |
|
|
|
1325 |
payload_stream->ReadBuffer(payload, payload_stream->Size);
|
|
|
1326 |
|
|
|
1327 |
PayloadGrid->Rows = (payload_size+15)/16;
|
|
|
1328 |
|
|
|
1329 |
unsigned char *p = (unsigned char *)payload;
|
|
|
1330 |
for (unsigned row=0; row<(payload_size+15)/16; row++)
|
|
|
1331 |
{
|
|
|
1332 |
for (unsigned col=0; col<16; col++)
|
|
|
1333 |
{
|
|
|
1334 |
AnsiString abyte;
|
|
|
1335 |
abyte.sprintf("%02X", *p);
|
|
|
1336 |
|
|
|
1337 |
PayloadGrid->Cell[col+1][row+1] = abyte;
|
|
|
1338 |
|
|
|
1339 |
p++;
|
|
|
1340 |
}
|
|
|
1341 |
}
|
|
|
1342 |
|
|
|
1343 |
free(payload);
|
|
|
1344 |
}
|
|
|
1345 |
|
|
|
1346 |
delete query;
|
|
|
1347 |
}
|
|
|
1348 |
// PayloadGrid
|
|
|
1349 |
|
|
|
1350 |
}
|
|
|
1351 |
//---------------------------------------------------------------------------
|
|
|
1352 |
|
|
|
1353 |
void __fastcall TRunTestsForm::SaveTxnsToFileClick(TObject *Sender)
|
|
|
1354 |
{
|
|
|
1355 |
TCursor Save_Cursor = Screen->Cursor;
|
|
|
1356 |
Screen->Cursor = crHourGlass; // Show hourglass cursor
|
|
|
1357 |
|
|
|
1358 |
try
|
|
|
1359 |
{
|
|
|
1360 |
AnsiString sql_statement;
|
|
|
1361 |
|
|
|
1362 |
TADOQuery *query = new TADOQuery(this);
|
|
|
1363 |
query->Connection = Data_Module->IntegrationDBConnection;
|
|
|
1364 |
|
|
|
1365 |
TADOQuery *query2 = new TADOQuery(this);
|
|
|
1366 |
query2->Connection = Data_Module->IntegrationDBConnection;
|
|
|
1367 |
|
|
|
1368 |
sql_statement="";
|
|
|
1369 |
sql_statement.sprintf("SELECT TXNSTORAGE_PATH "
|
|
|
1370 |
"FROM ITERATIONS "
|
|
|
1371 |
"WHERE PROJECT_CODE='%s' "
|
|
|
1372 |
"AND ITERATION=%d ",
|
|
|
1373 |
m_currentproject.c_str(),
|
|
|
1374 |
m_currentiteration);
|
|
|
1375 |
|
|
|
1376 |
query->SQL->Text = sql_statement;
|
|
|
1377 |
query->Open();
|
|
|
1378 |
|
|
|
1379 |
AnsiString txnstorage_path = query->FieldByName("TXNSTORAGE_PATH")->AsString;
|
|
|
1380 |
|
|
|
1381 |
AnsiString target_path;
|
|
|
1382 |
|
|
|
1383 |
if (!m_user_gen_dir.IsEmpty() && (txnstorage_path[2] != ':') )
|
|
|
1384 |
{
|
|
|
1385 |
target_path = m_user_gen_dir;
|
|
|
1386 |
target_path += "\\";
|
|
|
1387 |
target_path += txnstorage_path;
|
|
|
1388 |
}
|
|
|
1389 |
else
|
|
|
1390 |
{
|
|
|
1391 |
target_path = txnstorage_path;
|
|
|
1392 |
}
|
|
|
1393 |
|
|
|
1394 |
if (access(target_path.c_str(), 0) == 0)
|
|
|
1395 |
{
|
|
|
1396 |
// Build a MASS Txn Map for fast lookup
|
|
|
1397 |
|
|
|
1398 |
TXNIndexMap mass_txns;
|
|
|
1399 |
|
|
|
1400 |
sql_statement="";
|
|
|
1401 |
sql_statement.sprintf("SELECT NAME,UDTYPE,UDSUBTYPE "
|
|
|
1402 |
"FROM MASS_TXNS "
|
|
|
1403 |
"WHERE PROJECTCODE='%s' "
|
|
|
1404 |
"AND ITERATION=%d ",
|
|
|
1405 |
m_currentproject.c_str(),
|
|
|
1406 |
m_currentiteration);
|
|
|
1407 |
|
|
|
1408 |
query->SQL->Text = sql_statement;
|
|
|
1409 |
query->Open();
|
|
|
1410 |
while (!query->Eof)
|
|
|
1411 |
{
|
|
|
1412 |
unsigned short udtype = query->FieldByName("UDTYPE")->AsInteger;
|
|
|
1413 |
unsigned short udsubtype = query->FieldByName("UDSUBTYPE")->AsInteger;
|
|
|
1414 |
unsigned int udindex = (udtype << 16) + udsubtype;
|
|
|
1415 |
|
|
|
1416 |
TXNIndexPair pair(udindex, query->FieldByName("NAME")->AsString);
|
|
|
1417 |
|
|
|
1418 |
mass_txns.insert(pair);
|
|
|
1419 |
|
|
|
1420 |
query->Next();
|
|
|
1421 |
}
|
|
|
1422 |
|
|
|
1423 |
sql_statement="";
|
|
|
1424 |
sql_statement.sprintf("select testscenario_no,testcase_seqno,name "
|
|
|
1425 |
"from test_scenarios "
|
|
|
1426 |
"where project_code='%s' and iteration=%d "
|
|
|
1427 |
"and testcase_id='%s' "
|
|
|
1428 |
"order by testcase_seqno",
|
|
|
1429 |
m_currentproject.c_str(),
|
|
|
1430 |
m_currentiteration,
|
|
|
1431 |
m_testcase.c_str());
|
|
|
1432 |
query->SQL->Text = sql_statement;
|
|
|
1433 |
query->Open();
|
|
|
1434 |
while ( !query->Eof )
|
|
|
1435 |
{
|
|
|
1436 |
unsigned int testscenario_no = query->FieldByName("TESTSCENARIO_NO")->AsInteger;
|
|
|
1437 |
|
|
|
1438 |
// Determine the set of Transaction Specifications for the ordered
|
|
|
1439 |
// set of test scenarios
|
|
|
1440 |
|
|
|
1441 |
sql_statement="";
|
|
|
1442 |
sql_statement.sprintf("select txnspec_no,seq_no,udtype,udsubtype,payload "
|
|
|
1443 |
"from transaction_specification "
|
|
|
1444 |
"where testscenario_no=%d "
|
|
|
1445 |
"order by seq_no",
|
|
|
1446 |
testscenario_no);
|
|
|
1447 |
query2->SQL->Text = sql_statement;
|
|
|
1448 |
query2->Open();
|
|
|
1449 |
while (!query2->Eof)
|
|
|
1450 |
{
|
|
|
1451 |
TBlobField *payload_field = dynamic_cast<TBlobField *>(query2->FieldByName("PAYLOAD"));
|
|
|
1452 |
|
|
|
1453 |
if (!payload_field->IsNull)
|
|
|
1454 |
{
|
|
|
1455 |
AnsiString filename;
|
|
|
1456 |
|
|
|
1457 |
unsigned short udtype = query2->FieldByName("UDTYPE")->AsInteger;
|
|
|
1458 |
unsigned short udsubtype = query2->FieldByName("UDSUBTYPE")->AsInteger;
|
|
|
1459 |
unsigned int udindex = (udtype << 16) + udsubtype;
|
|
|
1460 |
|
|
|
1461 |
// Locate the MASS Txn based on UD Type and SubType
|
|
|
1462 |
|
|
|
1463 |
TXNIndexMap::iterator txn_itr = mass_txns.find(udindex);
|
|
|
1464 |
|
|
|
1465 |
if (txn_itr != mass_txns.end())
|
|
|
1466 |
{
|
|
|
1467 |
string structure_name = (*txn_itr).second.c_str();
|
|
|
1468 |
|
|
|
1469 |
AnsiString target_directory;
|
|
|
1470 |
target_directory.sprintf("%s/%s", target_path.c_str(), m_testcase.c_str());
|
|
|
1471 |
|
|
|
1472 |
if (access(target_directory.c_str(), 0) != 0)
|
|
|
1473 |
{
|
|
|
1474 |
mkdir(target_directory.c_str());
|
|
|
1475 |
}
|
|
|
1476 |
|
|
|
1477 |
if (access(target_directory.c_str(), 0) == 0)
|
|
|
1478 |
{
|
|
|
1479 |
filename.sprintf("%s/%s/%s_%03d_%02d_%s.xdr",
|
|
|
1480 |
target_path.c_str(),
|
|
|
1481 |
m_testcase.c_str(),
|
|
|
1482 |
m_testcase.c_str(),
|
|
|
1483 |
query->FieldByName("TESTCASE_SEQNO")->AsInteger,
|
|
|
1484 |
query2->FieldByName("SEQ_NO")->AsInteger,
|
|
|
1485 |
structure_name.c_str()
|
|
|
1486 |
);
|
|
|
1487 |
|
|
|
1488 |
payload_field->SaveToFile(filename);
|
|
|
1489 |
} // Found Target Directory
|
|
|
1490 |
} // Found MASS Txn
|
|
|
1491 |
} // if (!payload_field->IsNull)
|
|
|
1492 |
|
|
|
1493 |
query2->Next();
|
|
|
1494 |
}
|
|
|
1495 |
|
|
|
1496 |
query->Next();
|
|
|
1497 |
}
|
|
|
1498 |
|
|
|
1499 |
delete query;
|
|
|
1500 |
delete query2;
|
|
|
1501 |
|
|
|
1502 |
AnsiString msg;
|
|
|
1503 |
msg.sprintf("Generated Transactions to: %s" , target_path.c_str());
|
|
|
1504 |
|
|
|
1505 |
MessageDlg(msg, mtInformation, TMsgDlgButtons() << mbOK, 0);
|
|
|
1506 |
}
|
|
|
1507 |
else
|
|
|
1508 |
{
|
|
|
1509 |
AnsiString msg;
|
|
|
1510 |
msg.sprintf("Directory '%s' Not Found or Not Accessible", target_path.c_str());
|
|
|
1511 |
|
|
|
1512 |
MessageDlg(msg, mtInformation, TMsgDlgButtons() << mbOK, 0);
|
|
|
1513 |
}
|
|
|
1514 |
}
|
|
|
1515 |
__finally
|
|
|
1516 |
{
|
|
|
1517 |
Screen->Cursor = Save_Cursor;
|
|
|
1518 |
}
|
|
|
1519 |
}
|
|
|
1520 |
//---------------------------------------------------------------------------
|
|
|
1521 |
|
|
|
1522 |
|
|
|
1523 |
void __fastcall TRunTestsForm::FormCreate(TObject *Sender)
|
|
|
1524 |
{
|
|
|
1525 |
#ifdef ADV_PROGRESS_BAR
|
|
|
1526 |
m_progressBar = new TAdvProgressBar( StatusBar );
|
|
|
1527 |
m_progressBar->Parent = StatusBar;
|
|
|
1528 |
m_progressBar->Steps = 10;
|
|
|
1529 |
m_progressBar->Position = 0;
|
|
|
1530 |
m_progressBar->ShowBorder = false;
|
|
|
1531 |
m_progressBar->ShowGradient = true;
|
|
|
1532 |
m_progressBar->ShowPercentage = true;
|
|
|
1533 |
m_progressBar->Stacked = false;
|
|
|
1534 |
m_progressBar->CompletionSmooth = false;
|
|
|
1535 |
m_progressBar->Visible = false;
|
|
|
1536 |
|
|
|
1537 |
// m_progressBar->Level0Color = Graphics::TColor( 0x006AA676 );
|
|
|
1538 |
// m_progressBar->Level0ColorTo = Graphics::TColor( 0x00BAE3C3 );
|
|
|
1539 |
m_progressBar->Level0Color = Graphics::TColor( 0x00C961AD );
|
|
|
1540 |
m_progressBar->Level0ColorTo = Graphics::TColor( 0x00FFBCEF );
|
|
|
1541 |
m_progressBar->Level1Color = Graphics::TColor( 0x00C961AD );
|
|
|
1542 |
m_progressBar->Level1ColorTo = Graphics::TColor( 0x00FFBCEF );
|
|
|
1543 |
m_progressBar->Level2Color = Graphics::TColor( 0x00C961AD );
|
|
|
1544 |
m_progressBar->Level2ColorTo = Graphics::TColor( 0x00FFBCEF );
|
|
|
1545 |
m_progressBar->Level3Color = Graphics::TColor( 0x00C961AD );
|
|
|
1546 |
m_progressBar->Level3ColorTo = Graphics::TColor( 0x00FFBCEF );
|
|
|
1547 |
#else
|
|
|
1548 |
m_progressBarOld = new TProgressBar ( StatusBar );
|
|
|
1549 |
m_progressBarOld->Parent = StatusBar;
|
|
|
1550 |
m_progressBarOld->Step = 10;
|
|
|
1551 |
m_progressBarOld->Max = 100;
|
|
|
1552 |
m_progressBarOld->Position = 0;
|
|
|
1553 |
m_progressBarOld->Visible = false;
|
|
|
1554 |
#endif
|
|
|
1555 |
}
|
|
|
1556 |
//---------------------------------------------------------------------------
|
|
|
1557 |
|
|
|
1558 |
void __fastcall TRunTestsForm::StatusBarResize(TObject *Sender)
|
|
|
1559 |
{
|
|
|
1560 |
RECT Rect;
|
|
|
1561 |
StatusBar->Perform( SB_GETRECT, 0, (LPARAM)&Rect );
|
|
|
1562 |
|
|
|
1563 |
const int progressPanel = 2;
|
|
|
1564 |
int offset = 0;
|
|
|
1565 |
for ( int i = 0; i < progressPanel; i++ )
|
|
|
1566 |
{
|
|
|
1567 |
offset += StatusBar->Panels->Items[ i ]->Width;
|
|
|
1568 |
}
|
|
|
1569 |
|
|
|
1570 |
#ifdef ADV_PROGRESS_BAR
|
|
|
1571 |
m_progressBar->Top = Rect.top + 2;
|
|
|
1572 |
m_progressBar->Left = Rect.left + offset + 4;
|
|
|
1573 |
m_progressBar->Width = StatusBar->Panels->Items[ progressPanel ]->Width - 6;
|
|
|
1574 |
m_progressBar->Height = Rect.bottom - Rect.top - 4;
|
|
|
1575 |
#else
|
|
|
1576 |
m_progressBarOld->Top = Rect.top;
|
|
|
1577 |
m_progressBarOld->Left = Rect.left + offset + 2;
|
|
|
1578 |
m_progressBarOld->Width = StatusBar->Panels->Items[ progressPanel ]->Width - 2;
|
|
|
1579 |
m_progressBarOld->Height = Rect.bottom - Rect.top;
|
|
|
1580 |
#endif
|
|
|
1581 |
}
|
|
|
1582 |
//---------------------------------------------------------------------------
|
|
|
1583 |
|