예제 #1
0
        /// <summary>
        /// Unlocks the webdav resource.
        /// </summary>
        /// <param name="resource">The resource.</param>
        public static void UnlockResource(int webDavElementPropertyId)
        {
            WebDavAbstractFactory             factory     = new WebDavAbstractFactory();
            WebDavStorageElementPropertiesRow propertyRow = null;

            try
            {
                propertyRow = new WebDavStorageElementPropertiesRow(webDavElementPropertyId);
            }
            catch
            {
                return;
            }
            ResourceInfo resInfo = GetResourceInfoFromPropertyRow(propertyRow);

            if (resInfo != null)
            {
                WebDavTicket ticket = WebDavTicket.Parse(resInfo.AbsolutePath);
                WebDavElementStorageProvider storageProvider =
                    factory.Create <WebDavElementStorageProvider>(ticket.AbsolutePath.StorageType);

                foreach (ActiveLockElement activeLockEl in storageProvider.GetActiveLocks(resInfo))
                {
                    OpaqueLockToken lockToken = OpaqueLockToken.Parse(activeLockEl.LockToken.InnerText);
                    storageProvider.Unlock(resInfo, lockToken);
                }
            }
        }
예제 #2
0
        private static McLockElement GetMcLockElement(OpaqueLockToken lockToken, PropertyInfoCollection propInfoColl)
        {
            if (propInfoColl == null)
            {
                throw new ArgumentNullException("propInfoColl");
            }

            McLockElement retVal         = null;
            PropertyInfo  mcLockDateProp = propInfoColl[PropertyInfo.McLockDateProperty];

            if (mcLockDateProp != null)
            {
                WebDavDocument    document     = WebDavDocument.CreateDocument();
                McLockDateElement mcLockDateEl = (McLockDateElement)
                                                 document.ImportNode((XmlElement)mcLockDateProp.Value, true);

                //Try to find McLock element with same token as lockToken
                foreach (McLockElement lockEl in mcLockDateEl.GetLocks())
                {
                    if (lockEl.Token == lockToken.ToString())
                    {
                        retVal = lockEl;
                        break;
                    }
                }
            }

            return(retVal);
        }
예제 #3
0
        /// <summary>
        /// Gets the active locked webdav resources.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <WebDavLockInfo> GetActiveLocksInfo()
        {
            WebDavAbstractFactory factory = new WebDavAbstractFactory();

            foreach (WebDavStorageElementPropertiesRow row in WebDavStorageElementPropertiesRow.List())
            {
                WebDavElementStorageProvider provider = factory.Create <WebDavElementStorageProvider>(row.ObjectTypeId);
                ResourceInfo resInfo = GetResourceInfoFromPropertyRow(row);
                if (resInfo != null)
                {
                    foreach (ActiveLockElement activeLockEl in provider.GetActiveLocks(resInfo))
                    {
                        OpaqueLockToken lockToken = OpaqueLockToken.Parse(activeLockEl.LockToken.InnerText);
                        McLockElement   mcLockEl  = GetMcLockElement(lockToken, provider.GetProperties(resInfo));

                        WebDavLockInfo retval = new WebDavLockInfo();
                        retval.WebDavElementPropertyId = row.PrimaryKeyId.Value;
                        retval.FileName      = resInfo.Name;
                        retval.ContentTypeId = ContentTypeResolver.GetContentTypeId(resInfo.ContentType);
                        retval.StartLocking  = new DateTime(mcLockEl.CreationDate * TimeSpan.TicksPerSecond);
                        retval.Duration      = DateTime.UtcNow - retval.StartLocking;
                        UserLight user = UserLight.Load(activeLockEl.Owner);
                        if (user != null)
                        {
                            retval.LockedBy = user.DisplayName;
                        }
                        else
                        {
                            retval.LockedBy = "Unknow";
                        }

                        yield return(retval);
                    }
                }
            }
        }
예제 #4
0
 public override void Unlock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 public override void RefreshLock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken, string timeout)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 public override void Unlock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public override void RefreshLock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken, string timeout)
 {
     throw new NotImplementedException();
 }
예제 #8
0
        private static McLockElement GetMcLockElement(OpaqueLockToken lockToken, PropertyInfoCollection propInfoColl)
        {
            if (propInfoColl == null)
            {
                throw new ArgumentNullException("propInfoColl");
            }

            McLockElement retVal = null;
            PropertyInfo mcLockDateProp = propInfoColl[PropertyInfo.McLockDateProperty];

            if (mcLockDateProp != null)
            {
                WebDavDocument document = WebDavDocument.CreateDocument();
                McLockDateElement mcLockDateEl = (McLockDateElement)
                                document.ImportNode((XmlElement)mcLockDateProp.Value, true);

                //Try to find McLock element with same token as lockToken
                foreach (McLockElement lockEl in mcLockDateEl.GetLocks())
                {
                    if (lockEl.Token == lockToken.ToString())
                    {
                        retVal = lockEl;
                        break;
                    }
                }
            }

            return retVal;
        }
예제 #9
0
        /// <summary>
        /// Refreshes the lock.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="lockToken">The lock token.</param>
        /// <param name="timeout">The timeout.</param>
        public override void RefreshLock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken, string timeout)
        {
            PropertyInfoCollection collection = GetProperties(element);

            WebDavLockManager.RefreshLock(this, collection, lockToken, timeout);
        }
예제 #10
0
        /// <summary>
        /// Unlocks the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="lockToken">The lock token.</param>
        public override void Unlock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken)
        {
            PropertyInfoCollection collection = GetProperties(element);

            WebDavLockManager.Unlock(this, collection, lockToken);
        }
예제 #11
0
 /// <summary>
 /// Unlocks the specified element.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="lockToken">The lock token.</param>
 public override void Unlock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken)
 {
     PropertyInfoCollection collection = GetProperties(element);
     WebDavLockManager.Unlock(this, collection, lockToken);
 }
예제 #12
0
 /// <summary>
 /// Refreshes the lock.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="lockToken">The lock token.</param>
 /// <param name="timeout">The timeout.</param>
 public override void RefreshLock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken, string timeout)
 {
     PropertyInfoCollection collection = GetProperties(element);
     WebDavLockManager.RefreshLock(this, collection, lockToken, timeout);
 }