Ejemplo n.º 1
0
        public int CreateListFolder(int ParentFolderId, string Name)
        {
            int retVal = -1;
            try
            {
                Authenticate();

                using (TransactionScope tran = DataContext.Current.BeginTransaction())
                {
                    //retVal = List.AddFolder(Name, ParentFolderId);
                    ListFolder folder = new ListFolder(ParentFolderId);

                    ListFolder newFolder = new ListFolder();
                    newFolder.Title = Name;
                    newFolder.Save();

                    folder.GetTreeService().AppendChild(newFolder);
                    folder.Save();

                    tran.Commit();

                    retVal = newFolder.PrimaryKeyId.Value;
                }

            }
            catch (UserNotAuthenticatedException)
            {
                errMsg.msg = "Your login or password is invalid.";
            }
            catch (Exception ex)
            {
                errMsg.msg = ex.Message;
            }
            return retVal;
        }
Ejemplo n.º 2
0
        private static void CreateFolderListXml(XmlNode currParent, int folderID, int deepLevel)
        {
            if (folderID == 0)
            {
                // Private
                ListFolder privateRootFolder = ListManager.GetPrivateRoot(Security.CurrentUser.UserID);
                InsertFolderInfo(currParent, privateRootFolder.PrimaryKeyId.Value, "@@2", privateRootFolder.HasChildren);

                // Public
                ListFolder publicRootFolder = ListManager.GetPublicRoot();
                InsertFolderInfo(currParent, publicRootFolder.PrimaryKeyId.Value, "@@1", publicRootFolder.HasChildren);

                // Projects
                InsertFolderInfo(currParent, -1, "@@3", true);
            }
            else if (folderID == -1)
            {
                // Enum Projects
                using (IDataReader reader = Project.GetListProjects())
                {
                    while (reader.Read())
                    {
                        ListFolder projectRootFolder = ListManager.GetProjectRoot((int)reader["ProjectId"]);

                        InsertFolderInfo(currParent, projectRootFolder.PrimaryKeyId.Value, (string)reader["Title"], true);
                    }
                }
            }
            else
            {
                ListFolder folder = new ListFolder(folderID);

                foreach (IbnServices.TreeNode childNode in folder.GetTreeService().GetChildNodes())
                {
                    InsertFolderInfo(currParent, childNode.ObjectId, childNode.Title, childNode.HasChildren);
                }
            }

            if (deepLevel == -1 || deepLevel > 0)
            {
                XmlNodeList childFolderList = currParent.SelectNodes("Folder");

                foreach (XmlNode folderItem in childFolderList)
                {
                    XmlNode childFolderItemNode = folderItem.SelectSingleNode("ChildList");
                    if (childFolderItemNode != null)
                    {
                        int ChildFolderID = Int32.Parse(folderItem.SelectSingleNode("Id").InnerXml);

                        CreateFolderListXml(childFolderItemNode, ChildFolderID, deepLevel == -1 ? -1 : deepLevel - 1);
                    }
                }
            }
        }