public InventorySkeletonEntry GetInventorySkeletonEntry(Guid userId, Guid folderId)
        {
            var statement = SKEL_SINGLE_SELECT_STMT.Bind(userId, folderId);
            var rowset    = _session.Execute(statement);

            InventorySkeletonEntry entry = null;

            foreach (var row in rowset)
            {
                //should only be one
                entry = MapRowToSkeletonItem(row);
                break;
            }

            if (entry != null)
            {
                //look up the version
                statement = FOLDER_VERSION_SINGLE_SELECT_STMT.Bind(userId, folderId);
                rowset    = _session.Execute(statement);

                foreach (var row in rowset)
                {
                    //should only be one
                    entry.Version = row.GetValue <long>("version");
                }
            }

            return(entry);
        }
        /// <summary>
        /// Builds a graph from the skeleton
        /// </summary>
        /// <param name="skel"></param>
        public SkeletonGraphNode(IEnumerable<InventorySkeletonEntry> skel)
        {
            Dictionary<Guid, List<InventorySkeletonEntry>> nodesByParent = new Dictionary<Guid, List<InventorySkeletonEntry>>();

            foreach (var node in skel)
            {
                if (node.Level == FolderLevel.Root)
                {
                    this.RootNode = true;
                    this.Self = node;
                    this.Parent = null;
                }

                List<InventorySkeletonEntry> childList;
                if (! nodesByParent.TryGetValue(node.ParentId, out childList))
                {
                    childList = new List<InventorySkeletonEntry>();
                    nodesByParent[node.ParentId] = childList;
                }

                childList.Add(node);
            }

            this.AllChildren = new Dictionary<Guid, SkeletonGraphNode>();

            //start at the root and work down
            this.RecursiveBuild(nodesByParent, this.AllChildren);
        }
Exemple #3
0
        /// <summary>
        /// Builds a graph from the skeleton
        /// </summary>
        /// <param name="skel"></param>
        public SkeletonGraphNode(IEnumerable <InventorySkeletonEntry> skel)
        {
            Dictionary <Guid, List <InventorySkeletonEntry> > nodesByParent = new Dictionary <Guid, List <InventorySkeletonEntry> >();

            foreach (var node in skel)
            {
                if (node.Level == FolderLevel.Root)
                {
                    this.RootNode = true;
                    this.Self     = node;
                    this.Parent   = null;
                }

                List <InventorySkeletonEntry> childList;
                if (!nodesByParent.TryGetValue(node.ParentId, out childList))
                {
                    childList = new List <InventorySkeletonEntry>();
                    nodesByParent[node.ParentId] = childList;
                }

                childList.Add(node);
            }

            this.AllChildren = new Dictionary <Guid, SkeletonGraphNode>();

            //start at the root and work down
            this.RecursiveBuild(nodesByParent, this.AllChildren);
        }
        public void MoveFolder(InventorySkeletonEntry folder, Guid newParent)
        {
            var skelMove = SKEL_MOVE_STMT.Bind(newParent, folder.UserId, folder.FolderId);

            _session.Execute(skelMove);

            VersionInc(folder.UserId, folder.FolderId);
            VersionInc(folder.UserId, folder.ParentId);
            VersionInc(folder.UserId, newParent);
        }
        public void MoveFolder(InventorySkeletonEntry folder, Guid newParent)
        {
            var skelMove = SKEL_MOVE_STMT.Bind(newParent, folder.UserId, folder.FolderId);
            _session.Execute(skelMove);

            VersionInc(folder.UserId, folder.FolderId);
            VersionInc(folder.UserId, folder.ParentId);
            VersionInc(folder.UserId, newParent);
        }