oracleKing 2011-04-17
读取WMF的Blob字段,生成wmf文件
/// <summary>
/// 读取WMF字段,生成临时WMF文件
/// </summary>
private void ReadWMFBlobField()
{
OracleConnection _connection = new OracleConnection(m_connectionString);
try
{
_connection.Open();
OracleCommand _selectCommand = _connection.CreateCommand();
OracleTransaction _transaction = _selectCommand.Connection.BeginTransaction();
_selectCommand.Transaction = _transaction;
string _selectSQL = "Select WMF from hSUSEr.ZDT where ZDNO = '"
+ m_zoneNo + "'";
_selectCommand.CommandText = _selectSQL;
OracleDataReader _dataReader = _selectCommand.ExecuteReader();
if (_dataReader.Read() == true)
{
OracleLob _oracleLob = _dataReader.GetOracleLob(0);
long _byteCount = _oracleLob.Length;
_dataReader.Close();
if (File.Exists(m_wmfFileName) == true)
{
File.Delete(m_wmfFileName);
}
FileStream _fileStream = File.Open(m_wmfFileName, FileMode.OpenOrCreate);
int _length = 30485760;
byte[] _buffer = new byte[_length];
int i = _oracleLob.Read(_buffer, 0, _length);
while (i > 0)
{
_fileStream.Write(_buffer, 0, i);
i = _oracleLob.Read(_buffer, 0, _length);
}
_fileStream.Close();
_oracleLob.Close();
_selectCommand.Parameters.Clear();
_transaction.Commit();
}
else
{
MessageBoxEx.Show("没有查找到相符合的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
读取DWG的Blob字段,生成DWG文件
/// <summary>
/// 读取DWG字段,生成DWG文件
/// </summary>
private void ReadDWGBlobField()
{
OracleConnection _connection = new OracleConnection(m_connectionString);
try
{
_connection.Open();
OracleCommand _selectCommand = _connection.CreateCommand();
OracleTransaction _transaction = _selectCommand.Connection.BeginTransaction();
_selectCommand.Transaction = _transaction;
string _selectSQL = "Select DWG from hsuser.ZDT where ZDNO = '"
+ m_zoneNo + "'";
_selectCommand.CommandText = _selectSQL;
OracleDataReader _dataReader = _selectCommand.ExecuteReader();
if (_dataReader.Read() == true)
{
OracleLob _oracleLob = _dataReader.GetOracleLob(0);
long _byteCount = _oracleLob.Length;
_dataReader.Close();
if (File.Exists(m_dwgFileName) == true)
{
File.Delete(m_dwgFileName);
}
FileStream _fileStream = File.Open(m_dwgFileName, FileMode.OpenOrCreate);
int _length = 30485760;
byte[] _buffer = new byte[_length];
int i;
while ((i = _oracleLob.Read(_buffer, 0, _length)) > 0)
{
_fileStream.Write(_buffer, 0, i);
}
_fileStream.Close();
_oracleLob.Clone();
_selectCommand.Parameters.Clear();
_transaction.Commit();
}
else
{
MessageBoxEx.Show("没有查找到相符合的记录!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}