예제 #1
0
        /// <summary>
        /// Adds a new object to the collection.
        /// </summary>
        /// <param name="key">The key of the object.</param>
        /// <param name="obj">The object to add</param>
        protected void Add(KeyBase key, PhotoObjectBase obj)
        {
            innerList.Add(key, obj);

            // Keep a map of the keys to the IDs
            keyMap.Add(obj.Id, key);
        }
예제 #2
0
        protected int GetIdentityValue(PhotoObjectBase obj)
        {
            IDbCommand command = this.GetCommand();

            command.CommandText = "SELECT @@IDENTITY";
            int id = (int)command.ExecuteScalar();

            obj.SetId(id);
            return(id);
        }
예제 #3
0
        internal override void Delete(PhotoObjectBase obj)
        {
            PhotoDirectory directory = (PhotoDirectory)obj;
            IDbCommand     command   = base.GetCommand();

            command.CommandText = "DELETE FROM tblDirectories WHERE ID = ?";
            command.Parameters.Add(base.CreateIntParam("ID", directory.Id));
            if (command.ExecuteNonQuery() != 1)
            {
                throw new Exception("Attempted to delete a PhotoDirectory record that did not exit");
            }
        }
예제 #4
0
        private void InitPage(HttpRequest request)
        {
            DirectoryBrowser dirBrowser       = (DirectoryBrowser)Session["photo_DirectoryBrowser"];
            PhotoDirectory   CurrentDirectory = (PhotoDirectory)Session["photo_CurrentDirectory"];

            if (dirBrowser == null || request.Params["method"] == null)
            {
//                string photosPath = request.ApplicationPath + Path.DirectorySeparatorChar;
                string mappedPhotosDbPath = request.MapPath("") + "\\photos";
                if (Session["photo_rootpath"] == null)
                {
                    Response.Write("错误的参数,通知管理员此异常现象");
                    Response.End();
                }
                string path = (string)Session["photo_rootpath"];
                dirBrowser = new DirectoryBrowser(mappedPhotosDbPath, path);
            }
            Hashtable directoryLookup = (Hashtable)Session["photo_DirectoryLookup"];

            if (directoryLookup == null)
            {
                directoryLookup = new Hashtable();
            }

            DisplayTreeview(dirBrowser, directoryLookup);
            // expand out the current directory node
            int directoryID = -1;

            if (CurrentDirectory != null)
            {
                directoryID = CurrentDirectory.Id;
            }
            else if (request.Params["directoryID"] != null)
            {
                directoryID = Int32.Parse(request.Params["directoryID"]);
            }
            else
            {
                PhotoObjectBase pd1 = dirBrowser.rootDir.GetByIndex(0);
                directoryID = pd1.Id;
            }
            squishyWARE.WebComponents.squishyTREE.TreeNode node = tvwMain.FindTreeNode(directoryID.ToString());
            ExpandNode(node);

            Session.Add("photo_DirectoryBrowser", dirBrowser);
            Session.Add("photo_DirectoryLookup", directoryLookup);

            // Must be called after DisplayTreeview
            ProcessMethod(request, directoryLookup, directoryID);
        }
예제 #5
0
        /// <summary>
        /// Deletes a photo from the database. Note that this does not delete any associated comments.
        /// </summary>
        /// <param name="obj">A Photo object representing the photo to be deleted.</param>
        internal override void Delete(PhotoObjectBase obj)
        {
            Photo photo = (Photo)obj;

            IDbCommand cmd = GetCommand();

            cmd.CommandText = "DELETE FROM tblPhotos WHERE ID = " + photo.Id;

            //cmd.Parameters.Add(CreateIntParam("ID", photo.Id));

            int rowsAffected = cmd.ExecuteNonQuery();

            if (rowsAffected != 1)
            {
                throw new Exception("Attempted to delete a Photo record that does not exist");
            }
        }
예제 #6
0
파일: CommentDB.cs 프로젝트: ishui/rms2
 internal override void Delete(PhotoObjectBase obj)
 {
     throw new NotImplementedException("Cannot delete comment objects");
 }
예제 #7
0
파일: Comments.cs 프로젝트: riyuexing/rms
        protected override KeyBase CreateKey(PhotoObjectBase obj)
        {
            Comment comment = (Comment)obj;

            return(new CommentKey(comment.Id, comment.Name, comment.DateAdded));
        }
예제 #8
0
파일: Photos.cs 프로젝트: ishui/rms2
        protected override KeyBase CreateKey(PhotoObjectBase obj)
        {
            Photo photo = (Photo)obj;

            return(new PhotoKey(photo.Id, photo.DateTaken, photo.Name));
        }
예제 #9
0
        /// <summary>
        /// Creates the collection key based on a PhotoDirectory object.
        /// </summary>
        /// <param name="obj">The PhotoDirectory object who's collection key we want.</param>
        /// <returns>A PhotoDirectoryKey object.</returns>
        protected override KeyBase CreateKey(PhotoObjectBase obj)
        {
            PhotoDirectory photoDirectory = (PhotoDirectory)obj;

            return(new PhotoDirectoryKey(photoDirectory.Id, photoDirectory.Name));
        }
예제 #10
0
 /// <summary>
 /// Creates a KeyBase object that is used to store PhotoObjectBase objects in
 /// the collection.
 /// </summary>
 /// <param name="obj">The object to create the key for.</param>
 /// <returns>A KeyBase object.</returns>
 protected abstract KeyBase CreateKey(PhotoObjectBase obj);
예제 #11
0
        /// <summary>
        /// Returns the zero-based index of the specified key in the PhotosCollectionBase.
        /// </summary>
        /// <param name="key">The key to locate in the PhotosCollectionBase. </param>
        /// <returns>The zero-based index of key, if key is found in the PhotosCollectionBase; otherwise, -1.</returns>
        public int IndexOf(PhotoObjectBase obj)
        {
            KeyBase key = CreateKey(obj);

            return(innerList.IndexOfKey(key));
        }
예제 #12
0
 internal abstract void Delete(PhotoObjectBase obj);
예제 #13
0
 protected void Add(KeyBase key, PhotoObjectBase obj)
 {
     this.innerList.Add(key, obj);
     this.keyMap.Add(obj.Id, key);
 }