private CatalogDef GetCatalog(XElement ele) { string text = GetStringAttValue(ele, "text"); string classString = GetStringAttValue(ele, "class"); string identify = GetStringAttValue(ele, "identify"); string filter = GetStringAttValue(ele, "filter"); string pattern = GetStringAttValue(ele, "pattern"); string folder = GetStringAttValue(ele, "folder"); SubProductCatalogDef catalog = new SubProductCatalogDef(classString, text, identify, filter, pattern, folder); if (ele.Element("Attributes") != null) { var xeles = ele.Element("Attributes").Elements("Attribute"); if (xeles != null) { foreach (XElement e in xeles) { CatalogAttriteDef attDef = GetCatalogAttributeDdef(e); if (attDef != null) { catalog.AttributeDefs.Add(attDef); } } } } return(catalog); }
/* * <Attribute text="产品类别" identify="SubProductIdentify" format="" visible="true"/> * <Attribute text="卫星" identify="Satellite" format="" visible="true"/> * <Attribute text="传感器" identify="Sensor" format="" visible="true"/> * <Attribute text="轨道时间" identify="OrbitDateTime" format="yyyy-MM-dd HH:mm:ss" visible="true"/> * <Attribute text="原始文件" identify="SourceFile" format="" visible="true"/> * <Attribute text="监测区域" identify="RegionIdentify" format="" visible="true"/> * <Attribute text="描述" identify="Description" format="" visible="true"/> * <Attribute text="轨道时间分组" identify="OrbitTimeGroup" format="yyyy-MM-dd" visible="true"/> * <Attribute text="文件名" identify="FileName" format="" visible="true"/> * <Attribute text="路径" identify="FileDir" format="" visible="true"/> * <Attribute text="类别中文" identify="CatalogItemCN" format="" visible="false"/> * <Attribute text="数据集定义" identify="CatalogDef" format="" visible="false"/> * <Attribute text="扩展信息" identify="ExtInfos" format="" visible="false"/> * <Attribute text="区域" identify="Region" format="" visible="false"/> * <Attribute text="轨道时间段" identify="OrbitTimes" format="yyyy-MM-dd HH:mm:ss ; yyyy-MM-dd HH:mm:ss" visible="false"> */ private void TryCreateInfoFromMainFile(string fname, string infoFileName, SubProductCatalogDef catalogDef) { string fileName = Path.GetFileNameWithoutExtension(fname); string[] parts = fileName.Split('_'); if (parts.Length < 2) { return; } RasterIdentify rst = new RasterIdentify(fname); CatalogItemInfo info = new CatalogItemInfo(); info.Properties.Add("ProductIdentify", parts[0]); info.Properties.Add("SubProductIdentify", parts[1]); info.Properties.Add("FileName", Path.GetFileName(fname)); info.Properties.Add("FileDir", Path.GetDirectoryName(fname)); info.Properties.Add("CatalogDef", catalogDef == null ? "" : catalogDef.ClassString); info.Properties.Add("Satellite", rst.Satellite); info.Properties.Add("Sensor", rst.Sensor); info.Properties.Add("OrbitDateTime", GetDateFormart(rst.OrbitDateTime, catalogDef, "OrbitDateTime")); info.Properties.Add("OrbitTimeGroup", GetDateFormart(rst.OrbitDateTime, catalogDef, "OrbitTimeGroup")); info.Properties.Add("CatalogItemCN", GetCatalogCN(info, MifEnvironment.CatalogItemCNDic)); RasterIdentify ri = new RasterIdentify(fname); info.Properties.Add("Region", GetRegionInfo(ri, fname)); info.Properties.Add("ExtInfos", GetExtInfo(ri, fname)); info.Properties.Add("CycFlagCN", string.IsNullOrEmpty(ri.CYCFlag) ? "\\" : GetCycFlagCN(info, ri.CYCFlag, MifEnvironment.CatalogItemCNDic)); info.Properties.Add("OrbitTimes", GetOrbitTimes(ri)); //..... info.SaveTo(infoFileName); _info = info; }
private string GetDateFormart(DateTime dt, SubProductCatalogDef catalogDef, string identify) { string defFormat = "yyyy-MM-dd HH:mm:ss"; if (catalogDef == null) { return(dt.ToString(defFormat)); } CatalogAttriteDef cad = catalogDef.GetCatalogAttrDefByIdentify(identify); if (cad == null || string.IsNullOrEmpty(cad.Format)) { return(dt.ToString(defFormat)); } return(dt.ToString(cad.Format)); }
private static SDatinfo CreateDatinfo(string fname, SubProductCatalogDef catalogDef) { string infoFileName = GetInfoFileName(fname); CatalogItemInfo ctl; if (!File.Exists(infoFileName)) { ctl = TryCreateInfoFromMainFile(fname, infoFileName, catalogDef); } else { ctl = new CatalogItemInfo(infoFileName); if (!ctl.Properties.ContainsKey("CatalogDef") || string.IsNullOrEmpty(ctl.Properties["CatalogDef"].ToString()) || !ctl.Properties.ContainsKey("CycFlagCN")) { ctl = TryCreateInfoFromMainFile(fname, infoFileName, catalogDef); } } if (ctl == null) { ctl = new CatalogItemInfo(infoFileName); } var datinfo = new SDatinfo { CatalogDef = ctl.GetPropertyValue("CatalogDef"), CatalogItemCN = ctl.GetPropertyValue("CatalogItemCN"), CycFlagCN = ctl.GetPropertyValue("CycFlagCN"), ExtInfos = ctl.GetPropertyValue("ExtInfos"), FileDir = ctl.GetPropertyValue("FileDir"), FileName = ctl.GetPropertyValue("FileName"), OrbitDateTime = ctl.GetPropertyValue("OrbitDateTime"), OrbitTimeGroup = ctl.GetPropertyValue("OrbitTimeGroup"), OrbitTimes = ctl.GetPropertyValue("OrbitTimes"), ProductIdentify = ctl.GetPropertyValue("ProductIdentify"), Region = ctl.GetPropertyValue("Region"), Satellite = ctl.GetPropertyValue("Satellite"), Sensor = ctl.GetPropertyValue("Sensor"), SubProductIdentify = ctl.GetPropertyValue("SubProductIdentify"), SourceFileName = fname }; return(datinfo); }
public CatalogItem(string fname, SubProductCatalogDef catalogDef, params object[] args) { _fileName = fname; string infoFileName = GetInfoFileName(fname); if (!File.Exists(infoFileName)) { TryCreateInfoFromMainFile(fname, infoFileName, catalogDef); } else { _info = new CatalogItemInfo(infoFileName); if (!_info.Properties.ContainsKey("CatalogDef") || string.IsNullOrEmpty(_info.Properties["CatalogDef"].ToString()) || !_info.Properties.ContainsKey("CycFlagCN")) { TryCreateInfoFromMainFile(fname, infoFileName, catalogDef); } } }