Ejemplo n.º 1
3
 public RfcConfigParameters GetParameters(String destinationName)
 {
     if (destinationName == repositorydestination)
     {
         RfcConfigParameters parms = new RfcConfigParameters();
         parms.Add(RfcConfigParameters.AppServerHost, appserverhost);
         parms.Add(RfcConfigParameters.SAPRouter, saprouter);
         parms.Add(RfcConfigParameters.SystemNumber, systemnumber);
         parms.Add(RfcConfigParameters.SystemID, systemid);
         parms.Add(RfcConfigParameters.User, user);
         parms.Add(RfcConfigParameters.Password, password);
         parms.Add(RfcConfigParameters.Client, client);                  
         parms.Add(RfcConfigParameters.PoolSize, poolsize);
         return parms;
     }
     else return null;
 }
 public RfcConfigParameters GetParameters()
 {
     RfcConfigParameters paras = new RfcConfigParameters();
     if (!string.IsNullOrEmpty(this.AbapDebug))
     {
         paras.Add(RfcConfigParameters.AbapDebug, this.AbapDebug.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.AliasUser))
     {
         paras.Add(RfcConfigParameters.AliasUser, this.AliasUser.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.AppServerHost))
     {
         paras.Add(RfcConfigParameters.AppServerHost, this.AppServerHost.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.AppServerService))
     {
         paras.Add(RfcConfigParameters.AppServerService, this.AppServerService.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.CharacterFaultIndicatorToken))
     {
         paras.Add(RfcConfigParameters.CharacterFaultIndicatorToken, this.CharacterFaultIndicatorToken.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.Client))
     {
         paras.Add(RfcConfigParameters.Client, this.Client.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.Codepage))
     {
         paras.Add(RfcConfigParameters.Codepage, this.Codepage.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.GatewayHost))
     {
         paras.Add(RfcConfigParameters.GatewayHost, this.GatewayHost.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.GatewayService))
     {
         paras.Add(RfcConfigParameters.GatewayService, this.GatewayService.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.IdleCheckTime))
     {
         paras.Add(RfcConfigParameters.IdleCheckTime, this.IdleCheckTime.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.IdleTimeout))
     {
         paras.Add(RfcConfigParameters.IdleTimeout, this.IdleTimeout.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.Language))
     {
         paras.Add(RfcConfigParameters.Language, this.Language.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.LogonCheck))
     {
         paras.Add(RfcConfigParameters.LogonCheck, this.LogonCheck.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.LogonGroup))
     {
         paras.Add(RfcConfigParameters.LogonGroup, this.LogonGroup.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.MaxPoolSize))
     {
         paras.Add(RfcConfigParameters.MaxPoolSize, this.MaxPoolSize.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.MaxPoolWaitTime))
     {
         paras.Add(RfcConfigParameters.MaxPoolWaitTime, this.MaxPoolWaitTime.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.MessageServerHost))
     {
         paras.Add(RfcConfigParameters.MessageServerHost, this.MessageServerHost.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.MessageServerService))
     {
         paras.Add(RfcConfigParameters.MessageServerService, this.MessageServerService.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.Name))
     {
         paras.Add(RfcConfigParameters.Name, this.Name.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.NoCompression))
     {
         paras.Add(RfcConfigParameters.NoCompression, this.NoCompression.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.OnCharacterConversionError))
     {
         paras.Add(RfcConfigParameters.OnCharacterConversionError, this.OnCharacterConversionError.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.PartnerCharSize))
     {
         paras.Add(RfcConfigParameters.PartnerCharSize, this.PartnerCharSize.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.Password))
     {
         paras.Add(RfcConfigParameters.Password, this.Password);
     }
     if (!string.IsNullOrEmpty(this.PasswordChangeEnforced))
     {
         paras.Add(RfcConfigParameters.PasswordChangeEnforced, this.PasswordChangeEnforced.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.PoolSize))
     {
         paras.Add(RfcConfigParameters.PoolSize, this.PoolSize.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.ProgramID))
     {
         paras.Add(RfcConfigParameters.ProgramID, this.ProgramID.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.RegistrationCount))
     {
         paras.Add(RfcConfigParameters.RegistrationCount, this.RegistrationCount.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.RepositoryDestination))
     {
         paras.Add(RfcConfigParameters.RepositoryDestination, this.RepositoryDestination.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.RepositoryPassword))
     {
         paras.Add(RfcConfigParameters.RepositoryPassword, this.RepositoryPassword.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.RepositorySncMyName))
     {
         paras.Add(RfcConfigParameters.RepositorySncMyName, this.RepositorySncMyName.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.RepositoryUser))
     {
         paras.Add(RfcConfigParameters.RepositoryUser, this.RepositoryUser.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.RepositoryX509Certificate))
     {
         paras.Add(RfcConfigParameters.RepositoryX509Certificate, this.RepositoryX509Certificate.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SAPRouter))
     {
         paras.Add(RfcConfigParameters.SAPRouter, this.SAPRouter.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SAPSSO2Ticket))
     {
         paras.Add(RfcConfigParameters.SAPSSO2Ticket, this.SAPSSO2Ticket.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SncLibraryPath))
     {
         paras.Add(RfcConfigParameters.SncLibraryPath, this.SncLibraryPath.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SncMode))
     {
         paras.Add(RfcConfigParameters.SncMode, this.SncMode.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SncMyName))
     {
         paras.Add(RfcConfigParameters.SncMyName, this.SncMyName.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SncPartnerName))
     {
         paras.Add(RfcConfigParameters.SncPartnerName, this.SncPartnerName.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SncPartnerNames))
     {
         paras.Add(RfcConfigParameters.SncPartnerNames, this.SncPartnerNames.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SncQOP))
     {
         paras.Add(RfcConfigParameters.SncQOP, this.SncQOP.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SystemID))
     {
         paras.Add(RfcConfigParameters.SystemID, this.SystemID.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SystemIDs))
     {
         paras.Add(RfcConfigParameters.SystemIDs, this.SystemIDs.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.SystemNumber))
     {
         paras.Add(RfcConfigParameters.SystemNumber, this.SystemNumber.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.Trace))
     {
         paras.Add(RfcConfigParameters.Trace, this.Trace.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.User))
     {
         paras.Add(RfcConfigParameters.User, this.User.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.UseSAPGui))
     {
         paras.Add(RfcConfigParameters.UseSAPGui, this.UseSAPGui.ToUpper());
     }
     if (!string.IsNullOrEmpty(this.X509Certificate))
     {
         paras.Add(RfcConfigParameters.X509Certificate, this.X509Certificate.ToUpper());
     }
     return paras;
 }
        public RfcConfigParameters GetParameters(string destinationName)
        {
            RfcConfigParameters parms = new RfcConfigParameters();

            parms.Add(RfcConfigParameters.Name, destinationName);
            parms.Add(RfcConfigParameters.AppServerHost, ConfigurationManager.AppSettings["SAP_APPSERVERASHOST"]);
            parms.Add(RfcConfigParameters.User, ConfigurationManager.AppSettings["SAP_USERNAME"]);
            parms.Add(RfcConfigParameters.Password, ConfigurationManager.AppSettings["SAP_PASSWORD"]);
            parms.Add(RfcConfigParameters.SystemNumber, ConfigurationManager.AppSettings["SAP_SYSTEMNUM"]);
            parms.Add(RfcConfigParameters.SystemID, ConfigurationManager.AppSettings["SAP_CLIENT"]);
            parms.Add(RfcConfigParameters.Client, ConfigurationManager.AppSettings["SAP_CLIENT"]);
            if (string.IsNullOrEmpty(this.SAPLanguage))
            {
                parms.Add(RfcConfigParameters.Language, ConfigurationManager.AppSettings["SAP_LANGUAGE"]);
            }
            else
            {
                parms.Add(RfcConfigParameters.PoolSize, this.SAPLanguage);
            }

            if (ConfigurationManager.AppSettings["SAP_ROUTER"] != null)
            {
                parms.Add(RfcConfigParameters.SAPRouter, ConfigurationManager.AppSettings["SAP_ROUTER"]);
            }
            return(parms);
        }
