Esempio n. 1
0
  }//public static void WriteXmlStylesheet()  
  
  ///<summary>Write XML.</summary>
  /// <param name="dataSet">Dataset.</param>  
  /// <param name="exceptionMessage">Exception Message.</param>
  /// <param name="filenameXml">Filename XML.</param>
  /// <param name="filenameStylesheet">Filename Stylesheet (XSLT).</param>
  public static void WriteXml
  (
       DataSet dataSet,
   ref string  exceptionMessage,
   ref string  filenameXml,
   ref string  filenameStylesheet
  )
  { 

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

   try
   {
    UtilityDirectory.WebServerFullPath( ref filenameXml );

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

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