public static void Main(string[] args)
        {
            int             argumentCount    = args.Length;
            String          exceptionMessage = null;
            OleDbConnection oleDbConnection  = null;

            //Open the database connection.
            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize(DatabaseConnectionString, ref exceptionMessage);

            TableProcessURI
            (
                ref oleDbConnection,
                selectQueryUriChrist,
                filenameUriHtmlChrist,
                filenameUriTextChrist,
                filenameUriXsdChrist,
                filenameUriXmlChrist,
                filenameUriXmlChrist2,
                filenameUriXsltChrist
            );

            TableProcessURI
            (
                ref oleDbConnection,
                selectQueryUriWordEngineering,
                filenameUriHtmlWordEngineering,
                filenameUriTextWordEngineering,
                filenameUriXsdWordEngineering,
                filenameUriXmlWordEngineering,
                filenameUriXmlWordEngineering2,
                filenameUriXsltWordEngineering
            );

            //Close the database connection.
            UtilityDatabase.DatabaseConnectionHouseKeeping(oleDbConnection, ref exceptionMessage);
        }//Main()
Beispiel #2
0
  }//ConfigurationXml	 

  /// <summary>Scripture Reference URI.</summary>
  /// <param name="databaseConnectionString">The database connection string.</param>
  /// <param name="filenameConfigurationXml">The filename configuration Xml.</param>
  /// <param name="exceptionMessage">The exception message.</param>  
  /// <param name="dataSet">The dataset.</param>
  public static void ScriptureReferenceURI
  (
       string  databaseConnectionString,
       string  filenameConfigurationXml,
   ref string  exceptionMessage,
   ref DataSet dataSet
  )
  {
   bool                                         boolView                                  = false;
   
   int                                          columnIndexScriptureReference             = -1;
   
   string                                       dataColumnName                            = null;
   string                                       scriptureReferenceColumnValue             = null;
   string                                       scriptureReferenceColumnName              = null;
   string                                       scriptureReferenceColumnNameURI           = null;
   string                                       scriptureReferenceURI                     = null;   
   string[][]                                   scriptureReferenceArray                   = null;    
   string                                       columnNamePrimary                         = null;
   string                                       columnValuePrimary                        = null; 
   string                                       tableName                                 = null;
   
   ArrayList                                    scriptureReferenceSet                     = null;
   ArrayList                                    scriptureReferenceURISet                  = null;
   ScriptureReferenceBookChapterVersePrePost[]  scriptureReferenceBookChapterVersePrePost = null;
   StringBuilder                                columnSet                                 = null;   
   StringBuilder                                uriCrosswalkXml                           = null;
   StringBuilder                                uriCrosswalkHtml                          = null;   
   StringBuilder                                SQLStatement                              = null;      
   OleDbConnection                              oleDbConnection                           = null;
   XmlNodeList                                  scriptureReferenceColumnSet               = null;

   scriptureReferenceColumnSet = UtilityXml.SelectNodes
   (
        filenameConfigurationXml,
    ref exceptionMessage,
        XPathColumnScriptureReference
   );
   try
   {
    oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
    (
         databaseConnectionString,
     ref exceptionMessage
    ); 

    foreach ( DataTable dataTable in dataSet.Tables )
    {
   
     columnIndexScriptureReference = UtilityDatabase.DataTableColumnIndex
     (
      dataTable,
      "ScriptureReference"
     ); 
     
     if ( columnIndexScriptureReference < 0 )
     {
      continue;
     }           	
    	
     tableName                = dataTable.TableName;
     scriptureReferenceSet    = new ArrayList();
     scriptureReferenceURISet = new ArrayList();
     SQLStatement = new StringBuilder();
     
     if ( tableName.IndexOf("View" ) < 0 )
     {
      boolView = false;
      SQLStatement.AppendFormat
      (
       InformationSchemaColumnNamePrimaryColumnSQL,
       tableName
      );
     }
     else
     {
      boolView = true;	
      SQLStatement.AppendFormat
      (
       InformationSchemaColumnNamePrimaryColumnSQL,
       tableName.Substring(4)
      );
     }

      #if (DEBUG)
       System.Console.WriteLine("SQLStatement: {0}", SQLStatement);
      #endif
     
     columnNamePrimary = (string) UtilityDatabase.DatabaseQuery
     (
          databaseConnectionString,
      ref exceptionMessage,
          SQLStatement.ToString(),
          CommandType.Text
     );
     
     if ( boolView == true )
     {
      columnNamePrimary = String.Concat( tableName.Substring(4), columnNamePrimary );	
     }	 

     #if (DEBUG)
      System.Console.WriteLine("ColumnNamePrimary: {0}", columnNamePrimary);
     #endif
     
     foreach ( DataColumn dataColumn in dataTable.Columns )
     {
      dataColumnName = dataColumn.ColumnName.Trim();
      /*
      #if (DEBUG)
       System.Console.WriteLine("Table Name: {0} | ColumnName: {1}", tableName, dataColumnName);
      #endif
      */
      if ( dataColumnName.IndexOf( ScriptureReferenceURIColumnNamePostfix ) >= 0 )
      {
       continue;
      }
      if ( dataColumnName.IndexOf( ScriptureReferenceColumnNamePostfix ) >= 0 )
      {
       scriptureReferenceSet.Add( dataColumnName );
       scriptureReferenceColumnName    = dataColumnName;
       scriptureReferenceColumnNameURI = scriptureReferenceColumnName + "URI";
       if ( dataTable.Columns.Contains( scriptureReferenceColumnNameURI ) == false )
       {
        /*
        #if (DEBUG)
         System.Console.WriteLine("Table Name: {0} | ColumnName: {1}", tableName, scriptureReferenceColumnNameURI);
        #endif
        */
        scriptureReferenceURISet.Add( scriptureReferenceColumnNameURI );
       }//if dataTable.Columns.Contains( scriptureReferenceColumnNameURI ) == false )
      }//if ( dataColumnName.IndexOf( ScriptureReferenceColumnNamePostfix ) >= 0 )
     }//foreach ( DataColumn dataColumn in dataTable.Columns )

     foreach ( object columnName in scriptureReferenceURISet )
     {
      scriptureReferenceColumnNameURI = columnName.ToString().Trim();
      dataTable.Columns.Add( scriptureReferenceColumnNameURI );
     }

     foreach ( DataColumn dataColumn in dataTable.Columns )
     {
      dataColumnName = dataColumn.ColumnName.Trim();
      /*
       #if (DEBUG)
        System.Console.WriteLine("Table Name: {0} | ColumnName: {1}", tableName, dataColumnName);
       #endif
      */ 
     }//foreach ( DataColumn dataColumn in dataTable.Columns )

     foreach ( DataRow dataRow in dataTable.Rows )
     {
      columnValuePrimary = dataRow[columnNamePrimary].ToString().Trim();
      columnSet = new StringBuilder();
      /*
       #if (DEBUG)
        System.Console.WriteLine("ColumnValuePrimary: {0}", columnValuePrimary);
       #endif
      */ 
      foreach ( object columnName in scriptureReferenceSet )
      {
       #if (DEBUG)
        System.Console.WriteLine("ColumnName: {0}", columnName);
       #endif
       scriptureReferenceColumnName  = columnName.ToString().Trim();
       scriptureReferenceColumnValue = dataRow[scriptureReferenceColumnName].ToString().Trim();
     
       #if (DEBUG)
        System.Console.WriteLine
        (
         "Scripture Reference Column Name: {0} | Value: {1}", 
         scriptureReferenceColumnName,
         scriptureReferenceColumnValue
        );
       #endif
       scriptureReferenceColumnNameURI = scriptureReferenceColumnName + "URI";
       if ( scriptureReferenceColumnValue != null && scriptureReferenceColumnValue != string.Empty )
       {
        ScriptureReference.ScriptureReferenceParser
        (
             new string[] { scriptureReferenceColumnValue },
             databaseConnectionString,
         ref exceptionMessage,
         ref scriptureReferenceBookChapterVersePrePost,
         ref scriptureReferenceArray,
         ref uriCrosswalkHtml,
         ref uriCrosswalkXml
        );//ScriptureReference.ScriptureReferenceParser()
        scriptureReferenceURI = uriCrosswalkHtml.ToString();
        if ( UtilityDatabase.DataSetTableColumnContains( dataSet, tableName, scriptureReferenceColumnNameURI ) == false )
        {
         UtilityDatabase.DataSetTableColumnAdd( dataSet, tableName, scriptureReferenceColumnNameURI );	
         dataRow[scriptureReferenceColumnNameURI] = scriptureReferenceURI;
         continue;
        }//if ( DataSetTableColumnContains( dataSet, dataTable, scriptureReferenceColumnNameURI ) )	
        dataRow[scriptureReferenceColumnNameURI] = scriptureReferenceURI;
        if ( scriptureReferenceURISet.IndexOf( scriptureReferenceColumnNameURI ) >= 0 )
        {
         continue;
        }

        if ( columnSet.Length != 0 )
        {
         columnSet.Append(',');
        }
        columnSet.AppendFormat
        (
         UtilityDatabase.DatabaseTemplateSQLSet,
         scriptureReferenceColumnNameURI,
         scriptureReferenceURI
        ); 
        /*
        #if (DEBUG)
         System.Console.WriteLine("columnSet: {0}", columnSet);      
        #endif
        */
        SQLStatement = new StringBuilder();
        SQLStatement.AppendFormat
        (
         UtilityDatabase.DatabaseTemplateSQLUpdateScriptureReferenceURISet,
         tableName,
         columnSet,
         columnNamePrimary,
         columnValuePrimary
        );   
        #if (DEBUG)
         System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString() );      
        #endif
        UtilityDatabase.DatabaseNonQuery
        (
             oleDbConnection,
         ref exceptionMessage,
             SQLStatement.ToString()
        );
       }//if ( scriptureReferenceColumnValue != null && scriptureReferenceColumnValue != string.Empty )
      }//foreach ( object columnName in dataTableColumnName )
     }//foreach ( DataRow dataRow in dataTable )
    }//foreach ( DataTable dataTable in dataSet ) 
    UtilityDatabase.DatabaseConnectionHouseKeeping
    (
         oleDbConnection,
     ref exceptionMessage
    );
   }//try
   catch (OleDbException exception)
   {
    //exceptionMessage = exception.Message;
    exceptionMessage = UtilityEventLog.WriteEntryOleDbErrorCollection( exception );
    System.Console.WriteLine("OleDbException: {0}", exceptionMessage);
   }//catch (OleDbException exception)
   catch (SecurityException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (SystemException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SystemException: {0}", exception.Message );
   }//catch (SystemException exception)
   catch (Exception exception)
   {
    exceptionMessage = exception.Message;   
    System.Console.WriteLine( "Exception: {0}", exception.Message );
   }//catch (Exception exception)
  }//public static void ScriptureReferenceURI()
Beispiel #3
0
  }//public static void UtilityContact.ContactDetailSave()   	

  ///<summary>ContactImageUpdate</summary>
  public static void ContactImageUpdate
  (
   ref string      databaseConnectionString,
   ref string      exceptionMessage,
   ref int         sequenceOrderId,
   ref DateTime    dated,   
   ref int         contactId,
   ref byte[]      imageContent,
   ref FileUpload  imageSource,
   ref string      imageType
  )
  {
   int              databaseNumberOfRowsAffected  =  -1;
   string           imageSourcePath               =  null;
   OleDbCommand     oleDbCommand                  =  null;
   OleDbConnection  oleDbConnection               =  null;
   OleDbParameter   oleDbParameter                =  null;
   try
   {
    if ( imageSource.HasFile == false ) { return; }
    imageSourcePath  =  imageSource.PostedFile.FileName;    
    UtilityImage.FileUploadByte
    (
     ref imageSource,
     ref imageContent,
     ref exceptionMessage
    );
    if ( exceptionMessage != null ) { return; }
    oleDbConnection  =  UtilityDatabase.DatabaseConnectionInitialize
    (
         databaseConnectionString,
     ref exceptionMessage
    );
	if ( exceptionMessage != null ) { return; }
	oleDbCommand                  =  new OleDbCommand( "uspContactImageUpdate", oleDbConnection );
    if ( oleDbCommand == null ) { return; }
    oleDbCommand.CommandType      =  CommandType.StoredProcedure;
    oleDbParameter                =  new OleDbParameter( "@sequenceOrderId", OleDbType.Integer );
    if ( sequenceOrderId > 0 )
    {
     oleDbParameter.Value         =  sequenceOrderId;
    }
    else
    {
     oleDbParameter.Value         =  DBNull.Value;
    } 
    oleDbCommand.Parameters.Add( oleDbParameter );
    
    oleDbParameter                =  new OleDbParameter( "@dated", OleDbType.Date );
    if ( dated > DateTime.MinValue )
    {
     oleDbParameter.Value          =  dated;
    }
    else
    {
     oleDbParameter.Value         =  DBNull.Value;
    } 
    oleDbCommand.Parameters.Add( oleDbParameter );

    oleDbParameter                =  new OleDbParameter( "@contactId", OleDbType.Integer );
    if ( contactId > 0 )
    {
     oleDbParameter.Value         =  contactId;
    }
    else
    {
     oleDbParameter.Value         =  DBNull.Value;
    } 
    oleDbCommand.Parameters.Add( oleDbParameter );

    oleDbParameter                =  new OleDbParameter( "@imageContent", OleDbType.Binary );
    oleDbParameter.Value          =  imageContent;
    oleDbCommand.Parameters.Add( oleDbParameter );

    oleDbParameter                =  new OleDbParameter( "@ImageSource", OleDbType.VarChar, 255 );
    oleDbParameter.Value          =  imageSourcePath;
    oleDbCommand.Parameters.Add( oleDbParameter );

    oleDbParameter                =  new OleDbParameter( "@imageType", OleDbType.VarChar, 255 );
    oleDbParameter.Value          =  imageType;
    oleDbCommand.Parameters.Add( oleDbParameter );
    
    databaseNumberOfRowsAffected  =  oleDbCommand.ExecuteNonQuery();
   }//try
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
  }
