}//main()

  ///<summary>Stub</summary>
  public static void Stub
  (
   ref UtilityServerManagementObjectSMOArgument  utilityServerManagementObjectSMOArgument,
   ref String              exceptionMessage
  )
  {

   Server  sQLServer  =  null;

   try 
   {

    sQLServer = new Server();

   }//try
   catch ( Exception exception )
   {
    UtilityDebug.Write
    (
     String.Format
     (
      "Exception: {0}",
      exception.Message
     )
    );
   }//catch ( Exception exception )   	
    
  }//public static void FileImport()
 /// <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;
  
  UtilityServerManagementObjectSMOArgument  utilityServerManagementObjectSMOArgument    =  null;
  
  utilityServerManagementObjectSMOArgument = new UtilityServerManagementObjectSMOArgument();
  
  booleanParseCommandLineArguments =  UtilityParseCommandLineArgument.ParseCommandLineArguments
  ( 
   argv, 
   utilityServerManagementObjectSMOArgument
  );
  
  if ( booleanParseCommandLineArguments  == false )
  {
   // error encountered in arguments. Display usage message
   UtilityDebug.Write
   (
    UtilityParseCommandLineArgument.CommandLineArgumentsUsage( typeof ( UtilityServerManagementObjectSMOArgument ) )    
   );  
   return;
  }//if ( booleanParseCommandLineArguments  == false )
  
  Stub
  (
   ref utilityServerManagementObjectSMOArgument,
   ref exceptionMessage
  );
  
 }//main()
  }//main()

  ///<summary>FaxSend</summary>
  public static void FaxSend
  (
   ref UtilityFaxArgument  utilityFaxArgument,
   ref String              exceptionMessage
  )
  {

   int             faxDocStatus                    =  -1;

   object          faxServerClassDocument          =  null;
   
   FaxDoc          faxDoc                          =  null;
   FaxServerClass  faxServerClass                  =  null;
   
   if ( utilityFaxArgument.FaxDocument == null || utilityFaxArgument.FaxDocument == String.Empty )
   {
    return;
   }//if ( utilityFaxArgument.FaxDocument == null || utilityFaxArgument.FaxDocument == String.Empty )    	

   try 
   {
    faxServerClass = new FaxServerClass();
    
    faxServerClass.Connect( utilityFaxArgument.FaxServerName ); //specifies the machinename
    
    faxServerClassDocument = faxServerClass.CreateDocument
    (
     utilityFaxArgument.FaxDocument
    );
    
    faxDoc = ( FaxDoc) faxServerClassDocument;
    
    faxDoc.FaxNumber = utilityFaxArgument.FaxNumber;
    faxDocStatus = faxDoc.Send();

    UtilityDebug.Write
    (
     String.Format
     (
      "Fax Status: {0}",
      faxDocStatus
     )
    );

    faxServerClass.Disconnect();

   }//try
   catch ( Exception exception )
   {
    UtilityDebug.Write
    (
     String.Format
     (
      "Exception: {0}",
      exception.Message
     )
    );
   }//catch ( Exception exception )   	
    
  }//public static void FileImport()
Example #4
0
  }//public void DatabaseSelect()

  /// <summary>DatabaseUpdate</summary>
  public static void DatabaseUpdate
  (
   ref  String   databaseConnectionString,
   ref  String   exceptionMessage,
   ref  Contact  contact   
  )
  {
   StringBuilder  sb  =  null;
   
   sb = new StringBuilder();
   sb.AppendFormat
   (
    SQLUpdateContactArgument,
    contact.ContactID,
    contact.FirstName,
    contact.LastName,
    contact.OtherName,
    contact.Prefix,
    contact.Suffix,
    contact.Company,
    contact.Commentary,
    contact.ScriptureReference
   );
   
   UtilityDatabase.DatabaseQuery
   (
         databaseConnectionString,
    ref  exceptionMessage,
         sb.ToString()
   );   

   UtilityDebug.Write(String.Format("SQL Contact: {0}", sb.ToString()));
  }//public void DatabaseUpdate()
  }//main()

  private static void GetCORSystemDirectory
  (
   ref StringBuilder sbGetCORSystemDirectory
  )
  {
   int            MAX_PATH  =  260;
   
   sbGetCORSystemDirectory  =  new StringBuilder(MAX_PATH);
   
   try
   {
   	GetCORSystemDirectory
    (
         sbGetCORSystemDirectory, 
         MAX_PATH, 
     ref MAX_PATH
    );
   
    UtilityDebug.Write
    (
     String.Format("MSCorEE.dll GetCORSystemDirectory: {0}", sbGetCORSystemDirectory)
    );
   }//try
   catch ( Exception exception )
   {
    UtilityDebug.Write
    (
     String.Format("Exception: {0}", exception.Message)
    );
   }//catch ( Exception exception )   	
   
  }//private static String sbGetCORSystemDirectory()
