예제 #1
0
  ///<summary>Read XML.</summary>
  /// <param name="dataSet">Dataset.</param>  
  /// <param name="exceptionMessage">Exception Message.</param>
  /// <param name="filenameXml">Filename XML.</param>
  /// <param name="filenameSchema">Filename Schema.</param>  
  public static void ReadXml
  (
   ref  DataSet  dataSet,
   ref  string   exceptionMessage,
   ref  string   filenameXml,
   ref  string   filenameSchema
  )
  { 
   HttpContext httpContextCurrent = HttpContext.Current; 
   
   dataSet = new DataSet();
   exceptionMessage = null;
   
   try
   {
    if ( filenameSchema != null && filenameSchema != string.Empty )
    {
     UtilityDirectory.WebServerFullPath( ref filenameSchema );
     dataSet.ReadXmlSchema( filenameSchema );
    }//if ( filenameSchema != null && filenameSchema != string.empty )
     
    UtilityDirectory.WebServerFullPath( ref filenameXml );
    //if ( !File.Exists(filenameXml)) 
    dataSet.ReadXml( filenameXml );

   }//try
   catch (SecurityException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (XmlException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "XmlException: {0}", exception.Message );
   }//catch (XmlException 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)
   #if (DEBUG)
    if ( httpContextCurrent != null && exceptionMessage != null )
    {
     httpContextCurrent.Response.Write( "Exception: " + exceptionMessage );
    }//if ( httpContextCurrent != null && exceptionMessage != null )
   #endif
  }//ReadXml()    
예제 #2
0
  }//WriteXml()    

  ///<summary>Read XML.</summary>
  /// <param name="dataSet">Dataset.</param>  
  /// <param name="exceptionMessage">Exception Message.</param>
  /// <param name="filenameXml">Filename XML.</param>
  public static void ReadXml
  (
       DataSet dataSet,
   ref string  exceptionMessage,
   ref string  filenameXml
  )
  { 
   HttpContext httpContext = HttpContext.Current; 
  
   exceptionMessage = null;
   
   try
   {
    UtilityDirectory.WebServerFullPath( ref filenameXml );
    dataSet.ReadXml(filenameXml);
   }//try
   catch (SecurityException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (XmlException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "XmlException: {0}", exception.Message );
   }//catch (XmlException 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)
  }//ReadXml()    
예제 #3
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()
        }//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()
예제 #5
0
        /// <summary>CompressFile</summary>
        public static void CompressFile
        (
            ref UtilityCompressArgument utilityCompressArgument,
            ref string exceptionMessage
        )
        {
            // Create the streams and byte arrays needed
            byte[]     buffer            = null;
            string     directoryName     = null;
            string     fileNamePattern   = null;
            ArrayList  filenames         = null;
            FileStream sourceStream      = null;
            FileStream destinationStream = null;
            GZipStream compressedStream  = null;

            try
            {
                directoryName = Path.GetDirectoryName(utilityCompressArgument.destination);
                if (Directory.Exists(directoryName) == false)
                {
                    Directory.CreateDirectory(directoryName);
                }
                // Open the FileStream to write to
                destinationStream = new FileStream(utilityCompressArgument.destination, FileMode.OpenOrCreate, FileAccess.Write);
                // Create a compression stream pointing to the destination stream
                compressedStream = new GZipStream(destinationStream, CompressionMode.Compress, true);
                foreach (string source in utilityCompressArgument.source)
                {
                    if (File.Exists(source))
                    {
                        filenames = new ArrayList();
                        filenames.Add(source);
                    }
                    else
                    {
                        directoryName   = Path.GetDirectoryName(source);
                        fileNamePattern = Path.GetFileName(source);
                        if (Directory.Exists(directoryName))
                        {
                            UtilityDirectory.Dir
                            (
                                directoryName,
                                fileNamePattern,
                                ref filenames
                            );
                        }
                    }
                    foreach (object filenameCurrent in filenames)
                    {
                        // Read the bytes from the source file into a byte array
                        sourceStream = new FileStream(filenameCurrent.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read);
                        // Read the source stream values into the buffer
                        buffer = new byte[sourceStream.Length];
                        sourceStream.Read(buffer, 0, buffer.Length);
                        System.Console.WriteLine("Filename: {0} | Length: {1}", filenameCurrent, buffer.Length);
                        // Now write the compressed data to the destination file
                        compressedStream.Write(buffer, 0, buffer.Length);
                        if (sourceStream != null)
                        {
                            sourceStream.Close();
                        }
                    }
                }
            }
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            finally
            {
                if (compressedStream != null)
                {
                    compressedStream.Close();
                }
                if (destinationStream != null)
                {
                    destinationStream.Close( );
                }
            }
        }
