Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        public int SAVE_MAIL_DATA(List <MAIL_DATA_BE> mail_data, SharedSettings.Settings settings)
        {
            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  save_mail = repo.CreateFunction("Z_MAIL_SAVE");

                IRfcTable p_maildata = save_mail.GetTable("P_MAILDATA");
                get_maildata_saptab(mail_data, ref p_maildata);

                save_mail.Invoke(rfcDest);

                IRfcStructure bapiret = save_mail.GetStructure("BAPIRET");

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

                //Revisamos que la consulta haya sido exitosa
                if (bapiret.GetString("TYPE") == "E")
                {
                    return(4); //Hubo un error
                }
                else
                {
                    return(0); //Guardado exitoso
                }
            }
            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;
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public string SAVE_MAIL_DATA(MAIL_DATA_BE mail_data, List <Attachment_BE> attachs, List <Relacionados> relacionados, SharedSettings.Settings settings)
        {
            byte[] pdf;
            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  save_mail = repo.CreateFunction("Z_MAIL_SAVE");


                IRfcStructure p_maildata     = save_mail.GetStructure("P_MAILDATA");
                IRfcTable     p_attachments  = save_mail.GetTable("P_ATTACHMENTS");
                IRfcTable     p_relacionados = save_mail.GetTable("P_RELACIONADOS");


                get_maildata_sapstr(mail_data, ref p_maildata);

                get_mailattach_saptab(attachs, ref p_attachments);
                get_relacionados_saptab(relacionados, ref p_relacionados);

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

                pdf = save_mail.GetByteArray("FILEPDFGEN");
                IRfcStructure bapiret = save_mail.GetStructure("BAPIRET");

                //string res = save_mail.GetString("MSG");

                //Revisamos que la consulta haya sido exitosa
                if (pdf.Length > 0 && String.IsNullOrEmpty(attachs[0].PATHFILEPDF) == false)
                {
                    if (System.IO.File.Exists(attachs[0].PATHFILEPDF) == false)
                    {
                        System.IO.File.WriteAllBytes(attachs[0].PATHFILEPDF, pdf);
                    }
                }
                if (bapiret.GetString("TYPE") == "E")
                {
                    string mensajeError = bapiret.GetString("MESSAGE");
                    return(mensajeError); //Hubo un error
                }
                else
                {
                    return(""); //Guardado exitoso
                }
            }
            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;
            }
        }
Esempio n. 6
0
        public Attachment_BE VALIDATE_XML(ref Attachment_BE attach, string metodoPago, SharedSettings.Settings settings)
        {
            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_DATA");

                validate_mail.SetValue("P_RFC_VENDOR", attach.RFC_VEND);
                validate_mail.SetValue("P_RFC_COMPANY", attach.RFC_COMP);
                validate_mail.SetValue("P_MET_PAGO", metodoPago);
                //Ejecutamos la consulta
                validate_mail.Invoke(rfcDest);

                attach.RFC_COMPANY = validate_mail.GetString("ERFC_COMPANY");
                attach.RFC_VENDOR  = validate_mail.GetString("ERFC_VENDOR");
                attach.LIFNR       = validate_mail.GetString("ELIFNR");
                attach.BUKRS       = validate_mail.GetString("EBUKRS");

                //attach.ECALLECOMP = validate_mail.GetString("ECALLECOMP");
                //attach.E_N_EXTCOMP = validate_mail.GetString("E_N_EXTCOMP");
                //attach.ECOLCOMP = validate_mail.GetString("ECOLCOMP");
                //attach.EMUNI_COMP = validate_mail.GetString("EMUNI_COMP");
                //attach.ECPCOMP = validate_mail.GetString("ECPCOMP");
                //attach.EPAISCOMP = validate_mail.GetString("EPAISCOMP");
                //attach.ECALLEVEND = validate_mail.GetString("ECALLEVEND");
                //attach.E_N_EXTVEND = validate_mail.GetString("E_N_EXTVEND");
                //attach.ECOLVEND = validate_mail.GetString("ECOLVEND");
                //attach.EMUNI_VEND = validate_mail.GetString("EMUNI_VEND");
                //attach.ECPVEND = validate_mail.GetString("ECPVEND");
                //attach.EPAISVEND = validate_mail.GetString("EPAISVEND");
                //attach.EEDO_COMP = validate_mail.GetString("EEDO_COMP");
                //attach.EEDO_VEND = validate_mail.GetString("EEDO_VEND");
                attach.Desc_Error = attach.Desc_Error + validate_mail.GetString("E_MET_PAGO");


                return(attach);
            }
            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;
            }
        }