Ejemplo n.º 4
0
        public RfcConfigParameters GetParameters(string destinationName)
        {
            var parametros = new RfcConfigParameters
            {
                {RfcConfigParameters.AppServerHost, Host},
                {RfcConfigParameters.User, User},
                {RfcConfigParameters.Password, Password},
                {RfcConfigParameters.Name, destinationName}
            };

            if (!string.IsNullOrEmpty(Language))
                parametros.Add(RfcConfigParameters.Language, Language);
            if (!string.IsNullOrEmpty(Client))
                parametros.Add(RfcConfigParameters.Client, Client);
            if (!string.IsNullOrEmpty(SystemNumber))
                parametros.Add(RfcConfigParameters.SystemNumber, SystemNumber);
            if (!string.IsNullOrEmpty(SystemId))
                parametros.Add(RfcConfigParameters.SystemID, SystemId);
            if (!string.IsNullOrEmpty(SapRouter))
                parametros.Add(RfcConfigParameters.SAPRouter, SapRouter);
            if (!string.IsNullOrEmpty(TimeOut))
                parametros.Add(RfcConfigParameters.IdleTimeout, TimeOut);
            if (!string.IsNullOrEmpty(PoolSize))
                parametros.Add(RfcConfigParameters.PoolSize, PoolSize);
            if (!string.IsNullOrEmpty(MaxPoolSize))
                parametros.Add(RfcConfigParameters.MaxPoolSize, MaxPoolSize);

            return parametros;
        }
        public RfcConfigParameters GetParameters(String destinationName)
        {
            if ("RETDEV1".Equals(destinationName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.Name, "RETDEV");
                parms.Add(RfcConfigParameters.AppServerHost, "192.168.0.208");
                parms.Add(RfcConfigParameters.SAPRouter, "");
                parms.Add(RfcConfigParameters.SystemNumber, "00");
                parms.Add(RfcConfigParameters.SystemID, "RET");
                parms.Add(RfcConfigParameters.User, "WWS");
                parms.Add(RfcConfigParameters.Password, "123456");
                parms.Add(RfcConfigParameters.Client, "765");
                parms.Add(RfcConfigParameters.Language, "ZH");

               // parms.Add(RfcConfigParameters.PoolSize, "5");
               // parms.Add(RfcConfigParameters.MaxPoolSize, "10");
               // parms.Add(RfcConfigParameters.IdleTimeout, "60");
                parms.Add(RfcConfigParameters.AbapDebug, "true");
                return parms;
            }
            else if ("RETNEW1".Equals(destinationName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.Name, "RETNEW");
                parms.Add(RfcConfigParameters.AppServerHost, "192.168.0.208");
                parms.Add(RfcConfigParameters.SAPRouter, "");
                parms.Add(RfcConfigParameters.SystemNumber, "00");
                parms.Add(RfcConfigParameters.SystemID, "RET");
                parms.Add(RfcConfigParameters.User, "wwsheng");
                parms.Add(RfcConfigParameters.Password, "wwsheng");
                parms.Add(RfcConfigParameters.Client, "900");
                parms.Add(RfcConfigParameters.Language, "ZH");
               // parms.Add(RfcConfigParameters.PoolSize, "5");
              //  parms.Add(RfcConfigParameters.MaxPoolSize, "10");
               // parms.Add(RfcConfigParameters.IdleTimeout, "60");
                parms.Add(RfcConfigParameters.AbapDebug, "true");

                return parms;
            }
            else if ("CHJ".Equals(destinationName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.Name, "CHJ");
                parms.Add(RfcConfigParameters.AppServerHost, "192.168.0.252");
                parms.Add(RfcConfigParameters.SystemNumber, "00");
                parms.Add(RfcConfigParameters.SAPRouter, "");
                parms.Add(RfcConfigParameters.SystemID, "DEV");
                parms.Add(RfcConfigParameters.User, "wwsheng");
                parms.Add(RfcConfigParameters.Password, "wwsheng");
                parms.Add(RfcConfigParameters.Client, "800");
                parms.Add(RfcConfigParameters.Language, "ZH");
                parms.Add(RfcConfigParameters.PoolSize, "5");
                parms.Add(RfcConfigParameters.MaxPoolSize, "10");
                parms.Add(RfcConfigParameters.IdleTimeout, "60");
                parms.Add(RfcConfigParameters.AbapDebug, "true");
                return parms;
            }
            else return null;
        }
Ejemplo n.º 6
0
        public RfcConfigParameters SAPConector(string user, string pass)
        {
            //Globales conn = new Globales();
            //string p_user = conn.GetUser();
            //string p_pass = conn.GetPass();

            //Globales conn = new Globales();
            string p_user = user;
            string p_pass = pass;

            RfcConfigParameters SapConnector = new RfcConfigParameters();

            SapConnector.Add(RfcConfigParameters.Name, "DES");
            SapConnector.Add(RfcConfigParameters.AppServerHost, server);
            SapConnector.Add(RfcConfigParameters.SAPRouter, sapRouter);
            SapConnector.Add(RfcConfigParameters.SystemNumber, instancia);
            SapConnector.Add(RfcConfigParameters.User, p_user);
            SapConnector.Add(RfcConfigParameters.Password, p_pass);
            SapConnector.Add(RfcConfigParameters.Client, mandante);
            SapConnector.Add(RfcConfigParameters.Language, "ES");
            SapConnector.Add(RfcConfigParameters.PoolSize, "10");
            SapConnector.Add(RfcConfigParameters.IdleTimeout, "10");

            return(SapConnector);
        }
