示例#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);
 }