📄 converter.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data.OracleClient;
using System.Windows.Forms;
using System.Data;
namespace OracelToXml
{
public class Converter:LC_XMLControl.IThransProtocol
{
#region IThransProtocol 成员
private ArrayList _allres = null;
public System.Collections.ArrayList allres
{
get
{
return _allres;
}
set
{
_allres = (ArrayList)value;
}
}
public void closeDesConnection()
{
}
public void closeSourceConnection()
{
}
public void createDesContentction(string constr)
{
}
public void createSourceContenction(string constr)
{
_sourceconnection = null;
if (_sourceconnection != null) _sourceconnection.Close();
string[] temp = constr.Split('#');
string cstr = "";
int k = 0;
if (temp.Length > 0)
{
for (int i = 0; i < temp.Length; i++)
{
if (temp[i].Trim().ToString() != "")
{
temp[k++] = temp[i];
}
}
}
cstr = "server=" + temp[0] + ";user=" + temp[2] + ";password=" + temp[3];
try
{
_sourceconnection = new OracleConnection(cstr);
_sourceconnection.Open();
}
catch (Exception e)
{
MessageBox.Show(e.Message.ToString());
}
}
private int _cursum;
public int cursum
{
get
{
return _cursum;
}
set
{
_cursum=value;
}
}
private object _desconnection;
public object desconnection
{
get
{
return _desconnection;
}
set
{
_desconnection=value;
}
}
private int _dtype;
public int dtype
{
get
{
return _dtype ;
}
set
{
_dtype=value;
}
}
private ArrayList _errorres = null;
public System.Collections.ArrayList errorres
{
get
{
return _errorres;
}
set
{
_errorres=(ArrayList)value;
}
}
public System.Collections.ArrayList getAllDesField(string table)
{
return null;
}
public System.Collections.ArrayList getAllDesTable()
{
return null;
}
public System.Collections.ArrayList getAllSourceField(string table)
{
ArrayList altemp = new ArrayList();
OracleCommand cmd = new OracleCommand("select * from user_tab_columns where TABLE_NAME=('" + table + "')");
cmd.Connection = _sourceconnection;
OracleDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
while (sdr.Read())
{
altemp.Add(sdr["COLUMN_NAME"].ToString());
}
}
sdr.Close();
return altemp;
}
public System.Collections.ArrayList getAllSourceTable()
{
ArrayList altemp = new ArrayList();
OracleCommand cmd = new OracleCommand("select * from user_tables");
cmd.Connection = _sourceconnection;
OracleDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
while (sdr.Read())
{
altemp.Add(sdr["TABLE_NAME"].ToString());
}
}
sdr.Close();
return altemp;
}
private string _info;
public string info
{
get
{
return _info;
}
set
{
_info=value;
}
}
private ArrayList _msg = null;
public System.Collections.ArrayList msg
{
get
{
return _msg;
}
set
{
_msg=(ArrayList)value;
}
}
public System.Data.DataTable sourceToXml(string source, System.Collections.ArrayList allfield)
{
string temp = "";
for (int i = 0; i < allfield.Count; i++)
{
temp += allfield[i].ToString() + ",";
}
temp = temp.Substring(0, temp.Length - 1);
OracleCommand cmd = new OracleCommand("select " + temp + " from " + source);
cmd.Connection = _sourceconnection;
DataTable dt = new DataTable();
OracleDataAdapter sda = new OracleDataAdapter(cmd);
sda.Fill(dt);
return dt;
}
private OracleConnection _sourceconnection;
public object sourceconnection
{
get
{
return _sourceconnection;
}
set
{
_sourceconnection=(OracleConnection)value;
}
}
private string _spliter;
public string spliter
{
get
{
return _spliter;
}
set
{
_spliter=value;
}
}
private int _stype;
public int stype
{
get
{
return _stype ;
}
set
{
_stype=value;
}
}
public void xmlToDes(string des, System.Collections.ArrayList rows, System.Collections.ArrayList field)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -