Exemple #1
0
  }//public static void Stub()

  /// <summary>UserLogin()</summary>
  public static void UserLogin
  (
   ref Hashtable userLogin,
   ref string    exceptionMessage
  )
  {
   HttpContext  httpContext  =  HttpContext.Current;
   exceptionMessage          =  null;
   userLogin           =  new Hashtable();

   try
   {
    userLogin.Add( "System.Environment.UserName", System.Environment.UserName );
    userLogin.Add( "System.Security.Principal.WindowsIdentity.GetCurrent().Name", System.Security.Principal.WindowsIdentity.GetCurrent().Name );
    if ( httpContext != null )
    {
     userLogin.Add( "HttpContext.Current.User.Identity.Name", HttpContext.Current.User.Identity.Name );
    } 
    userLogin.Add( "WindowsIdentity.GetCurrent().Name", WindowsIdentity.GetCurrent().Name );
    userLogin.Add( "Thread.CurrentPrincipal.Identity.Name", Thread.CurrentPrincipal.Identity.Name );
   }//try
   catch ( SecurityException exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
   if ( httpContext == null ) { UtilityCollection.PrintKeysAndValues( userLogin ); }
  }//public static void UserLogin()
Exemple #2
0
 /// <summary>ManagementSelectQuery()</summary>
 public static void ManagementSelectQuery
 (
  string query
 )
 {
  string                    exceptionMessage          =  null;
  ManagementObjectSearcher  managementObjectSearcher  =  null;
  SelectQuery               selectQuery               =  null;
  try
  {
 	selectQuery               =  new SelectQuery( query );
   managementObjectSearcher  =  new ManagementObjectSearcher( selectQuery );
   foreach( ManagementObject managementObject in managementObjectSearcher.Get() )
   {
    foreach ( PropertyData propertyData in managementObject.Properties )
    {
     System.Console.WriteLine
     (
      "Property: {0}, Value: {1}",
      propertyData.Name, 
      propertyData.Value
     );
    }//foreach ( PropertyData propertyData in managementObject.Properties )
   }//foreach( ManagementObject managementObject in managementObjectSearcher.Get() )
  }//try
  catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
 }//ManagementSelectQuery
        ///<summary>Service</summary>
        ///<remarks>
        /// Subject: Browsing host services  8/10/2005 7:47 AM PST By: Ignacio Machin ( .NET/ C# MVP ) In: microsoft.public.dotnet.languages.csharp
        /// ServiceController.GetServices
        ///</remarks>
        public static void Service()
        {
            string exceptionMessage = null;

            string[] services = null;

            object imagePath   = null;
            object displayName = null;

            try
            {
                services = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services").GetSubKeyNames();
                foreach (string service in services)
                {
                    imagePath = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + service).GetValue("ImagePath");
                    if (imagePath == null)
                    {
                        continue;
                    }
                    displayName = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + service).GetValue("DisplayName");
                    System.Console.WriteLine
                    (
                        "Service Name: {0} | ImagePath: {1} | DisplayName: {2}",
                        service,
                        imagePath,
                        displayName
                    );
                } //foreach ( string service in services )
            }     //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, "Exception", ref exceptionMessage); }
            finally
            {
            } //finally
        }     //Service()
  }//public static void ConfigurationXml()

  /// <summary>Read the XML Configuration file.</summary>
  public static void ConfigurationXml
  (
       string filenameConfigurationXml,
   ref string exceptionMessage,
   ref string databaseConnectionString,
   ref int    smtpPort,
   ref string smtpServer
  )
  {
   try
   {
    UtilityXml.XmlDocumentNodeInnerText
    (
          filenameConfigurationXml,
      ref exceptionMessage,
          XPathDatabaseConnectionString,
      ref databaseConnectionString
    );
    UtilityXml.GetNodeValue
    (
         filenameConfigurationXml,
     ref exceptionMessage,
         XPathPort,
     ref smtpPort
    );
    UtilityXml.GetNodeValue
    (
         filenameConfigurationXml,
     ref exceptionMessage,
         XPathServer,
     ref smtpServer
    );
   }//try
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, "Exception", ref exceptionMessage ); }
  }//ConfigurationXml	 
        }//public static void ResponseOutputStreamWrite()

        ///<summary>ResponseOutputStreamWrite</summary>
        ///<remarks>MSDNBrasil.com.br/forum/ShowPost.aspx?PostID=91538</remarks>
        public static void ResponseOutputStreamWrite
        (
            ref System.Web.UI.WebControls.FileUpload fileUpload,
            ref string exceptionMessage
        )
        {
            HttpContext httpContext = System.Web.HttpContext.Current;

            byte[] buffer              = null;
            int    bytesRead           = -1;
            int    fileExtensionIndex  = -1;
            string responseContentType = null;
            Stream stream              = null;

            try
            {
                if (httpContext == null)
                {
                    return;
                }
                if (fileUpload.HasFile == false)
                {
                    return;
                }
                responseContentType = httpContext.Response.ContentType;
                fileExtensionIndex  = UtilityFile.FileExtensionIndex(fileUpload.PostedFile.FileName);
                stream = fileUpload.PostedFile.InputStream;
                httpContext.Response.Clear();
                httpContext.Response.AppendHeader("Content-Length", fileUpload.PostedFile.ContentLength.ToString());
                if (fileExtensionIndex > -1)
                {
                    httpContext.Response.ContentType = UtilityFile.FileExtension[fileExtensionIndex][UtilityFile.FileExtensionRankContentType];
                }
                else
                {
                    httpContext.Response.ContentType = UtilityFile.DefaultContentType;
                }
                buffer = new byte[ByteSize];
                while (true)
                {
                    bytesRead = stream.Read(buffer, 0, ByteSize);
                    if (bytesRead <= 0)
                    {
                        break;
                    }
                    httpContext.Response.OutputStream.Write(buffer, 0, buffer.Length);
                } //while ( true )
            }     //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            httpContext.Response.End();
            httpContext.Response.ContentType = responseContentType;

            /*
             * httpContext.Server.Transfer( httpContext.Request.ServerVariables["PATH_INFO"] );
             * httpContext.Response.Redirect( httpContext.Request.ServerVariables["PATH_INFO"] );
             */
            httpContext.Server.Transfer(httpContext.Request.ServerVariables["PATH_INFO"]);
        }//public static void ResponseOutputStreamWrite()
        }//public static void ResponseOutputStreamWrite()

        ///<summary>ResponseOutputStreamWrite</summary>
        public static void ResponseOutputStreamWrite
        (
            ref byte[]  bufferSource,
            ref string path,
            ref string contentType,
            ref string exceptionMessage
        )
        {
            HttpContext httpContext = System.Web.HttpContext.Current;

            byte[]       bufferBlock         = null;
            int          bytesRead           = -1;
            string       filename            = null;
            string       responseContentType = null;
            MemoryStream memoryStream        = null;

            try
            {
                if (httpContext == null)
                {
                    return;
                }
                responseContentType = httpContext.Response.ContentType;
                httpContext.Response.Clear();
                httpContext.Response.AppendHeader("Content-Length", bufferSource.Length.ToString());
                httpContext.Response.ContentType = contentType;
                filename = Path.GetFileName(path);
                httpContext.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                memoryStream = new MemoryStream(bufferSource, 0, bufferSource.Length);
                bufferBlock  = new byte[ByteSize];
                while (true)
                {
                    bytesRead = memoryStream.Read(bufferBlock, 0, ByteSize);
                    if (bytesRead <= 0)
                    {
                        break;
                    }
                    httpContext.Response.OutputStream.Write(bufferBlock, 0, bufferBlock.Length);
                } //while ( true )
            }     //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            httpContext.Response.End();
            httpContext.Response.ContentType = responseContentType;

            /*
             * httpContext.Server.Transfer( httpContext.Request.ServerVariables["PATH_INFO"] );
             * httpContext.Response.Redirect( httpContext.Request.ServerVariables["PATH_INFO"] );
             */
            httpContext.Server.Transfer(httpContext.Request.ServerVariables["PATH_INFO"]);
        } //public static void ResponseOutputStreamWrite()
