本文整理汇总了C#中Epi.Page.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# Page.GetView方法的具体用法?C# Page.GetView怎么用?C# Page.GetView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epi.Page
的用法示例。
在下文中一共展示了Page.GetView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertPage
/// <summary>
/// Creates a page in a specified view
/// </summary>
/// <old-param name="pageposition">Position of the page</old-param>
/// <old-param name="viewid">Id of the view</old-param>
/// <old-param name="pagename">Name of the page</old-param>
public void InsertPage(Page page)
{
try
{
#region Input Validation
if (page == null)
{
throw new ArgumentNullException("page");
}
#endregion Input validation
Query query = db.CreateQuery("insert into metaPages([Name], [Position], [ViewId], [CheckCodeBefore], [CheckCodeAfter], [BackgroundId]) values (@Name, @Position, @ViewId, @CheckCodeBefore, @CheckCodeAfter, @BackgroundId)");
query.Parameters.Add(new QueryParameter("@Name", DbType.String, page.Name));
query.Parameters.Add(new QueryParameter("@Position", DbType.Int32, page.Position));
query.Parameters.Add(new QueryParameter("@ViewId", DbType.Int32, page.GetView().Id));
query.Parameters.Add(new QueryParameter("@CheckCodeBefore", DbType.String, page.CheckCodeBefore));
query.Parameters.Add(new QueryParameter("@CheckCodeAfter", DbType.String, page.CheckCodeAfter));
query.Parameters.Add(new QueryParameter("@BackgroundId", DbType.Int32, page.BackgroundId));
db.ExecuteNonQuery(query);
page.Id = GetMaxPageId(page.GetView().Id);
}
catch (Exception ex)
{
throw new GeneralException("Could not create page in the database", ex);
}
finally
{
}
}
示例2: DeletePage
/// <summary>
/// Deletes a page from the Xml metadata project file
/// </summary>
/// <param name="page">Id of the page</param>
public void DeletePage(Page page)
{
try
{
#region Input Validation
if (page.Id < 1)
{
throw new ArgumentOutOfRangeException("PageId");
}
#endregion
XmlDocument doc = GetXmlDocument();
XmlNode pagesNode = GetPagesNode(page.GetView().ViewElement);
XmlNode pageNode = pagesNode.SelectSingleNode("//Page[@PageId= '" + page.Id + "']");
pageNode.ParentNode.RemoveChild(pageNode);
Save();
}
catch (Exception ex)
{
throw new GeneralException("Could not delete page in the database", ex);
}
finally
{
}
}
示例3: InsertPage
/// <summary>
/// Creates a page in a specified view
/// </summary>
/// <old-param name="pageposition">Position of the page</old-param>
/// <old-param name="viewid">Id of the view</old-param>
/// <old-param name="pagename">Name of the page</old-param>
public void InsertPage(Page page)
{
try
{
#region Input Validation
if (page == null)
{
throw new ArgumentNullException("page");
}
#endregion Input validation
XmlDocument doc = GetXmlDocument();
XmlNode pagesNode = GetPagesNode(page.GetView().ViewElement);
CreatePage(page.GetView(), page.Name, page.Position);
XmlNode pageNode = pagesNode.SelectSingleNode("//Page[@PageId= '" + page.Id + "']");
page.Id = GetMaxPageId(page.GetView().Id) + 1;
pageNode.Attributes["PageId"].Value = page.Id.ToString();
Save();
//Query query = db.CreateQuery("insert into metaPages([Name], [Position], [ViewId], [CheckCodeBefore], [CheckCodeAfter]) values (@Name, @Position, @ViewId, @CheckCodeBefore, @CheckCodeAfter)");
//query.Parameters.Add(new QueryParameter("@Name", DbType.String, page.Name));
//query.Parameters.Add(new QueryParameter("@Position", DbType.Int32, page.Position));
//query.Parameters.Add(new QueryParameter("@ViewId", DbType.Int32, page.GetView().Id));
//query.Parameters.Add(new QueryParameter("@CheckCodeBefore", DbType.String, page.CheckCodeBefore));
//query.Parameters.Add(new QueryParameter("@CheckCodeAfter", DbType.String, page.CheckCodeAfter));
//db.ExecuteNonQuery(query);
//page.Id = GetMaxPageId(page.GetView().Id);
}
catch (Exception ex)
{
throw new GeneralException("Could not create page in the database", ex);
}
finally
{
}
}
示例4: DeleteFields
/// <summary>
/// Deletes fields on a page from the Xml metadata project file
/// </summary>
/// <param name="page"></param>
public void DeleteFields(Page page)
{
try
{
XmlDocument doc = GetXmlDocument();
XmlNode fieldsNode = GetFieldsNode(page.GetView().ViewElement);
XmlNodeList nodeList = fieldsNode.SelectNodes("Field[@PageId = '" + page.Id + "']");
foreach (XmlNode node in nodeList)
{
node.ParentNode.RemoveChild(node);
}
Save();
}
catch (Exception ex)
{
throw new GeneralException("Could not delete fields in the database", ex);
}
finally
{
}
}
示例5: RenderableField
/// <summary>
/// Constructor
/// </summary>
/// <param name="page">The page the field belongs to</param>
public RenderableField(Page page)
: base(page.GetView())
{
this.page = page;
}
示例6: CopyField
//.........这里部分代码省略.........
((IInputField)field).IsReadOnly = lists.Contains("N");
((IInputField)field).ShouldRepeatLast = lists.Contains("R");
}
}
if (field is ImageField)
{
((ImageField)field).ShouldRetainImageSize = false;
}
if (field is LabelField)
{
if (fieldRow["Plocx"] != DBNull.Value)
{
field.ControlLeftPositionPercentage = double.Parse(fieldRow["Plocx"].ToString()) / 100;
}
if (fieldRow["Plocy"] != DBNull.Value)
{
field.ControlTopPositionPercentage = double.Parse(fieldRow["Plocy"].ToString()) / 100;
}
if ((fieldRow["Pfont"] != DBNull.Value) && (fieldRow["Pfontsize"] != DBNull.Value))
{
field.ControlFont = new System.Drawing.Font(fieldRow["Pfont"].ToString(), float.Parse(fieldRow["Pfontsize"].ToString()));
}
}
if (field is TableBasedDropDownField)
{
((TableBasedDropDownField)field).SourceTableName = GetCodeTableName(fieldRow["Lists"].ToString(), tableName);
((TableBasedDropDownField)field).TextColumnName = GetCodeTableTextField(fieldRow["Lists"].ToString());
}
if (field is DDLFieldOfCodes)
{
((DDLFieldOfCodes)field).CodeColumnName = GetCodeTableValueField(fieldRow["Lists"].ToString());
if (!(field is DDLFieldOfCommentLegal) && !(field is DDLFieldOfLegalValues))
{
((DDLFieldOfCodes)field).AssociatedFieldInformation = GetCodeTableAssociatedFields(fieldRow["Lists"].ToString(), field.GetView());
}
}
if (field is MirrorField)
{
((MirrorField)field).SourceFieldId = 1;
}
if (field is RelatedViewField)
{
// Relate Condition
if (fieldRow["FormatString"] != DBNull.Value)
{
((RelatedViewField)field).Condition = (fieldRow["FormatString"].ToString());
}
((RelatedViewField)field).RelatedViewID = 1; // this will be re-set later during CopyViewRelations()
}
if (field is NumberField)
{
if (fieldRow["FormatString"] != DBNull.Value)
{
Match m = Regex.Match(fieldRow["FormatString"].ToString(), "[;]");
if (m.Success)
{
string[] pattern = (fieldRow["FormatString"].ToString()).Split(';');
((NumberField)field).Pattern = pattern[1];
}
else
{
((NumberField)field).Pattern = (fieldRow["FormatString"].ToString());
}
}
示例7: UpdateOptionFields
/// <summary>
/// Updates option field data in the destination view's data table to match
/// Epi Info 7 format for option fields.
/// </summary>
/// <param name="page">A page in the destination view</param>
private void UpdateOptionFields(Page page)
{
// Epi Info 7 stores data for option fields as integers, with 0 being the 1st option, 2 for the second option, etc. Epi Info 3 just
// stores the literal text value that the user selected. We must convert from Epi 3 format to Epi 7 format otherwise we'll wind up with
// errors on import. TODO: Check for SQL server compliance; likely SQL server will behave differently than Access-to-Access imports.
try
{
string viewNameWithPrefix = "view" + page.GetView().Name;
string tableName = page.GetView().TableName;
DataTable fieldsTable = sourceProject.Metadata.GetFieldsOnPageAsDataTable(viewNameWithPrefix, page.Position);
// iterate over all fields in the page
foreach (DataRow fieldRow in fieldsTable.Rows)
{
// find the field type
MetaFieldType fieldType = Epi.Epi2000.MetadataDbProvider.InferFieldType(fieldRow);
// If it's an option field...
if (fieldType == MetaFieldType.Option)
{
string fieldName = fieldRow["Name"].ToString();
Epi.Data.Services.CollectedDataProvider collectedDataProvider = destinationProject.CollectedData;
Epi.Data.IDbDriver db = collectedDataProvider.GetDatabase();
// If the Epi 3 view is corrupted in such a way that the data
// column for this field doesn't exist, we have to break here else we run into errors
if (db.ColumnExists(page.GetView().TableName, fieldName) == false)
{
break;
}
// We start a queue. The queue will store each option in the option field.
Queue<string> options = new Queue<string>();
// Enqueue items to the queue in the order they came out of the list column
string[] items = fieldRow["Lists"].ToString().Split(';');
for (int i = 0; i < items.Length; i++)
{
options.Enqueue(items[i]);
}
// Create a temporary column that will store our translated data
string tempFieldName = "Epi7_import_" + fieldName;
TableColumn column = new TableColumn(tempFieldName, GenericDbColumnType.Int16, true);
db.AddColumn(tableName, column);
// For each option in our options queue...
for(int i = 0; options.Count > 0; i++)
{
// ... run an UPDATE query that upates our temporary import column with an int16 value based on the Epi 3 string literal value
Query updateQuery = db.CreateQuery("UPDATE " + tableName + " SET " + tempFieldName + " = " + (i).ToString() + " WHERE " + fieldName + " = @Options"); // TODO: If Epi 7 option fields are ever changed from 0-based to 1-based, this MUST be updated, too!
updateQuery.Parameters.Add(new QueryParameter("@Options", DbType.String, options.Dequeue()));
db.ExecuteNonQuery(updateQuery);
}
// Delete the original Epi 3 column with its string literal values
db.DeleteColumn(tableName, fieldName);
// Very important - we must compact to avoid 'Too many fields defined' error
db.CompactDatabase();
// We now need to re-create the data column for our field, which we just deleted
column = new TableColumn(fieldName, GenericDbColumnType.Int16, true);
db.AddColumn(tableName, column);
// Then we copy the data from the temp import field into the column we just added above
// (Note: We can't do an ALTER TABLE... RENAME COLUMN because Access does not support this)
Query copyQuery = db.CreateQuery("UPDATE " + tableName + " SET " + fieldName + " = " + tempFieldName);
db.ExecuteNonQuery(copyQuery);
// Finally, we delete the temporary import column.
db.DeleteColumn(tableName, tempFieldName);
}
}
}
catch
{
}
}
示例8: CopyFields
/// <summary>
/// Converts the fields in a page
/// </summary>
/// <param name="page">A page object</param>
private void CopyFields(Page page)
{
try
{
string viewNameWithPrefix = "view" + page.GetView().Name;
DataTable fieldsTable = sourceProject.Metadata.GetFieldsOnPageAsDataTable(viewNameWithPrefix, page.Position);
bool hasOptionFields = false;
foreach (DataRow fieldRow in fieldsTable.Rows)
{
string fieldName = fieldRow["Name"].ToString();
if (Char.IsNumber(fieldName[0]))
{
Logger.Log(DateTime.Now + ": " + string.Format(SharedStrings.IMPORT_WARNING_FIELD_LEADING_DIGIT, fieldName));
continue;
}
MetaFieldType fieldType = Epi.Epi2000.MetadataDbProvider.InferFieldType(fieldRow);
Epi.Data.Services.CollectedDataProvider collectedDataProvider = destinationProject.CollectedData;
Epi.Data.IDbDriver db = collectedDataProvider.GetDatabase();
if (fieldType != MetaFieldType.CommandButton && fieldType != MetaFieldType.Grid && fieldType != MetaFieldType.Group && fieldType != MetaFieldType.LabelTitle && fieldType != MetaFieldType.Mirror && fieldType != MetaFieldType.Relate &&
db.ColumnExists(page.TableName, fieldName) == false)
{
if (db.TableExists(page.TableName))
{
Logger.Log(DateTime.Now + ": " + string.Format(
SharedStrings.IMPORT_LOG_NO_DATA_COLUMN, fieldName, page.TableName));
}
}
if (fieldType != MetaFieldType.Codes)
{
CopyField(fieldRow, page, viewNameWithPrefix);
}
if (fieldType == MetaFieldType.Option)
{
hasOptionFields = true;
}
}
DataRow[] codeRows = fieldsTable.Select(ColumnNames.TYPE + " = 'COMBO'");
foreach (DataRow codeRow in codeRows)
{
MetaFieldType fieldType = Epi.Epi2000.MetadataDbProvider.InferFieldType(codeRow);
if (fieldType == MetaFieldType.Codes)
{
CopyField(codeRow, page, viewNameWithPrefix);
}
}
if (hasOptionFields == true)
{
UpdateOptionFields(page);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}