Beispiel #1
0
        /// <summary>
        /// Emuulates SAP Adapter Receive Endpoint
        /// </summary>
        public void Initialise()
        {
            //RfcDestinationManager.RegisterDestinationConfiguration(new MyClientConfig());//1
            RfcServerManager.RegisterServerConfiguration(new SAPIDocReceiveConfiguration());//2

            Type[] handlers = new Type[1] {
                typeof(SAPIDocReceiveHandler)
            };                                                                                 //3
            RfcServer server = RfcServerManager.GetServer("SQLCONDA_SERVER_CONFIG", handlers); //3

            server.RfcServerError            += OnRfcServerError;
            server.RfcServerApplicationError += OnRfcServerError;

            //register TID specific handler
            server.TransactionIDHandler = new SAPTIDHandler();

            //server.TransactionIDHandler = new MyServerHandler();
            server.Start();//4

            Console.WriteLine("Server has been started. Press X to exit.\n");

            while (true)
            {
                if (Console.ReadLine().Equals("X"))
                {
                    break;
                }
            }
            server.Shutdown(true); //Shuts down
        }
Beispiel #2
0
        public static bool LoadSAPServerConfig()
        {
            try
            {
                //RfcDestinationCollection clientsSetting = ConfigFileTool.SAPClientServerSetting.getClientSettings();
                //if (clientsSetting != null)
                //{
                //    RfcDestinationManager.RegisterDestinationConfiguration(new DefaultDestinationConfiguration(clientsSetting));
                //}
                if (_serverStarted == false)
                {
                    RfcServerCollection severSetting = ConfigFileTool.SAPClientServerSetting.getServerSettings();
                    if (severSetting != null)
                    {
                        RfcServerManager.RegisterServerConfiguration(new DefaultServerConfiguration(severSetting));
                    }
                    _serverStarted = true;
                }


                // RfcServerManager.loadedFromParameterFile = true;
                return(true);
            }
            catch (Exception)
            {
                throw new SAPException("无法从配置文件加载");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Emulates SAP Adapter Receive Endpoint
        /// </summary>
        public void Initialise()
        {
            //hard coded for testing but will pick up from ProgId in config
            string serverName = "SQLARTMAS_SERVER";
            string progId     = "SQLARTMAS";

            SAPTIDHandler rfcTIDHandler = new SAPTIDHandler();

            try
            {
                if (_sapIDocReceiveConfiguration == null)
                {
                    _sapIDocReceiveConfiguration =
                        new SAPIDocReceiveConfiguration(serverName, _rfcDestination.Name, progId);
                }
                else
                {
                    _sapIDocReceiveConfiguration.AddParameters(serverName, progId);
                }

                RfcServerManager.RegisterServerConfiguration(_sapIDocReceiveConfiguration);

                Type[] handlers = new Type[1] {
                    typeof(SAPIDocReceiveHandler)
                };                                                          //3
                _server = RfcServerManager.GetServer(serverName, handlers); //3

                _server.RfcServerError            += OnRfcServerError;
                _server.RfcServerApplicationError += OnRfcServerError;

                SAPIDocReceiveHandler.IDocEndReceiveCompleteEvent +=
                    new SAPIDocReceiveHandler.IDocReceiveEventHandler(OnIDocEndReceiveComplete);

                SAPIDocReceiveHandler.IDocBeginReceiveCompleteEvent +=
                    new SAPIDocReceiveHandler.IDocReceiveEventHandler(OnIDocBeginReceiveComplete);

                // register for session startevent in order to capture SessionId
                rfcTIDHandler.IDocSessionStart += new SAPTIDHandler.IDocsSessionEventHandler(OnRfcSessionStart);

                //register TID specific handler
                _server.TransactionIDHandler = rfcTIDHandler;

                // Create a new session for this particular destination
                // RfcSessionManager.BeginContext(_rfcDestination);


                //server.TransactionIDHandler = new MyServerHandler();
                _server.Start();//4
            }

            catch (RfcInvalidStateException rfcEx)
            {
                // cascade up callstack
                throw rfcEx;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            //Type[] handlers = new Type[1] { typeof(SAPIDocReceiveHandler) };//3
            //RfcServer server = RfcServerManager.GetServer("SQLARTMAS", handlers);//3



            //Console.WriteLine("Server has been started. Press X to exit.\n");

            //while (true)
            //{
            //    if (Console.ReadLine().Equals("X")) break;
            //}
            //server.Shutdown(true); //Shuts down
        }