Exemple #7
0
 ///<summary>SpVoiceSpeak</summary>
 public static void SpVoiceSpeak
 (
  ref UtilitySpeechArgument  utilitySpeechArgument,
  ref string                 exceptionMessage
 )
 {
  object                 voice                  =  null;
  object[]               voiceArgv              =  null;                  
  SpeechVoiceSpeakFlags  speechVoiceSpeakFlags  =  SpeechVoiceSpeakFlagsDefault;
  SpAudioFormatClass     spAudioFormatClass     =  null;
  SpFileStream           spFileStream           =  null;
  SpVoice                spVoice                =  null;
  Type                   typeSAPISpVoice        =  null;
  try
  {
   spVoice                =  new SpVoice();
   typeSAPISpVoice        =  Type.GetTypeFromProgID("SAPI.SpVoice");
   voice                  =  Activator.CreateInstance( typeSAPISpVoice );
   voiceArgv              =  new object[2];
   voiceArgv[1]           =  0;
   speechVoiceSpeakFlags  =  SpeechVoiceSpeakFlagsEnum( false, utilitySpeechArgument.xml );
   if ( string.IsNullOrEmpty( utilitySpeechArgument.pathAudio ) == false )
   {
    spAudioFormatClass         =  new SpAudioFormatClass();
    spAudioFormatClass.Type    =  SpeechAudioFormatType.SAFTGSM610_11kHzMono; //Heavily compressed
    spFileStream               =  new SpFileStream();
    spFileStream.Format        =  spAudioFormatClass;
    spFileStream.Open( utilitySpeechArgument.pathAudio, SpeechStreamFileMode.SSFMCreateForWrite, false );
    spVoice.AudioOutputStream  =  spFileStream;
    spVoice.Rate = -5; //Ranges from -10 to 10 
   }
   foreach( string text in utilitySpeechArgument.text )
   {
    /*
    spVoice.Speak( text, speechVoiceSpeakFlags );
    */
    voiceArgv[0]  =  text;
    typeSAPISpVoice.InvokeMember("Speak", BindingFlags.InvokeMethod, null, voice, voiceArgv);
   }
   speechVoiceSpeakFlags = SpeechVoiceSpeakFlagsEnum( true, utilitySpeechArgument.xml );
   foreach( string pathSource in utilitySpeechArgument.pathSource )
   {
    if ( string.IsNullOrEmpty( pathSource ) ) { continue; }
    if ( File.Exists( pathSource ) == false ) { continue; }     
    spVoice.Speak( pathSource, speechVoiceSpeakFlags );
   }//foreach( string pathSource in utilitySpeechArgument.pathSource )
  }//try
  catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
  if ( spFileStream != null ) { spFileStream.Close(); }
 }//public static void SpVoiceSpeak()