예제 #6
0
  }//public static void BCP()
  
  /// <summary>BCP.</summary>
  public static void BCP
  (
   ref String              filenameConfigurationXml,
   ref XmlNodeList         xmlNodeListDatabase,
   ref UtilityBCPArgument  utilityBCPArgument,
   ref ArrayList           arrayListTableName,
   ref String              exceptionMessage
  )
  {

   Boolean                redirectStandardOutputError = true;
   
   String                 BCPCommandOut;
   String                 BCPDataFile;
   String                 BCPDirectory;
   String                 BCPErrorFile;   
   String[]               databaseOwnerTableName;
   String                 dateTimeNow                 =  DateTime.Now.ToString(FormatDate);
   
   String                 redirectStandardOutput      = null;
   String                 redirectStandardError       = null;
   String                 verb                        = null;
   
   StringBuilder          capitalLetters;
   
   HttpContext            httpContext                 = HttpContext.Current;
   
   arrayListTableName = new ArrayList();
   
   if ( utilityBCPArgument.DatabaseName == null || utilityBCPArgument.DatabaseName.Length == 0 )
   {
   	utilityBCPArgument.DatabaseName  =  DatabaseName.Split( DelimiterCharArrayComma );
   }//if ( utilityBCPArgument.DatabaseName == null || utilityBCPArgument.DatabaseName.Length == 0 )	

   if ( utilityBCPArgument.TableName == null || utilityBCPArgument.TableName.Length == 0 )
   {
   	utilityBCPArgument.TableName = UtilityBCP.TableName.Split( UtilityBCP.DelimiterCharArrayComma );
   }//if ( utilityBCPArgument.TableName == null || utilityBCPArgument.TableName.Length == 0 )	

   if ( utilityBCPArgument.TableName != null && utilityBCPArgument.TableName.Length != 0 )
   {
    foreach ( String tableNameCurrent in utilityBCPArgument.TableName )
    {
   	 if ( tableNameCurrent.Trim() == String.Empty )
   	 {
      continue;   	 	
     }//if ( tableNameCurrent.Trim() == String.Empty )   	 	
   	 arrayListTableName.Add( tableNameCurrent );
    }//foreach ( String tableNameCurrent in utilityBCPArgument.tableName )   	
   }//if ( utilityBCPArgument.TableName != null && utilityBCPArgument.TableName.Length != 0 )
      
   UtilityDatabase.PopulateDatabaseTable
   (
    ref filenameConfigurationXml,
    ref xmlNodeListDatabase,
    ref utilityBCPArgument.databaseName,
    ref arrayListTableName,
    ref exceptionMessage
   ); 

   capitalLetters = utilityBCPArgument.CapitalLetters();
   
   foreach (object databaseOwnerTableNameCurrent in arrayListTableName)
   {
    databaseOwnerTableName = ((String) (databaseOwnerTableNameCurrent)).Split( DelimiterCharArrayFullStop );

    BCPDirectory           = String.Format
    (
     FormatBCPDirectory,
     utilityBCPArgument.DirectoryDataFile.ToString(),
     databaseOwnerTableName[RankDatabaseNamingConventionDatabaseName],
     databaseOwnerTableName[RankDatabaseNamingConventionTableName]
    ); 

    BCPDataFile            = String.Format
    (
     FormatBCPDataFile,
     BCPDirectory,
     databaseOwnerTableName[RankDatabaseNamingConventionTableName],
     dateTimeNow
    ); 

    BCPErrorFile            = String.Format
    (
     FormatBCPErrorFile,
     BCPDirectory,
     databaseOwnerTableName[RankDatabaseNamingConventionTableName],
     dateTimeNow
    ); 
    
    BCPCommandOut = String.Format
    (
     FormatBCPCommandOut,
     databaseOwnerTableNameCurrent,
     BCPDataFile,
     BCPErrorFile,
     capitalLetters
    ); 

    UtilityDebug.Write
    (
     String.Format
     (
      "BCP Directory: {0} | BCPDataFile: {1} | BCPErrorFile: {2} | BCPCommandOut: {3}",
      BCPDirectory,
      BCPDataFile,
      BCPErrorFile,
      BCPCommandOut
     )
    );

    UtilityDirectory.CreateDirectory
    (
     ref BCPDirectory,
     ref exceptionMessage
    );

    UtilityProcess.FileStart
    (
     ref CommandBCP,
     ref BCPCommandOut,
     ref verb,
     ref redirectStandardOutputError,
     ref redirectStandardOutput,
     ref redirectStandardError
    );
    
   }//foreach (object databaseOwnerTableNameCurrent in arrayListTableName)
  }//public static void BCP()