Beispiel #4
0
        }     //AlphabetSequenceDatabaseQuery()

        /// <summary>The database query.</summary>
        /// <param name="databaseConnectionString">The database connection string.</param>
        /// <param name="exceptionMessage">The exception message.</param>
        /// <param name="wordQuery">The word.</param>
        /// <param name="scriptureReferenceAssociates">The scripture reference associates.</param>
        /// <param name="alphabetSequenceIndex">The alphabet sequence index.</param>
        /// <param name="scriptureReferenceAlphabetSequence">The scripture reference alphabet sequence.</param>
        public static void AlphabetSequenceQuery
        (
            ref String databaseConnectionString,
            ref String exceptionMessage,
            ref String[]                              wordQuery,
            String scriptureReferenceAssociates,
            ref int[]                                 alphabetSequenceIndex,
            ref ScriptureReferenceAlphabetSequence[]  scriptureReferenceAlphabetSequence
        )
        {
            int sequenceOrderId = -1;
            int theWordId       = -1;
            int wordQueryTotal  = wordQuery.Length;

            string chapterForward  = null;
            string chapterBackward = null;
            //string commentary                        = null;

            string scriptureReference = null;
            string scriptureReferenceChapterBackward = null;
            string scriptureReferenceChapterForward  = null;
            string scriptureReferenceVerseBackward   = null;
            string scriptureReferenceVerseForward    = null;
            string verseForward  = null;
            string verseBackward = null;

            OleDbConnection oleDbConnection = null;
            OleDbCommand    oleDbCommand    = null;

            OleDbDataReader oleDbDataReader = null;

            OleDbParameter oleDbParameterWord = null;
            OleDbParameter oleDbParameterScriptureReferenceAssociates      = null;
            OleDbParameter oleDbParameterAlphabetSequence                  = null;
            OleDbParameter oleDbParameterScriptureReferenceVerseForward    = null;
            OleDbParameter oleDbParameterScriptureReferenceChapterForward  = null;
            OleDbParameter oleDbParameterScriptureReferenceChapterBackward = null;
            OleDbParameter oleDbParameterScriptureReferenceVerseBackward   = null;
            OleDbParameter oleDbParameterScriptureReference                = null;
            OleDbParameter oleDbParameterSequenceOrderId = null;
            OleDbParameter oleDbParameterVerseForward    = null;
            OleDbParameter oleDbParameterChapterForward  = null;
            OleDbParameter oleDbParameterChapterBackward = null;
            OleDbParameter oleDbParameterVerseBackward   = null;
            OleDbParameter oleDbParameterCommentary      = null;
            OleDbParameter oleDbParameterTheWordId       = null;

            AlphabetSequenceIndexCalculate
            (
                ref wordQuery,
                ref alphabetSequenceIndex
            );

            try
            {
                if
                (
                    databaseConnectionString == null ||
                    databaseConnectionString.IndexOf("Bible") < 0
                )
                {
                    databaseConnectionString = DatabaseConnectionString;
                }//if ( databaseConnectionString == null )

                oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                                  (
                    databaseConnectionString,
                    ref exceptionMessage
                                  );

                if (oleDbConnection == null || exceptionMessage != null)
                {
                    return;
                }//if ( oleDbConnection == null || exceptionMessage != null )

                oleDbCommand             = new OleDbCommand(SQLSelectAlphabetSequence, oleDbConnection);
                oleDbCommand.CommandType = CommandType.StoredProcedure;

                oleDbParameterWord = new OleDbParameter(ParameterWord, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceAssociates      = new OleDbParameter(ParameterWord, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterAlphabetSequence                  = new OleDbParameter(ParameterAlphabetSequence, OleDbType.Integer);
                oleDbParameterScriptureReferenceVerseForward    = new OleDbParameter(ParameterScriptureReferenceVerseForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceChapterForward  = new OleDbParameter(ParameterScriptureReferenceChapterForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceChapterBackward = new OleDbParameter(ParameterScriptureReferenceChapterBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceVerseBackward   = new OleDbParameter(ParameterScriptureReferenceVerseBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReference                = new OleDbParameter(ParameterScriptureReference, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterVerseForward    = new OleDbParameter(ParameterVerseForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterChapterForward  = new OleDbParameter(ParameterChapterForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterChapterBackward = new OleDbParameter(ParameterChapterBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterVerseBackward   = new OleDbParameter(ParameterVerseBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterSequenceOrderId = new OleDbParameter(ParameterSequenceOrderId, OleDbType.Integer);
                oleDbParameterCommentary      = new OleDbParameter(ParameterCommentary, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterTheWordId       = new OleDbParameter(ParameterTheWordId, OleDbType.Integer);
                oleDbParameterSequenceOrderId = new OleDbParameter(ParameterSequenceOrderId, OleDbType.Integer);

                /*
                 * @word                               VARCHAR(600)  =  NULL  OUTPUT,
                 * @scriptureReferenceAssociates       VARCHAR(600)  =  NULL  OUTPUT,
                 * @alphabetSequence                   INT           =  -1    OUTPUT,
                 * @scriptureReferenceVerseForward     VARCHAR(600)  =  NULL  OUTPUT,
                 * @scriptureReferenceChapterForward   VARCHAR(600)  =  NULL  OUTPUT,
                 * @scriptureReferenceChapterBackward  VARCHAR(600)  =  NULL  OUTPUT,
                 * @scriptureReferenceVerseBackward    VARCHAR(600)  =  NULL  OUTPUT,
                 * @scriptureReference                 VARCHAR(600)  =  NULL  OUTPUT,
                 * @verseForward                       VARCHAR(600)  =  NULL  OUTPUT,
                 * @chapterForward                     VARCHAR(600)  =  NULL  OUTPUT,
                 * @chapterBackward                    VARCHAR(600)  =  NULL  OUTPUT,
                 * @verseBackward                      VARCHAR(600)  =  NULL  OUTPUT,
                 * @sequenceOrderId                    INT           =  -1    OUTPUT
                 */

                oleDbCommand.Parameters.Add(oleDbParameterWord);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceAssociates);
                oleDbCommand.Parameters.Add(oleDbParameterAlphabetSequence);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceVerseForward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceChapterForward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceChapterBackward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceVerseBackward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReference);
                oleDbCommand.Parameters.Add(oleDbParameterVerseForward);
                oleDbCommand.Parameters.Add(oleDbParameterChapterForward);
                oleDbCommand.Parameters.Add(oleDbParameterChapterBackward);
                oleDbCommand.Parameters.Add(oleDbParameterVerseBackward);

                /*
                 * oleDbCommand.Parameters.Add(oleDbParameterCommentary);
                 * oleDbCommand.Parameters.Add(oleDbParameterTheWordId);
                 */
                oleDbCommand.Parameters.Add(oleDbParameterSequenceOrderId);

                oleDbParameterWord.Direction = ParameterDirection.InputOutput;
                oleDbParameterScriptureReferenceAssociates.Direction      = ParameterDirection.InputOutput;
                oleDbParameterAlphabetSequence.Direction                  = ParameterDirection.InputOutput;
                oleDbParameterScriptureReferenceVerseForward.Direction    = ParameterDirection.Output;
                oleDbParameterScriptureReferenceChapterForward.Direction  = ParameterDirection.Output;
                oleDbParameterScriptureReferenceChapterBackward.Direction = ParameterDirection.Output;
                oleDbParameterScriptureReferenceVerseBackward.Direction   = ParameterDirection.Output;
                oleDbParameterScriptureReference.Direction                = ParameterDirection.Output;
                oleDbParameterVerseForward.Direction    = ParameterDirection.Output;
                oleDbParameterChapterForward.Direction  = ParameterDirection.Output;
                oleDbParameterChapterBackward.Direction = ParameterDirection.Output;
                oleDbParameterVerseBackward.Direction   = ParameterDirection.Output;

                /*
                 * oleDbParameterCommentary.Direction                         = ParameterDirection.InputOutput;
                 * oleDbParameterTheWordId.Direction                          = ParameterDirection.InputOutput;
                 */
                oleDbParameterSequenceOrderId.Direction = ParameterDirection.InputOutput;

                for (int wordQueryIndex = 0; wordQueryIndex < wordQuery.Length; ++wordQueryIndex)
                {
                    oleDbParameterAlphabetSequence.Value             = alphabetSequenceIndex[wordQueryIndex];
                    oleDbParameterScriptureReferenceAssociates.Value = scriptureReferenceAssociates;
                    oleDbParameterSequenceOrderId.Value = -1;
                    oleDbParameterTheWordId.Value       = null;
                    oleDbParameterWord.Value            = wordQuery[wordQueryIndex];

                    oleDbCommand.ExecuteScalar();

                    scriptureReferenceVerseForward    = (oleDbParameterScriptureReferenceVerseForward.Value).ToString();
                    scriptureReferenceChapterForward  = (oleDbParameterScriptureReferenceChapterForward.Value).ToString();
                    scriptureReferenceChapterBackward = (oleDbParameterScriptureReferenceChapterBackward.Value).ToString();
                    scriptureReferenceVerseBackward   = (oleDbParameterScriptureReferenceVerseBackward.Value).ToString();

                    scriptureReference = (oleDbParameterScriptureReference.Value).ToString();
                    verseForward       = (oleDbParameterVerseForward.Value).ToString();
                    chapterForward     = (oleDbParameterChapterForward.Value).ToString();
                    chapterBackward    = (oleDbParameterChapterBackward.Value).ToString();
                    verseBackward      = (oleDbParameterVerseBackward.Value).ToString();
                    sequenceOrderId    = Int32.Parse(oleDbParameterSequenceOrderId.Value.ToString());

                    /*
                     * theWordId          = Int32.Parse ( oleDbParameterTheWordId.Value.ToString() );
                     */

                    scriptureReferenceAlphabetSequence[wordQueryIndex] = new ScriptureReferenceAlphabetSequence
                                                                         (
                        wordQuery[wordQueryIndex],
                        scriptureReferenceAssociates,
                        alphabetSequenceIndex[wordQueryIndex],
                        scriptureReferenceVerseForward,
                        scriptureReferenceChapterForward,
                        scriptureReferenceChapterBackward,
                        scriptureReferenceVerseBackward,
                        scriptureReference,
                        verseForward,
                        chapterForward,
                        chapterBackward,
                        verseBackward,
                        sequenceOrderId
                                                                         );

     #if (DEBUG)
                    System.Console.WriteLine("SequenceOrderId: {0}", sequenceOrderId);
                    System.Console.WriteLine("TheWordId: {0}", theWordId);
     #endif
                } //for ( int wordQueryIndex = 0; wordQueryIndex < wordQueryTotal; ++wordQueryIndex )
            }     //try
            catch (OleDbException exception)
            {
                exceptionMessage = UtilityDatabase.DisplayOleDbErrorCollection(exception);
                System.Console.WriteLine("OleDbException: {0}", exceptionMessage);
                System.Console.WriteLine("OleDbException: {0}", oleDbParameterAlphabetSequence.Value);
                return;
            }//catch (OleDbException exception)
            catch (Exception exception)
            {
                exceptionMessage = exception.Message;
                System.Console.WriteLine("Exception: {0}", exception.Message);
                return;
            }//catch (Exception exception)
            finally
            {
                if (oleDbDataReader != null)
                {
                    oleDbDataReader.Close();
                }
                UtilityDatabase.DatabaseConnectionHouseKeeping
                (
                    oleDbConnection,
                    ref exceptionMessage
                );
            } //finally
            return;
        }     //AlphabetSequenceQuery()
Beispiel #5
0
        }//public static void DatabaseQuery()

        /// <summary>The database query.</summary>
        /// <param name="databaseConnectionString">The database connection string.</param>
        /// <param name="exceptionMessage">The exception message.</param>
        /// <param name="word">The word.</param>
        /// <param name="scriptureReferenceAssociates">The scripture reference associates.</param>
        /// <param name="alphabetSequence">The alphabet sequence.</param>
        /// <param name="scriptureReferenceAlphabetSequence">The scripture reference alphabet sequence.</param>
        public static void DatabaseQuery
        (
            ref string databaseConnectionString,
            ref string exceptionMessage,
            string[]                              word,
            string scriptureReferenceAssociates,
            ref int[]                                 alphabetSequence,
            ref ScriptureReferenceAlphabetSequence[]  scriptureReferenceAlphabetSequence
        )
        {
            int wordTotal = word.Length;

            string chapterForward  = null;
            string chapterBackward = null;

            string scriptureReference = null;
            string scriptureReferenceChapterBackward = null;
            string scriptureReferenceChapterForward  = null;
            string scriptureReferenceVerseBackward   = null;
            string scriptureReferenceVerseForward    = null;
            string verseForward  = null;
            string verseBackward = null;


            OleDbConnection oleDbConnection = null;
            OleDbCommand    oleDbCommand    = null;

            OleDbDataReader oleDbDataReader = null;

            OleDbParameter oleDbParameterWord = null;
            OleDbParameter oleDbParameterScriptureReferenceAssociates      = null;
            OleDbParameter oleDbParameterAlphabetSequence                  = null;
            OleDbParameter oleDbParameterScriptureReferenceVerseForward    = null;
            OleDbParameter oleDbParameterScriptureReferenceChapterForward  = null;
            OleDbParameter oleDbParameterScriptureReferenceChapterBackward = null;
            OleDbParameter oleDbParameterScriptureReferenceVerseBackward   = null;
            OleDbParameter oleDbParameterScriptureReference                = null;
            OleDbParameter oleDbParameterVerseForward    = null;
            OleDbParameter oleDbParameterChapterForward  = null;
            OleDbParameter oleDbParameterChapterBackward = null;
            OleDbParameter oleDbParameterVerseBackward   = null;

            AlphabetSequenceIndexCalculate
            (
                ref word,
                ref alphabetSequence
            );

            try
            {
                if (databaseConnectionString == null)
                {
                    databaseConnectionString = DatabaseConnectionString;
                }//if ( databaseConnectionString == null )

                oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                                  (
                    databaseConnectionString,
                    ref exceptionMessage
                                  );

                if (oleDbConnection == null || exceptionMessage != null)
                {
                    return;
                }//if ( oleDbConnection == null || exceptionMessage != null )

                oleDbCommand             = new OleDbCommand(SQLSelectAlphabetSequence, oleDbConnection);
                oleDbCommand.CommandType = CommandType.StoredProcedure;

                oleDbParameterWord = new OleDbParameter(ParameterWord, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceAssociates      = new OleDbParameter(ParameterWord, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterAlphabetSequence                  = new OleDbParameter(ParameterAlphabetSequence, OleDbType.Integer);
                oleDbParameterScriptureReferenceVerseForward    = new OleDbParameter(ParameterScriptureReferenceVerseForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceChapterForward  = new OleDbParameter(ParameterScriptureReferenceChapterForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceChapterBackward = new OleDbParameter(ParameterScriptureReferenceChapterBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReferenceVerseBackward   = new OleDbParameter(ParameterScriptureReferenceVerseBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterScriptureReference                = new OleDbParameter(ParameterScriptureReference, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterVerseForward    = new OleDbParameter(ParameterVerseForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterChapterForward  = new OleDbParameter(ParameterChapterForward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterChapterBackward = new OleDbParameter(ParameterChapterBackward, OleDbType.VarChar, DatabaseOutputParameterSize);
                oleDbParameterVerseBackward   = new OleDbParameter(ParameterVerseBackward, OleDbType.VarChar, DatabaseOutputParameterSize);

                oleDbCommand.Parameters.Add(oleDbParameterWord);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceAssociates);
                oleDbCommand.Parameters.Add(oleDbParameterAlphabetSequence);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceVerseForward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceChapterForward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceChapterBackward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReferenceVerseBackward);
                oleDbCommand.Parameters.Add(oleDbParameterScriptureReference);
                oleDbCommand.Parameters.Add(oleDbParameterVerseForward);
                oleDbCommand.Parameters.Add(oleDbParameterChapterForward);
                oleDbCommand.Parameters.Add(oleDbParameterChapterBackward);
                oleDbCommand.Parameters.Add(oleDbParameterVerseBackward);

                oleDbParameterWord.Direction = ParameterDirection.InputOutput;
                oleDbParameterScriptureReferenceAssociates.Direction      = ParameterDirection.InputOutput;
                oleDbParameterAlphabetSequence.Direction                  = ParameterDirection.InputOutput;
                oleDbParameterScriptureReferenceVerseForward.Direction    = ParameterDirection.Output;
                oleDbParameterScriptureReferenceChapterForward.Direction  = ParameterDirection.Output;
                oleDbParameterScriptureReferenceChapterBackward.Direction = ParameterDirection.Output;
                oleDbParameterScriptureReferenceVerseBackward.Direction   = ParameterDirection.Output;
                oleDbParameterScriptureReference.Direction                = ParameterDirection.Output;
                oleDbParameterVerseForward.Direction    = ParameterDirection.Output;
                oleDbParameterChapterForward.Direction  = ParameterDirection.Output;
                oleDbParameterChapterBackward.Direction = ParameterDirection.Output;
                oleDbParameterVerseBackward.Direction   = ParameterDirection.Output;

                for (int wordCount = 0; wordCount < wordTotal; ++wordCount)
                {
                    oleDbParameterWord.Value = word[wordCount];
                    oleDbParameterScriptureReferenceAssociates.Value = scriptureReferenceAssociates;
                    oleDbParameterAlphabetSequence.Value             = alphabetSequence[wordCount];

                    oleDbCommand.ExecuteScalar();

                    scriptureReferenceVerseForward    = (oleDbParameterScriptureReferenceVerseForward.Value).ToString();
                    scriptureReferenceChapterForward  = (oleDbParameterScriptureReferenceChapterForward.Value).ToString();
                    scriptureReferenceChapterBackward = (oleDbParameterScriptureReferenceChapterBackward.Value).ToString();
                    scriptureReferenceVerseBackward   = (oleDbParameterScriptureReferenceVerseBackward.Value).ToString();
                    scriptureReference = (oleDbParameterScriptureReference.Value).ToString();
                    verseForward       = (oleDbParameterVerseForward.Value).ToString();
                    chapterForward     = (oleDbParameterChapterForward.Value).ToString();
                    chapterBackward    = (oleDbParameterChapterBackward.Value).ToString();
                    verseBackward      = (oleDbParameterVerseBackward.Value).ToString();

                    scriptureReferenceAlphabetSequence[wordCount] = new ScriptureReferenceAlphabetSequence
                                                                    (
                        word[wordCount],
                        scriptureReferenceAssociates,
                        alphabetSequence[wordCount],
                        scriptureReferenceVerseForward,
                        scriptureReferenceChapterForward,
                        scriptureReferenceChapterBackward,
                        scriptureReferenceVerseBackward,
                        scriptureReference,
                        verseForward,
                        chapterForward,
                        chapterBackward,
                        verseBackward
                                                                    );

                    return;
                } //for ( int wordCount = 0; wordCount < word.Length; ++wordCount )
            }     //try
            catch (OleDbException exception)
            {
                exceptionMessage = UtilityDatabase.DisplayOleDbErrorCollection(exception);
                System.Console.WriteLine("OleDbException: {0}", exceptionMessage);
                System.Console.WriteLine("OleDbException: {0}", oleDbParameterAlphabetSequence.Value);
                return;
            }//catch (OleDbException exception)
            catch (Exception exception)
            {
                exceptionMessage = exception.Message;
                System.Console.WriteLine("Exception: {0}", exception.Message);
                return;
            }//catch (Exception exception)
            finally
            {
                if (oleDbDataReader != null)
                {
                    oleDbDataReader.Close();
                }
                UtilityDatabase.DatabaseConnectionHouseKeeping
                (
                    oleDbConnection,
                    ref exceptionMessage
                );
            } //finally
            return;
        }     //AlphabetSequenceDatabaseQuery()
  }//static void Main( string[] argv )
  
  ///<summary>XmlParse()</summary>
  static void XmlParse
  ( 
       string    databaseConnectionString,
   ref string    exceptionMessage,
       string[]  xmlDocumentFilenames
  )
  {
   
   int                       childrenCount                    =  0;
   int                       childrenTotal                    =  0;
   
   int                       elementConfigurationCount        =  0;
   int                       elementConfigurationIndex        =  0;
   int                       elementConfigurationTotal        =  ElementConfiguration.Length;
   
   int                       grandChildrenCount               =  0;
   int                       grandChildrenTotal               =  0;
   int                       grandChildrenValueLength         =  0;   
   
   int                       oleDbParameterCollectionCount    =  0;
   int                       oleDbParameterCollectionIndex    =  0;   
   int                       oleDbParameterCollectionTotal    =  0;
   
   string[][]                children                         =  null;
   string[][]                grandChildren                    =  null;   

   DateTime                  dateTime                         =  new DateTime();

   OleDbConnection           oleDbConnection                  =  null;
   OleDbCommand              oleDbCommand                     =  null;
   OleDbParameterCollection  oleDbParameterCollection         =  null;
  
   XPathDocument             xPathDocument                    = null;

   XPathNavigator            xPathNavigatorChildren           = null;
   XPathNavigator            xPathNavigatorGrandChildren      = null;
   XPathNavigator            xPathNavigatorParent             = null;
   
   XPathNodeIterator         xPathNodeIteratorChildren        = null;
   XPathNodeIterator         xPathNodeIteratorGrandChildren   = null;
   XPathNodeIterator         xPathNodeIteratorParent          = null;   

   //Open the database connection.
   oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize( databaseConnectionString, ref exceptionMessage );
   
   foreach ( string xmlDocumentFilename in xmlDocumentFilenames )
   {
    if ( !File.Exists( xmlDocumentFilename ) )
    {
     System.Console.WriteLine("File Not Found: {0}", xmlDocumentFilename );
     continue;
    }//if ( !File.Exists( xmlDocumentFilename ) )

    #if ( DEBUG )
     System.Console.WriteLine("XML Document Filename: {0}", xmlDocumentFilename);      
    #endif
         
    try
    {
     //Create an XML document instance, and load XML data.
     xPathDocument             = new XPathDocument( xmlDocumentFilename );

     xPathNavigatorParent      = xPathDocument.CreateNavigator();
     xPathNodeIteratorParent   = xPathNavigatorParent.SelectChildren( XPathNodeType.Element );

     xPathNodeIteratorParent.MoveNext();

     xPathNavigatorChildren    = xPathNodeIteratorParent.Current;
     xPathNodeIteratorChildren = xPathNavigatorChildren.SelectChildren( XPathNodeType.Element );
     childrenCount             = -1;
     childrenTotal             = xPathNodeIteratorChildren.Count;
    
     children                  = new string[childrenTotal][];

     while ( xPathNodeIteratorChildren.MoveNext() )
     {
      ++childrenCount;
      children[childrenCount]  = new string[2];
      children[childrenCount][NodeRankName]  = xPathNodeIteratorChildren.Current.Name.Trim();
      children[childrenCount][NodeRankValue] = xPathNodeIteratorChildren.Current.ToString().Trim();     

      /*
      #if ( DEBUG )
       System.Console.WriteLine
       (
        "Children Name: {0} | Value: {1}",
        children[childrenCount][NodeRankName],
        children[childrenCount][NodeRankValue]
       );      
      #endif
      */
      
      for 
      ( 
       elementConfigurationCount = 0, elementConfigurationIndex = -1; 
       elementConfigurationCount < elementConfigurationTotal; 
       ++elementConfigurationCount 
      )
      {       
       if ( ElementConfiguration[elementConfigurationCount][ElementRankName] == children[childrenCount][NodeRankName] )
       {
        elementConfigurationIndex = elementConfigurationCount;
       }//if ( ElementConfiguration[elementConfigurationCount][ElementRankName] == children[childrenCount][NodeRankName] )        
      }//for ( elementConfigurationCount = 0, elementConfigurationIndex = -1; elementConfigurationCount < elementConfigurationTotal; ++elementConfigurationCount )       
     
      //Element not found; therefore, do not process.
      if ( elementConfigurationIndex == -1 )
      {
       continue;        
      }//if ( elementConfigurationIndex == -1 )
        
      oleDbCommand = new OleDbCommand
      ( 
       ElementConfiguration[elementConfigurationIndex][ElementRankStoredProcedure], 
       oleDbConnection 
      );
      
      oleDbCommand.CommandType = CommandType.StoredProcedure;
      OleDbCommandBuilder.DeriveParameters(  oleDbCommand );
      oleDbParameterCollection       = oleDbCommand.Parameters;
      oleDbParameterCollectionTotal  = oleDbParameterCollection.Count;
     
      xPathNavigatorGrandChildren    = xPathNodeIteratorChildren.Current;
      xPathNodeIteratorGrandChildren = xPathNavigatorGrandChildren.SelectChildren( XPathNodeType.Element );
      grandChildrenCount             = -1;
      grandChildrenTotal             = xPathNodeIteratorGrandChildren.Count;
      grandChildren                  = new string[grandChildrenTotal][];

      while ( xPathNodeIteratorGrandChildren.MoveNext() )
      {
       ++grandChildrenCount;        
       grandChildren[grandChildrenCount] = new string[2];        
       grandChildren[grandChildrenCount][NodeRankName]  = xPathNodeIteratorGrandChildren.Current.Name.Trim();
       grandChildren[grandChildrenCount][NodeRankValue] = xPathNodeIteratorGrandChildren.Current.ToString().Trim();
       grandChildrenValueLength                         = grandChildren[grandChildrenCount][NodeRankValue].Length;
       for 
       ( 
        oleDbParameterCollectionCount = 0, oleDbParameterCollectionIndex = -1; 
        oleDbParameterCollectionCount < oleDbParameterCollectionTotal; 
        ++oleDbParameterCollectionCount
       ) 
       {
        if ( string.Compare ( grandChildren[grandChildrenCount][NodeRankName], oleDbParameterCollection[oleDbParameterCollectionCount].ParameterName, true ) == 0 )
        {
         oleDbParameterCollectionIndex = oleDbParameterCollectionCount;
         switch ( oleDbParameterCollection[oleDbParameterCollectionCount].OleDbType )
         {
          case OleDbType.DBTimeStamp:
           if ( grandChildrenValueLength == 12 || grandChildrenValueLength == 14 )
           {
            dateTime = UtilityDateTimeParse.DateTimeParse( grandChildren[grandChildrenCount][NodeRankValue] );
           }//if ( grandChildrenValueLength == 12 || grandChildrenValueLength == 14 )
           else if ( grandChildrenValueLength == 33 )
           {
            dateTime = XmlConvert.ToDateTime( grandChildren[grandChildrenCount][NodeRankValue] ); 
           }//else if ( grandChildren[grandChildrenCount][NodeRankValue].Length == 33 )            
           oleDbParameterCollection[oleDbParameterCollectionCount].Value = dateTime; 
           break;
          
          default:                 
           oleDbParameterCollection[oleDbParameterCollectionCount].Value = grandChildren[grandChildrenCount][NodeRankValue];
           break;
         }//switch ( oleDbParameterCollection[oleDbParameterCollectionCount].OleDbType )
         break; 
        }//if ( string.Compare ( grandChildren[grandChildrenCount][NodeRankName], oleDbParameterCollection[oleDbParameterCollectionCount].ParameterName, true ) == 0 )
       }//foreach ( OleDbParameter oleDbParameter in oleDbParameters )
       #if ( DEBUG )
        if ( oleDbParameterCollectionIndex > -1 ) //Database Parameter Found.
        {
         System.Console.WriteLine
         (        
          "OleDbParameter Name: {0} | Type: {1} | Value: {2}",
          oleDbParameterCollection[oleDbParameterCollectionIndex].ParameterName,
          oleDbParameterCollection[oleDbParameterCollectionIndex].OleDbType,
          oleDbParameterCollection[oleDbParameterCollectionIndex].Value           
         );
        }//Database Parameter Found.
        else
        {
         System.Console.WriteLine
         (        
          "GrandChildren Name: {0} | Value: {1}",
          grandChildren[grandChildrenCount][NodeRankName],
          grandChildren[grandChildrenCount][NodeRankValue]
         );
        }//Database Parameter Not Found.
        #endif            
      }//while ( xPathNodeIteratorGrandChildren.MoveNext() )

      for 
      ( 
       oleDbParameterCollectionCount = 0; 
       oleDbParameterCollectionCount < oleDbParameterCollectionTotal; 
       ++oleDbParameterCollectionCount
      )
      {
       switch ( oleDbParameterCollection[oleDbParameterCollectionCount].OleDbType )
       {
        case OleDbType.Guid:
         if ( oleDbParameterCollection[oleDbParameterCollectionCount].Value == null )
         {
          oleDbParameterCollection[oleDbParameterCollectionCount].Value = System.Guid.NewGuid();  
         }   
         break;
       }//switch ( oleDbParameterCollection[oleDbParameterCollectionCount].OleDbType )
      }//for ( oleDbParameterCollectionCount = 0; oleDbParameterCollectionCount < oleDbParameterCollectionTotal; ++oleDbParameterCollectionCount )

      oleDbCommand.ExecuteNonQuery();
     }//while ( xPathNodeIteratorChildren.MoveNext() )
    }//try    
    catch( OleDbException oleDbException )
    {
     exceptionMessage = UtilityEventLog.WriteEntryOleDbErrorCollection( oleDbException );
     System.Console.WriteLine("OleDbException: {0}", exceptionMessage);
    }//catch( OleDbException oleDbException )
    catch( IOException ioException )
    {
     System.Console.WriteLine("IOException: {0}", ioException.Message);
    }//catch( OleDbException oleDbException )
    catch( XPathException xPathException )
    {
     System.Console.WriteLine("XPathException: {0}", xPathException.Message );
    }//catch( XPathException xPathException )
    catch( XmlException xmlException )
    {
     System.Console.WriteLine("XmlException: {0}", xmlException.Message);
    }//catch(XmlException xmlEx)
    catch( Exception exception )
    {
     System.Console.WriteLine( "Exception: {0}", exception.Message );
    }//catch(Exception ex)
   }//foreach ( string xmlDocumentFilename in xmlDocumentFilenames )
   
   //Close the database connection.
   UtilityDatabase.DatabaseConnectionHouseKeeping( oleDbConnection, ref exceptionMessage );
   
  }//static void XmlParse( string[] xmlDocumentFilenames )
Beispiel #7
0
        }//main()

        ///<summary>Stub.</summary>
        public static void FileImport
        (
            ref String databaseConnectionString,
            ref AccountChartArgument accountChartArgument,
            ref String exceptionMessage
        )
        {
            int dataFileIndex = 0;
            int sQLStatementAttributeIndex        = -1;
            int sQLStatementAttributeIndexCurrent = -1;
            int streamRecordIndex = 0;

            String databaseStatementUpdate   = null;
            String databaseStatementTruncate = null;

            String directoryNameRoot = null;
            String fileNameCurrent   = null;
            String fileNamePattern   = null;
            String streamColumn      = null;
            String streamRecord      = null;


            StringBuilder[] stringBuilderStreamColumn = null;

            ArrayList arrayListDirectoryName = null;
            ArrayList arrayListFileName      = null;

            OleDbConnection oleDbConnection = null;

            stringBuilderStreamColumn = new StringBuilder[SQLStatementAttribute.Length];

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                databaseConnectionString,
                ref exceptionMessage
                              );

            if (accountChartArgument.TableTruncate)
            {
                databaseStatementTruncate = String.Format
                                            (
                    SQLStatementTruncate,
                    SQLStatementClass
                                            );

                UtilityDebug.Write(databaseStatementTruncate);

                UtilityDatabase.DatabaseNonQuery
                (
                    oleDbConnection,
                    ref exceptionMessage,
                    databaseStatementTruncate
                );
            }//if ( accountChartArgument.TableTruncate )

            try
            {
                for (dataFileIndex = 0; dataFileIndex < accountChartArgument.dataFile.Length; ++dataFileIndex)
                {
                    UtilityDirectory.Dir
                    (
                        ref accountChartArgument.dataFile[dataFileIndex],
                        ref directoryNameRoot,
                        ref fileNamePattern,
                        ref arrayListDirectoryName,
                        ref arrayListFileName
                    );

                    UtilityDebug.Write
                    (
                        String.Format
                        (
                            "accountChartArgument.dataFile[{0}]: {1}",
                            dataFileIndex,
                            accountChartArgument.dataFile[dataFileIndex]
                        )
                    );

                    foreach (object fileNameObject in arrayListFileName)
                    {
                        fileNameCurrent = fileNameObject.ToString();

                        UtilityDebug.Write
                        (
                            String.Format
                            (
                                "fileNameCurrent: {0}",
                                fileNameCurrent
                            )
                        );

                        // Create an instance of StreamReader to read from a file.
                        // The using statement also closes the StreamReader.
                        using (StreamReader streamReader = new StreamReader(fileNameCurrent))
                        {
                            while (true)
                            {
                                //Read and display lines from the file until the end of the file is reached.
                                streamRecord = streamReader.ReadLine();

                                if (streamRecord == null)
                                {
                                    break;
                                }//if ( streamRecord == null )

                                /*
                                 * UtilityDebug.Write
                                 * (
                                 * String.Format
                                 * (
                                 * "streamRecord: {0}",
                                 * streamRecord
                                 * )
                                 * );
                                 */

                                for
                                (
                                    sQLStatementAttributeIndex = 0;
                                    sQLStatementAttributeIndex < SQLStatementAttribute.Length;
                                    ++sQLStatementAttributeIndex
                                )
                                {
                                    streamRecordIndex = streamRecord.IndexOf
                                                        (
                                        SQLStatementAttribute[sQLStatementAttributeIndex][SQLStatementAttributeRankName]
                                                        );

                                    if (streamRecordIndex == 0)
                                    {
                                        sQLStatementAttributeIndexCurrent = sQLStatementAttributeIndex;
                                        break;
                                    } //if ( streamRecordIndex == 0 )
                                }     //for

                                if (sQLStatementAttributeIndexCurrent == -1)
                                {
                                    continue;
                                }//if ( sQLStatementAttributeIndexCurrent == -1 )

                                streamRecord = streamRecord.Trim();

                                streamRecord = streamRecord.Replace("'", "''");

                                if (sQLStatementAttributeIndex < SQLStatementAttribute.Length)
                                {
                                    streamColumn = streamRecord.Substring(SQLStatementAttribute[sQLStatementAttributeIndexCurrent][SQLStatementAttributeRankName].Length + 1);
                                    streamColumn = streamColumn.Trim();
                                    stringBuilderStreamColumn[sQLStatementAttributeIndexCurrent] = new StringBuilder(streamColumn);
                                }
                                else
                                {
                                    streamColumn = streamRecord.Trim();
                                    stringBuilderStreamColumn[sQLStatementAttributeIndexCurrent].Append(streamColumn);
                                }

                                /*
                                 * UtilityDebug.Write
                                 * (
                                 * String.Format
                                 * (
                                 * "Name: {0} | Value: {1}",
                                 * SQLStatementAttribute[ sQLStatementAttributeIndexCurrent ][ SQLStatementAttributeRankName ],
                                 * stringBuilderStreamColumn[ sQLStatementAttributeIndexCurrent ]
                                 * )
                                 * );
                                 */

                                if (sQLStatementAttributeIndexCurrent != SQLStatementAttribute.Length - 1)
                                {
                                    continue;
                                }//if ( sQLStatementAttributeIndexCurrent < SQLStatementAttribute.Length - 1 )

                                databaseStatementUpdate = String.Format
                                                          (
                                    SQLStatementUpdate,
                                    SQLStatementClass,
                                    stringBuilderStreamColumn[SQLStatementAttributeIndexAccountNumber],
                                    SQLStatementAttribute[SQLStatementAttributeIndexAccountTitle][SQLStatementAttributeRankAlias],
                                    SQLStatementAttribute[SQLStatementAttributeIndexAccountNumber][SQLStatementAttributeRankAlias],
                                    SQLStatementAttribute[SQLStatementAttributeIndexNormalBalance][SQLStatementAttributeRankAlias],
                                    SQLStatementAttribute[SQLStatementAttributeIndexDefinition][SQLStatementAttributeRankAlias],
                                    stringBuilderStreamColumn[SQLStatementAttributeIndexAccountTitle],
                                    stringBuilderStreamColumn[SQLStatementAttributeIndexNormalBalance],
                                    stringBuilderStreamColumn[SQLStatementAttributeIndexDefinition]
                                                          );

                                /*
                                 * UtilityDebug.Write( databaseStatementUpdate );
                                 */

                                UtilityDatabase.DatabaseNonQuery
                                (
                                    oleDbConnection,
                                    ref exceptionMessage,
                                    databaseStatementUpdate
                                );

                                if (exceptionMessage != null)
                                {
                                    UtilityDebug.Write
                                    (
                                        String.Format
                                        (
                                            "databaseStatementUpdate: {0}",
                                            databaseStatementUpdate
                                        )
                                    );
                                }
                            } //while ( true )
                        }     //using (StreamReader streamReader = new StreamReader(fileNameCurrent))
                    }         //foreach ( object fileNameCurrent in arrayListFileName )
                }             //for ( dataFileIndex = 0; dataFileIndex < accountChartArgument.dataFile.Length; ++dataFileIndex )
            }                 //try
            catch (Exception exception)
            {
                UtilityDebug.Write
                (
                    String.Format
                    (
                        "Exception: {0}",
                        exception.Message
                    )
                );
            }//catch ( Exception exception )

            UtilityDatabase.DatabaseConnectionHouseKeeping
            (
                oleDbConnection,
                ref exceptionMessage
            );
        }//public static void FileImport()
Beispiel #8
0
  }//Main()
 
  ///<summary>The Import File.</summary>
  ///<param name="databaseConnectionString">The database connection string.</param>
  ///<param name="uriImportFileName">The file names to import.</param>
  public static void URIImportFile
  (
   string   databaseConnectionString,
   string[] uriImportFileName
  )
  {
   int                       importConfigurationCount       =  -1;
   int                       importConfigurationTotal       =  -1;
   int                       importType                     =  -1;

   int                       status                         =  -1;

   string                    exceptionMessage               = null;

   /*
   string                    navigatorLocalName             =  null;
   string                    navigatorValue                 =  null;
   */
   
   string                    nodeName                       =  null;
   string                    nodeValue                      =  null;
  
   DateTime                  dated                          =  DateTime.Now;
   
   Guid                      uriStatusGuid                  =  new Guid();
   
   String                    jehovah                        =  null;
   String                    keyword                        =  null;
   String                    title                          =  null;
   String                    uri                            =  null;
   
   OleDbCommand              oleDbCommandJehovah            =  null;
   OleDbCommand              oleDbCommandURI                =  null;
   OleDbCommand              oleDbCommandURIStatus          =  null;   
   
   OleDbConnection           oleDbConnection                = null;
   
   OleDbParameter            oleDbParameterJehovahDated     =  null;
   OleDbParameter            oleDbParameterJehovahJehovah   =  null;
   OleDbParameter            oleDbParameterJehovahURI       =  null;
   
   OleDbParameter            oleDbParameterURIDated         =  null;
   OleDbParameter            oleDbParameterURIKeyword       =  null;
   OleDbParameter            oleDbParameterURITitle         =  null;   
   OleDbParameter            oleDbParameterURIURI           =  null;

   OleDbParameter            oleDbParameterURIStatusDated   =  null;
   OleDbParameter            oleDbParameterURIStatusGuid    =  null;
   OleDbParameter            oleDbParameterURIStatusURI     =  null;
   OleDbParameter            oleDbParameterURIStatusStatus  =  null;   

   OleDbParameterCollection  oleDbParameterCollectionURI    = null;
   
   XmlDocument               xmlDocument                    =  null;
   XmlElement                xmlElementRoot                 =  null;
   XmlNodeList               xmlNodeListAddress             =  null;
   
   try
   {

     //Open the database connection.
     oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize( databaseConnectionString, ref exceptionMessage );

     importConfigurationTotal  =  ImportConfiguration.Length;

     foreach ( String uriImportFileNameCurrent in uriImportFileName )
     {
    
      //Determine the content of the import file based on the filename pattern for example URIChrist or URIWordEngineering
      importType  =  -1;
      for ( importConfigurationCount =  0; importConfigurationCount < importConfigurationTotal; ++importConfigurationCount )
      {
       if ( uriImportFileNameCurrent.IndexOf( ImportConfiguration[importConfigurationCount][ImportConfigurationFileNamePattern] ) > 0 )
       {
        importType = importConfigurationCount;
        break;
       }
      }
      if ( importType < 0 )
      {
       System.Console.WriteLine("{0} file name pattern.", uriImportFileNameCurrent);
       continue;
      }

      if ( !File.Exists(uriImportFileNameCurrent) )
      {
       System.Console.WriteLine("{0} Not Found.", uriImportFileNameCurrent);
       continue; 
      }      	
 
      oleDbCommandJehovah               =  new OleDbCommand( DatabaseStoredProcedureNameJehovah, oleDbConnection );
      oleDbCommandURI                   =  new OleDbCommand( ImportConfiguration[importType][ImportConfigurationStoredProcedureName], oleDbConnection );
      oleDbCommandURIStatus             =  new OleDbCommand( DatabaseStoredProcedureNameURIStatus, oleDbConnection );

      oleDbCommandJehovah.CommandType   =  CommandType.StoredProcedure;
      oleDbCommandURI.CommandType       =  CommandType.StoredProcedure;
      oleDbCommandURIStatus.CommandType =  CommandType.StoredProcedure;      
       
      oleDbParameterJehovahDated        =  oleDbCommandJehovah.Parameters.Add(ParameterDated,    OleDbType.Date);
      oleDbParameterJehovahJehovah      =  oleDbCommandJehovah.Parameters.Add(ParameterJehovah,  OleDbType.VarChar, SizeJehovah);
      oleDbParameterJehovahURI          =  oleDbCommandJehovah.Parameters.Add(ParameterURI,      OleDbType.VarChar, SizeURI);

      oleDbParameterURIDated            =  oleDbCommandURI.Parameters.Add(ParameterDated,        OleDbType.Date);
      oleDbParameterURIKeyword          =  oleDbCommandURI.Parameters.Add(ParameterKeyword,      OleDbType.VarChar, SizeKeyword);
      oleDbParameterURITitle            =  oleDbCommandURI.Parameters.Add(ParameterTitle,        OleDbType.VarChar, SizeTitle);
      oleDbParameterURIURI              =  oleDbCommandURI.Parameters.Add(ParameterURI,          OleDbType.VarChar, SizeURI);

      oleDbParameterURIStatusURI        =  oleDbCommandURIStatus.Parameters.Add(ParameterURI,    OleDbType.VarChar, SizeURI);
      oleDbParameterURIStatusDated      =  oleDbCommandURIStatus.Parameters.Add(ParameterDated,  OleDbType.Date);
      oleDbParameterURIStatusStatus     =  oleDbCommandURIStatus.Parameters.Add(ParameterStatus, OleDbType.Integer);
      oleDbParameterURIStatusGuid       =  oleDbCommandURIStatus.Parameters.Add(ParameterGuid,   OleDbType.Guid);      
    
      oleDbParameterURIStatusGuid.Direction = ParameterDirection.Output;

      oleDbParameterCollectionURI       =  oleDbCommandURI.Parameters;
      
      xmlDocument                       = new XmlDocument();
      xmlDocument.PreserveWhitespace    = false;
      xmlDocument.Load( uriImportFileNameCurrent );

      xmlElementRoot                    =  xmlDocument.DocumentElement;
      xmlNodeListAddress                =  xmlElementRoot.SelectNodes( XPathExpressionAddress );
      
      foreach ( XmlNode xmlNodeAddress in xmlNodeListAddress )
      {
       //Initialize the default values. 
       dated   = DateTime.Now;
       keyword = null;
       status  = URIStatusHTTP404FileNotFound;
       title   = null;
       uri     = AboutBlank;
       
       foreach (XmlNode xmlNodeAddressElement in xmlNodeAddress )
       {
        nodeName = xmlNodeAddressElement.Name;
        nodeValue = xmlNodeAddressElement.InnerText.Trim();
        switch (nodeName)
        {
         case NameDated: 
          if ( nodeValue != string.Empty )
          { 
           dated = XmlConvert.ToDateTime( nodeValue );
          } 
          oleDbParameterJehovahDated.Value = dated;
          oleDbParameterURIDated.Value = dated;
          oleDbParameterURIStatusDated.Value = dated;
          break;

         case NameJehovah: 
          jehovah = nodeValue;
          System.Console.WriteLine("URI: {0} | Jehovah: {1}", uri, jehovah);          
          oleDbParameterJehovahJehovah.Value  =  jehovah;
          oleDbCommandJehovah.ExecuteNonQuery();
          break;

         case NameStatus:
          if ( nodeValue != string.Empty )
          {
           status = XmlConvert.ToInt16( nodeValue );
          }            
          oleDbParameterURIStatusStatus.Value  = status;
          oleDbCommandURIStatus.ExecuteNonQuery();
          uriStatusGuid = new Guid( (oleDbParameterURIStatusGuid.Value).ToString() );
          System.Console.WriteLine
          (
           "URI: {0} | Dated: {1} | Status: {2} | Guid: {3}", 
           uri, 
           dated,
           status,
           uriStatusGuid
          );
          uri = AboutBlank;
          break;

         case NameKeyword: 
          keyword = nodeValue;
          oleDbParameterURIKeyword.Value  =  keyword;          
          break;

         case NameTitle: 
          title = nodeValue;
          oleDbParameterURITitle.Value    =  title;          
          break;

         case NameURI: 
          if ( nodeValue != string.Empty )
          {
           uri = nodeValue;
          } 
          oleDbParameterJehovahURI.Value   = uri;
          oleDbParameterURIURI.Value       = uri;
          oleDbParameterURIStatusURI.Value = uri;
          break;
        }//switch (nodeName) 	
       }//foreach (XmlNode xmlNodeAddressElement in xmlNodeAddress )
       
       if ( uri == AboutBlank ) { continue; }

       foreach ( OleDbParameter oleDbParameter in oleDbParameterCollectionURI )
       {
        System.Console.Write("{0}: {1}|", oleDbParameter, oleDbParameter.Value );
       }//foreach ( OleDbParameter oleDbParameter in oleDbParameterCollectionURI )
       System.Console.WriteLine();             
       oleDbCommandURI.ExecuteNonQuery();
       
      }//foreach ( XmlNode xmlNodeAddress in xmlNodeListAddress )
     }//for ( String URIImportFileNameCurrent in URIImportFileName )  

    //Close the database connection.
    UtilityDatabase.DatabaseConnectionHouseKeeping( oleDbConnection, ref exceptionMessage );

   }//try
   catch( OleDbException oleDbException )
   {
    exceptionMessage = UtilityEventLog.WriteEntryOleDbErrorCollection( oleDbException );
    System.Console.WriteLine("OleDbException: {0}", exceptionMessage);
   }//catch( OleDbException oleDbException )
   catch( IOException ioException )
   {
    System.Console.WriteLine("IOException: {0}", ioException.Message);
   }//catch( OleDbException oleDbException )
   catch( XPathException xPathException )
   {
     System.Console.WriteLine("XPathException: {0}", xPathException.Message );
   }//catch( XPathException xPathException )
   catch( XmlException xmlException )
   {
     System.Console.WriteLine("XMLException: {0}", xmlException.Message );
   }//catch( XmlException xmlException )
   catch( Exception exception )
   {
     System.Console.WriteLine("Exception: {0}", exception.Message );
   }//catch( Exception exception )
  }//URIImportFileName
        }//DictionaryTextFile()

        ///<summary>Search: Display the number of results.</summary>
        ///<param name="dictionaryWord">The dictionary word.</param>
        ///<param name="exceptionMessage">The exception message.</param>
        ///<param name="sbResultElement">The result element.</param>
        public static void Search
        (
            String dictionaryWord,
            ref String exceptionMessage,
            ref StringBuilder sbResultElement
        )
        {
            DataSet         dataSet         = null;
            HttpContext     httpContext     = HttpContext.Current;
            OleDbConnection oleDbConnection = null;
            StringBuilder   SQLStatement    = null;

            sbResultElement = new StringBuilder();

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                DatabaseConnectionString,
                ref exceptionMessage
                              );

            SQLStatement = new StringBuilder();
            SQLStatement.AppendFormat
            (
                SQLStatementDictionarySelect,
                dictionaryWord
            );

   #if (DEBUG)
            System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString());
   #endif

            UtilityDatabase.DatabaseQuery
            (
                DatabaseConnectionString,
                ref exceptionMessage,
                ref dataSet,
                SQLStatement.ToString(),
                CommandType.Text
            );

            if (httpContext != null && exceptionMessage != null)
            {
                httpContext.Response.Write(exceptionMessage);
            }//if ( httpContext != null )

            foreach (DataTable dataTable in dataSet.Tables)
            {
                sbResultElement.Append("<TABLE align='center'>");
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    sbResultElement.Append("<TR>");

                    /*
                     * foreach (DataColumn dataColumn in dataTable.Columns)
                     * {
                     * sbResultElement.AppendFormat
                     * (
                     * HTMLTableColumn,
                     * dataRow[dataColumn]
                     * );
                     * }//foreach (DataColumn dataColumn in dataTable.Columns)
                     */
                    sbResultElement.AppendFormat
                    (
                        HTMLTableColumn,
                        dataRow["Commentary"]
                    );
                    sbResultElement.Append("</TR>");
                } //foreach(DataRow dataRow in dataTable.Rows)
                sbResultElement.Append("</TABLE>");
            }     //foreach(DataTable dataTable in dataSet.Tables)

   #if (DEBUG)
            System.Console.WriteLine("{0}", sbResultElement);
   #endif
        }//Search()
        }//main()

        /// <summary>The dictionary text file.</summary>
        /// <param name="directorynameSource">The directory name, source, for example, ..\\ProjectGutenberg.</param>
        /// <param name="fileSearchPattern">The file search pattern, for example. *.txt.</param>
        public static void DictionaryTextFile
        (
            String directorynameSource,
            String fileSearchPattern
        )
        {
            int    lineMaximumEnglish = -1;
            int    lineNumber         = 0;
            int    sequenceOrderId    = 0;
            String filenameDictionary = null;
            String exceptionMessage   = null;
            String line = null;

            StringBuilder sbDictionary           = null;
            StringBuilder SQLStatement           = null;
            ArrayList     arrayListDirectoryname = null;
            ArrayList     arrayListFilename      = null;

            System.Collections.IEnumerator enumeratorFilename = null;

            OleDbConnection oleDbConnection = null;

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                DatabaseConnectionString,
                ref exceptionMessage
                              );

            UtilityDatabase.DatabaseNonQuery
            (
                oleDbConnection,
                ref exceptionMessage,
                SQLStatementDictionaryTruncate
            );

            UtilityDirectory.Dir
            (
                ref DirectorynameSource,
                ref fileSearchPattern,
                ref arrayListDirectoryname,
                ref arrayListFilename
            );//UtilityDirectory.Dir

            enumeratorFilename = arrayListFilename.GetEnumerator();

            while (enumeratorFilename.MoveNext())
            {
                filenameDictionary = (String)enumeratorFilename.Current;
                System.Console.WriteLine("{0}", filenameDictionary);
                sbDictionary = new StringBuilder();

                try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    using (StreamReader sr = new StreamReader(filenameDictionary))
                    {
                        bool nonEnglish    = false;
                        bool wordTranslate = false;

                        int indexEnglishAlphabet = -1;
                        int lineLength           = -1;
                        int linePosition         = -1;

                        String charCurrent = null;

                        StringBuilder wordEnglish = null;
                        StringBuilder wordKorean  = null;

                        UnicodeCategory unicodeCategoryCurrent;
                        // Read and display lines from the file until the end of
                        // the file is reached.
                        while ((line = sr.ReadLine()) != null)
                        {
                            ++lineNumber;

                            /*
                             #if (DEBUG)
                             * System.Console.WriteLine
                             * (
                             * "Line #: {0} | {1}",
                             * lineNumber,
                             * line
                             * );
                             #endif
                             */

                            line       = line.Trim();
                            lineLength = line.Length;
                            if (lineLength == 0)
                            {
                                continue;
                            }

                            if (Array.IndexOf(PunctuationSymbolAnyOf, line[0]) >= 0)
                            {
                                continue;
                            }
                            else if (line[0] == ' ')
                            {
                                continue;
                            }
                            else if (Char.IsLetter(line[0]))
                            {
                                continue;
                            }
                            else if (line[1] == '.' || line[2] == '.')
                            {
                                continue;
                            }
       #if (DEBUG)
                            System.Console.WriteLine
                            (
                                "Char.IsLetterOrDigit\nLine #: {0} | {1}",
                                lineNumber,
                                line
                            );
       #endif

                            indexEnglishAlphabet = line.IndexOfAny(EnglishAlphabetAnyOf);

                            if (indexEnglishAlphabet < 1)
                            {
                                continue;
                            }

       #if (DEBUG)
                            System.Console.WriteLine("indexEnglishAlphabet: {0}", indexEnglishAlphabet);
       #endif

                            if (indexEnglishAlphabet < 1)
                            {
                                continue;
                            }

                            nonEnglish             = false;
                            unicodeCategoryCurrent = Char.GetUnicodeCategory(line, 0);

                            switch (unicodeCategoryCurrent)
                            {
                            case UnicodeCategory.DecimalDigitNumber:
                                break;

                            case UnicodeCategory.LowercaseLetter:
                                break;

                            case UnicodeCategory.UppercaseLetter:
                                break;

                            default:
                                nonEnglish = true;
                                break;
                            }

       #if (DEBUG)
                            System.Console.WriteLine("if ( nonEnglish == false )");
       #endif

                            if (nonEnglish == false)
                            {
                                continue;
                            }

                            wordEnglish = new StringBuilder();
                            wordKorean  = new StringBuilder();

                            wordKorean.Append(line.Substring(0, indexEnglishAlphabet - 1));
                            wordEnglish.Append(line.Substring(indexEnglishAlphabet));
                            wordEnglish = wordEnglish.Replace("'", "''");

                            if (wordEnglish.Length > lineMaximumEnglish)
                            {
                                lineMaximumEnglish = lineLength;
                            }

                            /*
                             * wordEnglish   = new StringBuilder();
                             * wordKorean    = new StringBuilder();
                             * wordTranslate = false;
                             *
                             * for ( linePosition = 0; linePosition < lineLength; ++linePosition )
                             * {
                             * charCurrent = line.Substring( linePosition, 1 );
                             *
                             * if ( KoreanConsonant.Contains( line.Substring( linePosition, 2 ) )
                             * {
                             ++linePosition;
                             * }
                             *
                             * unicodeCategoryCurrent = Char.GetUnicodeCategory(line, linePosition);
                             *
                             * switch ( unicodeCategoryCurrent )
                             * {
                             * case UnicodeCategory.DecimalDigitNumber:
                             * wordTranslate = true;
                             * break;
                             *
                             * case UnicodeCategory.LowercaseLetter:
                             * wordTranslate = true;
                             * break;
                             *
                             * case UnicodeCategory.UppercaseLetter:
                             * wordTranslate = true;
                             * break;
                             * }
                             *
                             * if ( wordTranslate == false )
                             * {
                             * wordKorean.Append( charCurrent );
                             * }
                             * else
                             * {
                             * wordEnglish.Append( charCurrent );
                             * }
                             *
                             * }//for ( linePosition = 0; linePosition < lineLength; ++linePosition )
                             */

                            if (wordKorean.Length == 0 || wordEnglish.Length == 0)
                            {
                                continue;
                            }

                            ++sequenceOrderId;

       #if (DEBUG)
                            System.Console.WriteLine
                            (
                                "SequenceOrderId: {0} | Korean: {1} | English: {2}",
                                sequenceOrderId,
                                wordKorean,
                                wordEnglish
                            );
       #endif

                            SQLStatement = new StringBuilder();
                            SQLStatement.AppendFormat
                            (
                                SQLStatementDictionaryInsert,
                                sequenceOrderId,
                                wordKorean,
                                wordEnglish
                            );

                            /*
                             #if (DEBUG)
                             * System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString() );
                             #endif
                             */

                            UtilityDatabase.DatabaseNonQuery
                            (
                                oleDbConnection,
                                ref exceptionMessage,
                                SQLStatement.ToString()
                            );
                        } //while ((line = sr.ReadLine()) != null)
                    }     //using (StreamReader sr = new StreamReader("TestFile.txt"))
                }         //try
                catch (Exception e)
                {
                    System.Console.WriteLine
                    (
                        "Line #:{0} | Line: {1} | Exception: {2}",
                        lineNumber,
                        line,
                        e.Message
                    );
                } //catch (Exception e)
            }     //while ( enumeratorFilename.MoveNext() )

            UtilityDatabase.DatabaseConnectionHouseKeeping
            (
                oleDbConnection,
                ref exceptionMessage
            );

   #if (DEBUG)
            System.Console.WriteLine
            (
                "Line Maximum: {0}",
                lineMaximumEnglish
            );
   #endif
        }//DictionaryTextFile()
Beispiel #11
0
        }//DictionaryTextFile()

        ///<summary>Search: Display the number of results.</summary>
        ///<param name="dictionaryWord">The dictionary word.</param>
        ///<param name="exceptionMessage">The exception message.</param>
        ///<param name="sbResultElement">The result element.</param>
        public static void Search
        (
            string dictionaryWord,
            ref string exceptionMessage,
            ref StringBuilder sbResultElement
        )
        {
            int dictionaryIdFirst        = -1;
            int dictionaryIdFirstCurrent = -1;

            DataSet         dataSet         = null;
            HttpContext     httpContext     = HttpContext.Current;
            OleDbConnection oleDbConnection = null;

            string dictionaryWordFirst  = null;
            string dictionaryWordSecond = null;

            StringBuilder sbSynonym    = null;
            StringBuilder SQLStatement = null;

            sbResultElement = new StringBuilder();

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                DatabaseConnectionString,
                ref exceptionMessage
                              );

            SQLStatement = new StringBuilder();
            SQLStatement.AppendFormat
            (
                SQLStatementDictionarySelect,
                dictionaryWord
            );

   #if (DEBUG)
            System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString());
   #endif

            UtilityDatabase.DatabaseQuery
            (
                DatabaseConnectionString,
                ref exceptionMessage,
                ref dataSet,
                SQLStatement.ToString(),
                CommandType.Text
            );

            if (httpContext != null && exceptionMessage != null)
            {
                httpContext.Response.Write(exceptionMessage);
            }//if ( httpContext != null )

            foreach (DataTable dataTable in dataSet.Tables)
            {
                /*
                 * dictionaryIdFirstCurrent = (int) UtilityDatabase.DataSetTableRowColumn
                 * (
                 * dataSet,
                 * dataTable.TableName,
                 * 0,
                 * DatabaseColumnSelect[DatabaseColumnRankDictionaryIdFirst]
                 * );
                 */

                sbSynonym = new StringBuilder();

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    dictionaryIdFirst    = (int)dataRow[DatabaseColumnSelect[DatabaseColumnRankDictionaryIdFirst]];
                    dictionaryWordFirst  = (string)dataRow[DatabaseColumnSelect[DatabaseColumnRankDictionaryWordFirst]];
                    dictionaryWordSecond = (string)dataRow[DatabaseColumnSelect[DatabaseColumnRankDictionaryWordSecond]];

                    if (dictionaryIdFirst != dictionaryIdFirstCurrent)
                    {
                        dictionaryIdFirstCurrent = dictionaryIdFirst;

                        sbResultElement.AppendFormat
                        (
                            FormatDictionaryWord,
                            dictionaryWordFirst
                        );

                        sbResultElement.AppendFormat
                        (
                            FormatDictionarySynonym,
                            dictionaryWordSecond
                        );
                    }//if ( dictionaryIdFirst != dictionaryIdFirstCurrent )
                    else
                    {
                        sbResultElement.Append(", " + dictionaryWordSecond);
                    }
                } //foreach(DataRow dataRow in dataTable.Rows)
            }     //foreach(DataTable dataTable in dataSet.Tables)

   #if (DEBUG)
            System.Console.WriteLine("{0}", sbResultElement);
   #endif
        }//Search()
Beispiel #12
0
        }//main()

        /// <summary>The dictionary text file.</summary>
        /// <param name="directorynameSource">The directory name, source, for example, ..\\ProjectGutenberg.</param>
        /// <param name="fileSearchPattern">The file search pattern, for example. *.txt.</param>
        public static void DictionaryTextFile
        (
            string directorynameSource,
            string fileSearchPattern
        )
        {
            Boolean dictionaryBeginFlag = false;
            Boolean dictionaryEndFlag   = false;

            int dictionaryId = 0;
            int indexDigit   = -1;
            int referenceId  = -1;
            int thesaurusId  = -1;

            double referenceDouble = 0;

            object commandReturn = null;

            string dictionaryWord     = null;
            string exceptionMessage   = null;
            string filenameDictionary = null;
            string referenceWord      = null;

            string[] thesaurusWord            = null;
            string   thesaurusWordCombination = null;
            string   thesaurusWordCurrentTrim = null;

            StringBuilder sbDictionary           = null;
            StringBuilder SQLStatement           = null;
            ArrayList     arrayListDirectoryname = null;
            ArrayList     arrayListFilename      = null;

            System.Collections.IEnumerator enumeratorFilename = null;

            OleDbConnection oleDbConnection = null;

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                DatabaseConnectionString,
                ref exceptionMessage
                              );

            UtilityDatabase.DatabaseNonQuery
            (
                oleDbConnection,
                ref exceptionMessage,
                SQLStatementDictionaryTruncate
            );

            UtilityDirectory.Dir
            (
                ref DirectorynameSource,
                ref fileSearchPattern,
                ref arrayListDirectoryname,
                ref arrayListFilename
            );//UtilityDirectory.Dir

            enumeratorFilename = arrayListFilename.GetEnumerator();

            while (enumeratorFilename.MoveNext())
            {
                filenameDictionary = (string)enumeratorFilename.Current;
                System.Console.WriteLine("{0}", filenameDictionary);
                sbDictionary = new StringBuilder();

                try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    using (StreamReader sr = new StreamReader(filenameDictionary))
                    {
                        String line;
                        // Read and display lines from the file until the end of
                        // the file is reached.
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Trim().Length == 0)
                            {
                                continue;
                            }
                            if (dictionaryBeginFlag == false)
                            {
                                if (String.Compare(line.Trim(), DictionaryBegin) == 0)
                                {
                                    dictionaryBeginFlag = true;
                                }
                                continue;
                            }
                            else if (dictionaryBeginFlag == true && String.Compare(line.Trim(), DictionaryEnd) == 0)
                            {
                                dictionaryEndFlag = true;
                                break;
                            }
                            if (line[0] != ' ')
                            {
                                dictionaryWord = line.Trim();
                                dictionaryWord = dictionaryWord.Replace("'", "''");
                                SQLStatement   = new StringBuilder();
                                SQLStatement.AppendFormat
                                (
                                    SQLStatementDictionaryInsertWord,
                                    dictionaryWord
                                );
        #if (DEBUG)
                                System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString());
        #endif
                                commandReturn = UtilityDatabase.DatabaseQuery
                                                (
                                    oleDbConnection,
                                    ref exceptionMessage,
                                    SQLStatement.ToString(),
                                    CommandType.Text
                                                );
                                if (commandReturn == DBNull.Value)
                                {
                                    dictionaryId = -1;
                                }//if ( commandReturn == DBNull.Value )
                                else
                                {
                                    dictionaryId = System.Convert.ToInt32(commandReturn);
                                } //else if ( commandReturn != DBNull.Value )
                            }     //if ( line[0] != ' ' )
                            else
                            {
                                line       = line.Trim();
                                indexDigit = line.IndexOfAny(DigitsAnyOf);
                                if (indexDigit < 0)
                                {
                                    continue;
                                }
                                referenceWord   = line.Substring(indexDigit);
                                referenceDouble = System.Convert.ToDouble(referenceWord);
                                referenceId     = System.Convert.ToInt32(referenceDouble);

                                thesaurusWordCombination = line.Substring(0, indexDigit - 1);
                                thesaurusWordCombination = thesaurusWordCombination.Trim();
                                thesaurusWord            = thesaurusWordCombination.Split(ThesaurusCombinationDelimiterArray);
                                foreach (String thesaurusWordCurrent in thesaurusWord)
                                {
                                    thesaurusWordCurrentTrim = thesaurusWordCurrent.Trim();
                                    SQLStatement             = new StringBuilder();
                                    SQLStatement.AppendFormat
                                    (
                                        SQLStatementDictionaryInsertWord,
                                        thesaurusWordCurrent.Trim()
                                    );
         #if (DEBUG)
                                    System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString());
         #endif

                                    commandReturn = UtilityDatabase.DatabaseQuery
                                                    (
                                        oleDbConnection,
                                        ref exceptionMessage,
                                        SQLStatement.ToString(),
                                        CommandType.Text
                                                    );

                                    if (commandReturn == DBNull.Value)
                                    {
                                        thesaurusId = -1;
                                    }//if ( commandReturn == DBNull.Value )
                                    else
                                    {
                                        thesaurusId = System.Convert.ToInt32(commandReturn);
                                    }//else if ( commandReturn != DBNull.Value )

                                    SQLStatement = new StringBuilder();
                                    SQLStatement.AppendFormat
                                    (
                                        SQLStatementDictionaryInsertReference,
                                        dictionaryId,
                                        thesaurusId,
                                        referenceId
                                    );
         #if (DEBUG)
                                    System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString());
         #endif
                                    UtilityDatabase.DatabaseNonQuery
                                    (
                                        oleDbConnection,
                                        ref exceptionMessage,
                                        SQLStatement.ToString()
                                    );
                                } //foreach ( String thesaurusWordCurrent in thesaurusWord )
                            }     //else
                        }         //while ((line = sr.ReadLine()) != null)
                    }             //using (StreamReader sr = new StreamReader("filenameDictionary"))
                }                 //try
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                } //catch (Exception e)
            }     //while ( enumeratorFilename.MoveNext() )

            UtilityDatabase.DatabaseConnectionHouseKeeping
            (
                oleDbConnection,
                ref exceptionMessage
            );
        }//DictionaryTextFile()
