public void InvokeFlowRuleCode(ManagementAgent ma, FlowRule rule, CSEntry csentry, MVEntry mventry) { Tracer.TraceInformation("enter-invokeflowrulecode {0}", rule.Name); try { FlowRuleCode r = (FlowRuleCode)rule; if (r.Direction.Equals(Direction.Import)) { ma.InvokeMapAttributesForImport(r.Name, csentry, mventry); } else { ma.InvokeMapAttributesForExport(r.Name, csentry, mventry); } r = null; } catch (Exception ex) { Tracer.TraceError("invokeflowrulecode {0}", ex.GetBaseException()); throw ex; } finally { Tracer.TraceInformation("exit-invokeflowrulecode {0}", rule.Name); } }
public void InvokeFlowRule(FlowRule rule, CSEntry csentry, MVEntry mventry) { Tracer.TraceInformation("enter-invokeflowrule {0}", rule.Name); Tracer.Indent(); try { FlowRule r = (FlowRule)rule; object targetValue = null; foreach (Value value in r.SourceExpression.Source) { if (value.GetType().Equals(typeof(MultiValueAttribute))) { MultiValueAttribute attr = (MultiValueAttribute)value; object mv = attr.GetValueOrDefault(r.Direction, csentry, mventry); targetValue = attr.Transform(mv, TransformDirection.Source); } if (value.GetType().Equals(typeof(Attribute))) { Attribute attr = (Attribute)value; object concateValue = attr.GetValueOrDefault(r.Direction, csentry, mventry); concateValue = attr.Transform(concateValue, TransformDirection.Source); targetValue = targetValue as string + concateValue; attr = null; continue; } if (value.GetType().Equals(typeof(Constant))) { targetValue = targetValue + ((Constant)value).Value; continue; } } targetValue = r.Target.Transform(targetValue, TransformDirection.Target); r.Target.SetTargetValue(r.Direction, csentry, mventry, targetValue); r = null; } catch (Exception ex) { Tracer.TraceError("invokeflowrule {0}", ex.GetBaseException()); throw ex; } finally { Tracer.Unindent(); Tracer.TraceInformation("exit-invokeflowrule {0}", rule.Name); } }
public void MapAttributesForImportExportDetached(string FlowRuleName, CSEntry csentry, MVEntry mventry, Direction direction) { Tracer.TraceInformation("enter-mapattributesforimportexportdetached [{0}]", direction); List <FlowRule> rules = null; try { string maName = csentry.MA.Name; Tracer.TraceInformation("mvobjectid: {0}, ma: {1}, rule: {2}", mventry.ObjectID, maName, FlowRuleName); ManagementAgent ma = config.ManagementAgent.Where(m => m.Name.Equals(maName)).FirstOrDefault(); if (ma == null) { throw new NotImplementedException("management-agent-" + maName + "-not-found"); } rules = ma.FlowRule.Where(r => r.Name.Equals(FlowRuleName) && r.Direction.Equals(direction)).ToList <FlowRule>(); if (rules == null) { throw new NotImplementedException(direction.ToString() + "-rule-'" + FlowRuleName + "'-not-found-on-ma-" + maName); } foreach (FlowRule r in rules) { Tracer.TraceInformation("found-rule name: {0}, description: {1}", r.Name, r.Description); } FlowRule rule = rules.Where(ru => ru.Conditions.AreMet(csentry, mventry)).FirstOrDefault(); if (rule == null) { throw new DeclineMappingException("no-" + direction.ToString() + "-rule-'" + FlowRuleName + "'-found-on-ma-'" + maName + "'-where-conditions-were-met"); } #region FlowRuleDefault if (rule.GetType().Equals(typeof(FlowRule))) { InvokeFlowRule(rule, csentry, mventry); return; } #endregion #region FlowRuleCode if (rule.GetType().Equals(typeof(FlowRuleCode))) { InvokeFlowRuleCode(ma, rule, csentry, mventry); return; } #endregion rule = null; } catch (Exception ex) { Tracer.TraceError("mapattributesforimportexportdetached {0}", ex.GetBaseException()); throw ex; } finally { if (rules != null) { rules.Clear(); rules = null; } Tracer.TraceInformation("exit-mapattributesforimportexportdetached [{0}]", direction); } }