예제 #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;
            }
        }
예제 #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;
            }
        }
예제 #3
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;
            }
        }
예제 #4
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;
            }
        }