本文整理汇总了C#中ITable.Search方法的典型用法代码示例。如果您正苦于以下问题:C# ITable.Search方法的具体用法?C# ITable.Search怎么用?C# ITable.Search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable.Search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetObservations
private static Dictionary<object, List<Observation>> GetObservations(ITable table)
{
var observationData = new Dictionary<object, List<Observation>>();
using (var comReleaser = new ComReleaser())
{
ICursor cursor = table.Search(null, true);
comReleaser.ManageLifetime(cursor);
IRow row;
while ((row = cursor.NextRow()) != null)
{
string data = string.Format("{0},{1},\"{2}\",{3},\"{4}\"", row.Value[10], row.Value[11], row.Value[3], row.Value[4], row.Value[5]);
string comment = string.Format("\"{0}\"", row.Value[6]);
object gpsId = row.Value[12];
if (observationData.ContainsKey(gpsId))
observationData[gpsId].Add(new Observation {Data = data, Comment = comment});
else
observationData[gpsId] = new List<Observation>
{new Observation {Data = data, Comment = comment}};
}
}
return observationData;
}
示例2: getUniqueValues
public HashSet<string> getUniqueValues(ITable tbl, string Fld)
{
HashSet<string> x = new HashSet<string>();
try
{
IQueryFilter qf = new QueryFilterClass();
qf.SubFields = Fld;
ICursor scur = tbl.Search(qf, true);
int fldIndex = scur.FindField(Fld);
if (fldIndex == -1) return x;
IRow srow = scur.NextRow();
while (srow != null)
{
string ky = srow.get_Value(fldIndex).ToString();
x.Add(ky);
srow = scur.NextRow();
}
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.ToString());
}
return x;
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:24,代码来源:geodatabaseutility.cs
示例3: Store
public void Store(ITable paramTable)
{
if (this._isDirty && this.CanWrite)
{
IRowBuffer theBuffer = null;
bool bNeedsInsert = false;
IQueryFilter theQF = new QueryFilterClass();
theQF.WhereClause = TEST_NAME_FIELD + " = '" + this._testName + "' "
+ " and " + PARAMETER_NAME_FIELD + " = '" + this._name + "'";
ICursor theSearchCursor = paramTable.Search(theQF, false);
theBuffer = theSearchCursor.NextRow() as IRowBuffer;
//ICursor theUpdateCursor = paramTable.Update(theQF, false);
//theBuffer = theUpdateCursor.NextRow() as IRowBuffer;
if (theBuffer == null)
{
bNeedsInsert = true;
theBuffer = paramTable.CreateRowBuffer();
}
Marshal.ReleaseComObject(theSearchCursor);
int index;
index = theBuffer.Fields.FindField(TEST_NAME_FIELD);
theBuffer.set_Value(index, this._testName);
index = theBuffer.Fields.FindField(PARAMETER_NAME_FIELD);
theBuffer.set_Value(index, this._name);
index = theBuffer.Fields.FindField(PARAMETER_VALUE_FIELD);
if (this._value == null || this._value.Length == 0)
{
theBuffer.set_Value(index, " ");
}
else
{
theBuffer.set_Value(index, this._value);
}
try
{
if (bNeedsInsert)
{
ICursor theInsertCursor = paramTable.Insert(false);
theInsertCursor.InsertRow(theBuffer);
theInsertCursor.Flush();
Marshal.ReleaseComObject(theInsertCursor);
}
else
{
//theUpdateCursor.UpdateRow((IRow)theBuffer);
//theUpdateCursor.Flush();
((IRow)theBuffer).Store();
}
}
catch (Exception ex)
{
util.Logger.Write("Exception storing parameter: " + ex.Message + Environment.NewLine + ex.StackTrace);
}
//Marshal.ReleaseComObject(theUpdateCursor);
this._isDirty = false;
}
}
示例4: LoadNames
protected void LoadNames(ITable nameTable)
{
this._names = new ArrayList();
ICursor theCursor = nameTable.Search(null, true);
IRow theRow = theCursor.NextRow();
while (theRow != null)
{
string[] theInfo = new string[2];
int index;
index = theRow.Fields.FindField(NAME_FIELD);
if (index < 0)
throw new System.MissingFieldException(OperationalDatasetCollection.TABLE_NAME, NAME_FIELD);
theInfo[0] = theRow.get_Value(index).ToString();
index = theRow.Fields.FindField(DESCRIPTION_FIELD);
if (index < 0)
throw new System.MissingFieldException(OperationalDatasetCollection.TABLE_NAME, DESCRIPTION_FIELD);
theInfo[1] = theRow.get_Value(index).ToString();
this._names.Add(theInfo);
theRow = theCursor.NextRow();
}
Marshal.ReleaseComObject(theCursor);
}
示例5: GetUniqueValue
/// <summary>
/// 获取指定字段的所有值
/// </summary>
/// <param name="table"></param>
/// <param name="sFieldName">字段别名</param>
private bool GetUniqueValue(ITable table, string sFieldName)
{
try
{
IDataStatistics _dataStatistics = new DataStatisticsClass();
ICursor _cursor;
int _fieldIndex = table.Fields.FindField(sFieldName);
_cursor = table.Search(null, false);
this.cboFieldsValue.Properties.Items.Clear();
_dataStatistics.Field = sFieldName;
_dataStatistics.Cursor = _cursor;
IEnumerator _enumerator = _dataStatistics.UniqueValues;
_enumerator.Reset();
while (_enumerator.MoveNext())
{
cboFieldsValue.Properties.Items.Add(_enumerator.Current.ToString());
}
return true;
}
catch (Exception ex)
{
return false;
//MessageBox.Show(ex.Message);
}
return true;
}
示例6: SelectByJoinMultiColumn
private void SelectByJoinMultiColumn(ITable joinTable)
{
ICursor joinCursor = joinTable.Search(null, true);
IRow joinRow;
List<string> whereCondList = new List<string>();
StringBuilder whereCond = new StringBuilder();
int whereClauseLength = 0;
string quotedHluTableName = QuoteIdentifier(_hluTableName);
while ((joinRow = joinCursor.NextRow()) != null)
{
StringBuilder cond = new StringBuilder();
for (int i = 0; i < joinTable.Fields.FieldCount; i++)
{
IField currFld = joinTable.Fields.get_Field(i);
cond.Append(String.Format(" AND {0} = {1}",
_hluSqlSyntax.QualifyColumnName(quotedHluTableName,
QuoteIdentifier(_hluFeatureClass.Fields.get_Field(
_hluFieldMap[_hluLayerStructure.Columns[currFld.Name].Ordinal]).Name)),
QuoteValue(currFld, joinRow.get_Value(i))));
}
cond.Remove(0, 5).Insert(0, "(").Append(")");
whereClauseLength += cond.Length + 4;
if (whereClauseLength < _whereClauseLengthMax)
{
whereCond.Append(" OR ").Append(cond);
}
else
{
whereCondList.Add(whereCond.Remove(0, 4).ToString());
whereCond = new StringBuilder(" OR ").Append(cond);
whereClauseLength = whereCond.Length;
}
}
if (whereCond.Length > 0) whereCondList.Add(whereCond.Remove(0, 4).ToString());
// make sure selection changed event handler won't intervene
int[] selectFieldOrdinalsBak = _selectFieldOrdinals;
_selectFieldOrdinals = null;
IQueryFilter queryFilter = new QueryFilterClass();
_hluFeatureSelection = (IFeatureSelection)_hluLayer;
_hluFeatureSelection.Clear();
for (int i = 0; i < whereCondList.Count - 1; i++)
{
queryFilter.WhereClause = whereCondList[i];
_hluFeatureSelection.SelectFeatures(queryFilter,
esriSelectionResultEnum.esriSelectionResultAdd, false);
}
// before last selection reenable event handler
_selectFieldOrdinals = selectFieldOrdinalsBak;
queryFilter.WhereClause = whereCondList[whereCondList.Count - 1];
_hluFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
}
示例7: FillFeatureCache
public static Hashtable FillFeatureCache(ITable inputSignsTable, int inFromIDFI, int inToIDFI,
IFeatureClass inputLineFeatures, string linesIDFieldName,
ITrackCancel trackcancel)
{
// make and fill a SortedList from the IDs referenced in the table
// for MultiNet data, there is only one ID field, so its index will be
// passed in as inFromIDFI, while -1 will be passed in to inToIDFI.
SortedList IDs = new System.Collections.SortedList();
ICursor inCursor = inputSignsTable.Search(null, true);
IRow row;
long fromID, toID;
bool exists;
int cancelCheckInterval = 100;
if (inToIDFI == -1)
{
while ((row = inCursor.NextRow()) != null)
{
fromID = Convert.ToInt64(row.get_Value(inFromIDFI));
exists = IDs.Contains(fromID);
if (!exists)
IDs.Add(fromID, fromID);
}
}
else
{
while ((row = inCursor.NextRow()) != null)
{
fromID = Convert.ToInt64(row.get_Value(inFromIDFI));
toID = Convert.ToInt64(row.get_Value(inToIDFI));
exists = IDs.Contains(fromID);
if (!exists)
IDs.Add(fromID, fromID);
exists = IDs.Contains(toID);
if (!exists)
IDs.Add(toID, toID);
}
}
// make the query filter for fetching features
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.SubFields = "*";
// Now fetch batches of features
long currID;
int numFeaturesPerQuery = 200;
int numToFetch = IDs.Count;
int totalRemaining, totalDone = 0;
int linesIDFieldIndex = inputLineFeatures.FindField(linesIDFieldName);
Hashtable outputFeatures = new System.Collections.Hashtable((int)numToFetch);
if (numFeaturesPerQuery > numToFetch)
numFeaturesPerQuery = numToFetch;
while (totalDone < numToFetch)
{
// Populate the QueryDef Where clause IN() statement for the current batch of features.
// This is going to be very slow unless linesIDFieldName is indexed and this is why
// we added a warning to the GP message window if this is the case. If you cannot
// index linesIDFieldName, then this code would run faster scanning the whole feature
// class looking for the records we need (no Where clause).
string whereClause = linesIDFieldName + " IN(";
for (int i = 0; i < numFeaturesPerQuery; i++)
{
currID = Convert.ToInt64(IDs.GetByIndex(totalDone + i), System.Globalization.CultureInfo.InvariantCulture);
whereClause += Convert.ToString(currID, System.Globalization.CultureInfo.InvariantCulture);
if (i != (numFeaturesPerQuery - 1))
whereClause += ",";
else
whereClause += ")";
}
queryFilter.WhereClause = whereClause;
// select the features
IFeatureCursor inputFeatureCursor = inputLineFeatures.Search(queryFilter, false);
// get the features
IFeature feature;
while ((feature = inputFeatureCursor.NextFeature()) != null)
{
// keep a copy of the OID and shape of feature - skip records that cause errors
// (perhaps pass the GPMessages in and log warnings in there if you need to log exceptions)
//.........这里部分代码省略.........
示例8: extractAllTags
private List<string> extractAllTags(ITable osmInputTable, IQueryFilter osmQueryFilter, int osmTagCollectionFieldIndex)
{
HashSet<string> listOfAllTags = new HashSet<string>();
if (osmInputTable == null)
{
return listOfAllTags.ToList();
}
IWorkspace datasetWorkspace = ((IDataset)osmInputTable).Workspace;
using (ComReleaser comReleaser = new ComReleaser())
{
if (osmQueryFilter == null)
{
osmQueryFilter = new QueryFilterClass();
}
//osmQueryFilter.SubFields = osmInputTable.Fields.get_Field(osmTagCollectionFieldIndex).Name;
ICursor osmCursor = osmInputTable.Search(osmQueryFilter, false);
comReleaser.ManageLifetime(osmCursor);
IRow osmRow = osmCursor.NextRow();
comReleaser.ManageLifetime(osmRow);
while (osmRow != null)
{
ESRI.ArcGIS.OSM.OSMClassExtension.tag[] storedTags = null;
try
{
storedTags = _osmUtility.retrieveOSMTags(osmRow, osmTagCollectionFieldIndex, null);
}
catch
{ }
if (storedTags != null)
{
foreach (tag tagItem in storedTags)
{
listOfAllTags.Add(tagItem.k);
}
}
osmRow = osmCursor.NextRow();
}
}
// sort the tag name alphabetically
IEnumerable<string> sortedTags = listOfAllTags.OrderBy(nameOfTag => nameOfTag);
return sortedTags.ToList();
}
示例9: determineOSMGeometryType
//internal List<ESRI.ArcGIS.OSM.OSMClassExtension.tag> MergeTagsFromOuterPolygonToRelation(ESRI.ArcGIS.OSM.OSMClassExtension.relation currentRelation, IFeatureClass polygonFeatureClass)
//{
// Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tag> mergedTagList = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
// IQueryFilter osmIDQueryFilter = new QueryFilterClass();
// try
// {
// int osmIDPolygonFieldIndex = polygonFeatureClass.FindField("OSMID");
// string sqlPolyOSMID = polygonFeatureClass.SqlIdentifier("OSMID");
// foreach (var relationItem in currentRelation.Items)
// {
// if (relationItem is ESRI.ArcGIS.OSM.OSMClassExtension.member)
// {
// ESRI.ArcGIS.OSM.OSMClassExtension.member currentRelationMember = relationItem as ESRI.ArcGIS.OSM.OSMClassExtension.member;
// if (currentRelationMember.role.ToLower().Equals("outer"))
// {
// using (ComReleaser comReleaser = new ComReleaser())
// {
// osmIDQueryFilter.WhereClause = sqlPolyOSMID + " = " + [email protected];
// IFeatureCursor featureCursor = polygonFeatureClass.Search(osmIDQueryFilter, false);
// comReleaser.ManageLifetime(featureCursor);
// IFeature foundPolygonFeature = featureCursor.NextFeature();
// if (foundPolygonFeature == null)
// continue;
// tag[] foundTags = OSMUtility.retrieveOSMTags(foundPolygonFeature, osmIDPolygonFieldIndex, ((IDataset)polygonFeatureClass).Workspace);
// foreach (tag currentWayTag in foundTags)
// {
// // first one in wins
// try
// {
// if (!mergedTagList.ContainsKey(currentWayTag.k))
// {
// mergedTagList.Add(currentWayTag.k, currentWayTag);
// }
// }
// catch { }
// }
// }
// }
// }
// else if (relationItem is tag)
// {
// tag relationTag = relationItem as tag;
// try
// {
// if (!mergedTagList.ContainsKey(relationTag.k))
// {
// mergedTagList.Add(relationTag.k, relationTag);
// }
// }
// catch { }
// }
// }
// }
// catch { }
// return mergedTagList.Values.ToList();
//}
internal osmRelationGeometryType determineOSMGeometryType(IFeatureClass lineFeatureClass, IFeatureClass polygonFeatureClass, ITable relationTable, string osmIDtoFind)
{
osmRelationGeometryType determinedGeometryType = osmRelationGeometryType.osmUnknownGeometry;
try
{
IQueryFilter osmIDQueryFilter = new QueryFilterClass();
osmIDQueryFilter.SubFields = "OSMID";
using (ComReleaser comReleaser = new ComReleaser())
{
if (lineFeatureClass != null)
{
osmIDQueryFilter.WhereClause = lineFeatureClass.WhereClauseByExtensionVersion(osmIDtoFind, "OSMID", 2);
IFeatureCursor lineFeatureCursor = lineFeatureClass.Search(osmIDQueryFilter, false);
comReleaser.ManageLifetime(lineFeatureCursor);
IFeature foundLineFeature = lineFeatureCursor.NextFeature();
if (foundLineFeature != null)
{
determinedGeometryType = osmRelationGeometryType.osmPolyline;
return determinedGeometryType;
}
osmIDQueryFilter.WhereClause = polygonFeatureClass.WhereClauseByExtensionVersion(osmIDtoFind, "OSMID", 2);
IFeatureCursor polygonFeatureCursor = polygonFeatureClass.Search(osmIDQueryFilter, false);
comReleaser.ManageLifetime(polygonFeatureCursor);
IFeature foundPolygonFeature = polygonFeatureCursor.NextFeature();
if (foundPolygonFeature != null)
{
determinedGeometryType = osmRelationGeometryType.osmPolygon;
return determinedGeometryType;
}
osmIDQueryFilter.WhereClause = relationTable.WhereClauseByExtensionVersion(osmIDtoFind, "OSMID", 2);
ICursor relationCursor = relationTable.Search(osmIDQueryFilter, false);
comReleaser.ManageLifetime(relationCursor);
IRow foundRelation = relationCursor.NextRow();
if (foundRelation != null)
{
// in order to be in the relation table is needs to be a either a super-relation or a mixed type entity (hence hybrid)
determinedGeometryType = osmRelationGeometryType.osmHybridGeometry;
//.........这里部分代码省略.........
示例10: FindRepeatPlans
bool FindRepeatPlans(ITable PlansTable, out string[] RepeatPlans, out string[] SummaryNames, out int RepeatCnt)
{
IFIDSet pNonEmptyPlansFIDSet = new FIDSetClass();
ICursor pPlansCur = null;
SummaryNames = null;
RepeatPlans = null;
RepeatCnt = 0;
try
{
pPlansCur = PlansTable.Search(null, false);
Int32 iPlanNameIDX = pPlansCur.Fields.FindField("NAME");
IRow pPlanRow = pPlansCur.NextRow();
//Create a collection of plan names
if (m_pStepProgressor.Position < m_pStepProgressor.MaxRange)
m_pStepProgressor.Step();
string[] sPlanNames = new string[0]; //define as dynamic array
int iCount = 0;
bool bCont = true;
Utils FabricUTILS = new Utils();
while (pPlanRow != null)
{
//Check if the cancel button was pressed. If so, stop process
bCont = m_pTrackCancel.Continue();
if (!bCont)
{
RepeatCnt++;
return false;
}
string sPlanNm = (string)pPlanRow.get_Value(iPlanNameIDX);
if (sPlanNm.Trim() == "")
sPlanNm = "<No Name>";
FabricUTILS.RedimPreserveString(ref sPlanNames, 1);
sPlanNames[iCount++] = sPlanNm.Trim() + ", OID:" + pPlanRow.OID;
Marshal.ReleaseComObject(pPlanRow);
pPlanRow = pPlansCur.NextRow();
if (m_pStepProgressor.Position < m_pStepProgressor.MaxRange)
m_pStepProgressor.Step();
}
if (pPlanRow!=null)
Marshal.ReleaseComObject(pPlanRow);
if (pPlansCur != null)
Marshal.ReleaseComObject(pPlansCur);
System.Array.Sort<string>(sPlanNames);
int m = -1;
string sName_m;
int k = -1;
string sName_k;
string sThisRepeat = "";
bool bIsNewGroup = false;
Dictionary<int, string> dictNameFromID = new Dictionary<int,string>();
int iCnt = sPlanNames.GetLength(0) - 1;
//Create a collection of repeat plan names
string[] sRepeatPlans = new string[0]; //define as dynamic array
FabricUTILS.RedimPreserveString(ref sRepeatPlans, 1);
sRepeatPlans[0] = "";
int idx = 0; // used with sRepeatPlans string array
int iOID =-1;
RepeatCnt = 0;
for (int j = iCnt; j >= 0; j--)
{
//Check if the cancel button was pressed. If so, stop process
bCont = m_pTrackCancel.Continue();
if (!bCont)
return false;
sName_m = "";
sName_k = "";
int l = sPlanNames[j].LastIndexOf(", OID:");
string sName_l = sPlanNames[j].Trim().Substring(0, l);
if (sName_l.ToUpper().Trim() == sThisRepeat.ToUpper().Trim())
bIsNewGroup = false;
else if (j < iCnt - 1)
bIsNewGroup = true;
if (j > 0)
{
k = sPlanNames[j - 1].LastIndexOf(", OID:");
sName_k = sPlanNames[j - 1].Trim().Substring(0, k);
}
if (j < sPlanNames.GetLength(0)-1)
{
m = sPlanNames[j + 1].LastIndexOf(", OID:");
sName_m = sPlanNames[j + 1].Trim().Substring(0, m);
}
sThisRepeat = sName_l;
if (sName_l.ToUpper() == sName_k.ToUpper() ||
sName_l.ToUpper() == sName_m.ToUpper())
//.........这里部分代码省略.........
示例11: LoadNANetworkLocations
/// <summary>
/// Load the input table and create field map to map fields from input table to NAClass
/// </summary>
/// <param name="strNAClassName">NAClass name</param>
/// <param name="inputTable">Input table</param>
public void LoadNANetworkLocations(string strNAClassName, ITable inputTable)
{
INamedSet classes = m_NAContext.NAClasses;
INAClass naClass = classes.get_ItemByName(strNAClassName) as INAClass;
// Delete existing rows from the specified NAClass
naClass.DeleteAllRows();
// Create a NAClassLoader and set the snap tolerance (meters unit)
INAClassLoader loader = new NAClassLoader();
loader.Locator = m_NAContext.Locator;
loader.Locator.SnapTolerance = 100;
loader.NAClass = naClass;
// Create field map to automatically map fields from input table to NAclass
INAClassFieldMap fieldMap = new NAClassFieldMapClass();
fieldMap.CreateMapping(naClass.ClassDefinition, inputTable.Fields);
loader.FieldMap = fieldMap;
// Avoid loading network locations onto non-traversable portions of elements
INALocator3 locator = m_NAContext.Locator as INALocator3;
locator.ExcludeRestrictedElements = true;
locator.CacheRestrictedElements(m_NAContext);
// Load input table
int rowsIn = 0;
int rowsLocated = 0;
loader.Load(inputTable.Search(null, true), null, ref rowsIn, ref rowsLocated);
// Message all of the network analysis agents that the analysis context has changed.
INAContextEdit naContextEdit = m_NAContext as INAContextEdit;
naContextEdit.ContextChanged();
}
示例12: LoadTests
protected void LoadTests(ITable testTable, ITable paramTable)
{
this._tests = new ArrayList();
IQueryFilter theQF = null;
ICursor theCursor = testTable.Search(theQF, true);
IRow theTestRow = theCursor.NextRow();
while (theTestRow != null)
{
QATest theTest = new QATest(theTestRow, paramTable, this.CanWrite);
if (theTest != null)
this._tests.Add(theTest);
theTestRow = theCursor.NextRow();
}
Marshal.ReleaseComObject(theCursor);
}
示例13: ITable2DTable
/// <summary>
///
/// </summary>
/// <param name="_pRTable"></param>
/// <returns></returns>
private DataTable ITable2DTable(ITable _pRTable)
{
DataTable pTable = new DataTable();
try
{
// 删除字段 X Y
IFields pfields;
IField pfield;
pfields = _pRTable.Fields;
int fieldIndex = pfields.FindField("x");
pfield = pfields.get_Field(fieldIndex);
_pRTable.DeleteField(pfield);
fieldIndex = pfields.FindField("y");
pfield = pfields.get_Field(fieldIndex);
_pRTable.DeleteField(pfield);
}
catch (Exception ex)
{
}
for (int i = 0; i < _pRTable.Fields.FieldCount; i++)
pTable.Columns.Add(_pRTable.Fields.get_Field(i).Name);
ICursor pCursor = _pRTable.Search(null,false);
IRow pRrow = pCursor.NextRow();
bool flag = true;
while (pRrow != null)
{
flag = true;
DataRow pRow = pTable.NewRow();
for (int i = 0; i < pRrow.Fields.FieldCount; i++)
{
pRow[i] = pRrow.get_Value(i).ToString();
//有缺失值的行排除掉
if (pRow[i].ToString() == "MISSING")
{
flag = false;
break;
}
}
if(flag)
{
pTable.Rows.Add(pRow);
}
pRrow = pCursor.NextRow();
}
return pTable;
}
示例14: ValidateAttributes
/// <summary>
/// Validates the attributes in a Feature Class/Table or its subtype for domain constraints
/// </summary>
/// <param name="ipErrorCollection">Collection of validation results</param>
/// <param name="ipTable">Feature class/Table whose attributes will be validated for domain constraints</param>
/// <param name="ipDomain">Domain for which attributes need to be validated</param>
/// <param name="strDomainFieldName">Name of the domain field</param>
/// <param name="bHasSubtype">input true if the feature class/table has subype else false</param>
/// <param name="strSubtypeFieldName">Name of the subtype field</param>
/// <param name="iSubtypeCode">Subtype code for the subtype that need to be validated for the domain constraints</param>
private void ValidateAttributes(IPLTSErrorCollection ipErrorCollection, ITable ipTable, IDomain ipDomain, string strDomainFieldName, bool bHasSubtype, string strSubtypeFieldName, int iSubtypeCode)
{
string strErrorConditionQueryString = "";
//Get the query string for searching records that violate domain constraints
if (ipDomain.Type == esriDomainType.esriDTRange)
{
strErrorConditionQueryString = GetQueryStringForRangeDomain(ipDomain as IRangeDomain, strDomainFieldName);
}
else if (ipDomain.Type == esriDomainType.esriDTCodedValue)
{
strErrorConditionQueryString = GetQueryStringForCodedDomain(ipDomain as ICodedValueDomain, strDomainFieldName);
}
if (!string.IsNullOrEmpty(strErrorConditionQueryString))
{
//Apply subtype filter if needed
if(bHasSubtype && !string.IsNullOrEmpty(strSubtypeFieldName))
strErrorConditionQueryString += " AND " + strSubtypeFieldName + " = " + iSubtypeCode;
//Use the query string to search records that violate domain constraints
IQueryFilter ipQF = new QueryFilter();
ipQF.WhereClause = strErrorConditionQueryString;
ICursor ipCursor = ipTable.Search(ipQF, true);
if (null != ipCursor)
{
IRow ipRow = ipCursor.NextRow();
while (null != ipRow)
{
//Create a Reviewer result
IPLTSError2 ipReviewerResult = new PLTSErrorClass() as IPLTSError2;
ipReviewerResult.ErrorKind = pltsValErrorKind.pltsValErrorKindStandard;
ipReviewerResult.OID = ipRow.OID;
ipReviewerResult.LongDescription = "Domain constraints violated for " + strDomainFieldName + " field";
ipReviewerResult.QualifiedTableName = (ipTable as IDataset).Name;
//If the record is a feature then use the feature geometry as Result's error geometry
IFeature ipFeature = ipRow as IFeature;
if (null != ipFeature)
{
IGeometry ipErrorGeometry = ipFeature.ShapeCopy;
if (!ipErrorGeometry.IsEmpty)
ipReviewerResult.ErrorGeometry = ipErrorGeometry;
}
//Add the result to the collection of results
ipErrorCollection.AddError(ipReviewerResult);
ipRow = ipCursor.NextRow();
}
//release cursor
System.Runtime.InteropServices.Marshal.ReleaseComObject(ipCursor);
ipCursor = null;
}
}
return;
}
示例15: exportTableToTxt
/// <summary>
/// Exports a given table to a .CSV file named after the input featureclass
/// </summary>
/// <param name="inTable">the input Table to export</param>
/// <param name="outdir">the output directory to store the table</param>
/// <param name="fileName">the name of the csv file</param>
/// <returns>the name of the csv file</returns>
public string exportTableToTxt(ITable inTable,string outdir,string fileName)
{
string filePath = outdir + "\\" + fileName;
List<string> vlLst = new List<string>();
string vl = null;
using (System.IO.StreamWriter sW = new System.IO.StreamWriter(filePath))
{
ICursor scur = inTable.Search(null, true);
IFields flds = inTable.Fields;
int fldCnt = flds.FieldCount;
for(int i =0;i<fldCnt;i++)
{
IField fld = flds.get_Field(i);
vlLst.Add(fld.Name);
}
sW.WriteLine(String.Join(",", vlLst.ToArray()));
vlLst.Clear();
IRow srow = scur.NextRow();
while (srow != null)
{
for (int i = 0; i < fldCnt; i++)
{
vl = srow.get_Value(i).ToString();
if (vl.ToLower() == "nan")
{
vl = "1";
}
vlLst.Add(vl);
}
sW.WriteLine(String.Join(",", vlLst.ToArray()));
vlLst.Clear();
srow = scur.NextRow();
}
sW.Close();
}
return filePath;
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:44,代码来源:geodatabaseutility.cs