public override global::System.Data.DataSet Clone() { HluGISLayer cln = ((HluGISLayer)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { HluGISLayer ds = new HluGISLayer(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
/// <summary> /// Retrieves the field of _hluFeatureClass that corresponds to the column of _hluLayerStructure whose name is passed in. /// </summary> /// <param name="columnName">Name of the column of _hluLayerStructure.</param> /// <returns>The field of _hluFeatureClass corresponding to column _hluLayerStructure[columnName].</returns> public static IField GetField(string columnName, IFeatureClass _hluFeatureClass, HluGISLayer.incid_mm_polygonsDataTable _hluLayerStructure, int[] _hluFieldMap) { if ((_hluLayerStructure == null) || (_hluFieldMap == null) || (_hluFeatureClass == null) || String.IsNullOrEmpty(columnName)) return null; DataColumn c = _hluLayerStructure.Columns[columnName.Trim()]; if ((c == null) || (c.Ordinal >= _hluFieldMap.Length)) return null; int fieldOrdinal = _hluFieldMap[c.Ordinal]; if ((fieldOrdinal >= 0) && (fieldOrdinal <= _hluFieldMap.Length)) return _hluFeatureClass.Fields.get_Field(fieldOrdinal); else return null; }
protected List<SqlFilterCondition> MapWhereClauseFields( HluGISLayer.incid_mm_polygonsDataTable _hluLayerStructure, List<SqlFilterCondition> whereClause) { List<SqlFilterCondition> outWhereClause = new List<SqlFilterCondition>(); for (int i = 0; i < whereClause.Count; i++) { SqlFilterCondition cond = whereClause[i]; if (!_hluLayerStructure.Columns.Contains(cond.Column.ColumnName)) { if ((!String.IsNullOrEmpty(cond.CloseParentheses)) && (outWhereClause.Count > 0)) { SqlFilterCondition condPrev = outWhereClause[outWhereClause.Count - 1]; condPrev.CloseParentheses += cond.CloseParentheses; outWhereClause[outWhereClause.Count - 1] = condPrev; } if ((!String.IsNullOrEmpty(cond.OpenParentheses)) && (i < whereClause.Count - 1)) { SqlFilterCondition condNext = whereClause[i + 1]; condNext.OpenParentheses += cond.OpenParentheses; whereClause[i + 1] = condNext; } continue; } string columnName = GetFieldName(_hluLayerStructure.Columns[cond.Column.ColumnName].Ordinal); if (!String.IsNullOrEmpty(columnName)) { cond.Column = new DataColumn(columnName, cond.Column.DataType); outWhereClause.Add(cond); } } return outWhereClause; }
public static bool IsHluLayer(IFeatureLayer layer, IFields origFields, IFieldChecker fieldChecker, object[] validWorkspaces, Dictionary<Type, int> typeMapSystemToSQL, ref HluGISLayer.incid_mm_polygonsDataTable hluLayerStructure, out int[] hluFieldMap, out string[] hluFieldNames) { hluFieldMap = null; hluFieldNames = null; if ((layer == null) || !layer.Valid || (((IFeatureLayerDefinition)layer).DefinitionSelectionSet != null)) return false; bool isHlu = true; try { IFeatureClass testFeatureClass = layer.FeatureClass; if (hluLayerStructure == null) hluLayerStructure = new HluGISLayer.incid_mm_polygonsDataTable(); IFeatureWorkspace testWorkspace = ((IDataset)testFeatureClass).Workspace as IFeatureWorkspace; if (testWorkspace == null) throw (new Exception("Invalid feature workspace.")); if (System.Array.IndexOf(validWorkspaces, ((IWorkspace)testWorkspace).WorkspaceFactory.GetClassID().Value) == -1) throw (new Exception("Invalid workspace type.")); if (testFeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) throw (new Exception("Invalid geometry type.")); IFieldsEdit fieldsEdit = (IFieldsEdit)origFields; foreach (DataColumn c in hluLayerStructure.Columns) { IField newField = new FieldClass(); IFieldEdit2 newFieldEdit = (IFieldEdit2)newField; newFieldEdit.Name_2 = c.ColumnName; int fieldType; if (!typeMapSystemToSQL.TryGetValue(c.DataType, out fieldType)) throw (new Exception("Invalid field type.")); newFieldEdit.Type_2 = (esriFieldType)fieldType; if ((c.MaxLength != -1) && (newField.Type == esriFieldType.esriFieldTypeString)) newFieldEdit.Length_2 = c.MaxLength; fieldsEdit.AddField(newField); } fieldChecker.ValidateWorkspace = (IWorkspace)testWorkspace; IEnumFieldError error; IFields fixedFields; fieldChecker.Validate(origFields, out error, out fixedFields); hluFieldMap = new int[origFields.FieldCount]; hluFieldNames = new string[hluFieldMap.Length]; for (int i = 0; i < fixedFields.FieldCount; i++) { IField fixedField = fixedFields.get_Field(i); int ordinal = testFeatureClass.Fields.FindField(fixedField.Name); if (ordinal == -1) throw (new Exception("Field name does not match the HLU GIS layer structure.")); IField fcField = testFeatureClass.Fields.get_Field(ordinal); if (fcField.Type != fixedField.Type) throw (new Exception("Field type does not match the HLU GIS layer structure.")); if ((fcField.Type == esriFieldType.esriFieldTypeString) && (fcField.Length > fixedField.Length)) throw (new Exception("Field length does not match the HLU GIS layer structure.")); hluFieldMap[i] = ordinal; //--------------------------------------------------------------------- // FIXED: KI107 (GIS layer column names) // Use the field names from the GIS layer so that they can be found // when performing any SELECT statements. hluFieldNames[i] = fcField.Name; //hluFieldNames[i] = fixedField.Name; //--------------------------------------------------------------------- } } catch { return false; } return isHlu; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); HluGISLayer ds = new HluGISLayer(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "incid_mm_polygonsDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }