本文整理汇总了C#中Epi.View.LoadFirstRecord方法的典型用法代码示例。如果您正苦于以下问题:C# View.LoadFirstRecord方法的具体用法?C# View.LoadFirstRecord怎么用?C# View.LoadFirstRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epi.View
的用法示例。
在下文中一共展示了View.LoadFirstRecord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessPages
/// <summary>
/// Processes all of the fields on a given form, page-by-page, except for the fields on the base table.
/// </summary>
/// <param name="sourceView">The source form</param>
/// <param name="destinationView">The destination form</param>
/// <param name="destinationGUIDList">The list of GUIDs that exist in the destination</param>
private void ProcessPages(View sourceView, View destinationView, List<string> destinationGUIDList)
{
for (int i = 0; i < sourceView.Pages.Count; i++)
{
sourceView.LoadFirstRecord();
OnAddStatusMessage(string.Format(ImportExportSharedStrings.PROCESSING_PAGE, (i + 1).ToString(), sourceView.Pages.Count.ToString()));
int recordsInserted = 0;
int recordsUpdated = 0;
Page sourcePage = sourceView.Pages[i];
Page destinationPage = destinationView.Pages[i];
try
{
List<string> fieldsToSkip = new List<string>();
foreach (Field sourceField in sourceView.Fields)
{
bool found = false;
foreach (Field destinationField in destinationView.Fields)
{
if (destinationField.Name.ToLower().Equals(sourceField.Name.ToLower()))
{
found = true;
}
}
if (!found)
{
fieldsToSkip.Add(sourceField.Name);
}
}
if (ColumnsToNull != null && ColumnsToNull.ContainsKey(sourceView.Name))
{
List<string> toNull = ColumnsToNull[sourceView.Name];
foreach (string s in toNull)
{
if (!fieldsToSkip.Contains(s))
{
fieldsToSkip.Add(s);
}
}
}
IDataReader sourceReader = sourceProjectDataDriver.GetTableDataReader(sourcePage.TableName);
while (sourceReader.Read())
{
//if (importWorker.CancellationPending)
//{
// this.BeginInvoke(new SetStatusDelegate(AddStatusMessage), "Import cancelled.");
// return;
//}
if (OnCheckForCancellation())
{
OnAddStatusMessage(ImportExportSharedStrings.IMPORT_CANCELLED);
sourceReader.Close();
sourceReader.Dispose();
return;
}
WordBuilder fieldNames = new WordBuilder(StringLiterals.COMMA);
WordBuilder fieldValues = new WordBuilder(StringLiterals.COMMA);
List<QueryParameter> fieldValueParams = new List<QueryParameter>();
string GUID = sourceReader["GlobalRecordId"].ToString();
if (sourceGUIDs != null && !sourceGUIDs.Contains(GUID))
{
continue;
}
if (destinationGUIDList.Contains(GUID) && update)
{
// UPDATE matching records
string updateHeader = string.Empty;
string whereClause = string.Empty;
fieldValueParams = new List<QueryParameter>();
StringBuilder sb = new StringBuilder();
int columnIndex = 0;
// Build the Update statement which will be reused
sb.Append(SqlKeyWords.UPDATE);
sb.Append(StringLiterals.SPACE);
sb.Append(destinationProjectDataDriver.InsertInEscape(destinationPage.TableName));
sb.Append(StringLiterals.SPACE);
sb.Append(SqlKeyWords.SET);
sb.Append(StringLiterals.SPACE);
updateHeader = sb.ToString();
sb.Remove(0, sb.ToString().Length);
// Build the WHERE caluse which will be reused
sb.Append(SqlKeyWords.WHERE);
//.........这里部分代码省略.........
示例2: ProcessBaseTable
/// <summary>
/// Processes a form's base table
/// </summary>
/// <param name="sourceView">The source form</param>
/// <param name="destinationView">The destination form</param>
/// <param name="destinationGUIDList">The list of GUIDs that exist in the destination</param>
private void ProcessBaseTable(View sourceView, View destinationView, List<string> destinationGUIDList)
{
sourceView.LoadFirstRecord();
OnAddStatusMessage(ImportExportSharedStrings.PROCESSING_BASE_TABLE);
int recordsInserted = 0;
int recordsUpdated = 0;
string sourceTable = sourceView.TableName;
string destinationTable = destinationView.TableName;
optionFieldsAsStrings = new List<string>();
// Check for string-based option fields.
foreach (Field f in destinationView.Fields)
{
if (f is OptionField)
{
OptionField optionField = f as OptionField;
if (optionField != null)
{
DataTable dt = destinationProjectDataDriver.GetTopTwoTable(optionField.Page.TableName);
if (dt.Columns[optionField.Name].DataType.ToString().Equals("System.String", StringComparison.OrdinalIgnoreCase))
{
optionFieldsAsStrings.Add(f.Name);
}
}
}
}
try
{
List<string> newGUIDList = new List<string>();
IDataReader sourceReader = sourceProjectDataDriver.GetTableDataReader(sourceView.TableName);
while (sourceReader.Read())
{
object recordStatus = sourceReader["RECSTATUS"];
QueryParameter paramRecordStatus = new QueryParameter("@RECSTATUS", DbType.Int32, recordStatus);
//if (importWorker.CancellationPending)
//{
// this.BeginInvoke(new SetStatusDelegate(AddStatusMessage), "Import cancelled.");
// return;
//}
if (OnCheckForCancellation())
{
OnAddStatusMessage(ImportExportSharedStrings.IMPORT_CANCELLED);
sourceReader.Close();
sourceReader.Dispose();
sourceReader = null;
return;
}
WordBuilder fieldNames = new WordBuilder(StringLiterals.COMMA);
WordBuilder fieldValues = new WordBuilder(StringLiterals.COMMA);
List<QueryParameter> fieldValueParams = new List<QueryParameter>();
string GUID = sourceReader["GlobalRecordId"].ToString();
if (sourceGUIDs != null && !sourceGUIDs.Contains(GUID))
{
continue;
}
fieldNames.Append("GlobalRecordId");
fieldValues.Append("@GlobalRecordId");
string FKEY = sourceReader["FKEY"].ToString();
QueryParameter paramFkey = new QueryParameter("@FKEY", DbType.String, FKEY); // don't add this yet
QueryParameter paramGUID = new QueryParameter("@GlobalRecordId", DbType.String, GUID);
fieldValueParams.Add(paramGUID);
if (destinationGUIDList.Contains(GUID))
{
if (update)
{
// UPDATE matching records
string updateHeader = string.Empty;
string whereClause = string.Empty;
fieldValueParams = new List<QueryParameter>();
StringBuilder sb = new StringBuilder();
// Build the Update statement which will be reused
sb.Append(SqlKeyWords.UPDATE);
sb.Append(StringLiterals.SPACE);
sb.Append(destinationProjectDataDriver.InsertInEscape(destinationTable));
sb.Append(StringLiterals.SPACE);
sb.Append(SqlKeyWords.SET);
sb.Append(StringLiterals.SPACE);
updateHeader = sb.ToString();
sb.Remove(0, sb.ToString().Length);
//.........这里部分代码省略.........
示例3: ProcessBaseTable
/// <summary>
/// Processes a form's base table
/// </summary>
/// <param name="sourceView">The source form</param>
/// <param name="destinationView">The destination form</param>
/// <param name="destinationGUIDList">The list of GUIDs that exist in the destination</param>
private void ProcessBaseTable(View sourceView, View destinationView, List<string> destinationGUIDList)
{
sourceView.LoadFirstRecord();
this.BeginInvoke(new SetStatusDelegate(SetStatusMessage), "Processing records on base table...");
int recordsInserted = 0;
int recordsUpdated = 0;
string sourceTable = sourceView.TableName;
string destinationTable = destinationView.TableName;
try
{
IDataReader sourceReader = sourceProjectDataDriver.GetTableDataReader(sourceView.TableName);
while (sourceReader.Read())
{
object recordStatus = sourceReader["RECSTATUS"];
QueryParameter paramRecordStatus = new QueryParameter("@RECSTATUS", DbType.Int32, recordStatus);
if (importWorker.CancellationPending)
{
this.BeginInvoke(new SetStatusDelegate(AddStatusMessage), "Import cancelled.");
return;
}
WordBuilder fieldNames = new WordBuilder(StringLiterals.COMMA);
WordBuilder fieldValues = new WordBuilder(StringLiterals.COMMA);
List<QueryParameter> fieldValueParams = new List<QueryParameter>();
fieldNames.Append("GlobalRecordId");
fieldValues.Append("@GlobalRecordId");
string GUID = sourceReader["GlobalRecordId"].ToString();
string FKEY = sourceReader["FKEY"].ToString();
QueryParameter paramFkey = new QueryParameter("@FKEY", DbType.String, FKEY); // don't add this yet
QueryParameter paramGUID = new QueryParameter("@GlobalRecordId", DbType.String, GUID);
fieldValueParams.Add(paramGUID);
if (destinationGUIDList.Contains(GUID))
{
if (update)
{
// UPDATE matching records
string updateHeader = string.Empty;
string whereClause = string.Empty;
fieldValueParams = new List<QueryParameter>();
StringBuilder sb = new StringBuilder();
// Build the Update statement which will be reused
sb.Append(SqlKeyWords.UPDATE);
sb.Append(StringLiterals.SPACE);
sb.Append(destinationProjectDataDriver.InsertInEscape(destinationTable));
sb.Append(StringLiterals.SPACE);
sb.Append(SqlKeyWords.SET);
sb.Append(StringLiterals.SPACE);
updateHeader = sb.ToString();
sb.Remove(0, sb.ToString().Length);
// Build the WHERE caluse which will be reused
sb.Append(SqlKeyWords.WHERE);
sb.Append(StringLiterals.SPACE);
sb.Append(destinationProjectDataDriver.InsertInEscape(ColumnNames.GLOBAL_RECORD_ID));
sb.Append(StringLiterals.EQUAL);
sb.Append("'");
sb.Append(GUID);
sb.Append("'");
whereClause = sb.ToString();
sb.Remove(0, sb.ToString().Length);
//if (sourceView.ForeignKeyFieldExists)
if (!string.IsNullOrEmpty(FKEY))
{
sb.Append(StringLiterals.LEFT_SQUARE_BRACKET);
sb.Append("FKEY");
sb.Append(StringLiterals.RIGHT_SQUARE_BRACKET);
sb.Append(StringLiterals.EQUAL);
sb.Append(StringLiterals.COMMERCIAL_AT);
sb.Append("FKEY");
fieldValueParams.Add(paramFkey);
Query updateQuery = destinationProjectDataDriver.CreateQuery(updateHeader + StringLiterals.SPACE + sb.ToString() + StringLiterals.SPACE + whereClause);
updateQuery.Parameters = fieldValueParams;
destinationProjectDataDriver.ExecuteNonQuery(updateQuery);
sb.Remove(0, sb.ToString().Length);
fieldValueParams.Clear();
recordsUpdated++;
}
//.........这里部分代码省略.........