Exemplo n.º 1
0
        public void GetItems(VersionControlServer server)
        {
            ItemSpec        spec    = new ItemSpec(ServerPath, RecursionType.OneLevel);
            GetItemsOptions options = GetItemsOptions.IncludeBranchInfo;

            m_itemSet = server.GetItems(spec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Folder, options);
        }
Exemplo n.º 2
0
        public List <FileDir> GetItems(string path, GetItemsOptions options = 0)
        {
            path = path.Replace('\\', '/');
            if (string.IsNullOrWhiteSpace(path))
            {
                path = "/";
            }
            path = path.Replace("//", "/");
            List <FileDir>     list      = new List <FileDir>();
            CloudBlobContainer container = GetContainer(true);

            if (path.EndsWith("/"))
            {
                IEnumerable <IListBlobItem> items = null;
                if (!string.IsNullOrWhiteSpace(path) && path != "/")
                {
                    CloudBlobDirectory dir = container.GetDirectoryReference(path);
                    items = dir.ListBlobs(false, BlobListingDetails.Metadata);// container.ListBlobs(path/*, new BlobRequestOptions() { UseFlatBlobListing = true }*/);
                }
                else
                {
                    items = container.ListBlobs(null, false, BlobListingDetails.Metadata);
                }

                //IEnumerable<IListBlobItem> x = client.ListBlobsWithPrefix(getPath(path));
                if (items != null)
                {
                    GetChildItems(list, items, options, null);
                }
            }
            else
            {
                try
                {
                    var items = container.ListBlobs(path);
                    if (items != null)
                    {
                        foreach (var i in items)
                        {
                            if (i is CloudBlockBlob)
                            {
                                list.Add(FromBlob((CloudBlockBlob)i));
                            }
                        }
                    }


                    //CloudBlockBlob blob = container.GetBlockBlobReference(path);
                    //blob.FetchAttributes();
                    //list.Add(FromBlob(blob));
                }
                catch (Exception)
                {
                    //Intentionally left blank.  FetchAttributes will throw exception if file doesn't exist.
                }
            }

            return(list);
        }
Exemplo n.º 3
0
        public List <FileDir> GetItems(string path, GetItemsOptions options = 0)
        {
            List <FileDir> items = new List <FileDir>();

            path = path.Replace('/', '\\').Replace("\\\\", "\\");


            if (path.EndsWith("\\"))
            {
                DirectoryInfo di = new DirectoryInfo(getFullPath(path));
                if (di.Exists)
                {
                    GetChildItems(items, di, options, m_baseDir.Length);
                }
            }
            else
            {
                FileInfo fi = new FileInfo(getFullPath(path));
                if (fi.Exists)
                {
                    items.Add(FromFI(fi, m_baseDir.Length));
                }
                else
                {
                    int i = path.LastIndexOf('\\');
                    if (i != -1)
                    {
                        path = path.Substring(0, i);
                    }

                    DirectoryInfo di = new DirectoryInfo(getFullPath(path));
                    if (di.Exists)
                    {
                        foreach (FileInfo fi2 in di.GetFiles(path.Substring(i + 1) + "*"))
                        {
                            items.Add(FromFI(fi2, m_baseDir.Length));
                        }
                    }
                }
            }
            return(items);
        }
Exemplo n.º 4
0
 protected void GetChildItems(List <FileDir> items, DirectoryInfo di, GetItemsOptions options, int prefixLength)
 {
     if (options.HasFlag(GetItemsOptions.IncludeFiles))
     {
         foreach (FileInfo fi in di.GetFiles())
         {
             items.Add(FromFI(fi, prefixLength));
         }
     }
     if (options.HasFlag(GetItemsOptions.IncludeDirectories))
     {
         foreach (DirectoryInfo cdi in di.GetDirectories())
         {
             items.Add(new FileDir()
             {
                 Name = cdi.Name, IsDirectory = true, Path = cdi.Parent.FullName.Length <= prefixLength?"": (cdi.Parent.FullName.Substring(prefixLength) + "\\")
             });
             if (options.HasFlag(GetItemsOptions.Deep))
             {
                 GetChildItems(items, cdi, options, prefixLength);
             }
         }
     }
 }