Example #6
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;

            AccountChartArgument accountChartArgument = null;

            accountChartArgument = new AccountChartArgument();

            booleanParseCommandLineArguments = UtilityParseCommandLineArgument.ParseCommandLineArguments
                                               (
                argv,
                accountChartArgument
                                               );

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

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

            /*
             * Query
             * (
             * ref DatabaseConnectionString,
             * ref exceptionMessage,
             * ref accountChartArgument,
             * ref internetDictionaryProjectIDPSQL,
             * ref internetDictionaryProjectIDPQuery,
             * ref iDataReader
             * );
             */
        }//main()
Example #7
0
  }//XmlElementAppend()

  /// <summary>XmlElementAppend</summary>
  public static void XmlElementAppend
  (
   ref XmlDocument  xmlDocument,
   ref XmlElement   xmlElement,
   ref XmlElement   xmlElementChild,
       String       elementName,
   ref object       elementValue,
   ref String       exceptionMessage
  )
  { 
   HttpContext httpContextCurrent = HttpContext.Current; 

   exceptionMessage = null;
   
   try
   {
    xmlElementChild            =  xmlDocument.CreateElement( elementName, null );
    xmlElementChild.SetAttribute("name", (String) elementValue);
    xmlElement.AppendChild( xmlElementChild );
   }//try
   catch (SecurityException exception)
   {
    exceptionMessage = String.Format("SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (XmlException exception)
   {
    exceptionMessage = String.Format("XmlException: {0}", exception.Message );
   }//catch (XmlException exception)
   catch (SystemException exception)
   {
    exceptionMessage = String.Format("SystemException: {0}", exception.Message );
   }//catch (SystemException exception)
   catch (Exception exception)
   {
    exceptionMessage = String.Format("Exception: {0}", exception.Message );
   }//catch (Exception exception)
   if ( exceptionMessage != null )
   {
    UtilityDebug.Write( exceptionMessage );
   }
  }//XmlElementAppend()
  }//public static void ConfigurationXml()

  /// <summary>ConfigurationXml.</summary>
  public static void ConfigurationXml
  (
   ref String         filenameConfigurationXml,
   ref String         exceptionMessage,
   ref String         connectionStringDatabase,
   ref String         databaseName,
   ref String         directoryDatafile,
   ref String         tableName,
   ref String         userName,
   ref String         domainName,
   ref String         password
  )
  {

   UtilityXml.XmlDocumentNodeInnerText
   (
         filenameConfigurationXml,
     ref exceptionMessage,         
         XPathConnectionStringDatabase,
     ref connectionStringDatabase
   );

   UtilityXml.XmlDocumentNodeInnerText
   (
         filenameConfigurationXml,
     ref exceptionMessage,         
         XPathBCPDatabase,
     ref databaseName
   );

   UtilityXml.XmlDocumentNodeInnerText
   (
         filenameConfigurationXml,
     ref exceptionMessage,         
         XPathBCPDirectoryDataFile,
     ref directoryDatafile
   );

   UtilityXml.XmlDocumentNodeInnerText
   (
         filenameConfigurationXml,
     ref exceptionMessage,         
         XPathBCPTable,
     ref tableName
   );

   UtilityImpersonate.GetUsernamePasswordDomainName
   (
    ref filenameConfigurationXml,
    ref userName,
    ref domainName,
    ref password,
    ref exceptionMessage
   );

   UtilityDebug.Write
   (
    String.Format
    (
     "filenameConfigurationXml: {0} | connectionStringDatabase: {1} | databaseName: {2} | directoryDatafile: {3} | tableName: {4}", 
     filenameConfigurationXml,
     connectionStringDatabase,
     databaseName,
     directoryDatafile,
     tableName
    )
   );
      
  }//public static void ConfigurationXml()
  }//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()
  }//UserName

  ///<summary>CapitalLetters.</summary>
  public StringBuilder CapitalLetters()
  {
   StringBuilder sb = new StringBuilder();
   
   if ( BatchSize >= 1 )
   {
    sb.Append( " -b " );
    sb.Append( BatchSize );
   }//if ( BatchSize >= 1 ) 

   if ( CharacterType )
   {
    sb.Append( " -c " );
   }//if ( CharacterType ) 

   if ( KeepIdentityValue )
   {
    sb.Append( " -E " );
   }//if ( keepIdentityValue ) 

   if ( KeepNullValue )
   {
    sb.Append( " -k " );
   }//if ( keepNullValue ) 

   if ( MaximumError >= 1 )
   {
    sb.Append( " -m " );
    sb.Append( MaximumError );
   }//if ( MaximumError >= 1 ) 

   if ( NativeType )
   {
    sb.Append( " -n " );
   }//if ( NativeType )

   if ( Password != null )
   {
    sb.Append( " -P " );
    sb.Append( Password );
   }//if ( Password != null )

   if ( ServerName != null )
   {
    sb.Append( " -S " );
    sb.Append( ServerName );
   }//if ( ServerName != null )

   if ( TrustedConnection )
   {
    sb.Append( " -T " );
   }//if ( TrustedConnection )

   if ( UserName != null )
   {
    sb.Append( " -U " );
    sb.Append( UserName );
   }//if ( UserName != null )

   UtilityDebug.Write
   (
    String.Format
    (
     "Capital Letters: {0}", 
     sb
    )
   );  
   
   return ( sb );

  }//public StringBuilder CapitalLetters()  	  
  }//public static void TypeInformation()
  
  ///<summary>TypeInformation.</summary>
  public static void TypeInformation
  (
       object        objectInstance,
   ref Type          typeClass,
   ref StringBuilder sbTypeNameValue,
   ref String[]      typeName,
   ref String        formatNameValue
  )
  {
   int           indexTypeName         =  -1;
   int           getValueIndex         =  -1;
   
   String        fieldInfoCurrentName  =  null;

   FieldInfo[]   fieldInfo             =  null;
   
   object[]      getValue              =  null;

   sbTypeNameValue                     =  null;
   
   //Get the type and fields
   fieldInfo = typeClass.GetFields();
   
   foreach( FieldInfo fieldInfoCurrent in fieldInfo )
   {

    /*
    System.Console.WriteLine("\nName          : {0}", fieldInfoCurrent.Name);
    System.Console.WriteLine("Declaring Type  : {0}", fieldInfoCurrent.DeclaringType);
    System.Console.WriteLine("IsPublic        : {0}", fieldInfoCurrent.IsPublic);
    System.Console.WriteLine("MemberType      : {0}", fieldInfoCurrent.MemberType);
    System.Console.WriteLine("FieldType       : {0}", fieldInfoCurrent.FieldType);
    System.Console.WriteLine("IsFamily        : {0}", fieldInfoCurrent.IsFamily);
    System.Console.WriteLine("GetValue        : {0}", fieldInfoCurrent.GetValue(this));
    */
    
    fieldInfoCurrentName = fieldInfoCurrent.Name;
    
    indexTypeName = Array.IndexOf(typeName, fieldInfoCurrentName);
    
    if ( indexTypeName < 0 )
    {
     continue;
    }//if ( indexTypeName < 0 )     	

    //if ( fieldInfoCurrent.FieldType.IsArray )
    //typeof(Array).IsAssignableFrom(type)
    if ( typeof(Array).IsAssignableFrom(fieldInfoCurrent.FieldType) )
    {
     getValue = (object[]) fieldInfoCurrent.GetValue(objectInstance);
     for( getValueIndex = 0; getValueIndex < getValue.Length; ++getValueIndex )
     {
      UtilityDebug.Write
      (
       String.Format
       (
        "{0}[{1}]: {2}",
        fieldInfoCurrentName, 
        getValueIndex, 
        getValue[getValueIndex]
       )    
      );

      TypeInformationNameValue
      (
       ref sbTypeNameValue,
       ref fieldInfoCurrentName,
           getValue[getValueIndex],
       ref formatNameValue
      );
     }//for( getValueIndex = 0; getValueIndex < getValue.Length; ++getValueIndex )
    }//if ( typeof(Array).IsAssignableFrom(fieldInfoCurrent.FieldType) )
    else
    {
     TypeInformationNameValue
     (
      ref sbTypeNameValue,
      ref fieldInfoCurrentName,
          getValue[getValueIndex],
      ref formatNameValue
     );
    }    	
    	
   }//foreach( FieldInfo fieldInfoCurrent in fieldInfo )
   
   UtilityDebug.Write
   (
    String.Format
    (
     "TypeInformation: {0}",
     sbTypeNameValue
    )    
   );
  }//public static void TypeInformation()  	
