Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public override object Handle(object request)
        {
            string fieldName = request as string;
            KCAcumaticaMappingField aField = KCExprEngine.MappingMaint.AFieldByName.SelectSingle(fieldName.Trim());

            if (aField != null)
            {
                return(true);
            }
            else
            {
                return(base.Handle(request));
            }
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        private IEnumerable <KCAcumaticaMappingField> GetAcumaticaSchema()
        {
            var  list       = new List <KCAcumaticaMappingField>();
            Type graphType  = null;
            var  filter     = MappingSetupFilter.Current;
            var  entityType = filter?.MappingEntity;

            if (filter != null)
            {
                graphType = GetConversionMaintType(entityType);
            }

            if (graphType == null)
            {
                return(list);
            }

            var graphViews = GraphHelper.GetGraphViews(graphType, true);

            foreach (var viewInfo in graphViews)
            {
                var blc             = graphType.FullName;
                var blcName         = graphType.Name;
                var viewName        = viewInfo.Name;
                var viewDisplayName = viewInfo.DisplayName;
                var dacName         = viewInfo.Cache.Name;
                var dacDisplayName  = viewInfo.Cache.DisplayName;
                var dacFields       = GetDacAndExtensionFields(graphType, dacName, viewName, viewInfo.Cache.CacheType);

                foreach (var field in dacFields.OrderBy(f => f))
                {
                    var row = new KCAcumaticaMappingField
                    {
                        EntityType      = entityType,
                        BLC             = blc,
                        BLCName         = blcName,
                        ViewName        = viewName,
                        ViewDisplayName = viewDisplayName,
                        DACName         = dacName,
                        DACDisplayName  = dacDisplayName,
                        FieldName       = field,
                        FieldHash       = KCCDHelper.GetMd5Sum(new [] { blcName, viewName, dacName, field })
                    };

                    list.Add(row);
                }
            }

            return(list);
        }