예제 #7
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()
예제 #8
0
  }//public static void WriteXmlStylesheet()  
  
  ///<summary>Write XML.</summary>
  /// <param name="dataSet">Dataset.</param>  
  /// <param name="exceptionMessage">Exception Message.</param>
  /// <param name="filenameXml">Filename XML.</param>
  /// <param name="filenameStylesheet">Filename Stylesheet (XSLT).</param>
  public static void WriteXml
  (
       DataSet dataSet,
   ref string  exceptionMessage,
   ref string  filenameXml,
   ref string  filenameStylesheet
  )
  { 

   string                    dataSetName                      = null;
   HttpContext               httpContext                      = HttpContext.Current; 
  
   exceptionMessage = null;
   dataSetName      = dataSet.DataSetName;
 
   if ( filenameXml == null )
   {
    filenameXml = dataSetName + UtilityFile.Extension("xml");
   }
   
   if ( filenameStylesheet == null )
   { 
    filenameStylesheet = dataSetName + UtilityFile.Extension("xslt");
   }

   try
   {
    UtilityDirectory.WebServerFullPath( ref filenameXml );

    //dataSet.WriteXmlSchema(filenameSchema);
    dataSet.WriteXml(filenameXml);
    WriteXmlStylesheet
    (
     ref exceptionMessage,
     ref filenameXml,
     ref filenameStylesheet
    );
   }//try
   catch (SecurityException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SecurityException: {0}", exception.Message );
    httpContext.Response.Write( "SecurityException: " + exception.Message );
   }//catch (SecurityException exception)
   catch (XmlException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "XmlException: {0}", exception.Message );
    httpContext.Response.Write( "XmlException: " + exception.Message );
   }//catch (XmlException exception)
   catch (SystemException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SystemException: {0}", exception.Message );
    httpContext.Response.Write( "SystemException: " + exception.Message );
   }//catch (SystemException exception)
   catch (Exception exception)
   {
    exceptionMessage = exception.Message;   
    System.Console.WriteLine( "Exception: {0}", exception.Message );
    httpContext.Response.Write( "Exception: " +  exception.Message );    
   }//catch (Exception exception)
  }//WriteXml()    
예제 #9
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()
예제 #11
0
  }//public static void WriteXmlStylesheet()  
  
  ///<summary>Write XML.</summary>
  /// <param name="dataSet">Dataset.</param>  
  /// <param name="exceptionMessage">Exception Message.</param>
  /// <param name="filenameXml">Filename XML.</param>
  /// <param name="filenameStylesheet">Filename Stylesheet (XSLT).</param>
  public static void WriteXml
  (
       DataSet dataSet,
   ref string  exceptionMessage,
   ref string  filenameXml,
   ref string  filenameStylesheet
  )
  { 
   string       dataSetName         =  null;
   string       directoryName       =  null;
   HttpContext  httpContextCurrent  =  HttpContext.Current;
  
   exceptionMessage = null;
   dataSetName      = dataSet.DataSetName;
 
   if ( filenameXml == null )
   {
    filenameXml = dataSetName + UtilityFile.Extension("xml");
   }

   try
   {
    UtilityDirectory.WebServerFullPath( ref filenameXml );
    directoryName = Path.GetDirectoryName( filenameXml );
    if ( directoryName != "" && Directory.Exists( directoryName ) == false )
    {
     Directory.CreateDirectory( directoryName );
    }
    //dataSet.WriteXmlSchema(filenameSchema);
    dataSet.WriteXml(filenameXml);
    if ( string.IsNullOrEmpty( filenameStylesheet ) == false )
    {
     WriteXmlStylesheet
     (
      ref exceptionMessage,
      ref filenameXml,
      ref filenameStylesheet
     );
    }
   }//try
   catch (SecurityException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (XmlException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "XmlException: {0}", exception.Message );
   }//catch (XmlException 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)
   #if (DEBUG)
    if ( httpContextCurrent != null && exceptionMessage != null )
    {
     httpContextCurrent.Response.Write( "Exception: " + exceptionMessage );
    }//if ( httpContextCurrent != null && exceptionMessage != null )
   #endif
  }//WriteXml()