Exemple #1
0
        public override object GetSimpleFieldValue(IDataSourceStore dsStore)
        {
            DataTypes dataType;

            if (!Enum.TryParse <DataTypes>(this.FieldType, out dataType))
            {
                throw new AccountingModuleException("Data type is not supported. Data type was: {0}. Field name was: {1}", this.FieldType, this.FieldName ?? string.Empty);
            }

            IDataSource ds = dsStore.GetDataSource(DataSources.Table);

            switch (dataType)
            {
            case DataTypes.Decimal: return(ds.GetValue <Decimal>(this.FieldName));

            case DataTypes.Int32: return(ds.GetValue <Int32>(this.FieldName));

            case DataTypes.String: return(ds.GetValue <String>(this.FieldName));

            case DataTypes.DateTime: return(ds.GetValue <DateTime>(this.FieldName));

            case DataTypes.TimeSpan: return(ds.GetValue <DateTime>(this.FieldName).TimeOfDay);

            default: throw new AccountingModuleException("Data type is not supported. Data type was: {0}. Field name was: {1}", dataType.ToString(), this.FieldName ?? string.Empty);
            }
        }
Exemple #2
0
 public override bool IsComplexConditionHold(IDataSourceStore dsStore)
 {
     foreach (var condition in this.innerConditions)
     {
         condition.IsHold(dsStore); // since we want every condition to be exhausted we do not use short-circuit evaluation
     }
     return(true);
 }
Exemple #3
0
 public override IEnumerable <IEventDefinition> GetHoldEvents(IDataSourceStore dsStore)
 {
     foreach (var evDef in this.eventDefinitions)
     {
         if (evDef.IsHold(dsStore))
         {
             yield return(evDef);
         }
     }
 }
Exemple #4
0
 public override bool IsComplexConditionHold(IDataSourceStore dsStore)
 {
     foreach (var condition in this.innerConditions)
     {
         if (condition.IsHold(dsStore))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #5
0
        public Dictionary <string, object> TakeReaction(IDataSourceStore dsStore)
        {
            Dictionary <string, object> fields = new Dictionary <string, object>();

            foreach (var fieldMatch in this.fieldMatches)
            {
                if (!(fieldMatch.TargetField is TableField))
                {
                    throw new AccountingModuleException("Target field must be of table field type. Field type was: {0}. Field name was: {1}", fieldMatch.TargetField.GetType().FullName);
                }

                object value           = fieldMatch.SourceField.GetValue(dsStore);
                string targetFieldName = ((TableField)fieldMatch.TargetField).FieldName;
                fields.Add(targetFieldName, value);
            }
            return(fields);
        }
        public override object GetComplexFieldValue(IDataSourceStore dsStore)
        {
            object temp = null;

            foreach (var fld in this.innerFields)
            {
                if (temp == null)
                {
                    temp = fld.GetValue(dsStore);
                }
                else
                {
                    temp = this.Add(temp, fld.GetValue(dsStore));
                }
            }
            return(temp);
        }
        public override object GetSimpleFieldValue(IDataSourceStore dsStore)
        {
            SpecialFieldValues specialFieldValue;

            if (!Enum.TryParse <SpecialFieldValues>(this.FieldValue, out specialFieldValue))
            {
                throw new AccountingModuleException("Special field value is not supported. Value was: {0}. Field name was: {1}", this.FieldValue, this.FieldName ?? string.Empty);
            }

            switch (specialFieldValue)
            {
            case SpecialFieldValues.CurrentDate: return(DateTime.Now.Date);

            case SpecialFieldValues.CurrentTime: return(DateTime.Now.TimeOfDay);

            case SpecialFieldValues.CurrentDateTime: return(DateTime.Now);

            default: throw new AccountingModuleException("Special field value is not supported. Value was: {0}. Field name was: {1}", specialFieldValue.ToString(), this.FieldName ?? string.Empty);
            }
        }
Exemple #8
0
 public abstract bool IsSimpleConditonHold(IDataSourceStore dsStore);
Exemple #9
0
 public override IEnumerable <Tuple <IEventReaction, Dictionary <string, object> > > TakeReactionsFor(IEventDefinition eventDefinition, IDataSourceStore dsStore)
 {
     foreach (var evRec in eventDefinition.EventReactions)
     {
         yield return(Tuple.Create <IEventReaction, Dictionary <string, object> >(evRec, evRec.TakeReaction(dsStore)));
     }
 }
Exemple #10
0
 public abstract object GetValue(IDataSourceStore dsStore);
Exemple #11
0
 public bool IsHold(IDataSourceStore dsStore)
 {
     return(this.Condition.IsHold(dsStore));
 }
Exemple #12
0
 public bool IsLessThan(Field another, IDataSourceStore dsStore)
 {
     return(CustomMathOps.IsLessThan(this.GetValue(dsStore), another.GetValue(dsStore)));
 }
 public abstract IEnumerable <Tuple <IEventReaction, Dictionary <string, object> > > TakeReactionsFor(IEventDefinition eventDefinition, IDataSourceStore dsStore);
Exemple #14
0
 public bool IsHold(IDataSourceStore dsStore)
 {
     return(this.IsSimpleConditonHold(dsStore));
 }
 public override bool IsSimpleConditonHold(IDataSourceStore dsStore)
 {
     return(sourceField.IsEqualTo(targetField, dsStore) || sourceField.IsLessThan(targetField, dsStore));
 }
 public bool IsHold(IDataSourceStore dsStore)
 {
     return(this.IsComplexConditionHold(dsStore));
 }
 public abstract bool IsComplexConditionHold(IDataSourceStore dsStore);
Exemple #18
0
 public override object GetValue(IDataSourceStore dsStore)
 {
     return(this.GetSimpleFieldValue(dsStore));
 }
Exemple #19
0
 public abstract object GetSimpleFieldValue(IDataSourceStore dsStore);
 public override bool IsSimpleConditonHold(IDataSourceStore dsStore)
 {
     return(sourceField.IsGreaterThan(targetField, dsStore));
 }
 public abstract IEnumerable <IEventDefinition> GetHoldEvents(IDataSourceStore dsStore);