/// <summary>生成索引数据</summary> private Metadata BuildIndexData(ISheet excelSheet, DataRow row) { var metadata = new Metadata(); var tags = this.MetadataTags; var cols = row.Table.Columns; foreach (DataColumn col in cols) { var tag = tags.GetValueBy(col.ColumnName); if (tag == null) { continue; } var tagValue = row[col]; if (tagValue == null || tagValue == DBNull.Value) { continue; } try { var tagType = MetadataTagType.String; if (!tag.Type.IsNullOrEmpty()) { tagType = tag.Type.ToEnum <MetadataTagType>(); } switch (tagType) { case MetadataTagType.Date: case MetadataTagType.ISODate: if (tagValue is double) { tagValue = excelSheet.GetDateFromCell((double)tagValue).ToUniversalTime(); } else { var dtValue = tagValue.ToString().Trim(); if (dtValue.Length == 0) { continue; } tagValue = dtValue.Replace("/", "-").ToStandardDateTime().ToUniversalTime(); } break; case MetadataTagType.StringArray: tagValue = tagValue.ToString().Split(',', ','); break; case MetadataTagType.String: if (tag.Name == MetadataConsts.ShowType) { var tagItem = ExtToIndexDataTypeValueProvider.Mapper.GetValueBy(tagValue.ToString()); tagValue = tagItem == null?tagValue.ToString() : tagItem.Value; } else { tagValue = tagValue.ToString(); } break; } metadata.SetValue(tag.Name, tagValue); } catch (Exception ex) { ex.Data["IndexTag"] = tag.Name; throw; } } return(metadata); }