Example #12
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 #13
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()
  }//public void ButtonReset_Click()

  /// <summary>ButtonOpen_Click().</summary>
  public void ButtonOpen_Click
  (
   Object sender, 
   EventArgs e
  )
  {
   StringBuilder    sb                      =  null;
   OleDbCommand     oleDbCommand            =  null;
   OleDbConnection	oleDbConnection         =  null;
   OleDbDataReader  oleDbDataReader         =  null;   
   
   string           medicalRecordPatientNo  = null;
   string           accountNo               = null;
   bool             databaseSelect          = false;
   
   try
   {   

    medicalRecordPatientNo  =  MedicalRecordPatientNo.Trim();
    accountNo               =  AccountNo.Trim();

    if 
    ( 
     medicalRecordPatientNo == string.Empty || medicalRecordPatientNo == null ||
     accountNo == string.Empty || accountNo == null
    )
    {
     Feedback = "Required columns Medical record patient No	and Account No";
     return;
    }
    
    sb = new StringBuilder();
    sb.AppendFormat
    ( 
     CoreDataRecordSelect,
     medicalRecordPatientNo,
     accountNo
    );

	oleDbConnection  =  new OleDbConnection
	(
	 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
	 serverMapPath + @"\" + AccessDatabaseFileName +
	 ";Persist Security Info=False"
	);
	
	oleDbConnection.Open();
	
    oleDbCommand = new OleDbCommand( sb.ToString(), oleDbConnection);
    oleDbDataReader = oleDbCommand.ExecuteReader();
    
    databaseSelect = false;
    while(oleDbDataReader.Read())
    {
     MedicalRecordPatientNo  =  oleDbDataReader.GetString(0);
     AccountNo               =  oleDbDataReader.GetString(1);
     AltMRN                  =  oleDbDataReader.GetString(2);
     NameLast                =  oleDbDataReader.GetString(3);
     NameFirst               =  oleDbDataReader.GetString(4);
     /*
     UtilityDebug.Write(string.Format("medicalRecordPatientNo: {0}", medicalRecordPatientNo));
     UtilityDebug.Write(string.Format("account: {0}", accountNo));
     */
     databaseSelect = true;
    }
    //close the reader 
    oleDbDataReader.Close();
    
    if ( databaseSelect == false )
    {
     Feedback = "Record Not Found";
     UtilityDebug.Write("Record Not Found");     
    }    	
   }
   catch ( Exception exception )
   {
    UtilityDebug.Write(string.Format("Exception: {0}", exception.Message));
   }//catch 
   finally
   {
    if (oleDbConnection.State == System.Data.ConnectionState.Open)
    {
     oleDbConnection.Close();
    }//if (oleDbConnection.State == System.Data.ConnectionState.Open)
   }//finally
   
  }//public void ButtonOpen_Click()
