DBReader/Classes/Logon

njms發表於2007-09-11

/**
*
* DBReader 1.0, Access to SAP tables using SAP's .Net Connector.
*
* Author: hardteck
* Email:
*
* Last modified: Fr, 17. Okt 2003, 11:31:32
*/
namespace SAPReader {
using System;
///


/// The Logon encapsulates the SAPLogon.
///
///

public class Logon : SAP.Connector.SAPLogonDestination {
///
/// The Constructor.
///

public Logon(){}
///
/// Given the name of an SAP System, this method returns
/// the corresponding destination object.
///

///
/// Name of the SAP System as displayed in the list
/// of available destinations.
///
///
public SAP.Connector.Destination getDestinationByName(string name){
// Map the name used for displaying the available destination,
// e.g. at SAPLogon, to the internal name used to address this item.
// BTW, the internal name (key) is derived from saplogon.ini.
string destName = this.GetDestinationNameFromPrintName(name);
// null returned if the destination does not exist.
if(destName == null || destName == "" ){
Console.WriteLine(this.GetType().ToString()
+ ".getDestinationByName: Destination " + name + " does not exist."
);
Console.WriteLine("Available Destinations are: ");
this.printAvailableDestinations(Console.Out);
Environment.Exit(0);
}
// This is the key statement for selecting the desired destination item:
this.DestinationName = destName;
// Now all information is retrieved from the SAPLogon's ini file
// to the respective variables of 'this' destination object.
// (The ini file is stored in the private variable:
// SAP.Connector.SAPLogonDestination.saplogon.fileName)

return (SAP.Connector.Destination)this;
}
///


/// Writes a list of available destinations to a stream.
///

/// Stream to write to.
public void printAvailableDestinations(System.IO.TextWriter txtWriter){
foreach(System.Collections.DictionaryEntry dest in this.AvailableDestinations){
txtWriter.WriteLine(dest.Value.ToString());
}
}
}
}

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/232040/viewspace-968998/,如需轉載,請註明出處,否則將追究法律責任。

相關文章