Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="volumeName"></param>
        /// <param name="fileName"></param>
        /// <param name="nodeNumber"></param>
        /// <returns></returns>
        internal static Node Get(string volumeName, string fileName, uint nodeNumber)
        {
            VolumeHeader volHeader = VolumeHeader.Get(volumeName);

            Node headerNode = null;

            switch (fileName)
            {
            case "Catalog":
                headerNode = CatalogFile.GetHeaderNode(volumeName);
                break;

            case "Attributes":
                headerNode = AttributesFile.GetHeaderNode(volumeName);
                break;

            case "ExtentsOverflow":
                headerNode = ExtentsOverflowFile.GetHeaderNode(volumeName);
                break;
            }

            HeaderRecord headerRecord = headerNode.Records[0] as HeaderRecord;

            return(Get(GetBytes(volumeName, fileName, nodeNumber), volumeName, fileName, nodeNumber));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (CatalogFile != null)
            {
                using (var ms = new MemoryStream())
                {
                    CatalogFile.CopyTo(ms);
                    Catalog.File = ms.ToArray();
                }
            }

            _context.Catalogs.Add(Catalog);
            await _context.SaveChangesAsync().ConfigureAwait(false);

            if (!SyncProducts)
            {
                return(RedirectToPage("./Index"));
            }
            var rules    = _context.DiscountRules.ToImmutableList();
            var products = _excelReaderService.GetLines(Catalog, rules);
            await _context.Products.AddRangeAsync(products).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        private void DisplayFile(CatalogFile file)
        {
            IFeatureLayer lyr = new FeatureLayer(Path.GetFileNameWithoutExtension(file.Tag.ToString()),
                                                 file.Tag.ToString());
            IMap map = new Map(new IFeatureLayer[] { lyr });

            mapControl1.Apply(map);
            mapControl1.ReRender();
        }
Ejemplo n.º 4
0
        protected CatalogFile ParseCatalogFile(XmlElement element)
        {
            var cf = CatalogFile.Create(
                element.GetAttribute("Id"),
                element.GetAttribute("Path")
                );

            return(cf);
        }
Ejemplo n.º 5
0
        public void SaveCatalog()
        {
            Logger.LogDebug($"Saving Catalog - {CatalogFile.FullName}");
            var formatter = new BinaryFormatter();

            using (var outStream = CatalogFile.Create())
            {
                formatter.Serialize(outStream, Catalog);
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            if (CatalogFile != null)
            {
                using (var ms = new MemoryStream())
                {
                    CatalogFile.CopyTo(ms);
                    Catalog.File = ms.ToArray();
                }
            }

            _context.Attach(Catalog).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CatalogExists(Catalog.Id))
                {
                    return(NotFound());
                }
                throw;
            }

            if (!SyncProducts)
            {
                return(RedirectToPage("./Index"));
            }

            _context.Products.RemoveRange(_context.Products.Where(p => p.CatalogId == Catalog.Id).Select(p => new Product {
                Id = p.Id
            }));

            await _context.SaveChangesAsync().ConfigureAwait(false);

            var rules    = _context.DiscountRules.ToImmutableList();
            var products = _excelReaderService.GetLines(Catalog, rules);
            await _context.Products.AddRangeAsync(products).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>A hash code for the current <see cref="T:System.Object"/>.</returns>
 public override int GetHashCode()
 {
     return(BootCritical.GetHashCode()
            ^ InBox.GetHashCode()
            ^ (String.IsNullOrEmpty(CatalogFile) ? 0 : CatalogFile.GetHashCode())
            ^ (String.IsNullOrEmpty(ClassDescription) ? 0 : ClassDescription.GetHashCode())
            ^ (String.IsNullOrEmpty(ClassGuid) ? 0 : ClassGuid.GetHashCode())
            ^ (String.IsNullOrEmpty(ClassName) ? 0 : ClassName.GetHashCode())
            ^ Date.GetHashCode()
            ^ DriverSignature.GetHashCode()
            ^ (String.IsNullOrEmpty(OriginalFileName) ? 0 : OriginalFileName.GetHashCode())
            ^ (String.IsNullOrEmpty(ProviderName) ? 0 : ProviderName.GetHashCode())
            ^ (String.IsNullOrEmpty(PublishedName) ? 0 : PublishedName.GetHashCode()));
 }
Ejemplo n.º 8
0
 void ucBudGISDataSource1_OnCatalogItemDoubleClicked(object sender, ICatalogItem catalogItem)
 {
     if (catalogItem is CatalogFile)
     {
         CatalogFile file = catalogItem as CatalogFile;
         DisplayFile(file);
     }
     else if (catalogItem is ICatalogEntityClass)
     {
     }
     else if (catalogItem is CatalogFeatureClass)
     {
         DisplayFeatureClass(catalogItem as CatalogFeatureClass);
     }
 }
Ejemplo n.º 9
0
        private bool AddInstallChunk(VfsFormats.Layout.InstallChunk installChunk)
        {
            if (this._InstallChunkInfo.ContainsKey(installChunk.Id) == true)
            {
                return(true);
            }

            var basePath    = Path.Combine(this._DataPath, Helpers.FilterPath(installChunk.InstallBundle));
            var catalogPath = Path.Combine(basePath, "cas.cat");

            if (File.Exists(catalogPath) == false)
            {
                return(false);
            }

            var catalog          = CatalogFile.Read(catalogPath);
            var installChunkInfo = new InstallChunkInfo(basePath);

            foreach (var entry in catalog.ChunkEntries)
            {
                var variantInfo = new ChunkVariantInfo(installChunkInfo, entry, null);

                List <ChunkVariantInfo> chunkVariants;
                if (this._ChunkInfo.TryGetValue(entry.SHA1.Text, out chunkVariants) == false)
                {
                    chunkVariants = this._ChunkInfo[entry.SHA1.Text] = new List <ChunkVariantInfo>();
                }

                chunkVariants.Add(variantInfo);
            }

            foreach (var entry in catalog.EncryptedChunkEntries)
            {
                var variantInfo = new ChunkVariantInfo(installChunkInfo, entry.Chunk, entry.CryptoInfo);

                List <ChunkVariantInfo> chunkVariants;
                if (this._ChunkInfo.TryGetValue(entry.Chunk.SHA1.Text, out chunkVariants) == false)
                {
                    chunkVariants = this._ChunkInfo[entry.Chunk.SHA1.Text] = new List <ChunkVariantInfo>();
                }

                chunkVariants.Add(variantInfo);
            }

            this._InstallChunkInfo.Add(installChunk.Id, installChunkInfo);
            return(true);
        }
Ejemplo n.º 10
0
        //================================
        // Static Methods
        //================================
        public static CatalogFile Create(string id, string path)
        {
            var instance = new CatalogFile();

            instance.Id = instance.ValidatedId(id);

            if (instance.IsEmptyValue(path))
            {
                throw new NotesvelInternalException(
                          EXCEPTION_PATH_IS_EMPTY,
                          "FileName of Catalog(" + id + ") is empty."
                          );
            }
            instance.Path = path;

            return(instance);
        }
        public async Task <CatalogFile> UploadNewCatalogFile(CatalogFileModel file, IFormFile uploadFile)
        {
            var blobUrl = await this.storageClient.AddNewCatalogBlob(file.uploadFile);

            var catalogFile = new CatalogFile
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = file.Name,
                Description = file.Description,
                BlobUri     = blobUrl,
                FileType    = FileType.Image
            };

            await this.repository.CreateDoc(catalogFile);

            return(catalogFile);
        }
