public override object Map(KCMapObjectRequest request) { foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(request.Target)) { PXResult <KCMapping> importMappingRow = _mappingMaint.ImportMappingRow.Select(request.EntityType, property.Name, request.ViewName).FirstOrDefault(); if (importMappingRow == null) { continue; } KCMapping mapping = importMappingRow.GetItem <KCMapping>(); KCChannelAdvisorMappingField caField = importMappingRow.GetItem <KCChannelAdvisorMappingField>(); string formula = mapping.RuleType == KCRuleTypesConstants.Expression ? mapping.SourceExpression : caField?.FieldName; IDictionary <string, object> mappingValue = GetMappingValue(request, property); if (string.IsNullOrWhiteSpace(formula) || mappingValue == null || (mapping.RuleType == KCRuleTypesConstants.Simple && mappingValue.GetValue(formula) == null)) { continue; } MapField(request.EntityType, request.Target, property, mappingValue, formula); } return(request.Target); }
public override object Map(KCMapObjectRequest request) { foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(request.Target)) { PXResult <KCMapping> exportMappingRow = _mappingMaint.ExportMappingRow.Select(request.EntityType, property.Name, request.ViewName).FirstOrDefault(); if (exportMappingRow == null) { continue; } KCMapping mapping = exportMappingRow.GetItem <KCMapping>(); KCAcumaticaMappingField acumaticaField = exportMappingRow.GetItem <KCAcumaticaMappingField>(); string formula = mapping.RuleType == KCRuleTypesConstants.Expression ? mapping.SourceExpression : acumaticaField?.FieldName; IDictionary <string, object> mappingValue = GetMappingValue(request, property); if (mappingValue == null || (property.PropertyType != typeof(bool?) && property.PropertyType != typeof(bool) && mappingValue.GetValue(formula) == null)) { continue; } MapField(request.EntityType, request.Target, property, mappingValue, formula); } return(request.Target); }
protected override IDictionary <string, object> GetMappingValue(KCMapObjectRequest request, PropertyDescriptor property) { PXResult <KCMapping> exportMappingRow = _mappingMaint.ExportMappingRow.Select(request.EntityType, property.Name, request.ViewName).FirstOrDefault(); if (exportMappingRow == null) { return(null); } KCMapping mapping = exportMappingRow.GetItem <KCMapping>(); KCAcumaticaMappingField acumaticaField = exportMappingRow.GetItem <KCAcumaticaMappingField>(); List <Dictionary <string, object> > mappingValue = MappingValues.GetValue(new KCMappingKey(acumaticaField.ViewDisplayName, request.Id)); return(mappingValue?.FirstOrDefault()); }
protected override IDictionary <string, object> GetMappingValue(KCMapObjectRequest request, PropertyDescriptor property) { IDictionary <string, object> mappingValue = request.Source.AsDictionary(); return(mappingValue); }
public abstract object Map(KCMapObjectRequest request);
protected abstract IDictionary <string, object> GetMappingValue(KCMapObjectRequest request, PropertyDescriptor property);