/// <summary> /// Constructs a page from database table row /// </summary> /// <param name="row"></param> /// <param name="view"></param> public Page(DataRow row, View view) { if (row[ColumnNames.NAME] != DBNull.Value) this.Name = row[ColumnNames.NAME].ToString(); // zero based Position in Epi 7 this.Position = Math.Abs(short.Parse(row[ColumnNames.PAGE_NUMBER].ToString())) - 1; string checkCodeBlock = row[ColumnNames.CHECK_CODE].ToString(); RebuildCheckCode(checkCodeBlock, view); }
/// <summary> /// Method LoadViews() /// </summary> //protected override void LoadViews() public void LoadViews() { this.views = new Collection<View>(); System.Collections.Hashtable RelatedViews = new System.Collections.Hashtable(); DataTable viewsTable = GetViewsAsDataTable(); foreach (DataRow viewRow in viewsTable.Rows) { View V = new Epi2000.View(viewRow, this); // set the is related view attribute IDataReader R = this.collectedData.GetTableDataReader(V.Name); while(R.Read()) { if (R["Name"].ToString().ToUpper().StartsWith("RELVIEW")) { if(! RelatedViews.ContainsKey(R["DataTable"].ToString())) { RelatedViews.Add(R["DataTable"].ToString(), R["DataTable"].ToString()); } } } R.Close(); this.views.Add(V); } foreach(Epi2000.View V in this.views) { if (RelatedViews.ContainsKey(V.Name)) { V.IsRelatedView = true; } } }
/// <summary> /// Constructs a page linked to a view /// </summary> /// <param name="view">A view object</param> public Page(View view) { }
/// <summary> /// Rebuilds the check code for the page /// </summary> /// <param name="checkCodeBlock">The check code block</param> /// <param name="view">The view</param> public void RebuildCheckCode(string checkCodeBlock, View view) { if (checkCodeBlock == null) { return; } System.Text.StringBuilder CheckCode = new System.Text.StringBuilder(); bool PageHasBeforeCheckCode = false; bool PageHasAfterCheckCode = false; string ckBefore = string.Empty; string ckAfter = string.Empty; Epi2000.MetadataDbProvider.SplitCheckCode(checkCodeBlock, ref ckBefore, ref ckAfter); if (!string.IsNullOrEmpty(ckAfter)) { PageHasAfterCheckCode = true; } if (!string.IsNullOrEmpty(ckBefore)) { PageHasBeforeCheckCode = true; } if (PageHasBeforeCheckCode || PageHasAfterCheckCode) { CheckCode.Append("\nPage "); if (this.name.Trim().IndexOf(' ') > -1 || this.name.ToLower().Equals("page")) { CheckCode.Append("["); CheckCode.Append(this.name.Trim().Replace("&", string.Empty)); // Imported page names can't have & symbol CheckCode.Append("]"); } else { CheckCode.Append(this.name.Trim().Replace("&", string.Empty)); // Imported page names can't have & symbol } if (PageHasBeforeCheckCode) { CheckCode.Append("\n\tBefore\n\t\t"); CheckCode.Append(ckBefore.Replace("\n", "\n\t\t")); CheckCode.Append("\n\tEnd-Before\n"); } if (PageHasAfterCheckCode) { CheckCode.Append("\n\tAfter\n\t\t"); CheckCode.Append(ckAfter.Replace("\n", "\n\t\t")); CheckCode.Append("\n\tEnd-After\n"); } CheckCode.Append("End-Page\n"); } this.CheckCodeBefore = CheckCode.ToString(); }