DBReader/Classes/Proxy

/**
*
* DBReader 1.0, Access to SAP tables using SAP's .Net Connector.
*
* Author: hardteck
* Email: hardteck@web.de
*
* Last modified: Fr, 17. Okt 2003, 11:31:20
*/
namespace SAPReader {
using System;
///
/// A proxy encapsulates the a SAPProxy to accessing SAP.
/// The class is responsible for a connection to SAP through
/// a Destination object ().
///
///
public class Proxy {
///
/// The proxy to accessing SAP as generated by
/// C#.Net Connector Wizard. This proxy provides only
/// the RFC_READ_TABLE function to read anly table from
/// SAP's database.
///
private SAPReader.SAPKernel.SAPProxy proxy = null;
///
/// The destination object.
///
private SAP.Connector.Destination dest = null;
///
/// Indicates whether the proxy is connected to SAP.
///
private bool isConnected = false;

///
/// The constructor.
/// Destination information.
///
public Proxy(SAP.Connector.Destination dest){
this.dest = dest;
}
///
/// The constructor.
/// Destination information provided
/// by a ConnectionInfo object.
///
///
public Proxy(SAPReader.ConnectionInfo conInfo) {
this.dest = new SAP.Connector.Destination();
this.updateDestination(conInfo);
}
///
/// The proxy to accessing SAP as generated by
/// C#.Net Connector Wizard. This proxy provides only
/// the RFC_READ_TABLE function to read anly table from
/// SAP's database.
///
public SAPReader.SAPKernel.SAPProxy SAPProxy {
set{this.proxy = value;}
get{return this.proxy;}
}
///
/// Updates the destination information.
///
///
public void updateDestination(SAPReader.ConnectionInfo conInfo){
this.dest.AppServerHost = conInfo.SAPServer;
this.dest.Client = conInfo.Client;
this.dest.Language = conInfo.Language;
this.dest.Password = conInfo.Password;
this.dest.SystemNumber = conInfo.SystemNumber;
this.dest.Username = conInfo.Username;
}
///
/// Indicates whether the proxy is connected to SAP.
///
public bool connected(){
return this.isConnected;
}
///
/// Connects the proxy to the SAP system.
/// Thrown when the
/// connection fails.
///
public void connectSAP(){
if (this.proxy == null) {
this.proxy = new SAPReader.SAPKernel.SAPProxy();
}
if (this.isConnected == false) {
proxy.Connection = new SAP.Connector.SAPConnection(dest);
try {
proxy.Connection.Open();
this.isConnected = true;
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
Environment.Exit(0);
}
}
}
///
/// Disconnects the proxy from the SAP system.
/// Thrown when the
/// disconnection fails.
///
public void disConnectSAP(){
if(this.isConnected == true){
try{
proxy.Connection.Close();
this.isConnected = false;;
}
catch(Exception e){
Console.WriteLine(e.ToString());
Environment.Exit(0);
}
}
}
///
/// Toggles the connection.
///
public void toggleConnection(){
if(this.isConnected)
this.disConnectSAP();
else
this.connectSAP();
}
}
}

[@more@]DBReaderClasses

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/232040/viewspace-968999/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/232040/viewspace-968999/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值