protected override void WriteInnerXml(XmlWriter writer) { // Call Base Method base.WriteInnerXml(writer); // <ID></ID> writer.WriteStartElement("ID"); writer.WriteValue(this._id); writer.WriteEndElement(); // <Name></Name> writer.WriteStartElement("Name"); writer.WriteValue(this._name); writer.WriteEndElement(); // <Units></Units> writer.WriteStartElement("Units"); writer.WriteValue(GeodatabaseUtility.GetDescription(this._units)); writer.WriteEndElement(); // <DataType></DataType> writer.WriteStartElement("DataType"); writer.WriteValue(this._dataType.ToString()); writer.WriteEndElement(); // <UsageType></UsageType> writer.WriteStartElement("UsageType"); writer.WriteValue(this._usageType.ToString()); writer.WriteEndElement(); if (this._userData.Count == 0) { // <UserData></UserData> writer.WriteStartElement("UserData"); writer.WriteAttributeString(Xml._XSI, "nil", null, "true"); writer.WriteEndElement(); } else { // <UserData> writer.WriteStartElement("UserData"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:PropertySet"); // <PropertyArray> writer.WriteStartElement("PropertyArray"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:PropertyArray"); // <PropertySetProperty></PropertySetProperty> foreach (Property property in this._userData) { property.WriteXml(writer); } // </PropertyArray> writer.WriteEndElement(); // </UserData> writer.WriteEndElement(); } // <UseByDefault></UseByDefault> writer.WriteStartElement("UseByDefault"); writer.WriteValue(this._useByDefault); writer.WriteEndElement(); // <AttributeParameters> writer.WriteStartElement("AttributeParameters"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfNetworkAttributeParameter"); // <NetworkAttributeParameter></NetworkAttributeParameter> foreach (NetworkAttributeParameter networkAttributeParameter in this._attributeParameters) { networkAttributeParameter.WriteXml(writer); } // </AttributeParameters> writer.WriteEndElement(); }
private void AddDataset(XmlWriter writer, IDatasetName datasetName) { // Check Parameters if (writer == null) { return; } if (datasetName == null) { return; } // Open Dataset IName name = datasetName as IName; if (name == null) { return; } object o = null; try { o = name.Open(); } catch { } if (o == null) { return; } IDataset dataset = o as IDataset; if (dataset == null) { return; } IFeatureClass featureClass = dataset as IFeatureClass; // <Dataset> writer.WriteStartElement("Dataset"); // <Dataset><Name> writer.WriteStartElement("Name"); writer.WriteValue(dataset.Name); writer.WriteEndElement(); // <Dataset><Type> string type = string.Empty; switch (dataset.Type) { case esriDatasetType.esriDTFeatureClass: if (featureClass == null) { type += "Unknown"; break; } switch (featureClass.FeatureType) { case esriFeatureType.esriFTAnnotation: case esriFeatureType.esriFTDimension: case esriFeatureType.esriFTSimple: type += GeodatabaseUtility.GetDescription(esriDatasetType.esriDTFeatureClass); break; default: type += GeodatabaseUtility.GetDescription(featureClass.FeatureType); break; } break; default: type += GeodatabaseUtility.GetDescription(dataset.Type); break; } writer.WriteStartElement("Type"); writer.WriteValue(type); writer.WriteEndElement(); // <Dataset><Geometry> string geometry = "-"; if (featureClass != null) { switch (featureClass.FeatureType) { case esriFeatureType.esriFTAnnotation: case esriFeatureType.esriFTDimension: geometry = GeodatabaseUtility.GetDescription(featureClass.FeatureType); break; default: geometry = GeodatabaseUtility.GetDescription(featureClass.ShapeType); break; } } writer.WriteStartElement("Geometry"); writer.WriteValue(geometry); writer.WriteEndElement(); //if (dataset is IFeatureClass) { // IFeatureClass featureClass = (IFeatureClass)dataset; // // <Dataset><FeatureType> // writer.WriteStartElement("FeatureType"); // writer.WriteValue(GeodatabaseUtility.GetDescription(featureClass.FeatureType)); // writer.WriteEndElement(); // // Add ...<Dataset><ShapeType> // switch (featureClass.FeatureType) { // case esriFeatureType.esriFTAnnotation: // case esriFeatureType.esriFTDimension: // break; // default: // writer.WriteStartElement("ShapeType"); // writer.WriteValue(GeodatabaseUtility.GetDescription(featureClass.ShapeType)); // writer.WriteEndElement(); // break; // } //} // Get Row Count ITable table = dataset as ITable; int intRowCount = -1; if (table != null) { try { intRowCount = table.RowCount(null); } catch { } } // <Dataset><RowCount> writer.WriteStartElement("RowCount"); switch (intRowCount) { case -1: writer.WriteValue("Error"); break; case 0: default: writer.WriteValue(intRowCount.ToString()); break; } writer.WriteEndElement(); if (intRowCount > 0) { if (dataset is IGeoDataset) { IGeoDataset geoDataset = (IGeoDataset)dataset; IEnvelope envelope = geoDataset.Extent; if (envelope != null && !envelope.IsEmpty) { // <Dataset><Extent> writer.WriteStartElement("Extent"); // <Dataset><Extent><XMax> writer.WriteStartElement("XMax"); writer.WriteValue(envelope.XMax.ToString()); writer.WriteEndElement(); // <Dataset><Extent><XMin> writer.WriteStartElement("XMin"); writer.WriteValue(envelope.XMin.ToString()); writer.WriteEndElement(); // <Dataset><Extent><YMax> writer.WriteStartElement("YMax"); writer.WriteValue(envelope.YMax.ToString()); writer.WriteEndElement(); // <Dataset><Extent><YMin> writer.WriteStartElement("YMin"); writer.WriteValue(envelope.YMin.ToString()); writer.WriteEndElement(); // <Dataset></Extent> writer.WriteEndElement(); // <Dataset><SmallImage> if (DataReportSettings.Default.ShowSmallImage) { string smallImage = System.IO.Path.GetTempFileName(); writer.WriteStartElement("SmallImage"); writer.WriteValue(smallImage); writer.WriteEndElement(); GeodatabaseUtility.CreateBitmap( dataset, DataReportSettings.Default.SmallImageType, DataReportSettings.Default.SmallImageSize, DataReportSettings.Default.SmallImageResolution, DataReportSettings.Default.SmallImageBackgroundColor, smallImage); } // <Dataset><LargeImage> if (DataReportSettings.Default.ShowLargeImage) { string largeImage = System.IO.Path.GetTempFileName(); writer.WriteStartElement("LargeImage"); writer.WriteValue(largeImage); writer.WriteEndElement(); GeodatabaseUtility.CreateBitmap( dataset, DataReportSettings.Default.LargeImageType, DataReportSettings.Default.LargeImageSize, DataReportSettings.Default.LargeImageResolution, DataReportSettings.Default.LargeImageBackgroundColor, largeImage); } } } } ISubtypes subtypes = dataset as ISubtypes; if (subtypes != null && subtypes.HasSubtype) { int subtypeCode = 0; IEnumSubtype enumSubtype = subtypes.Subtypes; string subtypeName = enumSubtype.Next(out subtypeCode); while (subtypeName != null) { // <Dataset><Sybtype> writer.WriteStartElement("Subtype"); // <Dataset><Sybtype><Name> writer.WriteStartElement("Name"); writer.WriteValue(subtypeName); writer.WriteEndElement(); // Get Row Count IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.WhereClause = string.Format("{0} = {1}", subtypes.SubtypeFieldName, subtypeCode.ToString()); int rowCount = table.RowCount(queryFilter); // <Dataset><Sybtype><RowCount> writer.WriteStartElement("RowCount"); writer.WriteValue(rowCount.ToString()); writer.WriteEndElement(); // <Dataset></Sybtype> writer.WriteEndElement(); // Get Next Subtype subtypeName = enumSubtype.Next(out subtypeCode); } } // </Dataset> writer.WriteEndElement(); }
// // PROTECTED METHODS // protected override void WriteInnerXml(XmlWriter writer) { // Write Inner Xml base.WriteInnerXml(writer); // <HasOID> bool hasOID = !string.IsNullOrEmpty(this._oidFieldName); writer.WriteStartElement("HasOID"); writer.WriteValue(hasOID); writer.WriteEndElement(); // <OIDFieldName> writer.WriteStartElement("OIDFieldName"); writer.WriteValue(this._oidFieldName); writer.WriteEndElement(); // <Fields> TableGroup tableGroupField = (TableGroup)base.Groups[0]; writer.WriteStartElement("Fields"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:Fields"); // <FieldArray> writer.WriteStartElement("FieldArray"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfField"); // <Field></Field> foreach (Field field in tableGroupField.Rows) { field.WriteXml(writer); } // </FieldArray> writer.WriteEndElement(); // </Fields> writer.WriteEndElement(); // <Indexes> TableGroup tableGroupIndex = (TableGroup)base.Groups[1]; writer.WriteStartElement("Indexes"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:Indexes"); // <IndexArray> writer.WriteStartElement("IndexArray"); writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfIndex"); // <Index></Index> foreach (Index index in tableGroupIndex.Groups) { index.WriteXml(writer); } // </IndexArray> writer.WriteEndElement(); // </Indexes> writer.WriteEndElement(); // <IsInteger> writer.WriteStartElement("IsInteger"); writer.WriteValue(this._isInteger); writer.WriteEndElement(); // <MeanCellHeight> writer.WriteStartElement("MeanCellHeight"); writer.WriteValue(this._meanCellHeight); writer.WriteEndElement(); // <MeanCellWidth> writer.WriteStartElement("MeanCellWidth"); writer.WriteValue(this._meanCellWidth); writer.WriteEndElement(); // <Height> writer.WriteStartElement("Height"); writer.WriteValue(this._height); writer.WriteEndElement(); // <Width> writer.WriteStartElement("Width"); writer.WriteValue(this._width); writer.WriteEndElement(); // <PixelType> writer.WriteStartElement("PixelType"); writer.WriteValue(GeodatabaseUtility.GetDescription(this._pixelType)); writer.WriteEndElement(); // <PrimaryField> writer.WriteStartElement("PrimaryField"); writer.WriteValue(this._primaryField); writer.WriteEndElement(); // <TableType> writer.WriteStartElement("TableType"); writer.WriteValue(this._tableType.ToString()); writer.WriteEndElement(); // <Extent> if (this._extent != null) { this._extent.WriteXml(writer); } // <SpatialReference> if (this._spatialReference != null) { this._spatialReference.WriteXml(writer); } }