Пример #1
0
        private IEnumerable <SsrsObject> MapFilesToSsrsObjects(SsrsObjectFilter filter)
        {
            var rootContainer = new DirectoryInfo(directoryPath);

            if (!rootContainer.Exists)
            {
                yield break;
            }
            var siteFilter = GetSiteFilter(filter.Site);

            foreach (var relativePath in new RelativeDirectoryExplorer().EnumerateRelativeFiles(rootContainer))
            {
                var containerPath = basePath + SsrsObjectPath.FromFileSystemPath(Path.GetDirectoryName(relativePath));
                var ssrsObject    = new SsrsObjectFileReader().Read(Path.Combine(directoryPath, relativePath), containerPath);
                if (filter.Excludes(ssrsObject))
                {
                    continue;
                }
                if (siteFilter?.Matches(ssrsObject.Path) == false)
                {
                    continue;
                }
                yield return(ssrsObject);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns true if the specified object is rejected by path or by type.
        /// </summary>
        public static bool Excludes(this SsrsObjectFilter filter, SsrsObject obj)
        {
            if (obj == null)
            {
                return(true);
            }
            if (!filter.Path.Matches(obj.Path))
            {
                return(true);
            }

            if (filter.ObjectTypes != SsrsFilterObjectTypes.All)
            {
                switch (obj.Type)
                {
                case SsrsObjectType.DataSource: return((filter.ObjectTypes & SsrsFilterObjectTypes.DataSource) == 0);

                case SsrsObjectType.Report: return((filter.ObjectTypes & SsrsFilterObjectTypes.Report) == 0);

                case SsrsObjectType.DataSet: return((filter.ObjectTypes & SsrsFilterObjectTypes.DataSet) == 0);
                }
                return(true);
            }
            return(false);
        }
Пример #3
0
        private IEnumerable <SsrsObject> ReadWithFilter(SsrsObjectFilter filter)
        {
            var ssrsObject = new SsrsObjectFileReader().Read(filePath, basePath);

            if (filter.Excludes(ssrsObject))
            {
                yield break;
            }
            yield return(ssrsObject);
        }
Пример #4
0
 public Task <IEnumerable <SsrsObject> > Enumerate(SsrsObjectFilter filter)
 {
     return(Task.FromResult(ReadWithFilter(filter)));
 }
Пример #5
0
 public Task <IEnumerable <SsrsObject> > Enumerate(SsrsObjectFilter filter)
 {
     return(Task.FromResult(MapFilesToSsrsObjects(filter)));
 }
        public async Task <IEnumerable <SsrsObject> > Enumerate(SsrsObjectFilter filter)
        {
            var enumerables = await Task.WhenAll(GetSources().Select(s => s.Enumerate(filter)));

            return(enumerables.SelectMany(i => i));
        }