本文整理汇总了C#中ITable.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ITable.Insert方法的具体用法?C# ITable.Insert怎么用?C# ITable.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable.Insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogRecord
public void LogRecord(ITable table, int ID, int index, double X_From, double Y_From, double M_From, double X_To, double Y_To, double M_To)
{
ICursor InsertCursor = table.Insert(false);
try
{
IRowBuffer rowBuffer = table.CreateRowBuffer();
rowBuffer.set_Value(rowBuffer.Fields.FindField("ID"), ID);
rowBuffer.set_Value(rowBuffer.Fields.FindField("index"), index);
rowBuffer.set_Value(rowBuffer.Fields.FindField("X_From"), X_From);
rowBuffer.set_Value(rowBuffer.Fields.FindField("Y_From"), Y_From);
rowBuffer.set_Value(rowBuffer.Fields.FindField("M_From"), M_From);
rowBuffer.set_Value(rowBuffer.Fields.FindField("X_To"), X_To);
rowBuffer.set_Value(rowBuffer.Fields.FindField("Y_To"), Y_To);
rowBuffer.set_Value(rowBuffer.Fields.FindField("M_To"), M_To);
InsertCursor.InsertRow(rowBuffer);
InsertCursor.Flush();
}
catch (Exception ex)
{
throw;
}
finally
{
ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(InsertCursor);
}
}
示例2: fillFields
private void fillFields()
{
if (rd != null) rd.addMessage("Output table name = " + wks.PathName + "\\" + tblName);
//bool weCreate = true;
//if (!geoUtil.ftrExists(wks, tblName))
//{
IFields nflds = new FieldsClass();
IFieldsEdit nfldsE = (IFieldsEdit)nflds;
IField nfld = new FieldClass();
IFieldEdit nfldE = (IFieldEdit)nfld;
nfldE.Name_2 = "Band";
nfldE.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfldE);
IField nfld2 = new FieldClass();
IFieldEdit nfld2E = (IFieldEdit)nfld2;
nfld2E.Name_2 = "Zone";
nfld2E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld2E);
IField nfld3 = new FieldClass();
IFieldEdit nfld3E = (IFieldEdit)nfld3;
nfld3E.Name_2 = "Count";
nfld3E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld3E);
oTbl = geoUtil.createTable(wks, tblName, nflds);
int[] fldIndex = new int[ZoneTypes.Length];
for (int zIndex=0; zIndex<ZoneTypes.Length;zIndex++)
{
string fldNm = ZoneTypes[zIndex].ToString();
fldNm = geoUtil.createField(oTbl, fldNm, esriFieldType.esriFieldTypeDouble);
fldIndex[zIndex] = oTbl.FindField(fldNm);
}
IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
if (wksE.IsBeingEdited())
{
wksE.StopEditing(true);
}
try
{
int bdIndex = oTbl.FindField("Band");
int vlIndex = oTbl.FindField("Zone");
int cntIndex = oTbl.FindField("Count");
int bndCnt = 1;
ICursor cur = oTbl.Insert(true);
IRowBuffer rw = oTbl.CreateRowBuffer();
foreach (Dictionary<double, object[]> zoneValueDicOut in zoneValueDicArr)
{
foreach (KeyValuePair<double, object[]> kVp in zoneValueDicOut)
{
double key = kVp.Key;
object[] vl = kVp.Value;
Dictionary<rasterUtil.zoneType, double> vDic = getValueDic(vl);
//IRow rw = null;
//if (!weCreate)
//{
// string qry = "Band = " + bndCnt.ToString() + " and Zone = " + key;
// IQueryFilter qf = new QueryFilterClass();
// qf.WhereClause = qry;
// ISelectionSet tblSelectionSet = oTbl.Select(qf, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionOnlyOne, wks);
// if (tblSelectionSet.Count > 0)
// {
// int id = tblSelectionSet.IDs.Next();
// rw = oTbl.GetRow(id);
// }
// else
// {
// rw = oTbl.CreateRow();
// }
//}
//else
//{
//rw = oTbl.CreateRow();
//}
//Console.WriteLine(key.ToString());
rw.set_Value(bdIndex, bndCnt);
rw.set_Value(vlIndex, key);
rw.set_Value(cntIndex, vl[0]);
for(int zIndex=0;zIndex<ZoneTypes.Length;zIndex++)// (rasterUtil.zoneType zT in ZoneTypes)
{
rasterUtil.zoneType zT = ZoneTypes[zIndex];
double zVl = vDic[zT];
//Console.WriteLine("\t"+fldNm+ ": " + zVl.ToString());
rw.set_Value(fldIndex[zIndex], zVl);
}
//rw.Store();
cur.InsertRow(rw);
}
bndCnt += 1;
}
//trs.CommitTransaction();
cur.Flush();
System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
System.Runtime.InteropServices.Marshal.ReleaseComObject(rw);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
//trs.AbortTransaction();
//.........这里部分代码省略.........
示例3: buildZoneClassCount
private void buildZoneClassCount()
{
string cTblName = geoUtil.getSafeOutputNameNonRaster(wks,tblName.Replace("_VAT","_CLASS"));
if (rd != null) rd.addMessage("Output table name = " + wks.PathName + "\\" + cTblName);
IFields nflds = new FieldsClass();
IFieldsEdit nfldsE = (IFieldsEdit)nflds;
IField nfld = new FieldClass();
IFieldEdit nfldE = (IFieldEdit)nfld;
nfldE.Name_2 = "Band";
nfldE.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfldE);
IField nfld2 = new FieldClass();
IFieldEdit nfld2E = (IFieldEdit)nfld2;
nfld2E.Name_2 = "Zone";
nfld2E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld2E);
IField nfld4 = new FieldClass();
IFieldEdit nfld4E = (IFieldEdit)nfld4;
nfld4E.Name_2 = "Class";
nfld4E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld4E);
IField nfld3 = new FieldClass();
IFieldEdit nfld3E = (IFieldEdit)nfld3;
nfld3E.Name_2 = "Count";
nfld3E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld3E);
oTbl2 = geoUtil.createTable(wks,cTblName,nflds);
IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
if (wksE.IsBeingEdited())
{
wksE.StopEditing(true);
}
//ITransactions trs = (ITransactions)wks;
//trs.StartTransaction();
try
{
int bdIndex = oTbl2.FindField("Band");
int vlIndex = oTbl2.FindField("Zone");
int cntIndex = oTbl2.FindField("Count");
int clsIndex = oTbl2.FindField("Class");
int bndCnt = 1;
ICursor cur = oTbl2.Insert(true);
IRowBuffer rw = oTbl2.CreateRowBuffer();
foreach (Dictionary<double, object[]> zoneValueDicOut in zoneValueDicArr)
{
foreach (KeyValuePair<double, object[]> kVp in zoneValueDicOut)
{
double key = kVp.Key;
object[] vl = kVp.Value;
Dictionary<double, int> uDic = (Dictionary<double, int>)vl[5];
foreach(KeyValuePair<double,int> uKvp in uDic)
{
double uDicKey = uKvp.Key;
int uDicVl = uKvp.Value;
rw.set_Value(bdIndex, bndCnt);
rw.set_Value(vlIndex, key);
rw.set_Value(cntIndex, uDicVl);
rw.set_Value(clsIndex, uDicKey);
cur.InsertRow(rw);
}
}
bndCnt += 1;
}
cur.Flush();
System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
System.Runtime.InteropServices.Marshal.ReleaseComObject(rw);
//trs.CommitTransaction();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
//trs.AbortTransaction();
}
finally
{
}
}
示例4: 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;
}
}
示例5: loadOSMRelations
//.........这里部分代码省略.........
int osmVisibleRelationFieldIndex = relationTable.FindField("osmvisible");
int osmVersionRelationFieldIndex = relationTable.FindField("osmversion");
int osmChangesetRelationFieldIndex = relationTable.FindField("osmchangeset");
int osmTimeStampRelationFieldIndex = relationTable.FindField("osmtimestamp");
int osmMemberOfRelationFieldIndex = relationTable.FindField("osmMemberOf");
int osmMembersRelationFieldIndex = relationTable.FindField("osmMembers");
int osmSupportingElementRelationFieldIndex = relationTable.FindField("osmSupportingElement");
// list for reference count and relation list for lines/polygons/relations
// set up the progress indicator
IStepProgressor stepProgressor = TrackCancel as IStepProgressor;
if (stepProgressor != null)
{
stepProgressor.MinRange = 0;
stepProgressor.MaxRange = relationCapacity;
stepProgressor.Position = 0;
stepProgressor.Message = _resourceManager.GetString("GPTools_OSMGPFileReader_loadingRelations");
stepProgressor.StepValue = 1;
stepProgressor.Show();
}
bool relationIndexRebuildRequired = false;
if (relationTable != null)
{
osmFileXmlReader = System.Xml.XmlReader.Create(osmFileLocation);
relationSerializer = new XmlSerializer(typeof(relation));
using (ComReleaser comReleaser = new ComReleaser())
{
using (SchemaLockManager linelock = new SchemaLockManager(osmLineFeatureClass as ITable), polygonLock = new SchemaLockManager(osmPolygonFeatureClass as ITable), relationLock = new SchemaLockManager(relationTable))
{
ICursor rowCursor = relationTable.Insert(true);
comReleaser.ManageLifetime(rowCursor);
IRowBuffer rowBuffer = relationTable.CreateRowBuffer();
comReleaser.ManageLifetime(rowBuffer);
IFeatureCursor lineFeatureInsertCursor = osmLineFeatureClass.Insert(true);
comReleaser.ManageLifetime(lineFeatureInsertCursor);
IFeatureBuffer lineFeatureBuffer = osmLineFeatureClass.CreateFeatureBuffer();
comReleaser.ManageLifetime(lineFeatureBuffer);
IFeatureCursor polygonFeatureInsertCursor = osmPolygonFeatureClass.Insert(true);
comReleaser.ManageLifetime(polygonFeatureInsertCursor);
IFeatureBuffer polygonFeatureBuffer = osmPolygonFeatureClass.CreateFeatureBuffer();
comReleaser.ManageLifetime(polygonFeatureBuffer);
int relationCount = 1;
int relationDebugCount = 1;
string lineSQLIdentifier = osmLineFeatureClass.SqlIdentifier("OSMID");
string polygonSQLIdentifier = osmPolygonFeatureClass.SqlIdentifier("OSMID");
message.AddMessage(_resourceManager.GetString("GPTools_OSMGPFileReader_resolvegeometries"));
osmFileXmlReader.MoveToContent();
while (osmFileXmlReader.Read())
{
if (osmFileXmlReader.IsStartElement())
{
if (osmFileXmlReader.Name == "relation")
{
示例6: Store
public void Store(ITable testTable, ITable paramTable)
{
try
{
if (this._isDirty && this._canWrite)
{
IRowBuffer theBuffer = null;
bool bNeedsInsert = false;
IQueryFilter theQF = new QueryFilterClass();
theQF.WhereClause = TEST_NAME_FIELD + " = '" + this._name + "'";
ICursor theSearchCursor = testTable.Search(theQF, false);
theBuffer = theSearchCursor.NextRow() as IRowBuffer;
//ICursor theUpdateCursor = testTable.Search(theQF, false);
//theBuffer = theUpdateCursor.NextRow() as IRowBuffer;
if (theBuffer == null)
{
bNeedsInsert = true;
theBuffer = testTable.CreateRowBuffer();
}
Marshal.ReleaseComObject(theSearchCursor);
int index;
index = theBuffer.Fields.FindField(TEST_NAME_FIELD);
theBuffer.set_Value(index, this._name);
index = theBuffer.Fields.FindField(COM_CLSID_FIELD);
theBuffer.set_Value(index, this._comClsid);
// Constrained to be YES or NO
index = theBuffer.Fields.FindField(MANDITORY_FIELD);
theBuffer.set_Value(index, this._isManditory ? "YES" : "NO");
if (bNeedsInsert)
{
ICursor theInsertCursor = testTable.Insert(false);
theInsertCursor.InsertRow(theBuffer);
theInsertCursor.Flush();
Marshal.ReleaseComObject(theInsertCursor);
}
else
{
//theUpdateCursor.UpdateRow((IRow)theBuffer);
//theUpdateCursor.Flush();
((IRow)theBuffer).Store();
}
//Marshal.ReleaseComObject(theUpdateCursor);
this._parameters.StoreParameters(paramTable);
this._isDirty = false;
}
}
catch (Exception ex)
{
util.Logger.Write("Error storing QA test." + Environment.NewLine
+ ex.Message + Environment.NewLine
+ ex.StackTrace.ToString(),
util.Logger.LogLevel.Error);
}
}