Exemple #1
0
        public WebDavSqlStoreCollection GetCollection(IWebDavStoreCollection parentCollection, string path, String rootPath, Guid rootGuid)
        {
            var       p                  = PrincipleFactory.Instance.GetPrinciple(FromType.WebDav);
            string    userkey            = p.UserProfile.SecurityObjectId.ToString();
            CacheBase mc                 = GetCachedObject(path) as CacheBase;
            WebDavSqlStoreCollection itm = null;

            if (mc != null)
            {
                itm = mc.GetCachedObject(userkey) as WebDavSqlStoreCollection;
            }
            if (itm != null)
            {
                return(itm);
            }
            itm = new WebDavSqlStoreCollection(parentCollection, path, rootPath, rootGuid, Store);
            if (mc == null)
            {
                mc = new CacheBase();
                mc.AddCacheObject(userkey, itm);
                AddCacheObject(path, mc);
            }
            else
            {
                mc.AddCacheObject(userkey, itm);
            }
            return(itm);
        }
Exemple #2
0
 /// <summary>
 ///     Retrieves all locks for the passed object
 /// </summary>
 /// <param name="storeItem">Item to look for locks for.</param>
 /// <returns></returns>
 public override List <IWebDavStoreItemLockInstance> GetLocks(IWebDavStoreItem storeItem)
 {
     try
     {
         List <IWebDavStoreItemLockInstance> items = new List <IWebDavStoreItemLockInstance>();
         using (var context = new OnlineFilesEntities())
         {
             List <ObjectLockInfo>    result;
             WebDavSqlStoreCollection item = storeItem as WebDavSqlStoreCollection;
             if (item != null)
             {
                 var collection = item;
                 result = context.ObjectLockInfoes.AsNoTracking().Where(d => d.ObjectGuid == collection.ObjectGuid && d.isFolder).ToList();
             }
             else
             {
                 WebDavSqlStoreDocument storeDocument = storeItem as WebDavSqlStoreDocument;
                 if (storeDocument != null)
                 {
                     var document = storeDocument;
                     result = context.ObjectLockInfoes.AsNoTracking().Where(d => d.ObjectGuid == document.ObjectGuid && !d.isFolder).ToList();
                 }
                 else
                 {
                     throw new NotSupportedException();
                 }
             }
             items.AddRange(result.Select(lockInfo => new WebDavSqlStoreItemLockInstance(
                                              PrincipleFactory.Instance.GetPrinciple(FromType.WebDav).UserProfile,
                                              lockInfo.Path,
                                              (WebDavLockScope)lockInfo.LockScope,
                                              (WebDavLockType)lockInfo.LockType,
                                              lockInfo.Owner.ToString(),
                                              lockInfo.RequestedLockTimeout,
                                              lockInfo.Token,
                                              new XmlDocument(),
                                              lockInfo.Depth,
                                              this,
                                              lockInfo.CreateDt
                                              )));
             return(items);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + ex.StackTrace);
         throw;
     }
 }
 public WebDavSqlStoreCollection GetCollection(IWebDavStoreCollection parentCollection, string path, String rootPath, Guid rootGuid)
 {
     var p = PrincipleFactory.Instance.GetPrinciple(FromType.WebDav);
     string userkey = p.UserProfile.SecurityObjectId.ToString();
     CacheBase mc = GetCachedObject(path) as CacheBase;
     WebDavSqlStoreCollection itm = null;
     if (mc != null)
         itm = mc.GetCachedObject(userkey) as WebDavSqlStoreCollection;
     if (itm != null)
         return itm;
     itm = new WebDavSqlStoreCollection(parentCollection, path, rootPath, rootGuid, Store);
     if (mc == null)
     {
         mc = new CacheBase();
         mc.AddCacheObject(userkey, itm);
         AddCacheObject(path, mc);
     }
     else
         mc.AddCacheObject(userkey, itm);
     return itm;
 }