本文整理汇总了C#中ICursor.FindField方法的典型用法代码示例。如果您正苦于以下问题:C# ICursor.FindField方法的具体用法?C# ICursor.FindField怎么用?C# ICursor.FindField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICursor
的用法示例。
在下文中一共展示了ICursor.FindField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeDatesOnTable
public bool ChangeDatesOnTable(ICursor pCursor, string FieldName, string sDate, bool Unversioned,
IStepProgressor m_pStepProgressor, ITrackCancel m_pTrackCancel)
{
bool bWriteNull = (sDate.Trim() == "");
object dbNull = DBNull.Value;
int FldIdx = pCursor.FindField(FieldName);
int iSysEndDate = pCursor.FindField("systemenddate");
int iHistorical = pCursor.FindField("historical");
bool bIsSysEndDate = (FieldName.ToLower() == "systemenddate");
bool bIsHistorical = (FieldName.ToLower() == "historical");
bool bHasSysEndDateFld = (iSysEndDate > -1);
bool bHasHistoricFld = (iHistorical > -1);
bool bCont = true;
bool m_bShowProgressor = (m_pStepProgressor != null);
if (bWriteNull)
{
IField pfld = pCursor.Fields.get_Field(FldIdx);
if (!pfld.IsNullable)
return false;
}
DateTime localNow = DateTime.Now;
IRow pRow = pCursor.NextRow();
while (pRow != null)
{
//Check if the cancel button was pressed. If so, stop process
if (m_bShowProgressor)
{
bCont = m_pTrackCancel.Continue();
if (!bCont)
break;
}
if (bWriteNull)
{
if (bIsHistorical) //if writing null to Historical field, use 0 instead
pRow.set_Value(FldIdx, 0);
else
pRow.set_Value(FldIdx, dbNull);
if (bIsHistorical && bHasSysEndDateFld) // if writing null to Historical field
pRow.set_Value(iSysEndDate, dbNull); // then also Null system end date
if (bIsSysEndDate && bHasHistoricFld) // if writing null to SystemEndDate field
pRow.set_Value(iHistorical, 0); //then set the Historical flag to false = 0
}
else
{
pRow.set_Value(FldIdx, sDate);
if (bIsSysEndDate && bHasHistoricFld) // if writing date to SystemEndDate field
pRow.set_Value(iHistorical, 1); //then set the Historical flag to true = 1
}
if (Unversioned)
pCursor.UpdateRow(pRow);
else
pRow.Store();
Marshal.ReleaseComObject(pRow);
pRow = pCursor.NextRow();
if (m_bShowProgressor)
{
if (m_pStepProgressor.Position < m_pStepProgressor.MaxRange)
m_pStepProgressor.Step();
}
}
Marshal.ReleaseComObject(pCursor);
if (!bCont)
return false;
return true;
}
示例2: ChangeDatesOnTableMulti
public bool ChangeDatesOnTableMulti(ICursor pCursor, List<bool> HistorySettings, List<string> sDate, bool Unversioned,
Dictionary<int, string> ParcelToHistory_DICT,IStepProgressor m_pStepProgressor, ITrackCancel m_pTrackCancel)
{
bool bSystemEndDate_Clear = HistorySettings[0];
bool bLegalStDate_Clear = HistorySettings[1];
bool bLegalEndDate_Clear = HistorySettings[2];
bool bSystemEndDate_Set = HistorySettings[3];
bool bLegalStDate_Set = HistorySettings[4];
bool bLegalEndDate_Set = HistorySettings[5];
object dbNull = DBNull.Value;
int FldIdxSystemEnd = pCursor.FindField("systemenddate");
int iHistorical = pCursor.FindField("historical");
int FldIdxLegalSt =pCursor.FindField("legalstartdate");
int FldIdxLegalEnd = pCursor.FindField("legalenddate");
bool bHasSysEndDateFld = (FldIdxSystemEnd > -1);
bool bHasHistoricFld = (iHistorical > -1);
bool bCont = true;
bool m_bShowProgressor = (m_pStepProgressor!=null);
IRow pRow = pCursor.NextRow();
while (pRow != null)
{
//Check if the cancel button was pressed. If so, stop process
if (m_bShowProgressor)
{
bCont = m_pTrackCancel.Continue();
if (!bCont)
break;
}
string sHistoryInfo = "";
string[] sUpdateDictionaryDates = null;
bool bTryGetTrue = false;
if (ParcelToHistory_DICT.TryGetValue(pRow.OID, out sHistoryInfo))
{
//update the strings in the dictionary
sUpdateDictionaryDates = sHistoryInfo.Split(',');
bTryGetTrue = true;
}
if (bSystemEndDate_Set && bTryGetTrue)
{
pRow.set_Value(FldIdxSystemEnd, sDate[0]);
if (bHasHistoricFld) // if writing date to SystemEndDate field
pRow.set_Value(iHistorical, 1); //then set the Historical flag to true = 1
//update the dictionary
//find the location of the System End Date
string x= ParcelToHistory_DICT[pRow.OID];
int i1 = x.IndexOf(",", 0);
int i2 = x.IndexOf(",", i1+1);
string s1= x.Remove(i1 + 1, i2 - i1);
string s2=s1.Insert(i1 + 1, sDate[0] + ",");
ParcelToHistory_DICT[pRow.OID] = s2;
}
if (bSystemEndDate_Clear && bTryGetTrue)
{
pRow.set_Value(FldIdxSystemEnd, dbNull);
if (bHasHistoricFld) // if writing date to SystemEndDate field
pRow.set_Value(iHistorical, 0); //then set the Historical flag to true = 1
//update the dictionary
//find the location of the System End Date
string x = ParcelToHistory_DICT[pRow.OID];
int i1 = x.IndexOf(",", 0);
int i2 = x.IndexOf(",", i1 + 1);
string s1 = x.Remove(i1 + 1, i2 - i1);
string s2 = s1.Insert(i1 + 1, ",");
ParcelToHistory_DICT[pRow.OID] = s2;
}
if (bLegalStDate_Set && bTryGetTrue)
{
pRow.set_Value(FldIdxLegalSt, sDate[1]);
//update the dictionary
//find the location of the System End Date
string x = ParcelToHistory_DICT[pRow.OID];
int i1 = x.IndexOf(",", 0);
int i2 = x.IndexOf(",", i1 + 1);
int i3 = x.IndexOf(",", i2 + 1);
string s1 = x.Remove(i2 + 1, i3 - i2);
string s2 = s1.Insert(i2 + 1,sDate[1] + ",");
ParcelToHistory_DICT[pRow.OID] = s2;
}
if (bLegalStDate_Clear && bTryGetTrue)
{
pRow.set_Value(FldIdxLegalSt, dbNull);
//update the dictionary
//find the location of the System End Date
string x = ParcelToHistory_DICT[pRow.OID];
int i1 = x.IndexOf(",", 0);
int i2 = x.IndexOf(",", i1 + 1);
int i3 = x.IndexOf(",", i2 + 1);
string s1 = x.Remove(i2 + 1, i3 - i2);
string s2 = s1.Insert(i2 + 1, ",");
ParcelToHistory_DICT[pRow.OID] = s2;
}
//.........这里部分代码省略.........