Ejemplo n.º 1
0
        /// <summary>
        /// Get all folders of the database.
        /// </summary>
        public List <Folder> GetListOfFolders()
        {
            List <Folder> list = new List <Folder>();

            void ProcessOneNode(RadTreeNode node)
            {
                list.Add(Folder.Create(GetIdFolder(node), node.Text, node.FullPath, node.Level));
                foreach (var item in node.Nodes)
                {
                    ProcessOneNode(item);
                }
            }

            DataTable  table = GetTableFolders();
            FxTreeView form  = new FxTreeView();

            form.Visible = false;
            FillTreeView(form.TvFolders, table);
            foreach (var item in form.TvFolders.Nodes)
            {
                ProcessOneNode(item);
            }
            form.TvFolders.DataSource = null;
            table.Clear();
            form.TvFolders.Dispose();
            table.Dispose();
            form.Close();
            return(list);
        }
Ejemplo n.º 2
0
        private int GetIdFolderUsingTreeview(string FullPath)
        {
            int x = IdFolderNotFound;

            int ProcessOneNode(RadTreeNode node)
            {
                if (node.FullPath == FullPath)
                {
                    return(GetIdFolder(node));
                }
                foreach (var item in node.Nodes)
                {
                    x = ProcessOneNode(item);
                    if (x != IdFolderNotFound)
                    {
                        return(x);
                    }
                }
                return(-1);
            }

            DataTable  table = GetTableFolders();
            FxTreeView form  = new FxTreeView();

            form.Visible = false;
            FillTreeView(form.TvFolders, table);

            int IdFolder = IdFolderNotFound;

            foreach (var item in form.TvFolders.Nodes)
            {
                IdFolder = ProcessOneNode(item);
                if (IdFolder != IdFolderNotFound)
                {
                    break;
                }
            }

            form.TvFolders.DataSource = null;
            table.Clear();
            form.TvFolders.Dispose();
            table.Dispose();
            form.Close();
            return(IdFolder);
        }
Ejemplo n.º 3
0
        public ReturnCode FolderForceDeleteUsingTreeview(string FolderPath)
        {
            // This method uses RadTreeView class to perform search operations //
            ReturnCode code = ReturnCodeFactory.Error();

            FolderPath = AddRootFolderNameIfNotSpecified(FolderPath);
            int IdFolder = GetIdFolder(FolderPath);

            if (FolderNotFound(IdFolder))
            {
                return(FolderNotFound());
            }
            if (IdFolder == DbManager.IdFolderRoot)
            {
                return(ReturnCodeFactory.Error("The root folder cannot be specified as an argument to this function."));
            }
            bool        FlagFound = false;
            int         count     = 0;
            Stack <int> stack     = new Stack <int>();

            void MarkNodeToBeDeleted(RadTreeNode node)
            {
                stack.Push(GetIdFolder(node));
                //Trace.WriteLine($"Push to stack >>> {node.FullPath} === {x}");
                foreach (var item in node.Nodes)
                {
                    MarkNodeToBeDeleted(item);
                }
            }

            void SearchNode(RadTreeNode node)
            {
                if (FlagFound)
                {
                    return;
                }
                //if (GetIdFolder(node) == IdFolder)
                if (node.FullPath == FolderPath)
                {
                    FlagFound = true;
                    MarkNodeToBeDeleted(node);
                }
                if (!FlagFound)
                {
                    foreach (var item in node.Nodes)
                    {
                        SearchNode(item);
                    }
                }
            }

            DataTable  table = GetTableFolders();
            FxTreeView form  = new FxTreeView();

            form.Visible = false;
            FillTreeView(form.TvFolders, table);

            foreach (var item in form.TvFolders.Nodes)
            {
                SearchNode(item);
            }

            using (SQLiteConnection connection = GetSqliteConnection())
                using (SQLiteCommand command = new SQLiteCommand(connection).ZzOpenConnection())
                    while (stack.Count > 0)
                    {
                        int x = stack.Pop();
                        command.Parameters.Clear();
                        command.ZzAdd("@IdFolder", x).ZzExecuteNonQuery(DbManager.SqlDeleteAllSettingsOfOneFolder);
                        if (stack.Count > 0)
                        {
                            command.ZzExecuteNonQuery(DbManager.SqlFolderDelete);
                        }
                        count++;
                    }

            code = FolderDelete(FolderPath, FolderPath);

            form.TvFolders.DataSource = null;
            table.Clear();
            form.TvFolders.Dispose();
            table.Dispose();
            form.Close();

            code.StringNote += $" Folders processed = {count}";
            return(code);
        }
Ejemplo n.º 4
0
        private ReturnCode FolderForceDeleteUsingTreeviewOldVersionDeprecated(string FolderPath)
        {
            // Trace.WriteLine($"FolderForceDelete(string FolderPath)  ---> {FolderPath}");
            // This method uses RadTreeView class to perform search operations //
            ReturnCode code = ReturnCodeFactory.Error();

            FolderPath = AddRootFolderNameIfNotSpecified(FolderPath);

            int IdFolder = GetIdFolder(FolderPath);

            if (FolderNotFound(IdFolder))
            {
                return(FolderNotFound());
            }

            //Trace.WriteLine($"FolderForceDelete(string FolderPath)  ---> Point 1 --- IdFolder = {IdFolder}");

            bool FlagFound = false;

            int count = 0;

            void SearchNode(RadTreeNode node)
            {
                if (FlagFound)
                {
                    return;
                }
                //if (GetIdFolder(node) == IdFolder)
                if (node.FullPath == FolderPath)
                {
                    FlagFound = true;
                    //Trace.WriteLine($"Found !!! ---> {node.FullPath}");
                    LocalMethodDeleteAllSettingsOfOneFolder(node);
                    LocalMethodDeleteFolderAndAllChildFolders(node);
                }
                if (!FlagFound)
                {
                    foreach (var item in node.Nodes)
                    {
                        SearchNode(item);
                    }
                }
            }

            void LocalMethodDeleteAllSettingsOfOneFolder(RadTreeNode node)
            {
                DeleteAllSettingsOfOneFolder(node.FullPath);
                //Trace.WriteLine($"Delete settings of folder ======= {node.FullPath}");
                foreach (var item in node.Nodes)
                {
                    LocalMethodDeleteAllSettingsOfOneFolder(item);
                }
            }

            void LocalMethodDeleteFolderAndAllChildFolders(RadTreeNode node)
            {
                foreach (var item in node.Nodes)
                {
                    LocalMethodDeleteFolderAndAllChildFolders(item);
                }
                ReturnCode result = FolderDelete(node.FullPath, string.Empty);

                if (IdFolder == GetIdFolder(node))
                {
                    code = result;
                }
                count++;
                //Trace.WriteLine($@"Delete folder /\/\/\/\/\/\/\ === {node.FullPath}");
            }

            DataTable  table = GetTableFolders();
            FxTreeView form  = new FxTreeView();

            form.Visible = false;
            FillTreeView(form.TvFolders, table);

            foreach (var item in form.TvFolders.Nodes)
            {
                SearchNode(item);
            }

            form.TvFolders.DataSource = null;
            table.Clear();
            form.TvFolders.Dispose();
            table.Dispose();
            form.Close();

            //Trace.WriteLine($@" >>>>>>>>>>>>>>>>>>>>> {ReturnCodeFormatter.ToString(code)}");
            code.StringNote += $" Folders processed = {count}";
            return(code);
        }