Beispiel #13
0
  }//public static void DatabaseSelect()

  /// <summary>DatabaseUpdate</summary>
  public static void DatabaseUpdate
  (
   ref string                databaseConnectionString,
   ref UtilityImageArgument  utilityImageArgument,
   ref string                exceptionMessage,
   ref HtmlInputFile         htmlInputFileSource
  )
  {
   HttpContext      httpContext                   =  HttpContext.Current;
   
   int              databaseNumberOfRowsAffected  =  0;
   int              sourceContentLength           =  0;
   int              sourceContentRead             =  0;
   
   byte[]           byteSource                    =  null;
   
   string           filenameSource                =  null;
   string           sourceContentType             =  null;

   OleDbCommand     oleDbCommand                  =  null;
   OleDbConnection  oleDbConnection               =  null;
   OleDbParameter   oleDbParameter                =  null;
       
   Stream           streamSource                  =  null;
   
   try
   {
    streamSource         =  htmlInputFileSource.PostedFile.InputStream;
    sourceContentLength  =  htmlInputFileSource.PostedFile.ContentLength;
    sourceContentType    =  htmlInputFileSource.PostedFile.ContentType;
    filenameSource       =  htmlInputFileSource.Value;
    byteSource           =  new byte[ sourceContentLength ];
    
    /*
    TypeCode typeCode = Type.GetTypeCode( byteSource.GetType() );
    httpContext.Response.Write( typeCode.ToString() );
    */

    sourceContentRead    =  streamSource.Read( byteSource, 0, sourceContentLength );

    oleDbConnection      =  UtilityDatabase.DatabaseConnectionInitialize
                            ( 
                              databaseConnectionString, 
                              ref exceptionMessage 
                            );
      
    oleDbCommand         =  new OleDbCommand
                            (
                             "usp_ImageCarbonFormUpdate",
                             oleDbConnection
                            );
                            
    oleDbCommand.CommandType  =  CommandType.StoredProcedure;
                            
    oleDbParameter       =  new OleDbParameter( "@URIImage", OleDbType.VarChar, 255 );
    oleDbParameter.Value =  filenameSource;
    oleDbCommand.Parameters.Add( oleDbParameter );
    
    oleDbParameter       =  new OleDbParameter( "@ImageType", OleDbType.VarChar, 255 );
    oleDbParameter.Value =  sourceContentType;
    oleDbCommand.Parameters.Add( oleDbParameter );

    oleDbParameter       =  new OleDbParameter( "@ImageCarbonFormMatch", OleDbType.Binary );
    oleDbParameter.Value =  byteSource;
    oleDbCommand.Parameters.Add( oleDbParameter );

    databaseNumberOfRowsAffected = oleDbCommand.ExecuteNonQuery();
    
   }//try
   catch ( Exception exception )
   {
    exceptionMessage = "Exception: " + exception.Message;
   }//catch ( Exception exception )
   finally
   {
    if ( oleDbConnection != null )
    {
   	 oleDbConnection.Close();
   	}//if ( oleDbConnection != null ) 
   }//finally	

   if ( exceptionMessage != null )
   {
    if ( httpContext == null )
    {
     System.Console.WriteLine( exceptionMessage );
    }//if ( httpContext == null )
    else
    {
     //httpContext.Response.Write( exceptionMessage );
    }//else 
   }//if ( exceptionMessage != null )
     
  }//public static void DatabaseUpdate()
