Subversion Repositories DevTools

Rev

Rev 2263 | Rev 2269 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2263 Rev 2267
Line 83... Line 83...
83
	EXPRESSIONID_KEYNUMBER,
83
	EXPRESSIONID_KEYNUMBER,
84
	EXPRESSIONID_MAC,
84
	EXPRESSIONID_MAC,
85
	EXPRESSIONID_SAMID,
85
	EXPRESSIONID_SAMID,
86
	EXPRESSIONID_SCENARIO_INDEX,
86
	EXPRESSIONID_SCENARIO_INDEX,
87
	EXPRESSIONID_HOSTNAME,
87
	EXPRESSIONID_HOSTNAME,
88
	EXPRESSIONID_USERNAME
88
	EXPRESSIONID_USERNAME,
-
 
89
	EXPRESSIONID_USESEQ,
-
 
90
    EXPRESSIONID_SETSHIFTSTART,   
-
 
91
    EXPRESSIONID_USESHIFTSTART,
89
};
92
    };
90
struct PredefinedFunction
93
struct PredefinedFunction
91
{
94
{
92
	const char *	functor;
95
	const char *	functor;
93
	FunctionId		functionId;
96
	FunctionId		functionId;
94
};
97
};
Line 111... Line 114...
111
	{ "MAC",			EXPRESSIONID_MAC },
114
	{ "MAC",			EXPRESSIONID_MAC },
112
	{ "SAMID",			EXPRESSIONID_SAMID },
115
	{ "SAMID",			EXPRESSIONID_SAMID },
113
	{ "SCENARIOINDEX",	EXPRESSIONID_SCENARIO_INDEX },
116
	{ "SCENARIOINDEX",	EXPRESSIONID_SCENARIO_INDEX },
114
	{ "HOSTNAME",		EXPRESSIONID_HOSTNAME },
117
	{ "HOSTNAME",		EXPRESSIONID_HOSTNAME },
115
	{ "USERNAME",		EXPRESSIONID_USERNAME },
118
	{ "USERNAME",		EXPRESSIONID_USERNAME },
-
 
119
	{ "USESEQ",			EXPRESSIONID_USESEQ },
-
 
120
	{ "SETSHIFTSTART",	EXPRESSIONID_SETSHIFTSTART },
-
 
121
	{ "USESHIFTSTART",	EXPRESSIONID_USESHIFTSTART },
116
	{ 0,				EXPRESSIONID_INVALID }
122
	{ 0,				EXPRESSIONID_INVALID }
117
};
123
};
118
 
124
 
119
static const std::locale myLocale;
125
static const std::locale myLocale;
120
 
126
 
Line 321... Line 327...
321
 
327
 
322
			m_cachedValue = value = time.FormatString( "dd-mm-yyyy" ).c_str();
328
			m_cachedValue = value = time.FormatString( "dd-mm-yyyy" ).c_str();
323
		}
329
		}
324
		return ( true );
330
		return ( true );
325
	case EXPRESSIONID_TOMORROW:
331
	case EXPRESSIONID_TOMORROW:
-
 
332
		{      
-
 
333
        	std::string days;
-
 
334
            int advanceDays;
-
 
335
			if ( skipCharacter( is, '(' ) &&
-
 
336
				 readTerm( is, days ) &&
-
 
337
				 skipCharacter( is, ')' ) )
326
		{
338
			{
-
 
339
				advanceDays	= 	atoi( days.c_str() );
-
 
340
                if (advanceDays == 0) advanceDays = 1; //for invalid format default to tomorrow
-
 
341
            }
-
 
342
            else
-
 
343
            {
-
 
344
                advanceDays = 1;
-
 
345
            }							
-
 
346
	
327
			const TDateTime time = TDateTime::CurrentDateTime() + 1;
347
			const TDateTime time = TDateTime::CurrentDateTime() + advanceDays;
328
 
348
 
329
			m_cachedValue = value = time.FormatString( "dd-mm-yyyy" ).c_str();
349
			m_cachedValue = value = time.FormatString( "dd-mm-yyyy" ).c_str();
330
		}
350
		}
-
 
351
		return ( true );        
-
 
352
    case EXPRESSIONID_SETSHIFTSTART:
-
 
353
		{                                         
-
 
354
            const TDateTime time = TDateTime::CurrentDateTime() + ( ( _timezone / 3600.0 ) / 24.0 );
-
 
355
            
-
 
356
			value = ( time.FormatString( "dd-mm-yyyy hh:nn:ss" ).c_str());
-
 
357
            
-
 
358
            evaluationContext.setStartTime (value);
-
 
359
		}
-
 
360
		return ( true );    
-
 
361
    case EXPRESSIONID_USESHIFTSTART:
-
 
362
		{                  
-
 
363
            value = evaluationContext.getStartTime();
-
 
364
		}
331
		return ( true );
365
		return ( true );
332
	case EXPRESSIONID_ACCOUNTTYPE:
