예제 #1
0
        public void Publish(string logicalTablePath)
        {
            if (logicalTablePath.Equals("cout", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            if (Configuration.ShouldPublish)
            {
                Trace.WriteLine($"PUBLISH: {logicalTablePath}");

                foreach (StreamAttributes item in LocalProvider.Enumerate(logicalTablePath, EnumerateTypes.File, true))
                {
                    using (Stream target = RemoteProvider.OpenWrite(item.Path))
                    {
                        using (Stream source = LocalProvider.OpenRead(item.Path))
                        {
                            source.CopyTo(target);
                        }
                    }
                }

                Trace.WriteLine($"Done with PUBLISH: {logicalTablePath}");
            }
        }
예제 #2
0
        public Stream OpenRead(string logicalPath)
        {
            // If configured to only use remote configuration, don't use the local copy for Config and Query
            if (Configuration.UseRemoteConfiguration)
            {
                if (logicalPath.StartsWith("Config\\", StringComparison.OrdinalIgnoreCase) || logicalPath.StartsWith("Query\\", StringComparison.OrdinalIgnoreCase))
                {
                    return(RemoteProvider.OpenRead(logicalPath));
                }
            }

            // Read the local copy first, if found
            if (LocalProvider.Attributes(logicalPath).Exists)
            {
                return(LocalProvider.OpenRead(logicalPath));
            }

            // If there's a remote copy, use that
            if (LocalProvider.Attributes(logicalPath).Exists == false && RemoteProvider.Attributes(logicalPath).Exists == true)
            {
                if (Configuration.ShouldDownload)
                {
                    // Download the file if configured to
                    Trace.WriteLine($"DOWNLOAD: {logicalPath}");
                    using (Stream target = LocalProvider.OpenWrite(logicalPath))
                    {
                        using (Stream source = RemoteProvider.OpenRead(logicalPath))
                        {
                            source.CopyTo(target);
                        }
                    }

                    return(LocalProvider.OpenRead(logicalPath));
                }

                return(RemoteProvider.OpenRead(logicalPath));
            }

            // If neither location had the item, throw
            throw new IOException($"\"{logicalPath}\" did not exist in {LocalProvider.Description} or {RemoteProvider.Description}");
        }