Ejemplo n.º 7
0
        public int VALIDATE_MAIL(string UIDL, SharedSettings.Settings settings)
        {
            string value = string.Empty;

            try
            {
                //Establecemos conexion con SAP
                RfcConfigParameters rfc = SAP_Connection.GetParameters(settings);

                RfcDestination rfcDest = null;
                rfcDest = RfcDestinationManager.GetDestination(rfc);

                //Creamos repositorio para la función
                RfcRepository repo          = rfcDest.Repository;
                IRfcFunction  validate_mail = repo.CreateFunction("Z_MAIL_VALIDATE");


                validate_mail.SetValue("UIDL", UIDL);

                //Ejecutamos la consulta
                validate_mail.Invoke(rfcDest);

                IRfcStructure ret = validate_mail.GetStructure("RETURN");
                value = ret.GetValue("NUMBER").ToString();
                if (value == "004")
                {
                    //Encontró correo previamente guardado
                    return(0);
                }
                else
                {
                    //No encontró correo return
                    return(4);
                }
            }
            catch (RfcCommunicationException e)
            {
                throw e;
            }
            catch (RfcLogonException e)
            {
                // user could not logon...
                throw e;
            }
            catch (RfcAbapRuntimeException e)
            {
                // serious problem on ABAP system side...
                throw e;
            }
            catch (RfcAbapBaseException e)
            {
                // The function module returned an ABAP exception, an ABAP message
                // or an ABAP class-based exception...
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        static void Main(string[] args)
        {
            // Set connection parameters
            var parameters = new RfcConfigParameters();
            parameters[RfcConfigParameters.Client] = "050";
            parameters[RfcConfigParameters.Language] = "DE";
            parameters[RfcConfigParameters.User] = "SCHUENGE";
            parameters[RfcConfigParameters.Password] = "";
            parameters[RfcConfigParameters.MessageServerHost] = "sawitk80.ceu.heidelberg.com";
            parameters[RfcConfigParameters.MessageServerService] = "3641";
            parameters[RfcConfigParameters.Name] = "K80";
            parameters[RfcConfigParameters.SystemID] = "K80";
            parameters[RfcConfigParameters.LogonGroup] = "K80001";

            // Get destination (i.e. connection to SAP ERP system)
            var destination = RfcDestinationManager.GetDestination(parameters);

            JsonWriter writer = new JsonTextWriter(new StreamWriter("test.json"));
            writer.Formatting = Formatting.Indented;
            writer.WriteStartObject();

            var customerNumber = "0080300010";

            ReadCustomerContacts(customerNumber, destination, writer);

            ReadCustomerEquipments(customerNumber, destination, writer);

            writer.WriteEndObject();
            writer.Close();
        }
Ejemplo n.º 9
0
        public static IRfcTable SAPExecuteDeulTableData(Hashtable[] arrht1, string Function_Name, string RfcStructure_Name, string SetTable_Name, string GetTable_Name)
        {
            RfcConfigParameters configParam = GetConfigParam();
            RfcDestination      destination = RfcDestinationManager.GetDestination(configParam);
            IRfcFunction        function    = destination.Repository.CreateFunction(Function_Name);

            IRfcTable rfcTable = function.GetTable(SetTable_Name);

            for (int i = 0; i < arrht1.Length; i++)
            {
                RfcStructureMetadata strMeta      = destination.Repository.GetStructureMetadata(RfcStructure_Name);
                IRfcStructure        rfcStructure = strMeta.CreateStructure();

                IDictionaryEnumerator ie = arrht1[i].GetEnumerator();

                while (ie.MoveNext())
                {
                    if (ie.Value.ToString().Length <= 4000)
                    {
                        rfcStructure.SetValue(ie.Key.ToString(), ie.Value);
                    }
                }

                rfcTable.Append(rfcStructure);
            }

            function.Invoke(destination);

            IRfcTable rfcTable2 = function.GetTable(GetTable_Name);

            return(rfcTable2);
        }
Ejemplo n.º 10
0
        public bool TestCon(ConfigSAP configSAP)
        {
            try
            {
                RfcConfigParameters parametros = new RfcConfigParameters();
                parametros.Add(RfcConfigParameters.SAPRouter, configSAP.SAProuter as string);
                parametros.Add(RfcConfigParameters.Client, configSAP.client as string);
                parametros.Add(RfcConfigParameters.Language, configSAP.language as string);
                parametros.Add(RfcConfigParameters.User, configSAP.user as string);
                parametros.Add(RfcConfigParameters.Password, configSAP.password as string);
                parametros.Add(RfcConfigParameters.AppServerHost, configSAP.applicationServer as string);
                parametros.Add(RfcConfigParameters.SystemNumber, configSAP.systemNumberSAP as string);
                parametros.Add(RfcConfigParameters.SystemID, configSAP.systemSAP as string);
                parametros.Add(RfcConfigParameters.Name, configSAP.systemSAP as string);
                try
                {
                    RfcDestination rfcDest = RfcDestinationManager.GetDestination(parametros);
                }
                catch (Exception) { }

                RfcDestination rfcDesti = null;
                rfcDesti = RfcDestinationManager.GetDestination(configSAP.systemSAP as string);
                RfcRepository repo    = rfcDesti.Repository;
                IRfcFunction  FUNCION = repo.CreateFunction("ZMATERIALES");
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 11
0
        public static string SAPExecuteStructureData(Hashtable ht, string Function_Name, string RfcStructure_Name, string param1)
        {
            RfcConfigParameters configParam = GetConfigParam();
            RfcDestination      destination = RfcDestinationManager.GetDestination(configParam);
            IRfcFunction        function    = destination.Repository.CreateFunction(Function_Name);

            RfcStructureMetadata strMeta      = destination.Repository.GetStructureMetadata(RfcStructure_Name);
            IRfcStructure        rfcStructure = strMeta.CreateStructure();


            IDictionaryEnumerator ie = ht.GetEnumerator();

            while (ie.MoveNext())
            {
                if (ie.Value.ToString().Length <= 4000)
                {
                    rfcStructure.SetValue(ie.Key.ToString(), ie.Value);
                }
            }

            function.SetValue(param1, rfcStructure);
            function.Invoke(destination);

            string returnCode = function.GetString("EV_E_TYPE");

            return(returnCode);
        }
Ejemplo n.º 12
0
        public static string SAPExecuteOnlyParam(string Function_Name, Hashtable ht)
        {
            RfcConfigParameters configParam = GetConfigParam();

            RfcDestination destination = RfcDestinationManager.GetDestination(configParam);
            IRfcFunction   function    = destination.Repository.CreateFunction(Function_Name);

            IDictionaryEnumerator ie = ht.GetEnumerator();

            while (ie.MoveNext())
            {
                if (ie.Value.ToString().Length <= 4000)
                {
                    function.SetValue(ie.Key.ToString(), ie.Value);
                }
            }

            function.Invoke(destination);

            string returnCode = function.GetString("E_BELNR");

            if (returnCode != "")
            {
                return("S|" + returnCode);
            }
            else
            {
                returnCode = function.GetString("E_MSG");
                return("E|" + returnCode);
            }
        }
Ejemplo n.º 13
0
        public static IRfcTable SAPExecuteTableData(Hashtable ImportData, string Function_Name, string GetTable_Name)
        {
            RfcConfigParameters configParam = GetConfigParam();
            RfcDestination      destination = RfcDestinationManager.GetDestination(configParam);
            IRfcFunction        function    = destination.Repository.CreateFunction(Function_Name);

            if (ImportData.Count > 0)
            {
                IDictionaryEnumerator ie = ImportData.GetEnumerator();

                while (ie.MoveNext())
                {
                    if (ie.Value.ToString().Length <= 4000)
                    {
                        function.SetValue(ie.Key.ToString(), ie.Value);
                    }
                }
            }

            function.Invoke(destination);

            IRfcTable rtable = function.GetTable(GetTable_Name);

            return(rtable);
        }
Ejemplo n.º 14
0
        private static RfcConfigParameters GetConfigParam()
        {
            RfcConfigParameters configParam = new RfcConfigParameters();

            configParam[RfcConfigParameters.Name]         = "DH_CONNECTION";
            configParam[RfcConfigParameters.User]         = "ICOM";
            configParam[RfcConfigParameters.Password]     = "donghee2007";
            configParam[RfcConfigParameters.Language]     = Login.G_cuture.Substring(0, 2).ToUpper();
            configParam[RfcConfigParameters.SystemNumber] = "00";
            configParam[RfcConfigParameters.PoolSize]     = "5";
            configParam[RfcConfigParameters.MaxPoolSize]  = "10";

            if (Login.G_TARGET_DB == "TEST")
            {
                configParam[RfcConfigParameters.AppServerHost] = "10.206.92.80";
                configParam[RfcConfigParameters.Client]        = "530";
            }
            else if (Login.G_TARGET_DB == "ACTIVE")
            {
                configParam[RfcConfigParameters.AppServerHost] = "10.206.92.203";
                configParam[RfcConfigParameters.Client]        = "100";
            }

            return(configParam);
        }
Ejemplo n.º 15
0
        public bool conectar()
        {
            RfcConfigParameters oParametros = new RfcConfigParameters();

            oParametros.Add(RfcConfigParameters.Name, sapName);
            oParametros.Add(RfcConfigParameters.User, sapUser);
            oParametros.Add(RfcConfigParameters.Password, sapPass);
            oParametros.Add(RfcConfigParameters.Client, sapClient);
            //oParametros.Add(RfcConfigParameters.Language, "EN");
            oParametros.Add(RfcConfigParameters.Language, "ES");
            oParametros.Add(RfcConfigParameters.AppServerHost, sapServer);
            oParametros.Add(RfcConfigParameters.SystemNumber, sapNumber);
            if (!sapRouter.Equals("") && !sapRouter.Equals(null))
            {
                oParametros.Add(RfcConfigParameters.SAPRouter, sapRouter);
            }
            if (!sapID.Equals("") && !sapID.Equals(null))
            {
                oParametros.Add(RfcConfigParameters.SystemID, sapID);
            }
            oParametros.Add(RfcConfigParameters.PoolSize, "5");

            oDestino = RfcDestinationManager.GetDestination(oParametros);

            try
            {
                oDestino.Ping();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 16
0
        public RfcConfigParameters GetParameters(string destinationName)
        {
            if ("PRD_000".Equals(destinationName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.AppServerHost, "192.168.1.146");
                parms.Add(RfcConfigParameters.SystemNumber, "01");
                parms.Add(RfcConfigParameters.SystemID, "DM0");

                parms.Add(RfcConfigParameters.User, "wwsheng");
                parms.Add(RfcConfigParameters.Password, "wwsheng");
                parms.Add(RfcConfigParameters.Client, "800");
                parms.Add(RfcConfigParameters.Language, "en");
                parms.Add(RfcConfigParameters.PoolSize, "5");
                parms.Add(RfcConfigParameters.MaxPoolSize, "10");
                parms.Add(RfcConfigParameters.IdleTimeout, "60");


                return(parms);
            }
            else
            {
                return(null);
            }
        }
        public RfcConfigParameters GetParameters(string destinationName)
        {
            string serverHost                       = ConfigurationManager.AppSettings["ServerHost"].ToString();
            string systemNumber                     = ConfigurationManager.AppSettings["SystemNumber"].ToString();
            string user                             = ConfigurationManager.AppSettings["User"].ToString();
            string password                         = ConfigurationManager.AppSettings["Password"].ToString();
            string client                           = ConfigurationManager.AppSettings["Client"].ToString();
            string language                         = ConfigurationManager.AppSettings["Language"].ToString();
            string poolSize                         = ConfigurationManager.AppSettings["PoolSize"].ToString();
            string peakConnectionsLimit             = ConfigurationManager.AppSettings["PeakConnectionsLimit"].ToString();
            string idleTimeout                      = ConfigurationManager.AppSettings["IdleTimeout"].ToString();
            RfcConfigParameters rfcConfigParameters = new RfcConfigParameters();

            try
            {
                rfcConfigParameters.Add("ASHOST", serverHost);
                rfcConfigParameters.Add("SYSNR", systemNumber);
                rfcConfigParameters.Add("USER", user);
                rfcConfigParameters.Add("PASSWD", password);
                rfcConfigParameters.Add("CLIENT", client);
                rfcConfigParameters.Add("LANG", language);
                rfcConfigParameters.Add("POOL_SIZE", poolSize);
                rfcConfigParameters.Add("MAX_POOL_SIZE", peakConnectionsLimit);
                rfcConfigParameters.Add("IDLE_TIMEOUT", idleTimeout);
            }
            catch
            {
                throw new NotImplementedException();
            }
            return(rfcConfigParameters);
        }
        //allows adding or modifying a destination for a specific application server
        public void AddEditDestination(string name, int poolSize, string user, string password, string language,
            string client, string applicationServer, string systemNumber)
        {
            // We need to check the given parameters for validity, e.g. that name is not null as this is not
            // relevant
            RfcConfigParameters newConfigParameters = new RfcConfigParameters();
            newConfigParameters[RfcConfigParameters.Name] = name;
            newConfigParameters[RfcConfigParameters.PeakConnectionsLimit] = Convert.ToString(poolSize);
            newConfigParameters[RfcConfigParameters.IdleTimeout] = Convert.ToString(10); // we keep connections for 10 minutes
            newConfigParameters[RfcConfigParameters.User] = user;
            newConfigParameters[RfcConfigParameters.Password] = password;
            newConfigParameters[RfcConfigParameters.Client] = client;
            newConfigParameters[RfcConfigParameters.Language] = language;
            newConfigParameters[RfcConfigParameters.AppServerHost] = applicationServer;
            newConfigParameters[RfcConfigParameters.SystemNumber] = systemNumber;
            RfcConfigParameters existingConfiguration;
            //if a destination of that name existed before, we need to fire a change event
            if (sapDestinations.TryGetValue(name, out existingConfiguration))
            {
                sapDestinations[name] = newConfigParameters;
                RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, newConfigParameters);
                Console.WriteLine("Fire change event " + eventArgs.ToString() + " for destination " + name);
                changeHandler(name, eventArgs);
            }
            else
            {
                sapDestinations[name] = newConfigParameters;
            }
            Console.WriteLine("Added application server destination " + name);

            // print the destination attributwes
            printDestination(name);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// create and get the RfcDestination
        /// </summary>
        /// <param name="userSessionId">userSessionId as string</param>
        /// <param name="sapUserVo">sapUserVo as SapUserVo</param>
        /// <returns>RfcDestination</returns>
        private RfcDestination CreateRfcDestination(string userSessionId, SapUserVo sapUserVo)
        {
            RfcDestination sapRfcDestination;

            //set rfcconfigparameters
            RfcConfigParameters configParameters = SetConnectionParameters(userSessionId, sapUserVo);

            try
            {
                sapRfcDestination = RfcDestinationManager.GetDestination(configParameters);

                MessageData messageData = new MessageData("scci00001", Properties.Resources.scci00001, sapRfcDestination.Name.ToString());
                logger.Info(messageData);
            }
            catch (Exception ex)
            {
                //cannot serialize sap rfc exception hence passing exception name and message to the messagedata
                MessageData messageData = new MessageData("scce00008", Properties.Resources.scce00008, ex.GetType().Name.ToString(), ex.Message);
                logger.Error(messageData, ex);
                throw new Framework.SystemException(messageData);
            }

            if (sapRfcDestination == null)
            {
                MessageData messageData    = new MessageData("scce00012", Properties.Resources.scce00012);
                Exception   causeException = new NullReferenceException();
                logger.Error(messageData, causeException);
                throw new Framework.SystemException(messageData, causeException);
            }

            return(sapRfcDestination);
        }
Ejemplo n.º 20
0
            public RfcConfigParameters ToRfcConfigParameters()
            {
                RfcConfigParameters rfcParams = new RfcConfigParameters();

                rfcParams.Add(RfcConfigParameters.AppServerHost, this.Server);
                rfcParams.Add(RfcConfigParameters.SystemID, this.ServerID);
                rfcParams.Add(RfcConfigParameters.SystemNumber, this.SystemNumber);
                rfcParams.Add(RfcConfigParameters.SAPRouter, this.SapRouter);
                rfcParams.Add(RfcConfigParameters.Client, this.Client);
                rfcParams.Add(RfcConfigParameters.User, this.User);
                rfcParams.Add(RfcConfigParameters.Password, this.Password);
                if (!String.IsNullOrEmpty(this.AliasUser))
                {
                    rfcParams.Add(RfcConfigParameters.AliasUser, this.AliasUser);
                }
                if (!String.IsNullOrEmpty(this.SsoTicket))
                {
                    rfcParams.Add(RfcConfigParameters.SAPSSO2Ticket, this.SsoTicket);
                }
                if (!String.IsNullOrEmpty(this.CodePage))
                {
                    rfcParams.Add(RfcConfigParameters.Codepage, this.CodePage);
                }
                if (!String.IsNullOrEmpty(this.Language))
                {
                    rfcParams.Add(RfcConfigParameters.Language, this.Language);
                }
                rfcParams.Add(RfcConfigParameters.PoolSize, this.PoolSize.ToString());
                rfcParams.Add(RfcConfigParameters.PeakConnectionsLimit, this.PeakLimit.ToString());
                rfcParams.Add(RfcConfigParameters.IdleCheckTime, (this.IdleCheckTime / 1000).ToString());
                rfcParams.Add(RfcConfigParameters.PoolIdleTimeout, (this.ExpirationPeriod / 1000).ToString());
                rfcParams.Add(RfcConfigParameters.MaxPoolWaitTime, this.ExpirationTime.ToString());

                return(rfcParams);
            }
Ejemplo n.º 21
0
        public RfcConfigParameters GetParameters(String destinationName)
        {
            SapConfig sapConfig = ConfigurationManager.GetSection(destinationName) as SapConfig;

            if (sapConfig == null)
            {
                return(null);
            }

            RfcConfigParameters parms = new RfcConfigParameters();

            //if (!Properties.Settings.Default.INNER)
            //{
            //    parms.Add(RfcConfigParameters.SAPRouter, "/H/210.75.9.162/H/");
            //}
            parms.Add(RfcConfigParameters.AppServerHost, sapConfig.AppServerHost); //SAP主机IP
            parms.Add(RfcConfigParameters.SystemNumber, "00");                     //SAP实例
            parms.Add(RfcConfigParameters.User, sapConfig.User);                   //用户名
            parms.Add(RfcConfigParameters.Password, sapConfig.Password);           //密码
            parms.Add(RfcConfigParameters.Client, sapConfig.Client);               // Client
            parms.Add(RfcConfigParameters.Language, "ZH");                         //登陆语言
            parms.Add(RfcConfigParameters.PoolSize, "10");
            parms.Add(RfcConfigParameters.MaxPoolSize, "100");
            parms.Add(RfcConfigParameters.SystemID, sapConfig.SystemID);
            parms.Add(RfcConfigParameters.IdleTimeout, "60");
            AvailableDestinations.Add(destinationName, parms);
            return(parms);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取RfcDestination
        /// </summary>
        /// <returns></returns>
        private RfcDestination GetDestination()
        {
            RfcConfigParameters configParams = this.GetConfigParams();
            RfcDestination      dest         = RfcDestinationManager.GetDestination(configParams);

            return(dest);
        }
        public RfcConfigParameters GetParameters(string destinationName)
        {
            RfcConfigParameters parameters = null;

            this.destinations.TryGetValue(destinationName, out parameters);
            return(parameters);
        }
Ejemplo n.º 24
0
 public static string SendToSAP500(string requestXML)
 {
     try
     {
         string strRes = "";//res.ZfmServiceResponse.EvResponse;
         RfcConfigParameters rfcPar = new RfcConfigParameters();
         rfcPar.Add(RfcConfigParameters.Name, "MSQ");
         rfcPar.Add(RfcConfigParameters.AppServerHost, "192.168.4.39");
         rfcPar.Add(RfcConfigParameters.Client, "500");
         rfcPar.Add(RfcConfigParameters.User, "INTUSER");
         rfcPar.Add(RfcConfigParameters.Password, "90-=op[]");
         rfcPar.Add(RfcConfigParameters.SystemNumber, "00");
         rfcPar.Add(RfcConfigParameters.Language, "ZH");
         RfcDestination dest   = RfcDestinationManager.GetDestination(rfcPar);
         RfcRepository  rfcrep = dest.Repository;
         IRfcFunction   myfun  = null;
         myfun = rfcrep.CreateFunction("ZFM_SERVICE_DRP");
         myfun.SetValue("IV_REQUEST", requestXML);//SAP里面的传入参数
         myfun.Invoke(dest);
         // IRfcTable lrfTable = myfun.GetTable("");
         strRes = myfun.GetString("EV_RESPONSE");
         return(strRes);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Ejemplo n.º 25
0
        public bool Login(ProxyParameter parameter)
        {
            try
            {
                RfcConfigParameters confParam = new RfcConfigParameters();
                confParam.Add(RfcConfigParameters.Name, Guid.NewGuid().ToString());
                confParam.Add(RfcConfigParameters.AppServerHost, parameter.AppServerHost);
                confParam.Add(RfcConfigParameters.SAPRouter, parameter.SAPRouter);
                confParam.Add(RfcConfigParameters.Client, parameter.Client);
                confParam.Add(RfcConfigParameters.User, parameter.User);
                confParam.Add(RfcConfigParameters.Password, parameter.Password);
                confParam.Add(RfcConfigParameters.SystemNumber, parameter.SystemNumber);
                confParam.Add(RfcConfigParameters.Language, parameter.Language);
                confParam.Add(RfcConfigParameters.PoolSize, "1");
                confParam.Add(RfcConfigParameters.MaxPoolSize, "10");
                confParam.Add(RfcConfigParameters.IdleTimeout, "10");

                destination = RfcDestinationManager.GetDestination(confParam);
                destination.Ping();

                connected = true;
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message + " " + ex.StackTrace);
                System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
            }
            return(connected);
        }
Ejemplo n.º 26
0
        //allows adding or modifying a destination for a specific application server
        public void AddOrEditDestination(string name, int poolSize, string user, string password, string language, string client, string applicationServer, string systemNumber)
        {
            //in productive code the given parameters should be checked for validity, e.g. that name is not null
            //as this is not relevant for the example, we omit it here
            RfcConfigParameters parameters = new RfcConfigParameters();

            parameters[RfcConfigParameters.Name]          = name;
            parameters[RfcConfigParameters.MaxPoolSize]   = Convert.ToString(poolSize);
            parameters[RfcConfigParameters.IdleTimeout]   = Convert.ToString(6); // we keep connections for 10 minutes
            parameters[RfcConfigParameters.User]          = user;
            parameters[RfcConfigParameters.Password]      = password;
            parameters[RfcConfigParameters.Client]        = client;
            parameters[RfcConfigParameters.Language]      = language;
            parameters[RfcConfigParameters.AppServerHost] = applicationServer;
            parameters[RfcConfigParameters.SystemNumber]  = systemNumber;
            RfcConfigParameters existingConfiguration;

            //if a destination of that name existed before, we need to fire a change event
            if (availableDestinations.TryGetValue(name, out existingConfiguration))
            {
                availableDestinations[name] = parameters;
                RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, parameters);
                MessageBox.Show("Fire change event " + eventArgs.ToString() + " for destination " + name);
                changeHandler(name, eventArgs);
            }
            else
            {
                availableDestinations[name] = parameters;
            }

            //MessageBox.Show("Added application server destination " + name);
        }
Ejemplo n.º 27
0
        private RfcConfigParameters GetCfgParameters()
        {
            RfcConfigParameters rfcCfg = new RfcConfigParameters();
            XmlDocument         doc    = new XmlDocument();
            string XmlName             = AppDomain.CurrentDomain.BaseDirectory + "DllConfig.xml";

            doc.Load(XmlName);
            rfcCfg.Add(RfcConfigParameters.Name,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("CONN")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.AppServerHost,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("ASHOST")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.Client,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("CLIENT")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.User,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("USER")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.Password,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("PASSWD")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.SystemNumber,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("SYSNR")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.Language,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("LANG")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.PoolSize,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("POOL_SIZE")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.IdleTimeout,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("TIMEOUT")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.LogonGroup,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("GROUP")).GetAttribute("Name").ToString());
            return(rfcCfg);
        }
        public static RfcConfigParameters getSAPParams()
        {
            XDocument oSettingsXML;

            try
            {
                oSettingsXML = XDocument.Load("settings.xml");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }

            XElement oXMLRootElem = oSettingsXML.Element("SETTINGS").Element("SAP");

            RfcConfigParameters sapconfig = new RfcConfigParameters();

            foreach (XElement xe in oXMLRootElem.Elements())
            {
                sapconfig.Add(xe.Name.LocalName, xe.Value);
            }
            ;

            return(sapconfig);
        }
Ejemplo n.º 29
0
        public RfcConfigParameters GetParameters(String serverName)
        {
            if ("PRD_REG_SERVER".Equals(serverName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.RepositoryDestination, "PRD_000");
                //the client config name

                parms.Add(RfcConfigParameters.GatewayHost, "192.168.1.146");
                //it's the ecc's host or the ip address

                parms.Add(RfcConfigParameters.GatewayService, "sapgw01");
                //it's the port of the ecc host
                parms.Add(RfcConfigParameters.ProgramID, "DES_RFC_SERVER");
                //registed program name in the ecc system.
                parms.Add(RfcConfigParameters.RegistrationCount, "5");
                parms.Add(RfcConfigParameters.Language, "EN");
                parms.Add(RfcConfigParameters.Codepage, "8400");

                return(parms);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 30
0
        private RfcDestination GetRfcDestination()
        {
            var p = new
            {
                Name          = "DEV",
                AppServerHost = "10.1.3.115",
                SystemNumber  = "00",
                SystemID      = "QM5",
                Client        = "999",
                Language      = "EN",
                PoolSize      = 10
            };

            var config = new RfcConfigParameters
            {
                { RfcConfigParameters.Name, p.Name },
                { RfcConfigParameters.AppServerHost, p.AppServerHost },
                { RfcConfigParameters.SystemNumber, p.SystemNumber },
                { RfcConfigParameters.SystemID, p.SystemID },
                { RfcConfigParameters.User, p.SAPUser },
                { RfcConfigParameters.Password, p.Password },
                { RfcConfigParameters.Client, p.Client },
                { RfcConfigParameters.Language, p.Language },
                { RfcConfigParameters.PoolSize, p.PoolSize.ToString(CultureInfo.InvariantCulture) }
            };
            var dest = RfcDestinationManager.GetDestination(config);

            return(dest);
        }
Ejemplo n.º 31
0
        public RfcConfigParameters GetParameters(string destinationName)
        {

            string appserverhost = ConfigurationManager.AppSettings["AppServerHost"];
            string saprouter = ConfigurationManager.AppSettings["SAPRouter"];
            string systemnumber = ConfigurationManager.AppSettings["SystemNumber"];
            string systemid = ConfigurationManager.AppSettings["SystemID"];
            string user = ConfigurationManager.AppSettings["User"];
            string password = ConfigurationManager.AppSettings["Password"];
            string client = ConfigurationManager.AppSettings["Client"];
            string poolsize = ConfigurationManager.AppSettings["PoolSize"];

            var parametros = new RfcConfigParameters
            {
                {RfcConfigParameters.AppServerHost, appserverhost},
                {RfcConfigParameters.SAPRouter, saprouter},
                {RfcConfigParameters.SystemNumber, systemnumber},
                {RfcConfigParameters.SystemID, systemid},
                {RfcConfigParameters.User, user},
                {RfcConfigParameters.Password, password},
                {RfcConfigParameters.Client, client},
                {RfcConfigParameters.PoolSize, poolsize}
            };
            return parametros;
        }
        public RfcConfigParameters GetParameters(string destinationName)
        {
            //throw new NotImplementedException();

            // ishak.kulekci 06.06.2013
            // destinationname boş olmaması gerekiyor, yoksa "ERROR no symbolic destination specified" şeklinde hata veriyor

            //SAPConnectionInfo sapConnectionInfo = ConfigHelper.ParseSAPConnectionInfo();
            SAPConnectionInfo sapConnectionInfo = ConfigHelper.ParseSAPConnectionInfoFromUI();

            RfcConfigParameters rfcConfigParameters = new RfcConfigParameters();
            rfcConfigParameters[RfcConfigParameters.AppServerHost] = sapConnectionInfo.ASHOST;
            rfcConfigParameters[RfcConfigParameters.SystemNumber] = sapConnectionInfo.SYSNR;
            rfcConfigParameters[RfcConfigParameters.Client] = sapConnectionInfo.CLIENT;
            rfcConfigParameters[RfcConfigParameters.User] = sapConnectionInfo.USER;
            rfcConfigParameters[RfcConfigParameters.Password] = sapConnectionInfo.PASSWD;
            rfcConfigParameters[RfcConfigParameters.Language] = sapConnectionInfo.LANG;
            rfcConfigParameters[RfcConfigParameters.PoolSize] = sapConnectionInfo.POOL_SIZE;
            //rfcConfigParameters[RfcConfigParameters.MaxPoolSize]
            rfcConfigParameters[RfcConfigParameters.PeakConnectionsLimit] = sapConnectionInfo.MAX_POOL_SIZE;
            // ishak.kulekci 06.06.2013
            // Name değeri üstte belirtilen destinationName ile aynı olmalı yoksa "Inconsistency in destination name: does not match ..." şeklinde hata veriyor
            rfcConfigParameters[RfcConfigParameters.Name] = destinationName; //sapConnectionInfo.NAME;

            return rfcConfigParameters;
        }
        public static string RFCxSociedad(string xname, string appsh, string xsapr, string sysn, string xuser, string pasw, string cliente, string sociedad)
        {
            RfcConfigParameters parms = new RfcConfigParameters();

            parms.Add(RfcConfigParameters.Name, xname);
            parms.Add(RfcConfigParameters.AppServerHost, appsh);
            parms.Add(RfcConfigParameters.SAPRouter, xsapr.ToString().Trim());
            parms.Add(RfcConfigParameters.SystemNumber, sysn.ToString().Trim());
            parms.Add(RfcConfigParameters.User, xuser.ToString().Trim());
            parms.Add(RfcConfigParameters.Password, pasw.ToString().Trim());
            parms.Add(RfcConfigParameters.Client, cliente.ToString().Trim());
            parms.Add(RfcConfigParameters.Language, "ES");
            parms.Add(RfcConfigParameters.PoolSize, "5");
            parms.Add(RfcConfigParameters.PeakConnectionsLimit, "10");
            parms.Add(RfcConfigParameters.PoolIdleTimeout, "600");

            RfcDestination rfcDest = null;

            rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository repo     = rfcDest.Repository; //Crea repositorio para la función
            IRfcFunction  conexion = repo.CreateFunction("Z_URFC");

            conexion.SetValue("SOCIEDAD", sociedad);
            conexion.Invoke(rfcDest);                  //Se ejecuta la consulta
            //string xresul = conexion.GetString("RFC");
            return(conexion.GetString("RFC"));
        }
Ejemplo n.º 34
0
        public static Destination GetDestination(RfcConfigParameters configParameters)
        {
            string serverKey = ServerConfiguration.AddServerDestination(configParameters);

            lock (serverConfigurationRegistrationLock) {
                if (!serverConfigurationRegistered)
                {
                    RfcDestinationManager.RegisterDestinationConfiguration(new ServerConfiguration());
                    serverConfigurationRegistered = true;
                }
            }

            if (ServerConfiguration.HasServerKey(serverKey))
            {
                Destination destination = new Destination()
                {
                    InUse          = true,
                    InUseSince     = DateTime.Now,
                    ServerKey      = serverKey,
                    Suffix         = String.Empty,
                    RfcDestination = RfcDestinationManager.GetDestination(serverKey)
                };

                return(destination);
            }

            return(null);
        }
Ejemplo n.º 35
0
        //allows adding or modifying a destination for a specific application server
        public void AddOrEditDestination(ConnectionInformations ci)
        {
            //in productive code the given parameters should be checked for validity, e.g. that name is not null
            //as this is not relevant for the example, we omit it here
            RfcConfigParameters par = new RfcConfigParameters();

            par.Add(RfcConfigParameters.Name, ci.Name);
            par.Add(RfcConfigParameters.AppServerHost, ci.AppServerHost);
            par.Add(RfcConfigParameters.SystemNumber, ci.SystemNumber);
            par.Add(RfcConfigParameters.SystemID, ci.SystemID);
            par.Add(RfcConfigParameters.User, ci.User);
            par.Add(RfcConfigParameters.Password, ci.Password);
            par.Add(RfcConfigParameters.Client, ci.Client);
            par.Add(RfcConfigParameters.Language, ci.Language);
            par.Add(RfcConfigParameters.PoolSize, ci.PoolSize);
            par.Add(RfcConfigParameters.MaxPoolSize, ci.MaxPoolSize);
            par.Add(RfcConfigParameters.IdleTimeout, ci.IdleTimeout);
            par.Add(RfcConfigParameters.SAPRouter, ci.SAPRouter);
            RfcConfigParameters existingConfiguration;

            //if a destination of that name existed before, we need to fire a change event
            if (availableDestinations.TryGetValue(ci.Name, out existingConfiguration))
            {
                availableDestinations[ci.Name] = par;
                RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, par);
                if (changeHandler != null)
                {
                    changeHandler(ci.Name, eventArgs);
                }
            }
            else
            {
                availableDestinations[ci.Name] = par;
            }
        }
Ejemplo n.º 36
0
    RfcConfigParameters IDestinationConfiguration.GetParameters(string destinationName)
    {
        RfcConfigParameters param = new RfcConfigParameters();

        SAPConnectionConfigManager ObjSapConConfigManager = new SAPConnectionConfigManager();
        SAPConnectionConfig        objSapconConfig        = (SAPConnectionConfig)ObjSapConConfigManager.objGetActiveSAPConnectionConfig(destinationName, 1);

        if (objSapconConfig != null)
        {
            //DataBase
            param.Add(RfcConfigParameters.SAPRouter, objSapconConfig.SAPRouter);
            param.Add(RfcConfigParameters.AppServerHost, objSapconConfig.AppServerHost);
            param.Add(RfcConfigParameters.SystemNumber, objSapconConfig.SystemNumber);
            param.Add(RfcConfigParameters.SystemID, objSapconConfig.SystemID);
            param.Add(RfcConfigParameters.User, objSapconConfig.SAPUser);
            param.Add(RfcConfigParameters.Password, objSapconConfig.SAPPassword);
            param.Add(RfcConfigParameters.Client, objSapconConfig.SAPClient);
            param.Add(RfcConfigParameters.Language, objSapconConfig.SAPLanguage);
            param.Add(RfcConfigParameters.PoolSize, objSapconConfig.PoolSize);
            param.Add(RfcConfigParameters.MaxPoolSize, objSapconConfig.MaxPoolSize);
            param.Add(RfcConfigParameters.IdleTimeout, objSapconConfig.IdleTimeout);
        }

        return(param);
    }
Ejemplo n.º 37
0
        public RfcConfigParameters GetParametersAsync()
        {
            RfcConfigParameters rfcConfigParameters = new RfcConfigParameters();

            try
            {
                String _sapName          = ConfigurationManager.AppSettings[Constante.SAP_NAME] ?? String.Empty;
                String _sapAppServerHost = ConfigurationManager.AppSettings[Constante.SAP_APP_SERVER_HOST] ?? String.Empty;
                String _sapSystemNum     = ConfigurationManager.AppSettings[Constante.SAP_SYSTEM_NUM] ?? String.Empty;
                String _sapSystemId      = ConfigurationManager.AppSettings[Constante.SAP_SYSTEM_ID] ?? String.Empty;
                String _sapUserName      = ConfigurationManager.AppSettings[Constante.SAP_USERNAME] ?? String.Empty;
                String _sapPassword      = ConfigurationManager.AppSettings[Constante.SAP_PASSWORD] ?? String.Empty;
                String _sapClient        = ConfigurationManager.AppSettings[Constante.SAP_CLIENT] ?? String.Empty;
                String _sapLanguage      = ConfigurationManager.AppSettings[Constante.SAP_LANGUAGE] ?? String.Empty;
                String _sapPoolSize      = ConfigurationManager.AppSettings[Constante.SAP_POOL_SIZE] ?? String.Empty;
                rfcConfigParameters.Add(RfcConfigParameters.Name, _sapName);
                rfcConfigParameters.Add(RfcConfigParameters.AppServerHost, _sapAppServerHost);
                rfcConfigParameters.Add(RfcConfigParameters.SystemNumber, _sapSystemNum);
                rfcConfigParameters.Add(RfcConfigParameters.SystemID, _sapSystemId);
                rfcConfigParameters.Add(RfcConfigParameters.User, _sapUserName);
                rfcConfigParameters.Add(RfcConfigParameters.Password, _sapPassword);
                rfcConfigParameters.Add(RfcConfigParameters.Client, _sapClient);
                rfcConfigParameters.Add(RfcConfigParameters.Language, _sapLanguage);
                rfcConfigParameters.Add(RfcConfigParameters.PoolSize, _sapPoolSize);
                _conexionSap.AddOrEditDestination(rfcConfigParameters);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(rfcConfigParameters);
        }
Ejemplo n.º 38
0
        public void AddOrEditDestination(RfcConfigParameters parameters)
        {
            string name = parameters[RfcConfigParameters.Name];

            if (availableDestinations.ContainsKey(name))
            {
                // Fire a change event
                if (ConfigurationChanged != null)

                /* Always check for null on event handlers... If AddOrEditDestination() gets called before this
                 * instance of InMemoryDestinationConfiguration is registered with the RfcDestinationManager, we
                 * would get a NullReferenceException when trying to raise the event... Stupid concept.
                 * Why doesn't the .NET framework do this for me?
                 */
                {
                    RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, parameters);
                    Console.WriteLine("Firing change event {0} for destination {1}", eventArgs.ToString(), name);
                    ConfigurationChanged(name, eventArgs);
                }
            }

            // Replace the current parameters of an existing destination or add a new one
            availableDestinations[name] = parameters;

            string tmp;

            Console.WriteLine("{1} destination {0} added/changed",
                              name,
                              parameters.TryGetValue(RfcConfigParameters.LogonGroup, out tmp) ? "Load balancing" : "Application server");
        }
        public DestinationConfiguration(Dictionary<string,string> configParameters)
        {
            _configParameters = new RfcConfigParameters();

            foreach(KeyValuePair<string, string> pair in configParameters)
            {
                _configParameters.Add(pair.Key, pair.Value);
            }
        }
Ejemplo n.º 40
0
 public RfcConfigParameters GetParameters(string destinationName)
 {
     RfcConfigParameters conf = new RfcConfigParameters();
     if (destinationName == "NSP")
     {
         conf.Add(RfcConfigParameters.AppServerHost, Parameters_DataTransfer.SAPLoginSettings.SAP_AppServerHost); // vlsrv25a
         conf.Add(RfcConfigParameters.SystemNumber, Parameters_DataTransfer.SAPLoginSettings.SAP_SystemNumber); // 00
         conf.Add(RfcConfigParameters.SystemID, Parameters_DataTransfer.SAPLoginSettings.SAP_SystemID); // T22
         conf.Add(RfcConfigParameters.User, Parameters_DataTransfer.SAPLoginSettings.SAP_User); // BAPI_BEESD
         conf.Add(RfcConfigParameters.Password, Parameters_DataTransfer.SAPLoginSettings.SAP_Password); // rfc%c&ll
         conf.Add(RfcConfigParameters.Client, Parameters_DataTransfer.SAPLoginSettings.SAP_Client); // 400
     }
     return conf;
 }
 //allows adding or modifying a destination for a specific application server
 public void AddOrEditDestination(string destName, string user, string password, string language, string client, string applicationServer, string systemNumber)
 {
     RfcConfigParameters parameters = new RfcConfigParameters();
     parameters[RfcConfigParameters.Name] = destName;
     parameters[RfcConfigParameters.PeakConnectionsLimit] = "10";
     parameters[RfcConfigParameters.PoolSize] = "35";
     parameters[RfcConfigParameters.IdleTimeout] = "1";
     parameters[RfcConfigParameters.User] = user;
     parameters[RfcConfigParameters.Password] = password;
     parameters[RfcConfigParameters.Client] = client;
     parameters[RfcConfigParameters.Language] = language;
     parameters[RfcConfigParameters.AppServerHost] = applicationServer;
     parameters[RfcConfigParameters.SystemNumber] = systemNumber;
     availableDestinations[destName] = parameters;
 }
Ejemplo n.º 42
0
        private RfcConfigParameters ConvertStringToConfigParameters(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
                throw new ArgumentNullException(nameof(connectionString));

            var rfcConfigParameters = new RfcConfigParameters();
            foreach (var param in connectionString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
                var keyValue = param.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                var key = keyValue[0].Trim().ToUpper();
                var value = keyValue[1].Trim();

                if (!rfcConfigParameters.ContainsKey(key))
                    rfcConfigParameters.Add(key, value);
            }
            return rfcConfigParameters;
        }
Ejemplo n.º 43
0
        public RfcConfigParameters GetParameters(String destinationName)
        {
            Manager manager = new Manager();
            SapConnection sapConnection = manager.GetSapConfigurationInformation();

            RfcConfigParameters parms = new RfcConfigParameters();
            parms.Add(RfcConfigParameters.AppServerHost, sapConnection.Host);
            parms.Add(RfcConfigParameters.SystemNumber, sapConnection.SystemNumber);
            parms.Add(RfcConfigParameters.User, sapConnection.User);
            parms.Add(RfcConfigParameters.Password, sapConnection.Password);
            parms.Add(RfcConfigParameters.Client, sapConnection.Client);
            parms.Add(RfcConfigParameters.Language, sapConnection.Language);
            parms.Add(RfcConfigParameters.PoolSize, sapConnection.PoolSize);
            parms.Add(RfcConfigParameters.MaxPoolSize, sapConnection.MaxPoolSize);
            parms.Add(RfcConfigParameters.Name, destinationName);

            return parms;
        }
        // Methods
        public DefaultDestinationConfiguration(RfcDestinationCollection destCollection)
        {
            try
            {
                IEnumerator enumerator = destCollection.GetEnumerator();
                this.destinations = new Dictionary<string, RfcConfigParameters>();
                while (enumerator.MoveNext())
                {
                    RfcDestinationParameters current = (RfcDestinationParameters)enumerator.Current;
                    RfcConfigParameters parameters2 = new RfcConfigParameters(0x20);

                    //RfcConfigParameters parameters2 = new RfcConfigParameters();
                    // Assembly a = Assembly.LoadFrom("sapnco.dll");
                   // String ConfigFileToolpath = System.AppDomain.CurrentDomain.BaseDirectory + "ConfigFileTool.dll";
                   // PropertyInfo[] properties = Assembly.LoadFrom(ConfigFileToolpath).GetType("ConfigFileTool.SapConfig.RfcDestinationParameters").GetProperties();
                    PropertyInfo[] properties = current.GetType().GetProperties();
                    //  PropertyInfo[] properties = Assembly.LoadFrom("ConfigFileTool.dll").GetType("ConfigFileTool.SapConfig.RfcDestinationParameters").GetProperties();

                   // String sapncoPath = System.AppDomain.CurrentDomain.BaseDirectory + "sapnco.dll";
                   //  Type type = Assembly.LoadFrom(sapncoPath).GetType("SAP.Middleware.Connector.RfcConfigParameters");
                   //  Type type = Assembly.LoadFrom("sapnco.dll").GetType("SAP.Middleware.Connector.RfcConfigParameters");
                    Type type = parameters2.GetType();
                    for (int i = 0; i < properties.Length; i++)
                    {

                        string str = properties[i].GetValue(current, null) as string;
                        if ((str != null) && (str.Length > 0))
                        {
                            parameters2[(string)type.GetField(properties[i].Name).GetValue(null)] = str;
                        }
                    }
                    this.destinations[current.Name] = parameters2;
                    SAPLogonConfigList.SystemNameList.Add(current.Name);
                }
            }
            catch (Exception exception)
            {

                throw new SAPException(exception.Message + "无法加载程序集ConfigFileTool.exe,或sapnco.dll");
            }
        }
        public void AddOrEditDestination(RfcConfigParameters parameters)
        {
            string name = parameters[RfcConfigParameters.Name];

            if (_availableDestinations.ContainsKey(name))
            {
                RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, parameters);

                if (ConfigurationChanged != null)
                {
                    ConfigurationChanged(name, eventArgs);
                }
            }

            _availableDestinations[name] = parameters;
            string tmp = "Application server";
            bool isLoadValancing = parameters.TryGetValue(RfcConfigParameters.LogonGroup, out tmp);
            if (isLoadValancing)
            {
                tmp = "Load balancing";
            }
        }
Ejemplo n.º 46
0
        public RfcConfigParameters GetParameters(String serverName)
        {
            if ("PRD_REG_SERVER".Equals(serverName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.RepositoryDestination, "PRD_000");
                //the client config name

                parms.Add(RfcConfigParameters.GatewayHost, "192.168.1.146");
                //it's the ecc's host or the ip address

                parms.Add(RfcConfigParameters.GatewayService, "sapgw01");
                //it's the port of the ecc host
                parms.Add(RfcConfigParameters.ProgramID, "DES_RFC_SERVER");
                //registed program name in the ecc system.
                parms.Add(RfcConfigParameters.RegistrationCount, "5");
                parms.Add(RfcConfigParameters.Language, "EN");
                parms.Add(RfcConfigParameters.Codepage, "8400");

                return parms;

            }
            else return null;
        }
Ejemplo n.º 47
0
 protected void Application_Start(object sender, EventArgs e)
 {
     //NB: do not remove!
     RfcConfigParameters parms = new RfcConfigParameters();
 }
Ejemplo n.º 48
0
        public RfcConfigParameters GetParameters(string destinationName)
        {
            if ("PRD_000".Equals(destinationName))
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.AppServerHost, "192.168.1.146");
                parms.Add(RfcConfigParameters.SystemNumber, "01");
                parms.Add(RfcConfigParameters.SystemID, "DM0");

                parms.Add(RfcConfigParameters.User, "wwsheng");
                parms.Add(RfcConfigParameters.Password, "wwsheng");
                parms.Add(RfcConfigParameters.Client, "800");
                parms.Add(RfcConfigParameters.Language, "en");
                parms.Add(RfcConfigParameters.PoolSize, "5");
                parms.Add(RfcConfigParameters.MaxPoolSize, "10");
                parms.Add(RfcConfigParameters.IdleTimeout, "60");

                return parms;
            }
            else return null;
        }
Ejemplo n.º 49
0
 public RfcConfigParameters GetParameters(String serverName)
 {
     if ("PORTAL_PROGAS".Equals(serverName))
     {
         RfcConfigParameters parms = new RfcConfigParameters();
         parms.Add(RfcConfigParameters.GatewayService, gatewayService);
         parms.Add(RfcConfigParameters.SAPRouter, saprouter);
         parms.Add(RfcConfigParameters.GatewayHost, gatewayhost);
         parms.Add(RfcConfigParameters.ProgramID, programid);
         parms.Add(RfcConfigParameters.RepositoryDestination, repositorydestination);
         parms.Add(RfcConfigParameters.RegistrationCount, registrationcount);
         return parms;
     }
     else return null;
 }
Ejemplo n.º 50
0
        //allows adding or modifying a destination for a group/server selection
        public void AddOrEditDestination(string name,
            int poolSize,
            string user,
            string password,
            string language,
            string client,
            string messageServerService,
            string messageServerHost,
            string logonGroup)
        {
            //in productive code the given parameters should be checked for validity, e.g. that name is not null
            //as this is not relevant for the example, we omit it here
            RfcConfigParameters parameters = new RfcConfigParameters();
            parameters[RfcConfigParameters.Name] = name;
            parameters[RfcConfigParameters.MaxPoolSize] = Convert.ToString(poolSize);
            parameters[RfcConfigParameters.IdleTimeout] = Convert.ToString(6); // we keep connections for 10 minutes
            parameters[RfcConfigParameters.User] = user;
            parameters[RfcConfigParameters.Password] = password;
            parameters[RfcConfigParameters.Client] = client;
            parameters[RfcConfigParameters.Language] = language;
            parameters[RfcConfigParameters.MessageServerService] = messageServerService;
            parameters[RfcConfigParameters.MessageServerHost] = messageServerHost;
            parameters[RfcConfigParameters.LogonGroup] = logonGroup;
            RfcConfigParameters existingConfiguration;

            //if a destination of that name existed before, we need to fire a change event
            if (availableDestinations.TryGetValue(name, out existingConfiguration))
            {
                availableDestinations[name] = parameters;
                RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, parameters);
                MessageBox.Show("Fire change event " + eventArgs.ToString() + " for destination " + name);
                changeHandler(name, eventArgs);
            }
            else
            {
                availableDestinations[name] = parameters;
            }

            //MessageBox.Show("Added application server destination " + name);
        }
Ejemplo n.º 51
0
 public RfcConfigParameters GetParameters(String serverName)
 {
     if ("PORTAL_PROGAS".Equals(serverName))
     {
         RfcConfigParameters parms = new RfcConfigParameters();
         parms.Add(RfcConfigParameters.GatewayService, "sapgw00");
         parms.Add(RfcConfigParameters.SAPRouter, "/H/201.35.69.162/S/3299/H/");
         parms.Add(RfcConfigParameters.GatewayHost, "10.10.0.93");// 10.10.0.94 SAP01
         parms.Add(RfcConfigParameters.ProgramID, "MyServer");
         parms.Add(RfcConfigParameters.RepositoryDestination, "DEV");
         parms.Add(RfcConfigParameters.RegistrationCount, "5");
         return parms;
     }
     else return null;
 }
Ejemplo n.º 52
0
            public RfcConfigParameters GetParameters(String destinationName)
            {
                if ("DEV".Equals(destinationName))
                {
                    RfcConfigParameters parms = new RfcConfigParameters();
                    parms.Add(RfcConfigParameters.AppServerHost, "10.10.0.93");// "172.16.83.113"
                    parms.Add(RfcConfigParameters.SAPRouter, "/H/201.35.69.162/S/3299/H/");//"/H/200.198.107.10/H/"
                    parms.Add(RfcConfigParameters.SystemNumber, "00");//"10"
                    parms.Add(RfcConfigParameters.SystemID, "DEV");//"D00"
                    parms.Add(RfcConfigParameters.User, "fusion");// "fus_ruy"
                    parms.Add(RfcConfigParameters.Password, "noisuf");//"fusion123"
                    parms.Add(RfcConfigParameters.Client, "400");// "400"                    
                    parms.Add(RfcConfigParameters.PoolSize, "5");//"5"
                    parms.Add(RfcConfigParameters.MaxPoolSize, "10");//"10"
                    parms.Add(RfcConfigParameters.IdleTimeout, "600");//"600"

                    return parms;
                }

                else return null;
            }