Example #1
0
        /// <summary>The entry point for the application.</summary>
        /// <param name="argv">A list of arguments</param>
        public static void Main(String[] argv)
        {
            Boolean booleanParseCommandLineArguments = false;
            String  exceptionMessage = null;

            StringBuilder internetDictionaryProjectIDPSQL   = null;
            StringBuilder internetDictionaryProjectIDPQuery = null;

            IDataReader iDataReader = null;

            InternetDictionaryProjectIDPArgument internetDictionaryProjectIDPArgument = null;

            internetDictionaryProjectIDPArgument = new InternetDictionaryProjectIDPArgument();

            booleanParseCommandLineArguments = UtilityParseCommandLineArgument.ParseCommandLineArguments
                                               (
                argv,
                internetDictionaryProjectIDPArgument
                                               );

            if (booleanParseCommandLineArguments == false)
            {
                // error encountered in arguments. Display usage message
                UtilityDebug.Write
                (
                    UtilityParseCommandLineArgument.CommandLineArgumentsUsage(typeof(InternetDictionaryProjectIDPArgument))
                );
                return;
            }//if ( booleanParseCommandLineArguments  == false )

            if (internetDictionaryProjectIDPArgument.DataFile != null && internetDictionaryProjectIDPArgument.DataFile.Length != 0)
            {
                FileImport
                (
                    ref DatabaseConnectionString,
                    ref internetDictionaryProjectIDPArgument,
                    ref exceptionMessage
                );
            }//if ( internetDictionaryProjectIDPArgument.DataFile != null && internetDictionaryProjectIDPArgument.DataFile != String.Empty )

            Query
            (
                ref DatabaseConnectionString,
                ref exceptionMessage,
                ref internetDictionaryProjectIDPArgument,
                ref internetDictionaryProjectIDPSQL,
                ref internetDictionaryProjectIDPQuery,
                ref iDataReader
            );
        }//main()
  }//public String SpanishCommentary

  /// <summary>ButtonSubmit_Click().</summary>
  public void ButtonSubmit_Click
  (
   Object sender, 
   EventArgs e
  )
  {

   String                                       exceptionMessage                                    =  null;
   
   StringBuilder                                internetDictionaryProjectIDPSQL                     =  null;
   StringBuilder                                internetDictionaryProjectIDPQuery                   =  null;   

   IDataReader                                  iDataReader                                         =  null;

   InternetDictionaryProjectIDPArgument         internetDictionaryProjectIDPArgument                =  null;

   internetDictionaryProjectIDPArgument = new InternetDictionaryProjectIDPArgument
   (
    EnglishWord,
    FrenchCommentary,
    GermanCommentary,
    ItalianCommentary,
    LatinCommentary,
    PortugueseCommentary,
    SpanishCommentary
   );

   InternetDictionaryProjectIDP.ConfigurationXml
   (
    ref FilenameConfigurationXml,
    ref exceptionMessage,
    ref DatabaseConnectionString,
    ref DatabaseFile
   );

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

   InternetDictionaryProjectIDP.Query
   (
    ref DatabaseConnectionString,
    ref exceptionMessage,
    ref internetDictionaryProjectIDPArgument,
    ref internetDictionaryProjectIDPSQL,
    ref internetDictionaryProjectIDPQuery,
    ref iDataReader
   );

   if ( exceptionMessage != null || iDataReader == null )
   {
    Feedback = exceptionMessage;
   	return;
   }//if ( exceptionMessage != null || iDataReader == null )
   
   RepeaterInternetDictionaryProjectIDP.DataSource = iDataReader;
   RepeaterInternetDictionaryProjectIDP.DataBind();
 
  }//public void ButtonSubmit_Click()
Example #3
0
        }//public static void FileImport()

        /// <summary>Query.</summary>
        public static void Query
        (
            ref String databaseConnectionString,
            ref String exceptionMessage,
            ref InternetDictionaryProjectIDPArgument internetDictionaryProjectIDPArgument,
            ref StringBuilder internetDictionaryProjectIDPSQL,
            ref StringBuilder internetDictionaryProjectIDPQuery,
            ref IDataReader iDataReader
        )
        {
            String internetDictionaryProjectIDPResult       = null;
            Type   typeInternetDictionaryProjectIDPArgument = internetDictionaryProjectIDPArgument.GetType();

            UtilityProperty.TypeInformation
            (
                internetDictionaryProjectIDPArgument,
                ref typeInternetDictionaryProjectIDPArgument,
                ref internetDictionaryProjectIDPQuery,
                ref DictionaryLanguageSQLQuery
            );

            internetDictionaryProjectIDPSQL = new StringBuilder(SQLStatementDictionarySelect);

            internetDictionaryProjectIDPSQL.Append(SQLStatementDictionaryFrom);

            if (internetDictionaryProjectIDPQuery != null)
            {
                internetDictionaryProjectIDPSQL.Append(SQLStatementDictionaryWhere);
                internetDictionaryProjectIDPSQL.Append(internetDictionaryProjectIDPQuery);
            }//if ( internetDictionaryProjectIDPQuery != null )

            internetDictionaryProjectIDPSQL.Append(SQLStatementDictionaryOrder);

            UtilityDebug.Write(internetDictionaryProjectIDPSQL);

            try
            {
                UtilityDatabase.DatabaseQuery
                (
                    databaseConnectionString,
                    ref exceptionMessage,
                    ref iDataReader,
                    internetDictionaryProjectIDPSQL.ToString(),
                    CommandType.Text
                );

    #if (DEBUG)
                while (iDataReader.Read())
                {
                    internetDictionaryProjectIDPResult = String.Format
                                                         (
                        SQLStatementDictionaryFormat,
                        iDataReader.GetValue(0),
                        iDataReader.GetValue(1),
                        iDataReader.GetValue(2),
                        iDataReader.GetValue(3),
                        iDataReader.GetValue(4),
                        iDataReader.GetValue(5),
                        iDataReader.GetValue(6)
                                                         );

                    UtilityDebug.Write(internetDictionaryProjectIDPResult);
                } //while( iDataReader.Read() )
    #endif
            }     //try
            catch (Exception exception)
            {
                System.Console.WriteLine("Exception: {0}", exception.Message);
            } //catch (Exception exception)
        }     //public static void Query()
Example #4
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()