private void InnerJoin(AssetStructureDM item, Guid folderId, Guid actedBy) { item.ParentId = folderId; SetPath(item, folderId); Save(item, actedBy); }
private void MoveFolder(AssetStructureDM item, Guid destinationId, Guid actedBy) { if (item.Puid == destinationId || item.ParentId == destinationId) { return; } var destination = GetItemByPuid(destinationId); if (destination.Path.Contains(item.Path)) { return; } var path = item.Path; var children = GetRecursiveChildren(item.Puid, false); var destinationPath = $"{destination.Path}{SymbolConst.PATH_SEPARATOR}{GetLastCode(path)}"; item.ParentId = destinationId; item.Path = destinationPath; item.Level = destinationPath.Split(SymbolConst.PATH_SEPARATOR).Length; DB.Update <AssetStructureDM>(item, actedBy); foreach (var child in children) { child.Path = child.Path.Replace(path, destinationPath); child.Level = child.Path.Split(SymbolConst.PATH_SEPARATOR).Length; } DB.BulkUpdate <AssetStructureDM>(children, actedBy); }
private void Save(AssetStructureDM item, Guid actedBy) { if (CheckItemByKey(item) == null) { DB.Insert <AssetStructureDM>(item, actedBy); } else { DB.Update <AssetStructureDM>(item, actedBy); } }
private void SetPath(AssetStructureDM item, Guid folderId) { var path = GetPath(folderId); if (!item.IsFolder) { item.Path = $"{path}{SymbolConst.PATH_SEPARATOR}Asset"; } else { var folder = Let <AssetFolder>().GetItemByFolderId(item.Puid); item.Path = $"{path}{SymbolConst.PATH_SEPARATOR}{folder.Code}"; } item.Level = item.Path.Split(SymbolConst.PATH_SEPARATOR).Length; }
private AssetStructureDM CheckItemByKey(AssetStructureDM item) { return(DB.CheckItem <AssetStructureDM>("Puid", new { Puid = item.Puid })); }