Ejemplo n.º 1
0
 public bool Import(Guid solutionId, IList <EntityMapXmlInfo> entityMaps)
 {
     if (entityMaps.NotEmpty())
     {
         foreach (var item in entityMaps)
         {
             var entity = _entityMapFinder.FindById(item.EntityMapId);
             if (entity != null)
             {
                 _entityMapUpdater.Update(item);
                 if (item.AttributeMaps.NotEmpty())
                 {
                     _attributeMapDeleter.DeleteByParentId(entity.EntityMapId);
                     _attributeMapCreater.CreateMany(item.AttributeMaps);
                 }
             }
             else
             {
                 item.CreatedBy      = _appContext.GetFeature <ICurrentUser>().SystemUserId;
                 item.SolutionId     = solutionId;
                 item.ComponentState = 0;
                 item.CreatedOn      = DateTime.Now;
                 _entityMapCreater.Create(item);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        public IActionResult EditEntityMap(Guid entitymapid)
        {
            var headEntityMap        = _entityMapFinder.FindById(entitymapid);
            EditEntityMapModel model = new EditEntityMapModel
            {
                EntityMapId          = entitymapid,
                EntityId             = headEntityMap.TargetEntityId,
                TargetEntityMetaData = _entityFinder.FindById(headEntityMap.TargetEntityId),
                SourceEntityMetaData = _entityFinder.FindById(headEntityMap.SourceEntityId),
                Attributes           = _attributeFinder.Query(n => n
                                                              .Where(f => f.EntityId == headEntityMap.TargetEntityId && f.Name.NotIn(AttributeDefaults.SystemAttributes)).Sort(s => s.SortAscending(f => f.Name))),
                SolutionId = SolutionId.Value,
                //单据头
                HeadEntityMap    = headEntityMap,
                RelationShipName = headEntityMap.RelationShipName,
                HeadAttributeMap = _attributeMapFinder.Query(n => n.Where(f => f.EntityMapId == headEntityMap.EntityMapId)),
                SourceEntityId   = headEntityMap.SourceEntityId,
                MapType          = headEntityMap.MapType
            };

            model.HeadRelationShip = _relationShipFinder.FindByName(model.RelationShipName);
            //单据体
            var childEntityMap = _entityMapFinder.FindByParentId(headEntityMap.EntityMapId);

            if (childEntityMap != null)
            {
                model.ChildEntityMap            = childEntityMap;
                model.ChildRelationShipName     = childEntityMap.RelationShipName;
                model.ChildTargetEntityMetaData = _entityFinder.FindById(childEntityMap.TargetEntityId);
                model.ChildSourceEntityMetaData = _entityFinder.FindById(childEntityMap.SourceEntityId);
                model.ChildAttributeMap         = _attributeMapFinder.Query(n => n.Where(f => f.EntityMapId == childEntityMap.EntityMapId));
                model.ChildTargetEntityId       = childEntityMap.TargetEntityId;
                model.ChildSourceEntityId       = childEntityMap.SourceEntityId;
            }
            return(View(model));
        }