/// <summary> /// 下载IGS产品。并返回成功后的本地路径。 /// </summary> /// <param name="gpsTime"></param> /// <param name="satType"></param> /// <returns></returns> protected List <string> DownloadProduct(Time gpsTime, SatelliteType satType = SatelliteType.G) { var urls = IgsProductUrlPathBuilder.SetSatelliteType(satType).Build(gpsTime).ToList(); if (Option.IsUniqueSource) { urls = urls.FindAll(m => Path.GetFileName(m).StartsWith(Option.IndicatedSourceCode)); } var TargetExtention = "*" + IgsProductNameBuilder.GetFileExtension(IgsProductSourceType, gpsTime).TrimEnd('Z', '.'); return(InputFileManager.GetLocalFilePathes(urls.ToArray(), TargetExtention, TargetExtention + ";" + TargetExtention + ".Z", this.Option.IsDownloadingSurplurseIgsProducts)); }
/// <summary> /// 根据类型和历元,按照给定的文件命名规则,读取本地文件 /// </summary> /// <param name="satType">卫星类型</param> /// <param name="gpsTime">时间</param> /// <returns></returns> protected virtual List <string> GetFiles(SatelliteType satType, Time gpsTime) { List <string> pathes = GetIgsProductLocalPathes(satType, gpsTime); List <string> services = new List <string>(); foreach (var path in pathes)//便利所有生产的路径,选择一个可用的 { if (!System.IO.File.Exists(path)) { log.Debug("不存在预期产品 " + this.IgsProductSourceType + ", " + path); continue; } try { var TargetExtention = "*" + IgsProductNameBuilder.GetFileExtension(IgsProductSourceType, gpsTime).TrimEnd('Z', '.'); var filePath = InputFileManager.GetLocalFilePath(path, TargetExtention, "*.*"); if (filePath == null) { continue; } FileInfo info = new FileInfo(path); if (info.Length == 0) { info.Delete(); continue; } //包含则添加 services.Add(path); } catch (Exception ex) { log.Error("文件解析错误," + path + ", " + ex.Message); } break; } return(services); }
/// <summary> /// 根据类型和历元,按照给定的文件命名规则,读取本地文件 /// </summary> /// <param name="satType">卫星类型</param> /// <param name="gpsTime">时间</param> /// <returns></returns> protected virtual List <TIgsProductFile> GetFiles(SatelliteType satType, Time gpsTime) { List <string> pathes = GetIgsProductLocalPathes(satType, gpsTime); List <TIgsProductFile> services = new List <TIgsProductFile>(); foreach (var path in pathes)//便利所有生产的路径,选择一个可用的 { if (!System.IO.File.Exists(path)) { log.Debug("不存在预期产品 " + this.IgsProductSourceType + ", " + path); continue; } try { var TargetExtention = "*" + IgsProductNameBuilder.GetFileExtension(IgsProductSourceType, gpsTime).TrimEnd('Z', '.'); var filePath = InputFileManager.GetLocalFilePath(path, TargetExtention, "*.*"); if (filePath == null) { continue; } string fileBufferKey = BuildFileBufferKey(filePath); TIgsProductFile service = default(TIgsProductFile); if (LoadedIgsProductFiles.Contains(fileBufferKey)) { log.Info("缓存已经加载同名文件,直接从缓存返回: " + filePath); service = LoadedIgsProductFiles[fileBufferKey]; } else { service = LoadFile(filePath); if (service == null || service.TimePeriod.Span == 0) { log.Info("数据源" + service + "不可用 " + this.IgsProductSourceType + "," + filePath); continue; } log.Info("成功载入 " + this.IgsProductSourceType + "," + filePath); if (LoadedIgsProductFiles.Count > Option.MaxIgsProductCacheCount) { LoadedIgsProductFiles.RemoveFirst(); //LoadedIgsProductFiles.Clear(); //log.Info("IGS 缓存产品超过最大数量 " + Option.MaxIgsProductCacheCount + ", 清空缓存重新来过。"); } LoadedIgsProductFiles[fileBufferKey] = service; } //包含则添加 services.Add(service); } catch (Exception ex) { log.Error("文件解析错误," + path + ", " + ex.Message); } break; } return(services); }