public void ProcessFile() { if (_fileNames.Count > 0) { var fileName = _fileNames[_processedFile]; var uncompressedFilename = fileName.Substring(fileName.LastIndexOf('/') + 1); using (var uncompressedFileStream = _zipFile.GetFileStream(fileName)) { if (fileName.StartsWith("Exports/")) { if (fileName.EndsWith(".xml")) { var linkedFilesUrl = App.Params.SiteUrl + "/" + App.Params.FileUploadLibrary + "/"; var compendiumXmlFileProcess = new CompendiumXmlFileProcessor(uncompressedFileStream, linkedFilesUrl, fileName); compendiumXmlFileProcess.Map = Map; compendiumXmlFileProcess.MapManager = MapManager; compendiumXmlFileProcess.ProgressChanged += OnProgressChanged; compendiumXmlFileProcess.ProgressCompleted += OnProgressCompleted; compendiumXmlFileProcess.ProcessFile(); } } else { UploadFiles(uncompressedFilename, uncompressedFileStream); } } } else { } }
public IFileProcessor CreateFileProcessor(FileInfo file, Proxy.IMapManager mapManager, Proxy.INode map, Point location) { if (file.Name.EndsWith(".zip")) { using (FileStream fileStream = file.OpenRead()) { bool isCompendiumExport = false; bool hasExportsFolderAndXml = false; bool hasLinkedFilesFolder = false; ZipFile zipFile = new ZipFile(fileStream); foreach (string filename in zipFile.FileNamesInZip) { if (filename.StartsWith("Exports/")) { if (filename.EndsWith(".xml")) { isCompendiumExport = true; //hasExportsFolderAndXml = true; break; } } //if (filename.StartsWith("Linked Files/")) //{ // hasLinkedFilesFolder = true; //} //if (hasExportsFolderAndXml && hasLinkedFilesFolder) //{ // isCompendiumExport = true; // break; //} } if (isCompendiumExport) { var compendiumFileProcessor = new CompendiumArchiveProcessor(file, mapManager, map); return compendiumFileProcessor; } } } else if (file.Name.EndsWith(".xml")) { using (var stream = file.OpenRead()) { var compendiumXmlProcessor = new CompendiumXmlFileProcessor(stream, "", ""); compendiumXmlProcessor.MapManager = mapManager; compendiumXmlProcessor.Map = map; if (compendiumXmlProcessor.Nodes.Any()) { return compendiumXmlProcessor; } } } return new DroppedFileProcessor(file, location); }
public IFileProcessor CreateFileProcessor(FileInfo file, Proxy.IMapManager mapManager, Proxy.INode map, Point location) { if (file.Name.EndsWith(".zip")) { using (FileStream fileStream = file.OpenRead()) { bool isCompendiumExport = false; bool hasExportsFolderAndXml = false; bool hasLinkedFilesFolder = false; ZipFile zipFile = new ZipFile(fileStream); foreach (string filename in zipFile.FileNamesInZip) { if (filename.StartsWith("Exports/")) { if (filename.EndsWith(".xml")) { isCompendiumExport = true; //hasExportsFolderAndXml = true; break; } } //if (filename.StartsWith("Linked Files/")) //{ // hasLinkedFilesFolder = true; //} //if (hasExportsFolderAndXml && hasLinkedFilesFolder) //{ // isCompendiumExport = true; // break; //} } if (isCompendiumExport) { var compendiumFileProcessor = new CompendiumArchiveProcessor(file, mapManager, map); return(compendiumFileProcessor); } } } else if (file.Name.EndsWith(".xml")) { using (var stream = file.OpenRead()) { var compendiumXmlProcessor = new CompendiumXmlFileProcessor(stream, "", ""); compendiumXmlProcessor.MapManager = mapManager; compendiumXmlProcessor.Map = map; if (compendiumXmlProcessor.Nodes.Any()) { return(compendiumXmlProcessor); } } } return(new DroppedFileProcessor(file, location)); }