本文整理汇总了C#中Epi.View.SaveRecord方法的典型用法代码示例。如果您正苦于以下问题:C# View.SaveRecord方法的具体用法?C# View.SaveRecord怎么用?C# View.SaveRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epi.View
的用法示例。
在下文中一共展示了View.SaveRecord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnMarkRelatedRecoredsAsDeleted
private void UnMarkRelatedRecoredsAsDeleted(Epi.Data.Services.CollectedDataProvider OutputDriver, View pView, List<int> pIDList)
{
Dictionary<string, bool> VisitedViews = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
string SQL = null;
StringBuilder InSQL = new StringBuilder();
InSQL.Append(" Where FKey In (");
foreach (int ID in pIDList)
{
pView.LoadRecord(ID);
pView.RecStatusField.CurrentRecordValue = 1;
pView.SaveRecord(ID);
InSQL.Append("'");
InSQL.Append(pView.CurrentGlobalRecordId);
InSQL.Append("',");
}
InSQL.Length = InSQL.Length - 1;
InSQL.Append(")");
foreach (Epi.Fields.Field field in pView.Fields)
{
if (field is Epi.Fields.RelatedViewField)
{
Epi.Fields.RelatedViewField rvf = field as Epi.Fields.RelatedViewField;
if (!VisitedViews.ContainsKey(rvf.ChildView.Name))
{
SQL = "Select UniqueKey From [" + rvf.ChildView.TableName + "] " + InSQL.ToString();
IDataReader reader = OutputDriver.ExecuteReader(OutputDriver.CreateQuery(SQL));
List<int> NewIdList = new List<int>();
while (reader.Read())
{
if (reader["UniqueKey"] != DBNull.Value)
{
NewIdList.Add((int)reader["UniqueKey"]);
}
}
VisitedViews.Add(rvf.ChildView.Name, true);
UnMarkRelatedRecoredsAsDeleted(OutputDriver, rvf.ChildView, NewIdList);
}
}
}
}
示例2: UpdateImageFields
private void UpdateImageFields(View destinationView)
{
string status = string.Format(SharedStrings.IMPORT_NOTIFICATION_IMAGE_UPDATE_START, destinationView.Name);
MessageEventArgs args = new MessageEventArgs(status, false);
RaiseEventImportStatus(status, args);
FieldCollectionMaster fields = destinationView.GetMetadata().GetFields(destinationView);
List<string> imageFieldNames = new List<string>();
bool hasImages = false;
// << change columns >>
foreach (Field field in fields)
{
if (field.FieldType == MetaFieldType.Image)
{
imageFieldNames.Add(field.Name);
hasImages = true;
string pageTableName = destinationView.TableName;
foreach (Page page in destinationView.Pages)
{
if (page.Fields.Contains(field.Name))
{
pageTableName = page.TableName;
}
}
if (destinationProject.CollectedData.ColumnExists(pageTableName, field.Name))
{
destinationProject.CollectedData.DeleteColumn(pageTableName, field.Name);
destinationProject.CollectedData.CreateTableColumn((Epi.Fields.IInputField)field, pageTableName);
}
}
}
// << convert to bytes - per record - per field >>
Epi.Epi2000.CollectedDataProvider collectedDataProvider = sourceProject.CollectedData;
Epi.Data.IDbDriver sourceData = collectedDataProvider.GetDatabase();
if (string.IsNullOrEmpty(destinationView.TableName) || collectedDataProvider.TableExists(destinationView.TableName) == false || hasImages == false)
{
status = string.Format(SharedStrings.IMPORT_NOTIFICATION_IMAGE_UPDATE_NONE, destinationView.Name);
RaiseEventImportStatus(status);
return;
}
Query selectQuery = sourceData.CreateQuery("SELECT * FROM " + destinationView.TableName);
DataTable sourceTable = sourceData.GetTableData(destinationView.TableName);
string imagePath = string.Empty;
int imageFieldsProcessed = 0;
foreach (DataRow sourceRow in sourceTable.Rows)
{
int uniqueKey = ((int)sourceRow["UniqueKey"]);
destinationProject.CollectedData.LoadRecordIntoView(destinationView, uniqueKey);
foreach (Field destField in destinationView.Fields)
{
try
{
if (destField is ImageField)
{
// TODO: FIX!!!
imagePath = sourceRow[destField.Name].ToString();
if (imagePath.StartsWith(".."))
{
imagePath = imagePath.TrimStart('.');
imagePath = "C:" + imagePath;
}
//imagePath = Path.Combine(sourceProject.Location,Path.GetFileName(imagePath));
byte[] imageAsBytes = Util.GetByteArrayFromImagePath(imagePath);
((ImageField)destField).CurrentRecordValue = imageAsBytes;
imageFieldsProcessed++;
//throw new ApplicationException("Image imports not supported.");
}
}
catch
{
Logger.Log(DateTime.Now + ": " + string.Format(SharedStrings.IMPORT_WARNING_NO_IMAGE_COPIED, imagePath, destinationView.Name));
}
}
// TODO: FIX!!!
destinationView.SaveRecord(uniqueKey);
}
status = string.Format(SharedStrings.IMPORT_NOTIFICATION_IMAGE_UPDATE_END, imageFieldsProcessed.ToString(), destinationView.Name);
args = new MessageEventArgs(status, false);
RaiseEventImportStatus(status, args);
}