Beispiel #14
0
  }//RegularExpressionPattern

  ///<summary>RegularExpressionInsert</summary>
  public static void RegularExpressionInsert
  (
   ref string    databaseConnectionString,
   ref int       sequenceOrderId,
   ref string    input,
   ref string    pattern,
   ref string    replace,
   ref string    title,
   ref string    uri,
   ref DateTime  dated,
   ref string    exceptionMessage
  )
  {
   HttpContext      httpContext      =  HttpContext.Current;
   int              executeNonQuery  =  -1;
   OleDbCommand     oleDbCommand     =  null;
   OleDbConnection  oleDbConnection  =  null;

   try
   {
    oleDbConnection  =  UtilityDatabase.DatabaseConnectionInitialize( databaseConnectionString, ref exceptionMessage );
    if ( exceptionMessage != null || oleDbConnection == null )
    {
     return;
    }//if ( exceptionMessage != null || oleDbConnection == null )
    oleDbCommand = new OleDbCommand( DatabaseStoredProcedureInsert, oleDbConnection );
    oleDbCommand.CommandType = CommandType.StoredProcedure;
    if ( sequenceOrderId > 0 )
    {
     oleDbCommand.Parameters.AddWithValue( "@sequenceOrderId", sequenceOrderId );
    }
    else
    {
     oleDbCommand.Parameters.AddWithValue( "@sequenceOrderId", DBNull.Value );
    }
    if ( !dated.Equals( DateTime.MinValue ) )
    {
     oleDbCommand.Parameters.AddWithValue( "@dated", dated );
    }
    else
    {
     oleDbCommand.Parameters.AddWithValue( "@dated", DBNull.Value );
    }
    oleDbCommand.Parameters.AddWithValue( "@input", @input );
    oleDbCommand.Parameters.AddWithValue( "@pattern", @pattern );
    oleDbCommand.Parameters.AddWithValue( "@replace", @replace );
    oleDbCommand.Parameters.AddWithValue( "@title", @title );
    oleDbCommand.Parameters.AddWithValue( "@uri", @uri );
    executeNonQuery = oleDbCommand.ExecuteNonQuery();
   }//try
   catch ( System.Exception exception )
   {
   	exceptionMessage = "System.Exception: " + exception.Message;
   }//catch ( System.Exception exception )
   if ( exceptionMessage != null || executeNonQuery < 1 )
   {
    System.Console.WriteLine( exceptionMessage );
    return;
   }//if ( exceptionMessage != null || executeNonQuery < 1 )
   UtilityDatabase.DatabaseConnectionHouseKeeping( oleDbConnection, ref exceptionMessage );
   if ( exceptionMessage != null || oleDbConnection != null )
   {
    return;
   }//if ( exceptionMessage != null || oleDbConnection != null )
  }//public static void RegularExpressionInsert()
