Example #1
0
        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);
        }
Example #2
0
        public override object Handle(object request)
        {
            string fieldName = request as string;
            KCChannelAdvisorMappingField caField = KCExprEngine.MappingMaint.CAFieldByNameAndEntityType.SelectSingle(fieldName.Trim(), _entityType);

            if (caField != null)
            {
                return(true);
            }
            else
            {
                return(base.Handle(request));
            }
        }