Exemple #8
0
 ///<summary>ArrayCopy</summary>
 public static void ArrayCopy
 (
      string[][] source,
  ref string[]   target,
      int        rank,
  ref string     exceptionMessage    
 )
 {
  try
  {
   target = new string[source.Length];
   for ( int index = 0; index < source.Length; ++index )
   {
    target[index] = source[index][rank];
   }  
  }//try
  catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
 }//ArrayCopy
        }//public static void Main()

        /// <summary>SendMagicPacket</summary>
        public static void SendMagicPacket
        (
            ref UtilityWakeOnLanArgument utilityWakeOnLanArgument,
            ref string exceptionMessage
        )
        {
            int magicPacketIndex = -1;

            byte[] magicPacket    = null;
            byte[] byteMACAddress = null;
            string MACAddress     = null;

            System.Net.Sockets.UdpClient udpClient = null;
            try
            {
                udpClient = new System.Net.Sockets.UdpClient
                            (
                    UtilityWakeOnLan.UDPBroadcast,
                    UtilityWakeOnLan.UDPPort
                            );
                for (int MACAddressIndex = 0; MACAddressIndex < utilityWakeOnLanArgument.MACAddress.Length; ++MACAddressIndex)
                {
                    MACAddress     = utilityWakeOnLanArgument.MACAddress[MACAddressIndex];
                    MACAddress     = MACAddress.Replace("-", String.Empty);
                    byteMACAddress = UtilityHex.ToByteArray(MACAddress);
                    magicPacket    = new byte[MagicPacketHeader.Length + (byteMACAddress.Length * MACAddressRepeat)];
                    for (magicPacketIndex = 0; magicPacketIndex < MagicPacketHeader.Length; ++magicPacketIndex)
                    {
                        magicPacket[magicPacketIndex] = MagicPacketHeader[magicPacketIndex];
                    }
                    for (int magicPacketRepeat = 0; magicPacketRepeat < MACAddressRepeat; ++magicPacketRepeat)
                    {
                        for (int byteMACAddressIndex = 0; byteMACAddressIndex < byteMACAddress.Length; ++byteMACAddressIndex)
                        {
                            magicPacket[magicPacketIndex] = byteMACAddress[byteMACAddressIndex];
                            ++magicPacketIndex;
                        }
                    }
                    udpClient.Send(magicPacket, magicPacket.Length);
                } //for( int MACAddressIndex = 0; MACAddressIndex < utilityWakeOnLanArgument.MACAddress.Length; ++MACAddressIndex )
            }     //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
        }         //public static void SendMagicPacket
  }//public static void MailSend()

  ///<summary>MailSend</summary>
  ///<remarks>
  /// Scott Mitchell AspNet.4GuysFromRolla.com/articles/102203-1.aspx Enhancing the 'Email the Rendered Output of an ASP.NET Web Control' Code 
  /// Scott Mitchell AspNet.4GuysFromRolla.com/articles/091102-1.aspx Emailing the Rendered Output of an ASP.NET Web Control 
  ///</remarks>  
  public static void MailSend
  (
       System.Web.UI.Page               page,
   ref string                           emailRecipient,
   ref string                           exceptionMessage
  )
  {
   HttpContext                     httpContext      =  HttpContext.Current;
   HtmlTextWriter                  htmlTextWriter   =  null;
   MailAddress                     mailAddressFrom  =  null; 
   MailAddress                     mailAddressTo    =  null; 
   System.Net.Mail.MailMessage     mailMessage      =  null;
   SmtpClient                      smtpClient       =  null;
   StringBuilder                   stringBuilder    =  null;
   StringWriter                    stringWriter     =  null;
   if ( httpContext == null ) { return; }
   try
   {
    smtpClient              =  new SmtpClient();
    mailAddressFrom         =  new MailAddress( "administrator@LocalHost" );
    mailAddressTo           =  new MailAddress( emailRecipient );
    mailMessage             =  new System.Net.Mail.MailMessage( mailAddressFrom, mailAddressTo );
    mailMessage.IsBodyHtml  =  true;
    stringBuilder           =  new StringBuilder();
    stringWriter            =  new StringWriter( stringBuilder );
    htmlTextWriter          =  new HtmlTextWriter( stringWriter );
    page.RenderControl( htmlTextWriter );
    mailMessage.Body        =  stringBuilder.ToString();
    smtpClient.Send( mailMessage );
   }
   catch( SmtpException exception ) { UtilityException.ExceptionLog( exception, "SmtpException", ref exceptionMessage ); }
   catch( SocketException exception ) { UtilityException.ExceptionLog( exception, "SocketException", ref exceptionMessage ); }
   catch( System.Web.HttpException exception ) { UtilityException.ExceptionLog( exception, "System.Web.HttpException", ref exceptionMessage ); }
   catch( Exception exception ) { UtilityException.ExceptionLog( exception, "Exception", ref exceptionMessage ); }
   finally
   {
    if ( mailMessage    != null )  { mailMessage.Dispose(); }
    if ( htmlTextWriter != null )  { htmlTextWriter.Close(); }
    if ( stringWriter   != null )  { stringWriter.Close(); }
   }//finally
   httpContext.Server.Transfer( httpContext.Request.ServerVariables["PATH_INFO"] );
  }//MailSend()
Exemple #11
0
 }//public static void SpVoiceSpeak()
 
 ///<summary>SpeechObjectTokensVoices</summary>
 public static void SpeechObjectTokensVoices
 (
  ref ISpeechObjectTokens  speechObjectTokens,
  ref string               exceptionMessage
 )
 {
  SpVoice              spVoice             =  null;
  try
  {
   spVoice = new SpVoice();
   speechObjectTokens  =  spVoice.GetVoices("", "");
   #if (DEBUG)
    foreach ( ISpeechObjectToken  speechObjectToken in speechObjectTokens )
    {
     System.Console.WriteLine("Voice: {0}", speechObjectToken.GetDescription(1033) );
    }
   #endif
  }//try
  catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
 }//public static ISpeechObjectTokens SpeechObjectTokensVoices()
  }//public static void SendQuit

  ///<summary>SmtpServiceStatus</summary>
  public static void SmtpServiceStatus
  (
   ref UtilityMailArgument  utilityMailArgument,
   ref string               exceptionMessage
  )
  {
   int            bytes          =  -1;
   //string         message        =  null;
   string         response       =  null;
   
   Byte[]         data;
   NetworkStream  networkStream  =  null;
   TcpClient      tcpClient      =  null;

   try
   {
    tcpClient      =  new TcpClient( utilityMailArgument.smtpServer, utilityMailArgument.smtpPort );
    networkStream  =  tcpClient.GetStream();
    data           =  new Byte[ SizeBuffer ];
    // Read the first batch of the TcpServer response bytes.
    bytes          =  networkStream.Read( data, 0, SizeBuffer );
    response       =  Encoding.ASCII.GetString( data, 0, bytes );
    if ( response.Substring(0, 3) != "220" )
    {
     return;
    }
    System.Console.WriteLine( response );
   }//try
   catch ( ArgumentNullException exception ) { UtilityException.ExceptionLog( exception, "ArgumentNullException", ref exceptionMessage ); }
   catch ( ArgumentOutOfRangeException exception ) { UtilityException.ExceptionLog( exception, "ArgumentOutOfRangeException", ref exceptionMessage ); }
   catch ( SocketException exception ) { UtilityException.ExceptionLog( exception, "SocketException", ref exceptionMessage ); }
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, "Exception", ref exceptionMessage ); }
   finally
   {
    if ( tcpClient != null )
    {
     tcpClient.Close();
    }//if ( tcpClient != null )
   }//finally
  }//public static void SmtpServiceStatus()