366
	case EXPRESSIONID_ACCOUNTTYPE:
333
		switch( evaluationContext.getTransaction().getUdType() )
367
		switch( evaluationContext.getTransaction().getUdType() )
334
		{
368
		{
335
		case 1:	// Card
369
		case 1:	// Card
Line 442... Line 476...
442
					Sequence & sequence = evaluationContext.
476
					Sequence & sequence = evaluationContext.
443
						getSequenceCollection().getSequence(
477
						getSequenceCollection().getSequence(
444
							fullName,
478
							fullName,
445
							persisted,
479
							persisted,
446
							atoi( first.c_str() ) );
480
							atoi( first.c_str() ) );
-
 
481
                    
-
 
482
                    // don't increment on very first use of a new sequence  
-
 
483
                    if(!sequence.isDirty() || sequence.isUpdate())
-
 
484
                    {                    
-
 
485
    					sequence.incrementValue(
-
 
486
    						atoi( first.c_str() ),
-
 
487
    						atoi( last.c_str() ),
-
 
488
    						atoi( increment.c_str() ) );
-
 
489
                    }    
447
					AnsiString os;
490
					AnsiString os;
448
					os.sprintf( "%d", sequence.getValue() );
491
					os.sprintf( "%d", sequence.getValue() );
449
					value = os.c_str();
492
					value = os.c_str();
450
 
-
 
451
					sequence.incrementValue(
-
 
452
						atoi( first.c_str() ),
-
 
453
						atoi( last.c_str() ),
493
                        
454
						atoi( increment.c_str() ) );
494
                    sequence.setDirty (true); //used to force an increment next time round as well as db refresh    
455
 
495
 
456
					return ( true );
496
					return ( true );
457
				}
497
				}
458
			}
498
			}
459
 
499
 
460
			MERROR( "Cannot parse argument list." );
500
			MERROR( "Cannot parse argument list." );
461
		}
501
		}
462
		break;
502
		break;
-
 
503
	case EXPRESSIONID_USESEQ:
-
 
504
		{
-
 
505
			bool persisted = false;
-
 
506
			std::string name;
-
 
507
			std::string discriminant;
-
 
508
			std::string	fullName;
-
 
509
 
-
 
510
			/**
-
 
511
			 *	SEQ( name, first, increment, last[, discriminant] )
-
 
512
			 *	name ::= transient name | # persisted name
-
 
513
			 */
-
 
514
			if ( skipCharacter( is, '(' ) )
-
 
515
			{
-
 
516
				persisted = skipCharacter( is, '#' );
-
 
517
				if ( readIdentifier( is, name ) &&
-
 
518
					 ( ( skipCharacter( is, ',' ) &&
-
 
519
						 readIdentifier( is, discriminant ) ) ||
-
 
520
					   skipCharacter( is, ')' ) ) )
-
 
521
				{
-
 
522
					if ( discriminant.length() )
-
 
523
					{
-
 
524
						/**
-
 
525
						 *	We have a discriminant, so we evaluate it to form
-
 
526
						 *	our name,
-
 
527
						 */
-
 
528
						FieldExpression subexpression( discriminant );
-
 
529
 
-
 
530
						std::string discriminantValue;
-
 
531
						if ( subexpression.evaluate( discriminantValue, true, evaluationContext, path, postponed ) )
-
 
532
						{
-
 
533
							AnsiString full;
-
 
534
							full.sprintf( "%s[%s]", name.c_str(), discriminantValue.c_str() );
-
 
535
							fullName = full.c_str();
-
 
536
						}
-
 
537
					}
-
 
538
					else
-
 
539
					{
-
 
540
						fullName = name;
-
 
541
					}
-
 
542
 
-
 
543
					Sequence & sequence = evaluationContext.
-
 
544
						getSequenceCollection().getSequence(
-
 
545
							fullName,
-
 
546
							true,      // really don't care
-
 
547
							1 );       // default if seq not already created
-
 
548
					AnsiString os;
-
 
549
					os.sprintf( "%d", sequence.getValue() );
-
 
550
					value = os.c_str();
-
 
551
                    
-
 
552
                    // note: there is intentionally no increment
-
 
553
 
-
 
554
					return ( true );
-
 
555
				}
-
 
556
			}
-
 
557
 
-
 
558
			MERROR( "Cannot parse argument list." );
-
 
559
		}
-
 
560
		break;        
463
	case EXPRESSIONID_KEYVERSION:
561
	case EXPRESSIONID_KEYVERSION:
464
		if ( evaluationContext.haveMessageDigest() )
562
		if ( evaluationContext.haveMessageDigest() )
465
		{
563
		{
466
			AnsiString os;
564
			AnsiString os;
467
			os.sprintf( "%hu", evaluationContext.getMessageDigest().getKeyVersion() );
565
			os.sprintf( "%hu", evaluationContext.getMessageDigest().getKeyVersion() );