/// <summary>
        /// Processes the delete command.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="Id">The id.</param>
        void ProcessDeleteCommand(string[] items, int Id)
        {
            for (int i = 0; i < items.Length; i++)
            {
                string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]);
                if (keys != null)
                {
                    int    id            = Int32.Parse(keys[0]);
                    string type          = keys[1];
                    string outlineNumber = keys[2];

                    if (type.Equals("Node"))
                    {
                        FolderElement.Delete(id);
                    }
                    else if (type.Equals("Folder"))
                    {
                        Mediachase.Ibn.Data.Services.TreeNode node = TreeManager.GetNodeByOulineNumber(Folder.GetAssignedMetaClass(), outlineNumber);
                        if (node != null)
                        {
                            DeleteEntryRecursive(node);
                            TreeManager.DeleteNode(node);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Deletes the entry recursive.
        /// </summary>
        /// <param name="node">The node.</param>
        private void DeleteEntryRecursive(Mediachase.Ibn.Data.Services.TreeNode node)
        {
            if (TreeManager.GetAllChildNodeCount(node) > 0)
            {
                foreach (Mediachase.Ibn.Data.Services.TreeNode childNode in TreeManager.GetAllChildNodes(node))
                {
                    DeleteEntryRecursive(childNode);
                }
            }

            int folderId = node.ObjectId;

            FolderElement[] elements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("ParentId", FilterElementType.Equal, folderId) });
            foreach (FolderElement element in elements)
            {
                element.Delete();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Loads the items.
        /// </summary>
        /// <param name="iStartIndex">Start index of the i.</param>
        /// <param name="iNumItems">The i num items.</param>
        /// <param name="sFilter">The s filter.</param>
        private void LoadItems(int iStartIndex, int iNumItems, string sFilter)
        {
            // declare collections
            Folder[] folders = null;
            Mediachase.Ibn.Data.Services.TreeNode[] nodes = null;
            FolderElement[] elements        = null;
            string          path            = sFilter;
            int             totalItemsCount = 0;

            // Load all elements if filter is empty
            if (String.IsNullOrEmpty(sFilter))
            {
                int  folderCount  = Folder.GetTotalCount(Folder.GetAssignedMetaClass());
                int  elementCount = FolderElement.GetTotalCount(FolderElement.GetAssignedMetaClass());
                bool skipFolders  = false;
                if (elementCount + folderCount <= iStartIndex)
                {
                    iStartIndex = 0;
                    iNumItems   = 20;
                }
                else if (folderCount < iStartIndex)
                {
                    skipFolders = true;
                    iStartIndex = iStartIndex - folderCount;
                }

                if (!skipFolders)
                {
                    folders = Folder.List <Folder>(Folder.GetAssignedMetaClass(), new FilterElementCollection(), new SortingElementCollection(), iStartIndex, iNumItems);
                }

                elements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElementCollection(), new SortingElementCollection(), iStartIndex, iNumItems);

                totalItemsCount = elementCount + folderCount;
            }
            else
            {
                // Calculate outline here
                string   outline      = String.Empty;
                string[] outlineArray = sFilter.Split(new char[] { '/' });


                if (outlineArray.Length > 1)
                {
                    int index = 0;
                    while (index < outlineArray.Length - 1)
                    {
                        Folder[] outlineFolders = Folder.List <Folder>(Folder.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("Name", FilterElementType.Equal, outlineArray[index]) });
                        if (outlineFolders.Length > 0)
                        {
                            if (String.IsNullOrEmpty(outline))
                            {
                                outline = outlineFolders[0].PrimaryKeyId.ToString();
                            }
                            else
                            {
                                outline += "." + outlineFolders[0].PrimaryKeyId.ToString();
                            }
                        }
                        index++;
                    }
                }

                // Must be first element
                if (String.IsNullOrEmpty(outline))
                {
                    if (String.IsNullOrEmpty(sFilter))
                    {
                        nodes = TreeManager.GetRootNodes(Folder.GetAssignedMetaClass());
                    }
                    else
                    {
                        folders = Folder.List <Folder>(Folder.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("Name", FilterElementType.StartsWith, sFilter) });
                    }
                }
                else
                {
                    Mediachase.Ibn.Data.Services.TreeNode node = TreeManager.GetNodeByOulineNumber(Folder.GetAssignedMetaClass(), outline);
                    nodes = TreeManager.GetChildNodes(Folder.GetAssignedMetaClass(), node.ObjectId);
                }

                if (!String.IsNullOrEmpty(path))
                {
                    if (path.Contains("/"))
                    {
                        path = path.Substring(0, path.LastIndexOf('/'));
                    }

                    elements = FolderElement.GetElementsByPath(path);
                }
                else
                {
                    path = String.Empty;
                }

                // Do blank keyword search
                if (elements == null && !sFilter.Contains("/"))
                {
                    elements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("Name", FilterElementType.Contains, sFilter) });
                }

                if (elements == null)
                {
                    elements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("ParentId", FilterElementType.Equal, 0) });
                }


                // Count all returned items
                totalItemsCount = elements.Length;

                if (nodes != null)
                {
                    totalItemsCount += nodes.Length;
                }

                if (folders != null)
                {
                    totalItemsCount += folders.Length;
                }
            }

            AssetItemsFilter.Items.Clear();



            AddItems(folders);
            AddItems(nodes);
            AddItems(elements);

            int iEndIndex = Math.Min(iStartIndex + iNumItems, totalItemsCount);

            AssetItemsFilter.ItemCount = Math.Min(totalItemsCount, iEndIndex + AssetItemsFilter.DropDownPageSize);
        }
Beispiel #4
0
        /// <summary>
        /// Builds the full path.
        /// </summary>
        /// <param name="metaClass">The meta class.</param>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        private string BuildFullPath(Mediachase.Ibn.Data.Meta.Management.MetaClass metaClass, Mediachase.Ibn.Data.Services.TreeNode node)
        {
            string path = String.Empty;

            Mediachase.Ibn.Data.Services.TreeNode[] nodes = TreeManager.GetPathToNode(metaClass, node);
            if (nodes.Length > 0)
            {
                foreach (Mediachase.Ibn.Data.Services.TreeNode treeNode in nodes)
                {
                    path += treeNode.Title + "/";
                }
            }

            return(path);
        }