Пример #1
0
        /// <summary>
        /// Recursively adds a collection of directories to the treeview.
        /// </summary>
        /// <param name="directoryLookup">A cache of all the PhotoDirectory objects.</param>
        /// <param name="dirBrowser">A reference to a DirectoryBrowser object.</param>
        /// <param name="dirs">A collection of PhotoDirectory objects.</param>
        /// <param name="parentNode">A reference to the parent tree node object, or null if at the root of the tree view.</param>
        private void addDirectoryNodes(Hashtable directoryLookup, DirectoryBrowser dirBrowser,
                                       PhotoDirectories dirs, squishyWARE.WebComponents.squishyTREE.TreeNode parentNode)
        {
            IEnumerator enumerator = dirs.GetEnumerator();

            while (enumerator.MoveNext())
            {
                PhotoDirectory dir = (PhotoDirectory)enumerator.Current;

                squishyWARE.WebComponents.squishyTREE.TreeNode node;
                if (parentNode == null)
                {
                    node = tvwMain.AddNode(HttpUtility.HtmlEncode(dir.Name), dir.Id.ToString());
                }
                else
                {
                    node = parentNode.AddNode(HttpUtility.HtmlEncode(dir.Name), dir.Id.ToString());
                }

                addDirectoryNodes(directoryLookup, dirBrowser, dir.GetDirectories(), node);

                if (!directoryLookup.Contains(dir.Id))
                {
                    directoryLookup.Add(dir.Id, dir);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Retrieves a list of sub-directories stored in the PhotosServer databse.
        /// </summary>
        /// <param name="token">A reference to the current directory browser session token object.</param>
        /// <param name="virtualPath">The virtual path to the parent directory.</param>
        /// <returns>A collection of PhotoDirectory objects</returns>
        public PhotoDirectories GetDirectories(SessionToken token, string virtualPath)
        {
            IDbCommand cmd = GetCommand();

            //cmd.CommandText = "SELECT ID, Name from tblDirectories where VirtualPath = ? " +
            cmd.CommandText = "SELECT ID, Name from tblDirectories where VirtualPath = '" + virtualPath + "' AND IsDeleted <> 'Y' ORDER BY Name";
            //cmd.Parameters.Add(CreateStringParam("VirtualPath", virtualPath));

            PhotoDirectories results = new PhotoDirectories();

            using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
            {
                while (reader.Read())
                {
                    PhotoDirectory photoDir = new PhotoDirectory(token,
                                                                 reader.GetInt32(0),
                                                                 reader.GetString(1),
                                                                 virtualPath);

                    results.Add(photoDir);
                }
            }

            return(results);
        }
Пример #3
0
        /// <summary>
        /// Displays the album treeview control.
        /// </summary>
        /// <param name="dirBrowser">A reference to the cached DirectoryBrowser object.</param>
        /// <param name="directoryLookup">A cache of all the PhotoDirectory objects.</param>
        private void DisplayTreeview(DirectoryBrowser dirBrowser, Hashtable directoryLookup)
        {
            PhotoDirectories dirs = dirBrowser.GetDirectories();

            tvwMain.Controls.Clear();
            addDirectoryNodes(directoryLookup, dirBrowser, dirs, null);
        }
Пример #4
0
 public PhotoDirectories GetDirectories()
 {
     if (this.dirs == null)
     {
         this.dirs = DirectoryUtilities.GetDirectories(this, base.token, base.token.MapPath(this.FullVirtualPath));
     }
     return(this.dirs);
 }
Пример #5
0
 public PhotoDirectories GetDirectories()
 {
     if (this.dirs == null)
     {
         this.dirs = DirectoryUtilities.GetDirectorie((PhotoDirectory)this.rootdir[0], this.token, this.token.PhotosRootFullPath + this._path);
     }
     return(this.dirs);
 }
Пример #6
0
        /// <summary>
        /// Retrieves a collection of directories contained in the directory.
        /// </summary>
        /// <returns>A collection of PhotoDirectory objects.</returns>
        public PhotoDirectories GetDirectories()
        {
            if (dirs == null)
            {
                dirs = DirectoryUtilities.GetDirectories(this, token, token.MapPath(FullVirtualPath));
            }

            return(dirs);
        }
Пример #7
0
        /// <summary>
        /// Returns the details of the sub-directories under the root photos folder.
        /// </summary>
        /// <returns>A collection of PhotoDirectory objects.</returns>
        public PhotoDirectories GetDirectories()
        {
            if (dirs == null)
            {
                dirs = DirectoryUtilities.GetDirectories(null, token, token.PhotosRootFullPath);
            }

            return(dirs);
        }
Пример #8
0
        public static PhotoDirectories GetDirectorie(PhotoDirectory parent, SessionToken token, string path)
        {
            PhotoDirectoryDB ydb = new PhotoDirectoryDB(token.DBConnection);

            if (!Directory.Exists(path))
            {
                path = path.Substring(token.PhotosRootFullPath.Length, path.Length - token.PhotosRootFullPath.Length);
                string name        = path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                string virtualPath = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));
                ydb.Delete(name, virtualPath);
                return(new PhotoDirectories());
            }
            PhotoDirectories directories  = ydb.GetDirectorie(token, "", parent.Name);
            PhotoDirectories directories2 = (PhotoDirectories)directories.Clone();

            DirectoryInfo[] infoArray = new DirectoryInfo(path).GetDirectories();
            return(directories);
        }
Пример #9
0
        public PhotoDirectories GetDirectories(SessionToken token, string virtualPath)
        {
            IDbCommand command = base.GetCommand();

            command.CommandText = "SELECT ID, Name from tblDirectories where VirtualPath = ? ORDER BY Name";
            command.Parameters.Add(base.CreateStringParam("VirtualPath", virtualPath));
            PhotoDirectories directories = new PhotoDirectories();

            using (IDataReader reader = command.ExecuteReader(CommandBehavior.Default))
            {
                while (reader.Read())
                {
                    PhotoDirectory photoDirectory = new PhotoDirectory(token, reader.GetInt32(0), reader.GetString(1), virtualPath);
                    directories.Add(photoDirectory);
                }
            }
            return(directories);
        }
Пример #10
0
        public static PhotoDirectories GetDirectories(PhotoDirectory parent, SessionToken token, string path)
        {
            string           virtualPath;
            PhotoDirectoryDB ydb = new PhotoDirectoryDB(token.DBConnection);

            if (!Directory.Exists(path))
            {
                path = path.Substring(token.PhotosRootFullPath.Length, path.Length - token.PhotosRootFullPath.Length);
                string name = path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                virtualPath = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));
                ydb.Delete(name, virtualPath);
                return(new PhotoDirectories());
            }
            PhotoDirectories directories  = ydb.GetDirectories(token, GetVirtualPath(token, path));
            PhotoDirectories directories2 = (PhotoDirectories)directories.Clone();

            DirectoryInfo[] infoArray = new DirectoryInfo(path).GetDirectories();
            if (directories2.Count != infoArray.Length)
            {
                foreach (DirectoryInfo info2 in infoArray)
                {
                    if (!info2.Name.Equals(ThumbnailUtilities.ThumbnailDirectory))
                    {
                        virtualPath = GetVirtualPath(token, info2.FullName);
                        if (!directories.Contains(virtualPath))
                        {
                            string         text3          = virtualPath.Substring(0, (virtualPath.Length - info2.Name.Length) - 1);
                            PhotoDirectory photoDirectory = new PhotoDirectory(token, info2.Name, text3);
                            ydb.Insert(parent, photoDirectory);
                            directories.Add(photoDirectory);
                        }
                        directories2.Remove(virtualPath);
                    }
                }
                foreach (PhotoDirectory directory in directories2)
                {
                    ydb.Delete(directory);
                    new PhotoDB(token.DBConnection).DeleteDirectoryPhotos(directory);
                    directories.Remove(directory);
                }
            }
            return(directories);
        }