Ejemplo n.º 12
0
        public bool Add(string path)
        {
            if (this._CatalogInfo.ContainsKey(path) == true)
            {
                return(true);
            }

            var basePath    = Path.Combine(this._DataPath, Helpers.FilterPath(path));
            var catalogPath = Path.Combine(basePath, "cas.cat");

            if (File.Exists(catalogPath) == false)
            {
                return(false);
            }

            var catalog = CatalogFile.Read(catalogPath);

            if (catalog.Unknown3s.Count > 0)
            {
                Console.WriteLine("'{0}' has unknown3s.", catalogPath);
            }

            var catalogInfo = new CatalogInfo(basePath);

            this._CatalogInfo.Add(path, catalogInfo);

            foreach (var entry in catalog.ChunkEntries)
            {
                var info = new EntryInfo(catalogInfo, entry);

                List <EntryInfo> entryInfos;
                if (this._EntryInfo.TryGetValue(entry.SHA1.Text, out entryInfos) == false)
                {
                    entryInfos = this._EntryInfo[entry.SHA1.Text] = new List <EntryInfo>();
                }

                entryInfos.Add(info);
            }

            return(true);
        }
Ejemplo n.º 13
0
        public void UploadFile(CatalogFile catalog)
        {
            var worbookReader = new WorbookReader(catalog);

            _logger.LogInformation($"Starting upload processs {worbookReader.CatalogConfiguration.FilePath}", worbookReader);
            var worbook     = worbookReader.ReadWorkbook();
            var definitions = worbookReader.CatalogConfiguration.CatalogDefinition.Where(p => p.Active).ToList();

            foreach (var definition in definitions)
            {
                if (definition != null)
                {
                    var bufferName  = definition.EntityName ?? definition.SheetName;
                    var sheetReader = _sheetReaderFactory.CreateInstance(worbook, _bufferBlocks[bufferName]);
                    sheetReader.ReadSheet(definition);
                    _bufferBlocks[bufferName].Complete();
                }
            }

            _logger.LogInformation("Reader process completed");
        }
