Exemplo n.º 1
0
        public ImportFilesObj[] AutoFindFilesByDirver(string productIdentify, string subProIdentify, IRasterDataProvider dataProvider, string dir)
        {
            if (string.IsNullOrEmpty(dir))
            {
                return(null);
            }
            if (_transDef == null)
            {
                _transDef = (new MVGXMLParser()).GetTransDef();
            }
            if (_transDef == null)
            {
                return(null);
            }
            RasterIdentify rs        = new RasterIdentify(dataProvider.fileName);
            string         searchStr = "*";

            if (rs == null)
            {
                return(null);
            }
            ProductDef proDef = _transDef.GetProductBySmartProductIdentify(productIdentify);

            if (proDef != null && !string.IsNullOrEmpty(proDef.FileIdentify))
            {
                searchStr += proDef.FileIdentify + "*";
            }
            SubProductDef subProDef = proDef.GetSubProductBySmartIdentfy(subProIdentify);

            if (subProDef != null && !string.IsNullOrEmpty(subProDef.FileIdentify))
            {
                searchStr += subProDef.FileIdentify + "*";
            }
            if (!string.IsNullOrEmpty(rs.Satellite))
            {
                searchStr += rs.Satellite + "*";
            }
            if (!string.IsNullOrEmpty(rs.Sensor))
            {
                searchStr += rs.Sensor + "*";
            }
            if (rs.OrbitDateTime != DateTime.MinValue)
            {
                searchStr += rs.OrbitDateTime.ToString("yyyyMMddHHmmss") + "*";
            }
            string[] files = Directory.GetFiles(dir, searchStr + ".mvg", SearchOption.AllDirectories);
            if (files == null || files.Length == 0)
            {
                return(null);
            }
            string mvgRegion = null;

            if (!string.IsNullOrEmpty(rs.RegionIdentify) && files.Length > 1)
            {
                for (int i = 0; i < files.Length; i++)
                {
                    mvgRegion = GetRegionName(files[i]);
                    if (string.IsNullOrEmpty(mvgRegion) || rs.RegionIdentify.IndexOf(mvgRegion) == -1)
                    {
                        files[i] = string.Empty;
                    }
                }
            }
            List <ImportFilesObj> importFiles = new List <ImportFilesObj>();
            ImportFilesObj        obj         = null;

            foreach (string file in files)
            {
                if (string.IsNullOrEmpty(file))
                {
                    continue;
                }
                obj = new ImportFilesObj(productIdentify, subProIdentify, Path.GetFileName(file), Path.GetDirectoryName(file));
                importFiles.Add(obj);
            }
            return(importFiles.Count == 0 ? null : importFiles.ToArray());
        }