Пример #1
0
        public async Task <NearestInterpolatingChunk <T> > GetLazySimpleInterpolator(StandardChunkMetadata template, TraceListener log)
        {
            if (template == null)
            {
                return(null);
            }

            string filename     = GetShortFilename(template);
            string fullFileName = GetFullFileName(template, filename);

            while (
                !(await BlobHelper.BlobExists(cachedFileContainer, fullFileName, log)) &&
                template.ZoomLevel > SourceDataZoom)
            {
                template = template.GetParentChunk();
                return(await GetLazySimpleInterpolator(template, log));
            }

            byte[] buffer = new byte[Math.Max(4, pixelDataSize)];
            return(new NearestInterpolatingChunk <T>(
                       template.LatLo.DecimalDegree, template.LonLo.DecimalDegree,
                       template.LatHi.DecimalDegree, template.LonHi.DecimalDegree,
                       template.LatSteps, template.LonSteps,
                       cachedFileContainer, fullFileName,
                       (ms, i, j) =>
            {
                ms.Seek(8 + pixelDataSize * (i * template.LatSteps + j), SeekOrigin.Begin);
                return ReadPixel(ms, buffer);
            }));
        }
        protected override void ProcessRecord()
        {
            var resolvedFilePath = resolveFilePath(_file);

            StorageContext context       = _context;
            BlobHelper     storageHelper = new BlobHelper(context);

            CloudBlob blob;
            bool      exists;

            try
            {
                exists = storageHelper.BlobExists(Container, Blob).Result;
            }
            catch (System.AggregateException exception)
            {
                throw new System.AggregateException(exception.InnerException.GetBaseException().Message);
            }

            try
            {
                if (exists)
                {
                    if (ShouldProcess(Blob))
                    {
                        var message = "Are you sure to overwrite '" + Context.BlobEndpoint + Container + "/" + Blob + "'?";

                        if (Force || ShouldContinue(message, "Confirm"))
                        {
                            blob = storageHelper.UploadBlob(Container, resolvedFilePath, Blob).Result;
                            WriteObject(blob);
                        }
                        else
                        {
                            throw new System.Management.Automation.HaltCommandException("Blob " + Blob + " already exists.");
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    blob = storageHelper.UploadBlob(Container, resolvedFilePath, Blob).Result;
                    WriteObject(blob);
                }
            }
            catch (System.AggregateException exception)
            {
                throw new System.AggregateException(exception.InnerException.GetBaseException().Message);
            }
        }
Пример #3
0
        public async Task <bool> ExistsComputedChunk(StandardChunkMetadata template, TraceListener log)
        {
            string filename = GetShortFilename(template);

            return(await BlobHelper.BlobExists(cachedFileContainer, GetFullFileName(template, filename), log));
        }