Пример #11
0
        private void Button_AddDir_Click(object sender, RoutedEventArgs e)
        {
            VistaFolderBrowserDialog folder = new VistaFolderBrowserDialog();

            folder.ShowDialog();
            if (!String.IsNullOrEmpty(folder.SelectedPath))
            {
                bool alreadyAdded = ctx.Directories.Any(d => d.Path.Equals(folder.SelectedPath));
                if (!alreadyAdded)
                {
                    var path = new PhotoDirectories()
                    {
                        Path = folder.SelectedPath
                    };
                    ctx.Directories.Add(path);
                    directoriesList.Add(path);
                    ctx.SaveChanges();
                }
                else
                {
                    MessageBox.Show("Ścieżka jest już dodana bądź jest nieprawidłowa.");
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Returns the details of the sub-directories contained within a given path.
        /// </summary>
        /// <param name="parent">The parent directory, or null it at the root.</param>
        /// <param name="token">A reference to the current directory browser session token object.</param>
        /// <param name="path">The physical path of the directory in question.</param>
        /// <returns>A collection of PhotoDirectory objects.</returns>
        public static PhotoDirectories GetDirectories(PhotoDirectory parent, SessionToken token, string path)
        {
            PhotoDirectoryDB db = new PhotoDirectoryDB(token.DBConnection);

            // If the directory doesn't exist then a directory must have been deleted
            if (!Directory.Exists(path))
            {
                // extract out the name and virtual path from the full physical path
                path = path.Substring(token.PhotosRootFullPath.Length,
                                      path.Length - token.PhotosRootFullPath.Length);
                string name        = path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                string virtualPath = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));

                db.Delete(name, virtualPath);

                return(new PhotoDirectories());
            }
            else
            {
                // Get a list of directories from the database
                PhotoDirectories results = db.GetDirectories(token, GetVirtualPath(token, path));

                PhotoDirectories originalResults = (PhotoDirectories)results.Clone();

                // Get a list of directories from the root path from the file system
                DirectoryInfo   dirInfo  = new DirectoryInfo(path);
                DirectoryInfo[] dirInfos = dirInfo.GetDirectories();

                // Only need to update the database if the number of directories in the database are
                // different to those on the file system.
                // TODO: Currently won't detect changes in directory names. Ideas to enable this
                //       as still be fast?
                if (originalResults.Count != dirInfos.Length)
                {
                    foreach (DirectoryInfo dir in dirInfos)
                    {
                        // Ignore thumbnail directories
                        if (!dir.Name.Equals(ThumbnailUtilities.ThumbnailDirectory))
                        {
                            string virtualPath = GetVirtualPath(token, dir.FullName);

                            // Do we have a PhotoDirectory for this directory already? If not then we need to
                            // add it to the database
                            if (!results.Contains(virtualPath))
                            {
                                string parentVirtualPath = virtualPath.Substring(0, virtualPath.Length - dir.Name.Length - 1);

                                PhotoDirectory photoDirectory = new PhotoDirectory(token, dir.Name, parentVirtualPath);

                                // insert this directory into the database
                                db.Insert(parent, photoDirectory);

                                results.Add(photoDirectory);
                            }

                            originalResults.Remove(virtualPath);
                        }
                    }

                    // Are there any PhotoDirectory objects in the original result set that aren't in
                    // the list of directories from the file system? If so, delete 'em
                    foreach (PhotoDirectory photoDirectory in originalResults)
                    {
                        db.Delete(photoDirectory);

                        PhotoDB photoDB = new PhotoDB(token.DBConnection);
                        photoDB.DeleteDirectoryPhotos(photoDirectory);

                        results.Remove(photoDirectory);
                    }
                }

                return(results);
            }
        }