Ejemplo n.º 1
0
        public bool Update(Schema.Domain.Entity targetEntityMetadata, Entity targetRecord, bool onDelete = false)
        {
            var entityMaps = _entityMapFinder.Query(n => n.Where(f => f.TargetEntityId == targetEntityMetadata.EntityId && (f.MapType == MapType.Control || f.MapType == MapType.ForceControl)));

            if (entityMaps.IsEmpty())
            {
                return(true);
            }
            if (targetRecord.IsEmpty())
            {
                return(false);
            }
            Guid headSourceId = Guid.Empty;
            var  emptyGuid    = Guid.Empty;

            foreach (var em in entityMaps)
            {
                var attributeMaps = _attributeMapFinder.Query(n => n.Where(f => f.EntityMapId == em.EntityMapId && f.RemainAttributeId != emptyGuid));
                //单据头
                if (attributeMaps.NotEmpty())
                {
                    var sourceAttributesMeta = _attributeFinder.FindByEntityId(em.SourceEntityId);
                    var targetEntityMetas    = _entityFinder.FindById(em.TargetEntityId);
                    var targetAttributesMeta = _attributeFinder.FindByEntityId(em.TargetEntityId);
                    //引用源单据的字段
                    var refSourceAttr = targetAttributesMeta.Find(n => n.ReferencedEntityId.HasValue && n.ReferencedEntityId.Value == em.SourceEntityId);
                    //更新单据头相关字段
                    _fieldValueUpdater.UpdateControlMap(em, attributeMaps, targetRecord.GetGuidValue(refSourceAttr.Name), refSourceAttr, sourceAttributesMeta, targetAttributesMeta, onDelete);
                }
                return(true);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public IActionResult AppendRecord(Guid entityid, Guid recordid)
        {
            AppendRecordModel model = new AppendRecordModel
            {
                EntityId   = entityid,
                ObjectId   = recordid,
                EntityMaps = _entityMapFinder.Query(n => n.Where(f => f.SourceEntityId == entityid && f.StateCode == RecordState.Enabled))
            };

            if (model.EntityMaps.NotEmpty())
            {
                var targetIds = model.EntityMaps.Select(n => n.TargetEntityId);
                model.TargetEntityMetas = _entityFinder.Query(n => n.Where(f => f.EntityId.In(targetIds)));
            }
            return(View($"~/Views/Entity/{WebContext.ActionName}.cshtml", model));
        }