ILock.ActiveLocks Property

IT Hit WebDAV for .NET

Gets the array of all locks for this item.

[Visual Basic]
Property ActiveLocks As LockInfo()
[C#]
LockInfo[] ActiveLocks {get;}

Remarks

This property must return all locks for the item including deep locks on any of the parent folders. All fields of each LockInfo structure in the array must be set.

Example

        public LockInfo[] ActiveLocks
        {
            get
            {
                int itemID = ID;
                ArrayList l = new ArrayList();
                
                SqlConnection conn = new SqlConnection(connStr);
                SqlCommand cmd;
                conn.Open();
                try
                {
                    cmd = conn.CreateCommand();
                    cmd.CommandText = "SELECT Parent FROM Repository WHERE ID = @ID";
                    cmd.Parameters.Add("@ID", SqlDbType.Int);
                    cmd.Prepare();

                    l.AddRange(GetLocks(ID, false)); // get all locks
                    while(true)
                    {
                        cmd.Parameters["@ID"].Value = itemID;
                        itemID = (int)cmd.ExecuteScalar();
                        if(itemID <= 0) break;
                        l.AddRange(GetLocks(itemID, true));  // get only deep locks
                    }
                }
                finally
                {
                    conn.Close();
                }
                
                return (LockInfo[])l.ToArray(typeof(LockInfo));
            }
        }
 

See Also

ILock Interface | ITHit.WebDAV.Server Namespace