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 virtual IEnumerable loadMappingSchema(PXAdapter adapter) { foreach (var row in Mapping.Select()) { Mapping.Delete(row); } int lineNbr = 1; var relationList = GetOrderMappingSchema(); foreach (KCFieldRelation relation in relationList) { var map = new KCMapping { LineNbr = lineNbr++, MappingRule = relation.MappingRule, Direction = relation.Direction, EntityType = relation.EntityType, RuleType = relation.RuleType, AViewName = relation.AViewDisplayName }; if (!string.IsNullOrWhiteSpace(relation.AFieldName) && !string.IsNullOrWhiteSpace(relation.AViewDisplayName)) { map.AFieldHash = AFieldByViewAndField.SelectSingle(relation.AViewDisplayName, relation.AFieldName)?.FieldHash; } if (!string.IsNullOrWhiteSpace(relation.SourceExpression)) { map.SourceExpression = relation.SourceExpression; } if (!string.IsNullOrWhiteSpace(relation.CFieldName)) { map.CFieldHash = CAFieldByNameAndEntityType.SelectSingle(relation.CFieldName, relation.EntityType)?.FieldHash; } Mapping.Insert(map); } return(adapter.Get()); }