private static void CheckLookupCondition(LookupArgs args) { bool?success = null; foreach (var condition in args.LookupValue.Conditions) { var prop = args.SourceProperty.FindProperty(condition.Name); if (prop == null) { continue; } switch (condition.Operator) { case Keywords.EQUAL: success = String.Equals(condition.Value, prop.Value == null ? "" : prop.Value.ToString(), StringComparison.CurrentCultureIgnoreCase); break; case Keywords.NOT_EQUAL: success = !String.Equals(condition.Value, prop.Value == null ? "" : prop.Value.ToString(), StringComparison.CurrentCultureIgnoreCase); break; } if (success != null && (bool)!success) { break; } } if (success != null && (bool)success) { SearchForLookupValue(args); } }
private static void LoadLookupValues(LookupArgs args, IEnumerable <EventLR> storedEvents) { foreach (var e in storedEvents) { args.Event = e; foreach (var lookupValue in args.Event.EventLookupValues) { args.LookupValue = lookupValue; CheckLookupCondition(args); } } }
private static void SearchForLookupValue(LookupArgs args) { var file = XmlDal.CacheModel.GetFile(args.FilePath); if (args.LookupValue.OnlyNetworkValues) { lock (file.Network) { foreach (var networkMessageInfo in file.Network.NetworkMessages) { if (networkMessageInfo.Source.iLine == args.SourceProperty.iLine) { continue; } bool?success = null; foreach (var criteria in args.LookupValue.Criteria) { var targetValue = networkMessageInfo.Source.FindEventValue(criteria.TargetName); switch (criteria.CriteriaType) { case LookupTargetType.Value: switch (criteria.Operator) { case Keywords.EQUAL: success = String.Equals(criteria.TargetValue ?? "", targetValue ?? "", StringComparison.CurrentCultureIgnoreCase); break; case Keywords.NOT_EQUAL: success = !String.Equals(criteria.TargetValue ?? "", targetValue ?? "", StringComparison.CurrentCultureIgnoreCase); break; } break; case LookupTargetType.Name: var sourceProperty = args.SourceProperty.FindProperty(criteria.SourceName); success = String.Equals( sourceProperty.Value == null ? "" : sourceProperty.Value.ToString(), targetValue, StringComparison.CurrentCultureIgnoreCase); break; default: throw new ArgumentOutOfRangeException(); } if ((bool)!success) { break; } } if (success == null || !(bool)success) { continue; } foreach (var valueName in args.LookupValue.ValueNames) { var sourceProperty = args.SourceProperty.FindProperty(valueName.Name); if (sourceProperty == null) { continue; } var targetProperty = networkMessageInfo.Source.FindEventValue(valueName.Name); if (targetProperty == null) { continue; } sourceProperty.Name = string.Format("_{0}", sourceProperty.Name); var category = args.LookupValue.UseCategory ? args.LookupValue.Category : sourceProperty.Category; args.SourceProperty.Properties.Add(new DynamicProperty(category, sourceProperty.Desc, valueName.Name, targetProperty)); } break; } } } else { switch (args.LookupValue.LookupDirection) { case LookupDirection.Prior: for (var i = args.SourceProperty.iLine - 1; i >= 0; i--) { var searchProperty = PropertyService.GetProperty(new LineArgs { iLine = i, Path = args.FilePath }); bool?success = null; foreach (var criteria in args.LookupValue.Criteria) { var targetValue = FindFirstEventValue(file.GetLine(i), criteria.TargetName); if (targetValue == null) { continue; } switch (criteria.CriteriaType) { case LookupTargetType.Value: success = String.Equals(criteria.TargetValue, targetValue, StringComparison.CurrentCultureIgnoreCase); break; case LookupTargetType.Name: var sourceProperty = args.SourceProperty.FindProperty(criteria.SourceName); success = String.Equals(sourceProperty.Value.ToString(), targetValue, StringComparison.CurrentCultureIgnoreCase); break; default: throw new ArgumentOutOfRangeException(); } if ((bool)!success) { break; } } if (success == null || !(bool)success) { continue; } foreach (var valueName in args.LookupValue.ValueNames) { var sourceProperty = args.SourceProperty.FindProperty(valueName.Name); if (sourceProperty == null) { continue; } var targetProperty = searchProperty.FindProperty(valueName.Name); if (targetProperty == null) { continue; } sourceProperty.Name = string.Format("_{0}", sourceProperty.Name); var category = args.LookupValue.UseCategory ? args.LookupValue.Category : sourceProperty.Category; args.SourceProperty.Properties.Add(new DynamicProperty(category, sourceProperty.Desc, valueName.Name, sourceProperty.Value)); } break; } break; case LookupDirection.Next: case LookupDirection.TopDown: case LookupDirection.BottomUp: throw new ArgumentOutOfRangeException(); } } }