Ejemplo n.º 14
0
        public ChunkLoader(CatalogFile catalog,
                           IEnumerable <KeyValuePair <byte, MemoryMappedFile> > files,
                           Dictionary <SHA1Hash, List <ChunkVariantInfo> > chunkLookup)
        {
            if (catalog == null)
            {
                throw new ArgumentNullException("catalog");
            }

            this._Catalog     = catalog;
            this._Files       = new Dictionary <byte, MemoryMappedFile>();
            this._ChunkLookup = new Dictionary <SHA1Hash, List <ChunkVariantInfo> >();

            foreach (var kv in files)
            {
                this._Files[kv.Key] = kv.Value;
            }

            foreach (var kv in chunkLookup)
            {
                this._ChunkLookup[kv.Key] = new List <ChunkVariantInfo>(kv.Value);
            }
        }
Ejemplo n.º 15
0
        public static ChunkLoader Load(string basePath)
        {
            var catalogPath = Path.Combine(basePath, "cas.cat");

            if (File.Exists(catalogPath) == false)
            {
                return(null);
            }

            Logger.Debug("Reading catalog '{0}'", catalogPath);
            var catalog = CatalogFile.Read(catalogPath);

            var chunkDataIndices          = catalog.NormalEntries.Select(ce => ce.DataIndex);
            var encryptedChunkDataIndices = catalog.EncryptedEntries.Select(ece => ece.Entry.DataIndex);

            var files = new Dictionary <byte, MemoryMappedFile>();

            foreach (var index in chunkDataIndices.Concat(encryptedChunkDataIndices).Distinct().OrderBy(v => v))
            {
                var dataPath = Path.Combine(basePath, string.Format("cas_{0:D2}.cas", index));
                if (File.Exists(dataPath) == false)
                {
                    foreach (var stream in files.Values)
                    {
                        stream.Dispose();
                    }
                    return(null);
                }

                var temp = File.OpenRead(dataPath);
                files[index] = MemoryMappedFile.CreateFromFile(
                    temp,
                    null,
                    0,
                    MemoryMappedFileAccess.Read,
                    null,
                    HandleInheritability.None,
                    false);
            }

            var chunkLookup = new Dictionary <SHA1Hash, List <ChunkVariantInfo> >();

            for (int i = 0; i < catalog.NormalEntries.Count; i++)
            {
                var entry = catalog.NormalEntries[i];

                List <ChunkVariantInfo> chunkVariants;
                if (chunkLookup.TryGetValue(entry.Id, out chunkVariants) == false)
                {
                    chunkVariants = chunkLookup[entry.Id] = new List <ChunkVariantInfo>();
                }

                chunkVariants.Add(new ChunkVariantInfo(i, ChunkVariantType.Normal));
            }

            for (int i = 0; i < catalog.PatchEntries.Count; i++)
            {
                var entry = catalog.PatchEntries[i];

                List <ChunkVariantInfo> chunkVariants;
                if (chunkLookup.TryGetValue(entry.Id, out chunkVariants) == false)
                {
                    chunkVariants = chunkLookup[entry.Id] = new List <ChunkVariantInfo>();
                }

                chunkVariants.Add(new ChunkVariantInfo(i, ChunkVariantType.Patch));
            }

            for (int i = 0; i < catalog.EncryptedEntries.Count; i++)
            {
                var entry = catalog.EncryptedEntries[i];

                List <ChunkVariantInfo> chunkVariants;
                if (chunkLookup.TryGetValue(entry.Entry.Id, out chunkVariants) == false)
                {
                    chunkVariants = chunkLookup[entry.Entry.Id] = new List <ChunkVariantInfo>();
                }

                chunkVariants.Add(new ChunkVariantInfo(i, ChunkVariantType.Encrypted));
            }

            return(new ChunkLoader(catalog, files, chunkLookup));
        }
Ejemplo n.º 16
0
 public WorbookReader(CatalogFile configuration)
 {
     _configuration = configuration;
 }