本文整理汇总了C#中Epi.View.GetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# View.GetMetadata方法的具体用法?C# View.GetMetadata怎么用?C# View.GetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epi.View
的用法示例。
在下文中一共展示了View.GetMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SynchronizeDataTable
/// <summary>
/// Synchronizes metadata and data table
/// [drops and/or inserts data columns in the view table]
/// </summary>
public void SynchronizeDataTable(View view, bool tryCompact = true)
{
try
{
if (isWebMode)
{
return;
}
Boolean noDataTable = dbDriver.TableExists(view.TableName) == false;
if (noDataTable)
{
CreateDataTableForView(view, 1);
}
else
{
foreach (Page page in view.Pages)
{
DataTable fieldMetadataSync = view.GetMetadata().GetFieldMetadataSync(page.Id);
DeleteUndefinedDataFields(page, fieldMetadataSync);
}
if (tryCompact)
{
try
{
dbDriver.CompactDatabase();
if (dbDriver.FullName.Contains("[MS Access]"))
{
string insertStatement = string.Format("insert into {0}([UniqueKey], [GlobalRecordId]) values (@UniqueKey, @GlobalRecordId)", view.TableName);
Query insertQuery = dbDriver.CreateQuery(insertStatement);
insertQuery.Parameters.Add(new QueryParameter("@UniqueKey", DbType.Int16, StartingId - 1));
insertQuery.Parameters.Add(new QueryParameter("@GlobalRecordId", DbType.String, ""));
dbDriver.ExecuteNonQuery(insertQuery);
string deleteStatement = string.Format("delete from {0} where UniqueKey={1} ", view.TableName, StartingId - 1);
Query deleteQuery = dbDriver.CreateQuery(deleteStatement);
dbDriver.ExecuteNonQuery(deleteQuery);
}
}
catch { }
}
view.SetTableName(view.TableName);
foreach (Page page in view.Pages)
{
SynchronizePageTable(page);
}
}
}
catch { }
}
示例2: UpdateMirrorFields
/// <summary>
/// Updates the sources of all mirror fields in a view
/// </summary>
/// <param name="view">An Epi7 view</param>
private void UpdateMirrorFields(View view)
{
List<Field> mirrorFieldsToRemove = new List<Field>();
foreach (Field field in view.Fields)
{
if (field is MirrorField)
{
if (view.Fields.Exists(GetSourceFieldName((MirrorField)field)))
{
UpdateMirrorFieldSource((MirrorField)field);
}
else
{
mirrorFieldsToRemove.Add(field);
Logger.Log(DateTime.Now + ": " + string.Format(SharedStrings.IMPORT_WARNING_MIRROR_FIELD_NO_SOURCE, field.Name, view.Name, GetSourceFieldName((MirrorField)field)));
}
}
}
foreach (Field mirrorField in mirrorFieldsToRemove)
{
view.GetMetadata().DeleteField(mirrorField);
}
}
示例3: IsSynchronized
public bool IsSynchronized(View view)
{
if (dbDriver.TableExists(view.TableName) == false)
{
return false;
}
DataTable pages = view.GetMetadata().GetPagesForView(view.Id);
string pageTableName = string.Empty;
int pageId = 0;
foreach (DataRow page in pages.Rows)
{
pageId = (int)page["PageId"];
pageTableName = string.Format("{0}{1}", view.Name, pageId);
DataTable metadataTable = view.GetMetadata().GetFieldMetadataSync(pageId);
DataTable fieldTypesTable = view.GetMetadata().GetFieldTypes();
List<string> columnNames = dbDriver.GetTableColumnNames(pageTableName);
int fieldType;
int dataTypeId;
string query = string.Empty;
DataRow[] fieldTypesRows;
foreach (DataRow row in metadataTable.Rows)
{
fieldType = (int)row["FieldTypeId"];
query = string.Format("FieldTypeId = {0}", (int)row["FieldTypeId"]);
fieldTypesRows = fieldTypesTable.Select(query);
if (fieldTypesRows.Length == 0)
{
continue;
}
dataTypeId = (int)fieldTypesRows[0]["DataTypeId"];
if ((fieldType == (int)MetaFieldType.LabelTitle) ||
(fieldType == (int)MetaFieldType.Group) ||
(fieldType == (int)MetaFieldType.CommandButton) ||
(fieldType == (int)MetaFieldType.Mirror))
{
continue;
}
if (fieldType == (int)MetaFieldType.Grid)
{
IsGridSynchronized();
}
if (columnNames.Contains((string)row[ColumnNames.NAME]) == false &&
columnNames.Contains(((string)row[ColumnNames.NAME]).ToUpper()) == false)
{
return false;
}
}
}
return true;
}
示例4: 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);
}