Exemple #13
0
 }//public static void DatabaseUpdate()
 
 ///<summary>FileUploadSource</summary>
 public static void FileUploadByte
 (
  ref FileUpload  fileUpload,
  ref byte[]      byteFileContent,
  ref string      exceptionMessage
 )
 {
  HttpContext       httpContext  =  HttpContext.Current;
  System.IO.Stream  stream       =  null;
  try
  {
   if ( fileUpload.HasFile )
   {
    byteFileContent    =  new byte[fileUpload.PostedFile.ContentLength];
    //stream  =  fileUpload.PostedFile.InputStream;
    stream  =  fileUpload.FileContent;
    stream.Read( byteFileContent, 0, fileUpload.PostedFile.ContentLength );
    //Convert byte[] to string 
    //imageContent       =  ( new System.Text.ASCIIEncoding()).GetString( byteFileContent );
   }//if ( fileUpload.HasFile )
  }//try
  catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
 }
        ///<summary>RenderImage</summary>
        public static void RenderImage
        (
            ref string databaseConnectionString,
            ref string exceptionMessage,
            ref int sequenceOrderId,
            ref string dataSource,
            ref string contentColumn,
            ref string sourceColumn,
            ref string typeColumn,
            ref byte[]  imageContent,
            ref string imageSource,
            ref string imageType
        )
        {
            HttpContext httpContext = HttpContext.Current;
            string      sqlQuery    = null;
            IDataReader iDataReader = null;

            try
            {
                if (httpContext == null)
                {
                    return;
                }
                sqlQuery = string.Format
                           (
                    RenderImageQueryFormat,
                    contentColumn,
                    sourceColumn,
                    typeColumn,
                    dataSource,
                    sequenceOrderId
                           );
                UtilityDatabase.DatabaseQuery
                (
                    databaseConnectionString,
                    ref exceptionMessage,
                    ref iDataReader,
                    sqlQuery,
                    CommandType.Text
                );
                if (exceptionMessage != null)
                {
                    return;
                }
                if (iDataReader.Read())
                {
                    imageContent = ( byte[] )iDataReader[contentColumn];
                    imageSource  = ( string )iDataReader[sourceColumn];
                    imageType    = ( string )iDataReader[typeColumn];
                    UtilityResponse.ResponseOutputStreamWrite
                    (
                        ref imageContent,
                        ref imageSource,
                        ref imageType,
                        ref exceptionMessage
                    );
                } //if ( iDataReader.Read() )
            }     //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            if (iDataReader != null && iDataReader.IsClosed == false)
            {
                iDataReader.Close();
            }
        }
        }     //Service()

        ///<summary>Software</summary>
        ///<remarks>
        /// Subject: Getting a list of installed programs on windows using C# 9/7/2005 6:35 AM PST By: Phil Williams In: microsoft.public.dotnet.languages.csharp
        ///</remarks>
        public static void Software()
        {
            string displayName      = null;
            string displayVersion   = null;
            string fileDescription  = null;
            string fileName         = null;
            string exceptionMessage = null;

            string[] subKeyNames = null;

            Microsoft.Win32.RegistryKey registryKey     = null;
            Microsoft.Win32.RegistryKey registrySubKey  = null;
            Microsoft.Win32.RegistryKey registrySubKey2 = null;

            System.Diagnostics.FileVersionInfo fileVersionInfo;

            try
            {
                registryKey    = Microsoft.Win32.Registry.LocalMachine;
                registrySubKey = registryKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
                subKeyNames    = registrySubKey.GetSubKeyNames();
                foreach (string subKeyName in subKeyNames)
                {
                    registrySubKey2 = registrySubKey.OpenSubKey(subKeyName);

                    /*
                     * if
                     * (
                     * ValueNameExists( registrySubKey2.GetValueNames(), "DisplayName") &&
                     * ValueNameExists( registrySubKey2.GetValueNames(), "DisplayVersion")
                     * )
                     */
                    if
                    (
                        registrySubKey2.GetValue("DisplayName") != null &&
                        registrySubKey2.GetValue("DisplayVersion") != null
                    )
                    {
                        displayName    = registrySubKey2.GetValue("DisplayName").ToString();
                        displayVersion = registrySubKey2.GetValue("DisplayVersion").ToString();
                        fileName       = displayName;

                        /*
                         * fileVersionInfo  =  System.Diagnostics.FileVersionInfo.GetVersionInfo( fileName );
                         * fileDescription  =  fileVersionInfo.FileDescription;
                         */
                        System.Console.WriteLine("Software Name: {0} | Version: {1}", displayName, displayVersion);
                    } //if ( ValueNameExists( registrySubKey2.GetValueNames(), "DisplayName") && ValueNameExists( registrySubKey2.GetValueNames(), "DisplayVersion" ) )
                    registrySubKey2.Close();
                }     //foreach ( string subKeyName in subKeyNames )
                registrySubKey.Close();
            }         //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, "Exception", ref exceptionMessage); }
            finally
            {
                if (registrySubKey != null)
                {
                    registrySubKey.Close();
                }
                if (registrySubKey2 != null)
                {
                    registrySubKey2.Close();
                }
            } //finally
        }     //Software()
        ///<summary>Import</summary>
        public static void Import
        (
            ref UtilityCommonwealthBankOfAustraliaTransactionArgument UtilityCommonwealthBankOfAustraliaTransactionArgument,
            ref string exceptionMessage
        )
        {
            double debitCredit = 0.0;
            int    rowCount    = -1;
            int    rowAffect   = -1;

            string[]        column          = null;
            string          commandText     = null;
            string          line            = null;
            OleDbCommand    oleDbCommand    = null;
            OleDbConnection oleDbConnection = null;
            StreamReader    streamReader    = null;

            try
            {
                oleDbConnection = new OleDbConnection(DatabaseConnectionString);
                oleDbConnection.Open();
                oleDbCommand = new OleDbCommand(DateFormat, oleDbConnection);
                oleDbCommand.ExecuteNonQuery();
                foreach (string filenameSource in UtilityCommonwealthBankOfAustraliaTransactionArgument.filenameSource)
                {
                    streamReader = new StreamReader(filenameSource);
                    rowCount     = 0;
                    while (streamReader != StreamReader.Null)
                    {
                        line = streamReader.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        ++rowCount;
                        if (rowCount < UtilityCommonwealthBankOfAustraliaTransactionArgument.firstRow)
                        {
                            continue;
                        }
                        column    = line.Split(',');
                        column[1] = column[1].Replace("\"", "");
                        Double.TryParse(column[1], out debitCredit);
                        column[2]   = column[2].Replace("\"", "");
                        column[2]   = column[2].Replace("'", "''");
                        commandText = string.Format
                                      (
                            SQLInsert,
                            column[0],
                            debitCredit,
                            column[2],
                            column[3]
                                      );
                        oleDbCommand = new OleDbCommand(commandText, oleDbConnection);
                        rowAffect    = oleDbCommand.ExecuteNonQuery();
                    }
                    if (streamReader != null)
                    {
                        streamReader.Close();
                    }
                }
            }
            catch (SqlException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            catch (InvalidOperationException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            if (oleDbConnection != null)
            {
                oleDbConnection.Close();
            }
        }
Exemple #17
0
        ///<summary>Import</summary>
        public static void Import
        (
            ref UtilityAussieHomeLoansTransactionHistoryArgument utilityAussieHomeLoansTransactionHistoryArgument,
            ref string exceptionMessage
        )
        {
            int rowCount  = -1;
            int rowAffect = -1;

            string[]        column      = null;
            string          commandText = null;
            string          line        = null;
            DateTime        transactionDate;
            DateTime        transactionEffectiveDate;
            OleDbCommand    oleDbCommand    = null;
            OleDbConnection oleDbConnection = null;
            StreamReader    streamReader    = null;

            System.Globalization.CultureInfo cultureInfoAU;
            System.Globalization.CultureInfo cultureInfoUS;
            try
            {
                cultureInfoAU = new System.Globalization.CultureInfo("en-AU");
                cultureInfoUS = new System.Globalization.CultureInfo("en-US");
                System.Threading.Thread.CurrentThread.CurrentCulture   = cultureInfoAU;
                System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfoAU;
                System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
                oleDbConnection = new OleDbConnection(DatabaseConnectionString);
                oleDbConnection.Open();
                oleDbCommand = new OleDbCommand(DateFormat, oleDbConnection);
                oleDbCommand.ExecuteNonQuery();
                foreach (string filenameSource in utilityAussieHomeLoansTransactionHistoryArgument.filenameSource)
                {
                    streamReader = new StreamReader(filenameSource);
                    rowCount     = 0;
                    while (streamReader != StreamReader.Null)
                    {
                        line = streamReader.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        ++rowCount;
                        if (rowCount < utilityAussieHomeLoansTransactionHistoryArgument.firstRow)
                        {
                            continue;
                        }
                        column    = line.Split(',');
                        column[0] = column[0].Trim();
                        DateTime.TryParse(column[1], out transactionDate);
                        DateTime.TryParse(column[2], out transactionEffectiveDate);

                        /*
                         * commandText  = string.Format
                         * (
                         * SQLInsert,
                         * column[0],
                         * transactionDate.ToString("d", cultureInfoUS),
                         * transactionEffectiveDate.ToString("d", cultureInfoUS),
                         * column[3],
                         * column[4],
                         * column[5],
                         * column[6]
                         * );
                         */
                        commandText = string.Format
                                      (
                            SQLInsert,
                            column[0],
                            column[1],
                            column[2],
                            column[3],
                            column[4],
                            column[5],
                            column[6]
                                      );
                        oleDbCommand = new OleDbCommand(commandText, oleDbConnection);
                        rowAffect    = oleDbCommand.ExecuteNonQuery();
                    }
                    if (streamReader != null)
                    {
                        streamReader.Close();
                    }
                }
            }
            catch (SqlException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            catch (InvalidOperationException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            if (oleDbConnection != null)
            {
                oleDbConnection.Close();
            }
        }
        ///<summary>ResponseOutputStreamWrite</summary>
        ///<remarks>Ben Reichelt DotNetJunkies.com/WebLog/barblog/archive/2005/01/02/40588.aspx Can't stream mp3 file in .net</remarks>
        public static void ResponseOutputStreamWrite
        (
            ref string path,
            ref string exceptionMessage
        )
        {
            HttpContext httpContext = System.Web.HttpContext.Current;

            byte[] buffer             = null;
            int    bytesRead          = -1;
            int    fileExtensionIndex = -1;
            long   fileLength         = -1;
            string filename           = null;

            System.IO.FileInfo   fileInfo   = null;
            System.IO.FileStream fileStream = null;
            try
            {
                if (string.IsNullOrEmpty(path))
                {
                    path = @"D:\Audio\Christian\Junko\Junko_-_AsForMeAndMyHouse.mp3";
                }
                if (File.Exists(path) == false)
                {
                    return;
                }
                fileInfo           = new FileInfo(path);
                filename           = System.IO.Path.GetFileName(path);
                fileExtensionIndex = UtilityFile.FileExtensionIndex(filename);
                fileLength         = fileInfo.Length;
                if (httpContext == null)
                {
                    return;
                }
                httpContext.Response.Buffer = true;
                httpContext.Response.Clear();
                httpContext.Response.ClearContent();
                httpContext.Response.ClearHeaders();
                //httpContext.Response.AddHeader( "Accept-Header", fileLength.ToString() );
                httpContext.Response.AppendHeader("Content-Disposition", "inline; filename=" + httpContext.Server.UrlEncode(filename));
                //httpContext.Response.AddHeader( "Content-Disposition", "attachment;filename=" + filename );

                /*
                 * if ( fileLength > -1 )
                 * {
                 * httpContext.Response.AppendHeader( "Content-Length", fileLength.ToString() );
                 * }
                 */
                //httpContext.Response.WriteFile( path );
                if (fileExtensionIndex > -1)
                {
                    httpContext.Response.ContentType = UtilityFile.FileExtension[fileExtensionIndex][UtilityFile.FileExtensionRankContentType];
                }
                else
                {
                    httpContext.Response.ContentType = UtilityFile.DefaultContentType;
                }
                fileStream = new System.IO.FileStream
                             (
                    path,
                    System.IO.FileMode.Open,
                    System.IO.FileAccess.Read,
                    System.IO.FileShare.ReadWrite
                             );
                buffer = new byte[ByteSize];
                while (true)
                {
                    bytesRead = fileStream.Read(buffer, 0, ByteSize);
                    if (bytesRead <= 0)
                    {
                        break;
                    }
                    httpContext.Response.OutputStream.Write(buffer, 0, buffer.Length);
                    httpContext.Response.Flush();
                } //while ( true )
                fileStream.Close();
            }     //try
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            httpContext.Response.End();
        }//public static void ResponseOutputStreamWrite()
        /// <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( );
                }
            }
        }
Exemple #20
0
  }//public static void UtilityContact.ContactDetailSave()   	

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

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

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

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

    oleDbParameter                =  new OleDbParameter( "@imageType", OleDbType.VarChar, 255 );
    oleDbParameter.Value          =  imageType;
    oleDbCommand.Parameters.Add( oleDbParameter );
    
    databaseNumberOfRowsAffected  =  oleDbCommand.ExecuteNonQuery();
   }//try
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
  }