Beispiel #15
0
        }//main()

        ///<summary>Stub.</summary>
        public static void FileImport
        (
            ref String databaseConnectionString,
            ref InternetDictionaryProjectIDPArgument internetDictionaryProjectIDPArgument,
            ref String exceptionMessage
        )
        {
            bool[] databaseTruncate = null;

            int dataFileIndex = 0;

            int dictionaryCommentaryIndex     = -1;
            int dictionaryLanguageIndex       = -1;
            int dictionaryLanguageIndexFirst  = -1;
            int dictionaryLanguageIndexSecond = -1;

            int dictionaryLanguageIndexPosition       = -1;
            int dictionaryLanguageIndexPositionFirst  = -1;
            int dictionaryLanguageIndexPositionSecond = -1;

            String databaseStatementUpdate   = null;
            String databaseStatementTruncate = null;

            String dictionaryWord       = null;
            String dictionaryCommentary = null;

            String directoryNameRoot = null;
            String fileNameCurrent   = null;
            String fileNamePattern   = null;
            String streamRecord      = null;

            ArrayList arrayListDirectoryName = null;
            ArrayList arrayListFileName      = null;

            OleDbConnection oleDbConnection = null;

            databaseTruncate = new bool[DictionaryLanguage.Length];

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                databaseConnectionString,
                ref exceptionMessage
                              );

            try
            {
                for (dataFileIndex = 0; dataFileIndex < internetDictionaryProjectIDPArgument.dataFile.Length; ++dataFileIndex)
                {
                    UtilityDirectory.Dir
                    (
                        ref internetDictionaryProjectIDPArgument.dataFile[dataFileIndex],
                        ref directoryNameRoot,
                        ref fileNamePattern,
                        ref arrayListDirectoryName,
                        ref arrayListFileName
                    );

                    foreach (object fileNameObject in arrayListFileName)
                    {
                        fileNameCurrent = fileNameObject.ToString();

                        dictionaryLanguageIndexFirst         = -1;
                        dictionaryLanguageIndexPositionFirst = 0;

                        dictionaryLanguageIndexSecond         = -1;
                        dictionaryLanguageIndexPositionSecond = 0;

                        for (dictionaryLanguageIndex = 0; dictionaryLanguageIndex < DictionaryLanguage.Length; ++dictionaryLanguageIndex)
                        {
                            dictionaryLanguageIndexPosition = fileNameCurrent.IndexOf(DictionaryLanguage[dictionaryLanguageIndex]);

                            if (dictionaryLanguageIndexPosition < 0)
                            {
                                continue;
                            }//if ( dictionaryLanguageIndexPosition < 0 )
                            else if (dictionaryLanguageIndexFirst <= -1)
                            {
                                dictionaryLanguageIndexPositionFirst = dictionaryLanguageIndexPosition;
                                dictionaryLanguageIndexFirst         = dictionaryLanguageIndex;
                            }//else if ( dictionaryLanguageIndexFirst <= -1 )
                            else if (dictionaryLanguageIndexPosition < dictionaryLanguageIndexPositionFirst)
                            {
                                dictionaryLanguageIndexPositionSecond = dictionaryLanguageIndexPositionFirst;
                                dictionaryLanguageIndexPositionFirst  = dictionaryLanguageIndexPosition;

                                dictionaryLanguageIndexSecond = dictionaryLanguageIndexFirst;
                                dictionaryLanguageIndexFirst  = dictionaryLanguageIndex;
                            }//else if ( dictionaryLanguageIndexPositionFirst < 0 )
                            else
                            {
                                dictionaryLanguageIndexPositionSecond = dictionaryLanguageIndexPosition;
                                dictionaryLanguageIndexSecond         = dictionaryLanguageIndex;
                            } //else
                        }     //for ( dictionaryLanguageIndex = 0; dictionaryLanguageIndex <= DictionaryLanguage.Length; ++dictionaryLanguageIndex )

                        /*
                         * UtilityDebug.Write
                         * (
                         * String.Format
                         * (
                         * "Language First: {0} | Second: {1} | First Position: {2} | Second Position: {3}",
                         * DictionaryLanguage[dictionaryLanguageIndexFirst],
                         * DictionaryLanguage[dictionaryLanguageIndexSecond],
                         * dictionaryLanguageIndexPositionFirst,
                         * dictionaryLanguageIndexPositionSecond
                         * )
                         * );
                         */

                        if (internetDictionaryProjectIDPArgument.TableTruncate && databaseTruncate[dictionaryLanguageIndexFirst] == false)
                        {
                            databaseTruncate[dictionaryLanguageIndexFirst] = true;

                            databaseStatementTruncate = String.Format
                                                        (
                                SQLStatementDictionaryTruncate,
                                DictionaryLanguage[dictionaryLanguageIndexFirst] + "Dictionary"
                                                        );

                            UtilityDebug.Write(databaseStatementTruncate);

                            UtilityDatabase.DatabaseNonQuery
                            (
                                oleDbConnection,
                                ref exceptionMessage,
                                databaseStatementTruncate
                            );
                        }
                        ;//if ( internetDictionaryProjectIDPArgument.TableTruncate )

                        // Create an instance of StreamReader to read from a file.
                        // The using statement also closes the StreamReader.
                        using (StreamReader streamReader = new StreamReader(fileNameCurrent))
                        {
                            while (true)
                            {
                                //Read and display lines from the file until the end of the file is reached.
                                streamRecord = streamReader.ReadLine();

                                if (streamRecord == null)
                                {
                                    break;
                                }//if ( streamRecord == null )

                                UtilityDebug.Write
                                (
                                    String.Format
                                    (
                                        "streamRecord: {0}",
                                        streamRecord
                                    )
                                );

                                if (streamRecord[0] == '#')
                                {
                                    continue;
                                }//if ( streamRecord[0] == '#' )

                                dictionaryCommentaryIndex = streamRecord.IndexOf('\t');

                                if (dictionaryCommentaryIndex <= -1)
                                {
                                    continue;
                                }//if ( dictionaryCommentaryIndex <= -1 )

                                dictionaryWord       = streamRecord.Substring(0, dictionaryCommentaryIndex);
                                dictionaryCommentary = (streamRecord.Substring(dictionaryCommentaryIndex)).Trim();

                                databaseStatementUpdate = String.Format
                                                          (
                                    SQLStatementDictionaryUpdate,
                                    DictionaryLanguage[dictionaryLanguageIndexFirst] + "Word",
                                    DictionaryLanguage[dictionaryLanguageIndexFirst] + "Dictionary",
                                    dictionaryWord,
                                    DictionaryLanguage[dictionaryLanguageIndexSecond] + "Commentary",
                                    dictionaryCommentary
                                                          );

                                UtilityDebug.Write(databaseStatementUpdate);

                                UtilityDatabase.DatabaseNonQuery
                                (
                                    oleDbConnection,
                                    ref exceptionMessage,
                                    databaseStatementUpdate
                                );
                            } //while ( true )
                        }     //using (StreamReader streamReader = new StreamReader(fileNameCurrent))
                    }         //foreach ( object fileNameCurrent in arrayListFileName )
                }             //for ( dataFileIndex = 0; dataFileIndex < internetDictionaryProjectIDPArgument.dataFile.Length; ++dataFileIndex )
            }                 //try
            catch (Exception exception)
            {
                UtilityDebug.Write
                (
                    String.Format
                    (
                        "Exception: {0}",
                        exception.Message
                    )
                );
            }//catch ( Exception exception )

            UtilityDatabase.DatabaseConnectionHouseKeeping
            (
                oleDbConnection,
                ref exceptionMessage
            );
        }//public static void FileImport()
        }//main()

        /// <summary>The dictionary text file.</summary>
        /// <param name="directorynameSource">The directory name, source, for example, ..\\ProjectGutenberg.</param>
        /// <param name="fileSearchPattern">The file search pattern, for example. *.txt.</param>
        public static void DictionaryTextFile
        (
            string directorynameSource,
            string fileSearchPattern
        )
        {
            int indexEntryStart    = -1;
            int indexEntryEnd      = -1;
            int indexParagraphPage = -1;
            int indexPoint26       = -1;
            int indexWordEnd       = -1;

            string filenameDictionary = null;
            string dictionaryFile     = null;
            string exceptionMessage   = null;
            string indexEntry         = null;
            string indexWord          = null;

            StringBuilder sbDictionary           = null;
            StringBuilder SQLStatement           = null;
            ArrayList     arrayListDirectoryname = null;
            ArrayList     arrayListFilename      = null;

            System.Collections.IEnumerator enumeratorFilename = null;

            OleDbConnection oleDbConnection = null;

            oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
                              (
                DatabaseConnectionString,
                ref exceptionMessage
                              );

            UtilityDatabase.DatabaseNonQuery
            (
                oleDbConnection,
                ref exceptionMessage,
                SQLStatementDictionaryTruncate
            );

            UtilityDirectory.Dir
            (
                ref DirectorynameSource,
                ref fileSearchPattern,
                ref arrayListDirectoryname,
                ref arrayListFilename
            );//UtilityDirectory.Dir

            enumeratorFilename = arrayListFilename.GetEnumerator();

            while (enumeratorFilename.MoveNext())
            {
                filenameDictionary = (string)enumeratorFilename.Current;
                System.Console.WriteLine("{0}", filenameDictionary);
                sbDictionary = new StringBuilder();

                try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    using (StreamReader sr = new StreamReader(filenameDictionary))
                    {
                        String line;
                        // Read and display lines from the file until the end of
                        // the file is reached.
                        while ((line = sr.ReadLine()) != null)
                        {
                            sbDictionary.Append(line);
                            //System.Console.WriteLine(line);
                        } //while ((line = sr.ReadLine()) != null)
                    }     //using (StreamReader sr = new StreamReader("TestFile.txt"))

                    dictionaryFile = sbDictionary.ToString();
                    indexPoint26   = dictionaryFile.IndexOf(ParagraphPoint26);
     #if (DEBUG)
                    System.Console.WriteLine("ParagraphPoint26: {0}", indexPoint26);
     #endif

                    indexEntryStart = dictionaryFile.IndexOf(ParagraphHW, indexPoint26);

                    while (indexEntryStart > 0)
                    {
                        indexEntryEnd = dictionaryFile.IndexOf(ParagraphHW, indexEntryStart + 1);

                        if (indexEntryEnd > 0)
                        {
                            indexEntry = dictionaryFile.Substring(indexEntryStart, indexEntryEnd - indexEntryStart);
                        }
                        else
                        {
                            indexEntry         = dictionaryFile.Substring(indexEntryStart);
                            indexParagraphPage = indexEntry.LastIndexOf(ParagraphPage);
                            if (indexParagraphPage >= 0)
                            {
                                indexEntry = indexEntry.Substring(indexEntry.Length - indexParagraphPage);
                            }
                            break;
                        }//if ( indexEntryEnd <= 0 )

                        indexWordEnd = indexEntry.IndexOf(AnchorEndHW);
                        if (indexWordEnd < 0)
                        {
                            indexEntryStart = indexEntryEnd;
                            continue;
                        }
                        indexWord = indexEntry.Substring(IndexHWWordStart, indexWordEnd - IndexHWWordStart);
                        for (int indexReplace = 0; indexReplace < DictionaryWordReplace.Length; ++indexReplace)
                        {
                            indexWord = indexWord.Replace
                                        (
                                DictionaryWordReplace[indexReplace][0],
                                DictionaryWordReplace[indexReplace][1]
                                        );
                            indexEntry = indexEntry.Replace
                                         (
                                DictionaryWordReplace[indexReplace][0],
                                DictionaryWordReplace[indexReplace][1]
                                         );
                        }

      #if (DEBUG)
                        System.Console.WriteLine
                        (
                            "Index Entry Start: {0} | End: {1} | Word: {2} | Entry: {3}",
                            indexEntryStart,
                            indexEntryEnd,
                            indexWord,
                            indexEntry
                        );
      #endif

                        SQLStatement = new StringBuilder();
                        SQLStatement.AppendFormat
                        (
                            SQLStatementDictionaryInsert,
                            indexWord,
                            indexEntry
                        );

      #if (DEBUG)
                        System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString());
      #endif

                        UtilityDatabase.DatabaseNonQuery
                        (
                            oleDbConnection,
                            ref exceptionMessage,
                            SQLStatement.ToString()
                        );

                        indexEntryStart = indexEntryEnd;
                    } //while ( indexEntryStart > 0 )
                }     //try
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                }
            }//while ( enumeratorFilename.MoveNext() )

            UtilityDatabase.DatabaseConnectionHouseKeeping
            (
                oleDbConnection,
                ref exceptionMessage
            );
        }//DictionaryTextFile()