Exemplo n.º 5
0
 public object GetItems(GetItemsOptions options)
 {
     return(_requestContext.SitecoreService.GetItems(options));
 }
Exemplo n.º 6
0
 public IEnumerable <T> GetItems <T>(GetItemsOptions options) where T : class
 {
     return(_requestContext.SitecoreService.GetItems <T>(options));
 }
Exemplo n.º 7
0
 public Task <ApiResult <IEnumerable <NoteFile> > > GetFiles([FromServices] IRepository <NoteFile> repository, Guid id,
                                                             GetItemsOptions options)
 {
     return(ApiHelper.CreateApiResultFromQueryAsync(repository.Entities.Where(entity => entity.NoteId == id),
                                                    Guid.Empty, options));
 }
Exemplo n.º 8
0
 public virtual async Task <ApiResult <IEnumerable <TEntity> > > GetItems(Guid id, GetItemsOptions options)
 {
     return(await ApiHelper.CreateApiResultFromQueryAsync(EntityRepository.Entities, id, options));
 }
Exemplo n.º 9
0
 public AbstractGetItemsBuilder(GetItemsOptions options)
     : base(options)
 {
     _options = options;
 }
Exemplo n.º 10
0
        public async Task <ApiResult <IEnumerable <T> > > CreateApiResultFromQueryAsync <T>(IQueryable <T> query, Guid id,
                                                                                            GetItemsOptions options) where T : BaseEntity
        {
            int rowsTotal = 1;

            if (Equals(id, Guid.Empty))
            {
                rowsTotal = query.Count();
            }

            return(ApiResult.SuccesGetResult(await _apiQuery.GetItemsFromQueryAsync(query, id, options), new PaginationData
            {
                CurrentPage = options?.Page ?? 1,
                ItemsPerPage = options?.RowsCount ?? rowsTotal,
                TotalItems = rowsTotal
            }));
        }
Exemplo n.º 11
0
        public async Task <IEnumerable <T> > GetItemsFromQueryAsync <T>(IQueryable <T> query, Guid id, GetItemsOptions options)
            where T : BaseEntity
        {
            query = query.Select(_entityExpressionsBuilder.GetDefaultEntitySelectorExpression <T>());
            if (!Equals(id, Guid.Empty))
            {
                query = query.Where(entity => entity.Id == id);
            }
            else
            {
                if (options != null && options.RowsCount > 0)
                {
                    query = query.Skip((options.Page - 1) * options.RowsCount).Take(options.RowsCount);
                }
            }

            return(await Task.FromResult((IEnumerable <T>) query.ToArray()));
        }
Exemplo n.º 12
0
        protected void GetChildItems(List <FileDir> list, IEnumerable <IListBlobItem> items, GetItemsOptions options, FileDir parentDir)
        {
            foreach (IListBlobItem item in items)
            {
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    if (options.HasFlag(GetItemsOptions.IncludeFiles))
                    {
                        list.Add(FromBlob((CloudBlockBlob)item));
                    }

                    if (parentDir != null)
                    {
                        parentDir.Length++;
                    }
                }
                else if (options.HasFlag(GetItemsOptions.IncludeDirectories) && item.GetType() == typeof(CloudBlobDirectory))
                {
                    CloudBlobDirectory bdir     = (CloudBlobDirectory)item;
                    string             pname    = bdir.Parent == null?"":bdir.Parent.Prefix;
                    FileDir            childDir = new FileDir()
                    {
                        Name = bdir.Prefix.Substring(pname.Length, bdir.Prefix.Length - pname.Length - 1), IsDirectory = true, Path = pname
                    };
                    list.Add(childDir);
                    if (options.HasFlag(GetItemsOptions.Deep))
                    {
                        GetChildItems(list, bdir.ListBlobs(), options, childDir);
                    }
                }
            }
        }