Exemple #21
0
  }//public static void Main( String[] argv )

  ///<summary>ImpersonateValidUser</summary>
  public static bool ImpersonateValidUser
  (
   ref  String                       domainName, 
   ref  String                       password,
   ref  String                       userName, 
   ref  WindowsImpersonationContext  windowsImpersonationContext,
   ref  String                       exceptionMessage
  )
  {
   HttpContext      httpContext                      =  HttpContext.Current;
   bool             impersonateValidUser             =  false;
   bool             revertToSelf                     =  false;
   int              duplicateToken                   =  -1;
   int              logonUserA                       =  -1;
   IntPtr           token                            =  IntPtr.Zero;
   IntPtr           tokenDuplicate                   =  IntPtr.Zero;
   WindowsIdentity  windowsIdentity                  =  null;
   
   if ( string.IsNullOrEmpty( userName ) )
   {
    userName = Environment.UserName; 
   } 

   if ( string.IsNullOrEmpty( domainName ) )
   {
   	if ( httpContext == null )
    {
     if ( userName.IndexOf('\\') > -1 ) { domainName = Environment.UserDomainName; }
     else                              { domainName = Environment.MachineName; }
    }
    else
    {     	
     domainName = Environment.MachineName;
    } 
   }

   #if (DEBUG)
   System.Console.WriteLine
   (
    "DomainName: {0} | Password: {1} | UserName: {2}",
    domainName,
    password,
    userName
   );
   #endif

   try
   {
    revertToSelf = RevertToSelf();
    if ( revertToSelf == true )
    {
     logonUserA = LogonUserA
     (
           userName, 
           domainName, 
           password, 
           LOGON32_LOGON_INTERACTIVE, 
           LOGON32_PROVIDER_DEFAULT, 
      ref  token
     );
     if ( logonUserA != 0 )
     {
      duplicateToken = DuplicateToken
      (
           token,
           2, 
       ref tokenDuplicate
      );

      if ( duplicateToken != 0 )
      {
       windowsIdentity = new WindowsIdentity
       (
        tokenDuplicate
       );

       windowsImpersonationContext = windowsIdentity.Impersonate();

       if ( windowsImpersonationContext != null )
       {
        impersonateValidUser = true;
        CloseHandle(token);
        CloseHandle(tokenDuplicate);
       }//if ( windowsImpersonationContext != null )
      }//if ( duplicateToken == 0 )
     }//if ( logonUserA != 0 )
    }//if ( revertToSelf == true )   

    if ( impersonateValidUser == false )
    {
     if ( token!= IntPtr.Zero )
     {             
      CloseHandle( token );
     }
     if ( tokenDuplicate!=IntPtr.Zero )
     {      
      CloseHandle( tokenDuplicate );
     }
    }//if ( impersonateValidUser )
   }//try
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
   #if (DEBUG)
   System.Console.WriteLine
   (
    "revertToSelf: {0} | logonUserA: {1} | duplicateToken: {2} | impersonateValidUser: {3}",
    revertToSelf,
    logonUserA,
    duplicateToken,
    impersonateValidUser
   );
   #endif
   #if (DEBUG)
    if ( impersonateValidUser )
    {
     System.Console.WriteLine
     (
      "windowsIdentity AuthenticationType: {0} | IsAnonymous: {1} | IsAuthenticated: {2} | IsGuest: {3} | IsSystem: {4} | Name {5}",
      windowsIdentity.AuthenticationType,
      windowsIdentity.IsAnonymous,
      windowsIdentity.IsAuthenticated,
      windowsIdentity.IsGuest,
      windowsIdentity.IsSystem,    
      windowsIdentity.Name
     );
    }
   #endif
   return ( impersonateValidUser );
  }//private void ImpersonateValidUser()