Example #15
0
  }//XmlElementAppend()

  /// <summary>XmlElementAppend</summary>
  public static void XmlElementAppend
  (
   ref XmlDocument  xmlDocument,
   ref XmlElement   xmlElementParent,
   ref XmlElement   xmlElementChild,
       String       xmlElementName,
   ref ArrayList    attributeName,
   ref ArrayList    attributeValue,
   ref String       exceptionMessage
  )
  { 
   HttpContext httpContextCurrent    =  HttpContext.Current; 
   String      attributeValueString  =  null;

   exceptionMessage = null;
   
   try
   {
    xmlElementChild       =  xmlDocument.CreateElement( xmlElementName, null );
    
    for( int attributeCount = 0; attributeCount < attributeName.Count; ++attributeCount )
    {
     //UtilityDebug.Write(String.Format("[{0}] | {1} | {2}", attributeCount, attributeName[attributeCount], attributeValue[attributeCount]));
     
     if ( attributeValue[attributeCount] == null )
     { 
      attributeValueString = null;
     }//if ( attributeValue[attributeCount] == null )
     else 
     {
      attributeValueString  =  attributeValue[attributeCount].ToString();
      attributeValueString  =  attributeValueString.Trim();
      
      if ( attributeValueString == String.Empty )
      {
       attributeValueString = null;
      }//if ( attributeValueString == String.Empty )
      
     }//else if ( attributeValue[attributeCount] != null )
          	
     if ( attributeValueString != null )
     {
      xmlElementChild.SetAttribute
      (
       (String) attributeName[attributeCount], 
       attributeValueString
      );
     }//if ( attributeValueString != null ) 
     
     //xmlElementChild.Attributes[attributeCount].Value  = attributeValueString;
     
    }//for( int attributeCount = 0; attributeCount < attributeName.Count; ++attributeCount ) 
    
    if ( xmlElementParent == null )
    {
     xmlDocument.DocumentElement.AppendChild( xmlElementChild );
     xmlElementParent = xmlDocument.DocumentElement;
    }//if ( xmlElementParent == null ) 
    else
    {
     xmlElementParent.AppendChild( xmlElementChild );
    }
    
   }//try
   catch (SecurityException exception)
   {
    exceptionMessage = String.Format("SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (XmlException exception)
   {
    exceptionMessage = String.Format("XmlException: {0}", exception.Message );
   }//catch (XmlException exception)
   catch (SystemException exception)
   {
    exceptionMessage = String.Format("SystemException: {0}", exception.Message );
   }//catch (SystemException exception)
   catch (Exception exception)
   {
    exceptionMessage = String.Format("Exception: {0}", exception.Message );
   }//catch (Exception exception)
   if ( exceptionMessage != null )
   {
    UtilityDebug.Write( exceptionMessage );
   }
  }//XmlElementAppend()
Example #16
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()
  }//static void Main( String[] argv ) 

  ///<summary>UtilityPrinceNinetySevenPercent</summary>
  public static void UtilityPrinceNinetySevenPercent
  (
   ref PrinceNinetySevenPercentArgument  princeNinetySevenPercentArgument,
   ref DataSet                           dataSet,
   ref String                            exceptionMessage      
  )
  {
  
   double      percent          =  0.00;
   DateTime    yearFrom         =  new DateTime(DateTime.Now.Year, 1, 1);
   DateTime    yearUntil        =  new DateTime(DateTime.Now.Year, 12, 31);
      
   try
   {
    DateTime    dated            =  System.Convert.ToDateTime( princeNinetySevenPercentArgument.DatedFrom );
    DateTime    datedFrom        =  System.Convert.ToDateTime( princeNinetySevenPercentArgument.DatedFrom );
    DateTime    datedUntil       =  System.Convert.ToDateTime( princeNinetySevenPercentArgument.DatedUntil );

    DataTable   dataTable          =  new DataTable();
    DataColumn  dataColumnDated    =  new DataColumn( "Dated", System.Type.GetType("System.DateTime") );
    //DataColumn  dataColumnPercent  =  new DataColumn( "Percent", System.Type.GetType("System.TimeSpan"), "(new System.DateTime(2005,12,31)).Subtract(Dated)" );
    DataColumn  dataColumnPercent  =  new DataColumn( "Percent", System.Type.GetType("System.Decimal") );
    DataRow     dataRow            =  null;
   
    dataSet = new DataSet();
   
    dataTable.Columns.Add( dataColumnDated );
    dataTable.Columns.Add( dataColumnPercent );
   
    dataSet.Tables.Add( dataTable );
   
    /*
    UtilityDebug.Write(String.Format("princeNinetySevenPercentArgument.ObliterateMasters: {0}", princeNinetySevenPercentArgument.ObliterateMasters));
    UtilityDebug.Write(String.Format("princeNinetySevenPercentArgument.Beans: {0}", princeNinetySevenPercentArgument.Beans));
    UtilityDebug.Write(String.Format("princeNinetySevenDatedArgument.DatedFrom: {0}", princeNinetySevenPercentArgument.DatedFrom));
    UtilityDebug.Write(String.Format("princeNinetySevenDatedArgument.DatedUntil: {0}", princeNinetySevenPercentArgument.DatedUntil));
    UtilityDebug.Write(String.Format("princeNinetySevenPercentArgument.PercentFrom: {0}", princeNinetySevenPercentArgument.PercentFrom));
    UtilityDebug.Write(String.Format("princeNinetySevenPercentArgument.PercentUntil: {0}", princeNinetySevenPercentArgument.PercentUntil));
    */

    while ( true )
    {
     if ( dated > datedUntil )
     {
      break;    	
     }//if ( dated > datedUntil )

     dataRow = dataTable.NewRow();
     dataRow["Dated"]   = dated;
     yearFrom           = new DateTime(dated.Year, 1, 1);
     yearUntil          = new DateTime(dated.Year, 12, 31);
     percent            = dated.Subtract( yearFrom ).Days * Percent100 / yearUntil.Subtract( yearFrom ).Days; 
     dataRow["Percent"] = percent;
     dataTable.Rows.Add( dataRow );

     UtilityDebug.Write(String.Format("Dated: {0} | Percent: {1}", dated, percent));
    
   	 switch( princeNinetySevenPercentArgument.ObliterateMasters )
   	 {
      case Obliterate.Day:
       dated = dated.AddDays( princeNinetySevenPercentArgument.Beans );
       break;
       
      case Obliterate.Month:
       dated = dated.AddMonths( princeNinetySevenPercentArgument.Beans );
       break;		
     
      case Obliterate.Year:
       dated = dated.AddYears( princeNinetySevenPercentArgument.Beans );
       break;
     }//switch( princeNinetySevenPercentArgument.ObliterateMasters )
    
    }//while ( true )
   }//try
   catch (Exception exception)
   {
    UtilityDebug.Write(String.Format("Exception: {0}", exception.Message));       	
   }//catch (Exception exception)
  }//public static void UtilityPrinceNinetySevenPercent()
  ///CreateAccessDatabase
  public static void CreateAccessDatabase
  (
   string accessDatabaseFileName
  )
  {

   Type             objectClassType          =  null;
   object           objectClassTypeInstance  =  null;  

   OleDbCommand     oleDbCommand             =  null;
   OleDbConnection  oleDbConnection          =  null;


   try
   {
	objectClassType = Type.GetTypeFromProgID("ADOX.Catalog");
 
	if ( objectClassType == null )
	{
     UtilityDebug.Write(string.Format("Exception: {0}", "Type.GetTypeFromProgID(ADOX.Catalog"));
     return;
    }//if ( objClassType == null ) 		
	
	// Delete the mdb file if it already exists
	if (System.IO.File.Exists( accessDatabaseFileName ) )
	{
	 System.IO.File.Delete( accessDatabaseFileName );
	}//if (System.IO.File.Exists( accessDatabaseFileName ) )

    objectClassTypeInstance = Activator.CreateInstance( objectClassType );

	objectClassTypeInstance.GetType().InvokeMember
	(
	 "Create",
     System.Reflection.BindingFlags.InvokeMethod, 
     null, 
     objectClassTypeInstance, 
     new object[]
     {
      "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + accessDatabaseFileName + ";" 
     }//new object[]
	);//objectClassTypeInstance.GetType().InvokeMember

    if (System.IO.File.Exists( accessDatabaseFileName ) == false )
	{
	 return;
	}//if (System.IO.File.Exists( accessDatabaseFileName ) == false )
	
	oleDbConnection  =  new OleDbConnection
	(
	 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
	 accessDatabaseFileName +
	 ";Persist Security Info=False"
	);
	
	oleDbConnection.Open();
	
    oleDbCommand = new OleDbCommand( TableCoreData, oleDbConnection);
    oleDbCommand.ExecuteNonQuery();
    
    oleDbCommand = new OleDbCommand( PrimaryKeyCoreData, oleDbConnection);
    oleDbCommand.ExecuteNonQuery();

   }//try
   catch ( Exception exception )
   {
    UtilityDebug.Write(string.Format("Exception: {0}", exception.Message));
   }//catch 
   finally
   {
    if (oleDbConnection.State == System.Data.ConnectionState.Open)
    {
     oleDbConnection.Close();
    }//if (oleDbConnection.State == System.Data.ConnectionState.Open)
   }//finally
  }//public static void CreateAccessDatabase