Exemplo n.º 1
0
  /// <summary>Page_Load</summary>
  public void Page_Load
  (
   object     sender, 
   EventArgs  e
  ) 
  {
  
   serverMapPath = this.MapPath("");
   AlphabetSequence.ConfigurationXml
   (
        serverMapPath + @"\" + filenameConfigurationXml,
    ref exceptionMessage,
    ref databaseConnectionString
   );

   if ( exceptionMessage != null )
   {
    LabelExceptionMessage.Text = exceptionMessage;
    return;
   }//if ( exceptionMessage != null ) 

   if (!Page.IsPostBack) 
   {
   }//if (!Page.IsPostBack)  
  
  }//Page_Load
Exemplo n.º 2
0
  }//Page_Load

  /// <summary>ButtonQuery_Click</summary>
  public void ButtonQuery_Click
  (
   Object sender, 
   EventArgs e
  ) 
  {
   int[]                                 alphabetSequence                   = new int[1];
   string[]                              word                               = new string[1];
   string                                scriptureReferenceAssociates       = "Genesis 1";
   ScriptureReferenceAlphabetSequence[]  scriptureReferenceAlphabetSequence = new ScriptureReferenceAlphabetSequence[1];

   word[0] = TextBoxWord.Text.Trim();
   scriptureReferenceAssociates = TextBoxScriptureReferenceAssociates.Text.Trim();
   try
   {

    AlphabetSequence.DatabaseQuery
    ( 
     ref databaseConnectionString,
     ref exceptionMessage,
         word,
         scriptureReferenceAssociates,
     ref alphabetSequence, 
     ref scriptureReferenceAlphabetSequence
    );
    
    if ( exceptionMessage != null )
    {
     LabelExceptionMessage.Text = "if ( exceptionMessage != null )";
     Response.Write("if ( exceptionMessage != null )");
    }//if ( exceptionMessage != null ) 

    TextBoxAlphabetSequence.Text                   = Convert.ToString( alphabetSequence[0] );
   
    TextBoxAlphabetSequence.Text                   = Convert.ToString( scriptureReferenceAlphabetSequence[0].AlphabetSequence );
    TextBoxScriptureReference.Text                 = scriptureReferenceAlphabetSequence[0].ScriptureReferenceCurrent;
    TextBoxVerseForward.Text                       = scriptureReferenceAlphabetSequence[0].VerseForward;
    TextBoxChapterForward.Text                     = scriptureReferenceAlphabetSequence[0].ChapterForward;
    TextBoxChapterBackward.Text                    = scriptureReferenceAlphabetSequence[0].ChapterBackward;
    TextBoxVerseBackward.Text                      = scriptureReferenceAlphabetSequence[0].VerseBackward;

    RepeaterAlphabetSequence.DataSource = scriptureReferenceAlphabetSequence;
    RepeaterAlphabetSequence.DataBind();

   }//try 
   catch (Exception exception) 
   {
    LabelExceptionMessage.Text = exception.Message;	
   }//catch
   finally 
   { 

   }//finally    
  }//ButtonQuery_Click
  }//public static void Main.

  ///<summary>ImportExport.</summary>
  ///<param name="filenameImport">The filename import.</param>
  ///<param name="filenameExport">The filename export.</param>
  ///<param name="scriptureReferenceAssociates">The alphabet sequence associates.</param>
  public static void ImportExport
  (
   string filenameImport,
   string filenameExport,
   string scriptureReferenceAssociates
  )
  {

   int[]                                 alphabetSequenceIndex              = null;
   int                                   dataRowIndex                       = -1;

   string exceptionMessage                                                  = null;
   string fileNameWithoutExtension                                          = null;
   string record                                                            = null;
   string[]                              word                               = null;

   System.Data.DataColumn                dataColumn                         = null;
   System.Data.DataColumn                dataColumnForeignKey               = null;
   System.Data.DataColumn                dataColumnPrimaryKey               = null;

   System.Data.DataRelation              dataRelation                       = null;
   System.Data.DataRow                   dataRow                            = null;
   System.Data.DataSet                   dataSet                            = null;

   System.Data.DataTable                 dataTableAlphabetSequence          = null;
   System.Data.DataTable                 dataTableTheWord                   = null;

   StreamReader                          streamReader                       = null;

   ScriptureReferenceAlphabetSequence[]  scriptureReferenceAlphabetSequence = null;

   StringBuilder                         sbTitle                            = null;

   sbTitle = new StringBuilder();

   try
   {
    if (!File.Exists(filenameImport))
    {
     System.Console.WriteLine("File not found: {0}", filenameImport); 
     return;
    }
    fileNameWithoutExtension = Path.GetFileNameWithoutExtension( filenameImport ); 
    dataSet = new DataSet();
    dataSet.DataSetName = TheWord.NodeRoot;
    // Create an instance of StreamReader to read from a file.
    // The using statement also closes the StreamReader.
     
    streamReader = new StreamReader(filenameImport); 

    // Create a new DataTable.
    dataTableTheWord = new DataTable(DataTableNameTheWord);

    dataColumn                =  new DataColumn();
    dataColumn.ColumnName     =  "SequenceOrderId";
    dataColumn.DataType       =  System.Type.GetType("System.Int32");
    dataColumn.DefaultValue   =  null;
    dataTableTheWord.Columns.Add( dataColumn );
    dataColumnPrimaryKey      = dataTableTheWord.Columns["SequenceOrderId"];

    dataColumn                = new DataColumn();
    dataColumn.ColumnName     = "Dated";
    dataColumn.DataType       = System.Type.GetType("System.DateTime");
    dataTableTheWord.Columns.Add( dataColumn );

    dataColumn                = new DataColumn();
    dataColumn.ColumnName     = "ScriptureReference";
    dataColumn.DataType       = System.Type.GetType("System.String");
    dataTableTheWord.Columns.Add( dataColumn );

    dataColumn                = new DataColumn();
    dataColumn.ColumnName     = "Title";
    dataColumn.DataType       = System.Type.GetType("System.String");
    dataTableTheWord.Columns.Add( dataColumn );

    dataSet.Tables.Add( dataTableTheWord );

    dataRow                   = dataTableTheWord.NewRow();
    dataRow["Dated"]          = System.DateTime.Today;

    dataTableTheWord.Rows.Add( dataRow );

    // Create a new DataTable.
    dataTableAlphabetSequence = new DataTable(DataTableNameAlphabetSequence);

    dataColumn = new DataColumn();
    dataColumn.ColumnName    = "TheWordId";
    dataColumn.DataType      = System.Type.GetType("System.Int32");
    dataColumn.DefaultValue  = null;
    dataTableAlphabetSequence.Columns.Add( dataColumn );
    dataColumnForeignKey     = dataTableAlphabetSequence.Columns["TheWordId"];

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "SequenceOrderId";
    dataColumn.DataType      = System.Type.GetType("System.Int32");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "Word";
    dataColumn.DataType      = System.Type.GetType("System.String");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "AlphabetSequenceIndex";
    dataColumn.DataType      = System.Type.GetType("System.Int32");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "Commentary";
    dataColumn.DataType      = System.Type.GetType("System.String");
    dataColumn.DefaultValue  = null;
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "ScriptureReference";
    dataColumn.DataType      = System.Type.GetType("System.String");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataSet.Tables.Add( dataTableAlphabetSequence );

    #if (DEBUG)   
     System.Console.WriteLine("Data Column Primary Key: {0}", dataColumnPrimaryKey);
     System.Console.WriteLine("Data Column Foreign Key: {0}", dataColumnForeignKey);
    #endif 
    
    dataRelation = new DataRelation
    (
      DataRelationNameAlphabetSequence, 
      dataColumnPrimaryKey,
      dataColumnForeignKey
    );

    dataRelation.Nested = true;
    dataSet.Relations.Add( dataRelation );

    // Read and display lines from the file until the end of 
    // the file is reached.
      
    while ( true ) 
    {
     record = streamReader.ReadLine();

     if ( record == null )
     {
      break;
     }

     dataRow = dataTableAlphabetSequence.NewRow();
     dataRow["Word"] = record;
     sbTitle.Append( record );
     sbTitle.Append( Environment.NewLine );
     dataTableAlphabetSequence.Rows.Add( dataRow );
    }//while ( true ) 

    alphabetSequenceIndex              = new int[dataTableAlphabetSequence.Rows.Count];
    scriptureReferenceAlphabetSequence = new ScriptureReferenceAlphabetSequence[dataTableAlphabetSequence.Rows.Count];
    word                               = new String[dataTableAlphabetSequence.Rows.Count];

    dataRowIndex = 0;
    foreach ( DataRow dataRowCurrent in dataTableAlphabetSequence.Rows )
    {
     word[dataRowIndex]                = ( string ) dataRowCurrent["Word"];
     System.Console.WriteLine( dataRowCurrent["Word"] );
     ++dataRowIndex;
    }//foreach ( DataRow dataRowCurrent in dataTableAlphabetSequence.Rows )

    UtilityDatabase.DataSetTableRowColumn
    (
     dataSet,
     "TheWord",
     0,
     "Title",
     sbTitle.ToString()
    );

    AlphabetSequence.AlphabetSequenceQuery
    (
     ref  DatabaseConnectionString,
     ref  exceptionMessage,
     ref  word,
          scriptureReferenceAssociates,
     ref  alphabetSequenceIndex,
     ref  scriptureReferenceAlphabetSequence
    );

    for ( dataRowIndex = 0; dataRowIndex < dataTableAlphabetSequence.Rows.Count; ++dataRowIndex )
    {

     UtilityDatabase.DataSetTableRowColumn
     (
      dataSet,
      DataTableNameAlphabetSequence,
      dataRowIndex,
      "AlphabetSequenceIndex",
      scriptureReferenceAlphabetSequence[ dataRowIndex ].AlphabetSequence
     );

     UtilityDatabase.DataSetTableRowColumn
     (
      dataSet,
      DataTableNameAlphabetSequence,
      dataRowIndex,
      "ScriptureReference",
      scriptureReferenceAlphabetSequence[ dataRowIndex ].ScriptureReferenceCurrent
     );

     UtilityDatabase.DataSetTableRowColumn
     (
      dataSet,
      DataTableNameAlphabetSequence,
      dataRowIndex,
      "SequenceOrderId",
      scriptureReferenceAlphabetSequence[ dataRowIndex ].SequenceOrderId
     );

    }//foreach ( DataRow dataRowCurrent in dataTableAlphabetSequence.Rows )

    ScriptureReference.ScriptureReferenceURI
    (
         TheWord.DatabaseConnectionString,
         TheWord.FilenameConfigurationXml,
     ref exceptionMessage,
     ref dataSet
    );//ScriptureReference.ScriptureReferenceURI

    UtilityXml.WriteXml
    (
         dataSet,
     ref exceptionMessage,
     ref filenameExport,
     ref TheWord.FilenameXslt
    );
   }//try
   catch (Exception exception)
   {
    System.Console.WriteLine("Exception: ", exception.Message);
   }//catch (Exception exception)
   finally
   {
   }//finally
  }//public static void ImportExport