Exemple #22
0
  }//public static void Main()

  ///<summary>WhoisLookup</summary>
  public static void WhoisLookup
  (
   ref UtilityWhoIsArgument utilityWhoIsArgument,
   ref StringBuilder[][]    sb,
   ref string               exceptionMessage
  )
  {
   byte[]        domainNameByte            =  null;
   bool          registryDomainSuffixOnly  =  false;
   int           domainIndex               =  -1;
   int           registryIndex             =  -1;
   string        domainName                =  null;
   string        domainNameNewLine         =  null;
   string[]      domainNameSplit           =  null;
   string        readLine                  =  null;
   string[]      registry                  =  null;
   string        registryCurrent           =  null;
   HttpContext   httpContext               =  HttpContext.Current;
   Stream        stream                    =  null;
   StreamReader  streamReader              =  null;
   TcpClient     tcpClient                 =  null;
   try
   {
   	if ( utilityWhoIsArgument.registry.Length > 0 )
   	{
     registry = utilityWhoIsArgument.registry;
    }
    else if ( utilityWhoIsArgument.registryDomainSuffixOnly == false )
    {
     UtilityString.ArrayCopy( RegistryWhoIs, ref registry, RankRegistryWhoIsName, ref exceptionMessage );
     if ( exceptionMessage != null ) { return; }    	
    }
    else
    {
     registryDomainSuffixOnly = true;
    }
    sb = new StringBuilder[utilityWhoIsArgument.domainName.Length][];
    for ( domainIndex = 0; domainIndex < utilityWhoIsArgument.domainName.Length; ++domainIndex )
    {
     domainName         =  utilityWhoIsArgument.domainName[domainIndex];
     domainNameNewLine  =  domainName + Environment.NewLine;
     domainNameByte     =  Encoding.ASCII.GetBytes( domainNameNewLine.ToCharArray() );
     if ( registryDomainSuffixOnly )
     {
      domainNameSplit  =  domainName.Split('.');
      registry         =  new string[1];
      registry[0]      =  RegistryWhoIs[0][RankRegistryWhoIsName];
      for ( int index = 0; index < RegistryWhoIs.Length; ++index )
      {
       if ( RegistryWhoIs[index][RankRegistryWhoIsName].EndsWith( domainNameSplit[domainNameSplit.Length-1].ToLower() ) ) 
       {
       	registry[0] = RegistryWhoIs[index][RankRegistryWhoIsName];
       	break;
       }//if ( RegistryWhoIs[index][RankRegistryWhoIsName].EndsWith( domainNameSplit[domainNameSplit.Length-1].ToLower() );
      }//for ( int index = 0; index < RegistryWhoIs.Length; ++index )
     }//if ( registryDomainSuffixOnly == true )
     sb[domainIndex] = new StringBuilder[registry.Length];
     for ( registryIndex = 0; registryIndex < registry.Length; ++registryIndex )
     {
      registryCurrent                 =  registry[registryIndex]; 
      tcpClient                       =  new TcpClient( registryCurrent, utilityWhoIsArgument.port );
      stream                          =  tcpClient.GetStream();
      stream.Write( domainNameByte, 0, domainNameNewLine.Length );
      streamReader                    =  new StreamReader( tcpClient.GetStream(), Encoding.ASCII );
      sb[domainIndex][registryIndex]  =  new StringBuilder( registryCurrent);
      if ( httpContext == null ) 
      { sb[domainIndex][registryIndex].Append( Environment.NewLine ); }
      else
      { sb[domainIndex][registryIndex].Append( "<br/>" ); }      
      while ( true )
      {
	   readLine  =  streamReader.ReadLine();
	   if ( readLine == null ) { break; }
       if ( httpContext == null ) { System.Console.WriteLine( readLine ); }
	   sb[domainIndex][registryIndex].Append( readLine );
	   if ( httpContext != null ) { sb[domainIndex][registryIndex].Append("<br/>"); }
	  }//while ( true )
	  tcpClient.Close();
     }//for ( registryIndex = 0; registryIndex < registry.Length; ++registryIndex ) 
    }//foreach ( string domainName in utilityWhoIsArgument.domainName )    	
   }//try
   catch ( SocketException exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
   catch ( Exception exception ) { UtilityException.ExceptionLog( exception, exception.GetType().Name, ref exceptionMessage ); }
   finally 
   {
   	if ( tcpClient != null ) { tcpClient.Close(); }
   }//finally	
  }//WhoisLookup
        /// <summary>EternalXml</summary>
        public static void EternalXml
        (
            ref EternalArgument eternalArgument,
            ref string exceptionMessage
        )
        {
            DataSet   dataSet           = null;
            ArrayList databaseName      = null;
            ArrayList sqlStatementUnion = null;
            ArrayList objectName        = null;
            ArrayList ownerName         = null;
            ArrayList unionIndex        = null;
            String    filenameXml       = null;

            try
            {
                UtilityDatabase.DatabaseQuery
                (
                    DatabaseConnectionString,
                    ref exceptionMessage,
                    ref dataSet,
                    eternalArgument.sqlQuery,
                    CommandType.Text
                );
                if (exceptionMessage != null)
                {
                    return;
                }
                ;
                UtilityDatabase.SQLSelectParse
                (
                    eternalArgument.sqlQuery,
                    ref unionIndex,
                    ref sqlStatementUnion,
                    ref databaseName,
                    ref ownerName,
                    ref objectName,
                    ref exceptionMessage
                );
                if (exceptionMessage != null)
                {
                    return;
                }
                ;
                if (dataSet.Tables.Count < 1)
                {
                    return;
                }//if ( dataSet.Tables.Count < 1 )
                dataSet.DataSetName = (String)databaseName[0];
                for (int objectNameCount = 0; objectNameCount < objectName.Count; ++objectNameCount)
                {
                    dataSet.Tables[objectNameCount].TableName = (String)objectName[objectNameCount];
                }//for ( int objectNameCount = 0; objectNameCount < objectName.Count; ++objectNameCount )
                ScriptureReference.ScriptureReferenceURI
                (
                    DatabaseConnectionString,
                    FilenameConfigurationXml,
                    ref exceptionMessage,
                    ref dataSet
                );
                if (exceptionMessage != null)
                {
                    return;
                }
                ;
                if (eternalArgument.date)
                {
                    filenameXml = UtilityFile.DatePostfix(eternalArgument.filenameXml);
                }
                else
                {
                    filenameXml = eternalArgument.filenameXml;
                }
                UtilityXml.WriteXml
                (
                    dataSet,
                    ref exceptionMessage,
                    ref filenameXml,
                    ref eternalArgument.filenameStylesheet
                );
                if (exceptionMessage != null)
                {
                    return;
                }
                ;
            }
            catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); }
        }
  }//public static void Stub()

  /*
  public static void MailSend
  (
   ref String    SmtpServer,
   ref String    From,
   ref String    To,
   ref String    Cc,
   ref String    Bcc,
   ref String    Subject,
   ref String    Body,
   ref String[]  Attachment,
   ref String    exceptionMessage
  )
  {
   HttpContext     httpContext     =  HttpContext.Current;
   MailAttachment  mailAttachment  =  null;
   MailMessage          =  null;

   exceptionMessage                =  null;

   if ( string.IsNullOrEmpty( SmtpServer ) )
   {
    SmtpServer = "localhost"; //Environment.UserDomainName;
   }

   if ( string.IsNullOrEmpty( From ) )
   {
    From = Environment.UserName;
   }

   if ( string.IsNullOrEmpty( To ) )
   {
    To = From;
   }

   if ( string.IsNullOrEmpty( Subject ) )
   {
    Subject = "Subject: " + From + "@" + SmtpServer;
   }

   if ( string.IsNullOrEmpty( Body ) )
   {
    Body = "Body: " + From + "@" + SmtpServer;
   }

   try
   {
    SmtpMail.SmtpServer  =  SmtpServer;
              =  new MailMessage();

    .From     =  From;
    .To       =  To;
    .Cc       =  Cc;
    .Bcc      =  Bcc;
    .Subject  =  Subject;
    .Body     =  Body;

    if ( Attachment != null )
    {
     foreach( String AttachmentCurrent in Attachment )
     {
      if ( AttachmentCurrent == null || AttachmentCurrent.Trim() == String.Empty )
      {
       continue;
      }//if ( AttachmentCurrent == null || AttachmentCurrent.Trim() == String.Empty )
      mailAttachment = new MailAttachment( AttachmentCurrent );
      .Attachments.Add( mailAttachment );
     }//foreach( String AttachmentCurrent in Attachment )
    }//if ( Attachment != null )

    SmtpMail.Send(  );

   }//try
   catch( SocketException exception )
   {
    exceptionMessage = "SocketException: " + exception.Message;
   }   	
   catch( System.Web.HttpException exception )
   {
    exceptionMessage = "HttpException: " + exception.Message;
   }   	
   catch ( Exception exception )
   {
    exceptionMessage = "Exception: " + exception.Message;
   }//catch ( Exception exception )
   
   if ( exceptionMessage != null )
   {
    if ( httpContext == null )
    {
     System.Console.WriteLine( exceptionMessage );
    }//if ( httpContext == null )
    else
    {
     httpContext.Response.Write( exceptionMessage );
    }//else 
   }//if ( exceptionMessage != null )
  }//public static void MailSend()
  */
  
  ///<summary>MailSend.</summary>
  public static void MailSend
  (
   ref UtilityMailArgument  utilityMailArgument,
   ref String               exceptionMessage
  )
  {

   string                          keyboardEntry       =  null;

   HttpContext                     httpContext         =  HttpContext.Current;
 
   MailAddress                     mailAddressBcc      =  null;
   MailAddress                     mailAddressCc       =  null;
   MailAddress                     mailAddressFrom     =  null;
   MailAddress                     mailAddressTo       =  null;
   System.Net.Mail.Attachment      mailAttachment      =  null;
   System.Net.Mail.MailMessage     mailMessage         =  null;
   SmtpClient                      smtpClient          =  null;

   exceptionMessage                =  null;

   try
   {
    
    smtpClient            =  new SmtpClient( utilityMailArgument.smtpServer );
    
    if ( !String.IsNullOrEmpty( utilityMailArgument.bcc ) )
    {
     mailAddressBcc       =  new MailAddress( utilityMailArgument.bcc );
    }//if ( !String.IsNullOrEmpty( utilityMailArgument.bcc ) )

    if ( !String.IsNullOrEmpty( utilityMailArgument.cc ) )
    {
     mailAddressCc       =  new MailAddress( utilityMailArgument.cc );
    }//if ( !String.IsNullOrEmpty( utilityMailArgument.cc ) )
    
    mailAddressFrom       =  new MailAddress( utilityMailArgument.from );
    
    mailAddressTo         =  new MailAddress( utilityMailArgument.to );
    
    mailMessage           =  new System.Net.Mail.MailMessage
    (
     mailAddressFrom,
     mailAddressTo
    );
    
    if ( mailAddressBcc != null )
    {
     mailMessage.Bcc.Add( mailAddressBcc );	
    }//if ( mailAddressBcc != null )	

    if ( mailAddressCc != null )
    {
     mailMessage.Bcc.Add( mailAddressCc );	
    }//if ( mailAddressCc != null )	

    mailMessage.Subject   =  utilityMailArgument.subject;
    mailMessage.Body      =  utilityMailArgument.body;

    if ( utilityMailArgument.attachment != null )
    {
     foreach( String attachment in utilityMailArgument.attachment )
     {
      if ( !string.IsNullOrEmpty( attachment ) )
      {
       mailAttachment = new System.Net.Mail.Attachment( attachment );
       mailMessage.Attachments.Add( mailAttachment );
      }//if ( !string.IsNullOrEmpty( attachment ) )
     }//foreach( String attachment in utilityMailArgument.attachment )
    }//if ( utilityMailArgument.attachment != null )

    if ( httpContext != null )
    {
     smtpClient.Send
     (
      mailMessage 
     );
    }//if ( httpContext != null )
    else
    {        	
     // Set the method that is called back when the send operation ends.
     smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
    
     smtpClient.SendAsync
     (
      mailMessage, 
      utilityMailArgument.userState
     );
    
     System.Console.WriteLine("Sending message... press c to cancel mail. Press any other key to continue.");
     keyboardEntry = Console.ReadLine();
     
     // If the user canceled the send, and mail hasn't been sent yet,
     // then cancel the pending operation.
     if ( keyboardEntry.StartsWith("c") && mailSent == false )
     {
      smtpClient.SendAsyncCancel();
     }//if ( keyboardEntry.StartsWith("c") && mailSent == false )
     
    }//if ( httpContext == null )  
   }//try
   catch( SmtpException exception ) { UtilityException.ExceptionLog( exception, "SmtpException", ref exceptionMessage ); }
   catch( SocketException exception ) { UtilityException.ExceptionLog( exception, "SocketException", ref exceptionMessage ); }
   catch( System.Web.HttpException exception ) { UtilityException.ExceptionLog( exception, "System.Web.HttpException", ref exceptionMessage ); }
   catch( Exception exception ) { UtilityException.ExceptionLog( exception, "Exception", ref exceptionMessage ); }
   finally
   {
    mailMessage.Dispose();
    //smtpClient.Dispose();
   }
  }//public static void MailSend()