Пример #1
0
        public static RfcConfigParameters GetParameters(SAP_CNX cnx, SharedSettings.Settings settings)
        {
            RfcConfigParameters parms = new RfcConfigParameters();

            parms.Add(RfcConfigParameters.Name, settings.sap_name);
            parms.Add(RfcConfigParameters.AppServerHost, settings.sap_host);
            parms.Add(RfcConfigParameters.SystemNumber, settings.sap_sysnumber);
            parms.Add(RfcConfigParameters.User, settings.sap_user);
            parms.Add(RfcConfigParameters.Password, settings.sap_pass);
            parms.Add(RfcConfigParameters.Client, settings.sap_client);
            parms.Add(RfcConfigParameters.Language, "EN");
            parms.Add(RfcConfigParameters.SAPRouter, settings.SAPRouter);
            parms.Add(RfcConfigParameters.PoolSize, "5");
            parms.Add(RfcConfigParameters.PeakConnectionsLimit, "10");
            parms.Add(RfcConfigParameters.PoolIdleTimeout, "600");

            return(parms);
        }
Пример #2
0
        public static string Save_sap_settings(SharedSettings.Settings settings)
        {
            SAP_CNX conexion    = new SAP_CNX();
            string  mensajeconn = "";

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

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

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


                //save_settings.SetValue("BUKRS", settings.company_code);
                save_settings.SetValue("FOLDER_FILE", "");

                string DELETE_ATTACH = "";
                //if (settings.delete_files_at_attach)
                DELETE_ATTACH = "";

                save_settings.SetValue("DELETE_ATTACH", DELETE_ATTACH);

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

                IRfcStructure bapiret = save_settings.GetStructure("RETURN");

                string type = bapiret.GetString("TYPE");
                if (type == "E")
                {
                    return(mensajeconn);
                }
                else
                {
                    return(mensajeconn);
                }
            }
            catch (RfcCommunicationException e)
            {
                //throw e;
                return(e.Message);
            }
            catch (RfcLogonException e)
            {
                // user could not logon...
                return(e.Message);
                //throw e;
            }
            catch (RfcAbapRuntimeException e)
            {
                // serious problem on ABAP system side...
                //throw e;
                return(e.Message);
            }
            catch (RfcAbapBaseException e)
            {
                // The function module returned an ABAP exception, an ABAP message
                // or an ABAP class-based exception...
                //throw e;
                return(e.Message);
            }
            catch (Exception e)
            {
                //throw e;
                return(e.Message);
            }
        }