AX Interfaz

Hilo iniciado por Zoemy Gabriela Esquivel Loría el 7 de febrero de 2012

Viendo 6 entradas - de la 1 a la 6 (de un total de 6)
  • Autor
    Entradas
  • #13308
    RangoZoemy Gabriela Esquivel Loría
    Zoemy Gabriela Esquivel Loría
    Participante
    APRENDIZ
    999 Rincoins

    ¿Alguién ha empleado el Services and Application Integration Framework (AIF)?, ¿que ventajas / desventajas tiene contra el Business Conector?, o que otras opciones existen para comunicar AX con sistemas externos??

    #13309
    RangoPedro Beltran
    Pedro Beltran
    Participante
    PARTICIPANTE
    1.049 Rincoins

    Yo estoy utilizando el web services CustInvoiceServices del AX para el ingreso de facturas de servicios, hasta ahora me ha funcionado muy bien.. Lo estoy consumiendo con .Net C# para ser mas especifico.

    #13310
    RangoZoemy Gabriela Esquivel Loría
    Zoemy Gabriela Esquivel Loría
    Participante
    APRENDIZ
    999 Rincoins

    De casualidad tu interfaz graba dimensiones de inventario?

    #13311
    RangoPedro Beltran
    Pedro Beltran
    Participante
    PARTICIPANTE
    1.049 Rincoins

    No no lo he echo aun pero me imagino que si se ha de poder hacer

    #13312
    RangoJose Alirio Yepes
    Jose Alirio Yepes
    Participante
    PARTICIPANTE
    1.249 Rincoins

    Pedro, si no es mucho atrevimiento, podías publicar algo muy sencillo.
    Yo no manejo C# , he estado intentando hacerlo desde Borland Delphi 7, pero creo que tengo errado la forma de hacerlo, lo digo porque uso dentro de Borland Delphi una herramienta que se conecta a un webservice y arma la estructra de funciones,
    Con esta aplicación me he conectado a otros webservice y me ha funcionado.

    incluso me gustaria intentarlo desde Android, jejejejee. pero veo que estoy errado en concepto, me da la impresión.

    Pero si es mas fácil hacerlo en C#, un ejemplo funcional seria de mucha ayuda. gracias

    #13313
    RangoPedro Beltran
    Pedro Beltran
    Participante
    PARTICIPANTE
    1.049 Rincoins

    Claro hay te envio un ejemplo del manejo de AIF en ax de como ingresar y consultar datos por Web Seervices aun no he podido realizar la actualizacion ni la eliminacion si consigues como realizarlo me ayudas..

    Elejemplo esta con un datagrid que lleno desde un notepad por eso vas a ver algo asi dgvDatos.Rows[i].Cells[1].Value.ToString(); solo lo cambias por lo que quieras que se muestre y listo

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using SysColl = System.Collections;
    using System.Windows.Forms;
    using System.IO;

    namespace testws
    {
        using testws.FTIS;
        using testws.CustCbo;
        using testws.RFAC;

        public partial class Form1 : Form
        {
            protected CustCbo.CustCboServiceClient m_CustCboServiceClient;
            bool Activo;

            //INICIALIZAMOS LOS COMPONENTES DEL FORMULARIOS
            public Form1()
            {
                InitializeComponent();
            }

            //REALIZA EL PROCESO DEL INGRESO DE LA FACTURA AL DYNAMIC
            private void IngresoFactura(bool Activo)
            {
                for (int i = 0; i <= dgvDatos.Rows.Count; i++)
                {

                    FreeTextInvoiceServiceClient service = new FreeTextInvoiceServiceClient();

                    if (null == service)
                    {
                        throw new Exception(“Cannot instantiate service.”);
                    }

                    AxdFreeTextInvoice FreeTextInvoice = new AxdFreeTextInvoice();

                    //Record
                    FTIS.AxdEntity_CustInvoiceTable CustInvoiceTable = new FTIS.AxdEntity_CustInvoiceTable();
                    //expireDateTime.timezone = AxdEnum_Timezone.GMTMINUS0600CENTRALTIME;

                    CustInvoiceTable.InvoiceAccount = dgvDatos.Rows[i].Cells[1].Value.ToString();
                    CustInvoiceTable.OrderAccount = dgvDatos.Rows[i].Cells[2].Value.ToString();
                    CustInvoiceTable.InvoiceDateSpecified = true;
                    //CustInvoiceTable.InvoiceDate = new DateTime(2010, 12, 7);
                    CustInvoiceTable.InvoiceDate = Convert.ToDateTime(dgvDatos.Rows[i].Cells[3].Value.ToString());
                    CustInvoiceTable.DueDateSpecified = true;
                    //CustInvoiceTable.DueDate = new DateTime(2010, 12, 30);
                    CustInvoiceTable.DueDate = Convert.ToDateTime(dgvDatos.Rows[i].Cells[4].Value.ToString());
                    //CustInvoiceTable.CurrencyCode = dgvDatos.Rows[i].Cells[5].Value.ToString();
                    //CustInvoiceTable.Payment = dgvDatos.Rows[i].Cells[6].Value.ToString();
                    //CustInvoiceTable.TaxGroup = dgvDatos.Rows[i].Cells[7].Value.ToString();
                    //CustInvoiceTable.PaymentSched = dgvDatos.Rows[i].Cells[8].Value.ToString();
                    //CustInvoiceTable.LanguageId = dgvDatos.Rows[i].Cells[9].Value.ToString();
                    CustInvoiceTable.Name = dgvDatos.Rows[i].Cells[10].Value.ToString();
                    //CustInvoiceTable.Address = dgvDatos.Rows[i].Cells[11].Value.ToString();
                    //CustInvoiceTable.Street = dgvDatos.Rows[i].Cells[12].Value.ToString();
                    //CustInvoiceTable.SalesTaker = dgvDatos.Rows[i].Cells[13].Value.ToString();
                    CustInvoiceTable.DocumentDateSpecified = true;
                    //CustInvoiceTable.DocumentDate = new DateTime(2010, 12, 7);
                    CustInvoiceTable.DocumentDate = Convert.ToDateTime(dgvDatos.Rows[i].Cells[14].Value.ToString());

                    int x = 0, j = i;

                    if (dgvDatos.Rows[j].Cells[10].Value.ToString() == dgvDatos.Rows[j + 1].Cells[10].Value.ToString() &&
                        dgvDatos.Rows[j].Cells[14].Value.ToString() == dgvDatos.Rows[j + 1].Cells[14].Value.ToString())
                    {

                        while (dgvDatos.Rows[j].Cells[10].Value.ToString() == dgvDatos.Rows[j + 1].Cells[10].Value.ToString() &&
                               dgvDatos.Rows[j].Cells[14].Value.ToString() == dgvDatos.Rows[j + 1].Cells[14].Value.ToString())
                        {
                            x = x + 1;
                            j = j + 1;
                        }

                        CustInvoiceTable.CustInvoiceLine = new AxdEntity_CustInvoiceLine[x + 1];

                        j = i;
                        for (int y = 0; y <= x; y++)
                        {
                            CustInvoiceTable.CustInvoiceLine[y] = new AxdEntity_CustInvoiceLine();
                            CustInvoiceTable.CustInvoiceLine[y].Description = dgvDatos.Rows[j].Cells[15].Value.ToString();
                            CustInvoiceTable.CustInvoiceLine[y].LedgerAccount = dgvDatos.Rows[j].Cells[16].Value.ToString();
                            CustInvoiceTable.CustInvoiceLine[y].TaxGroup = dgvDatos.Rows[j].Cells[17].Value.ToString();
                            CustInvoiceTable.CustInvoiceLine[y].TaxItemGroup = dgvDatos.Rows[j].Cells[18].Value.ToString();
                            CustInvoiceTable.CustInvoiceLine[y].AmountCurSpecified = true;
                            CustInvoiceTable.CustInvoiceLine[y].AmountCur = Convert.ToDecimal(dgvDatos.Rows[j].Cells[19].Value.ToString());
                            j = j + 1;
                        }

                    }
                    else//CUANDO NO HAY MAS QUE SOLO UN REGISTRO EN LA FACTURA
                    {
                        CustInvoiceTable.CustInvoiceLine = new AxdEntity_CustInvoiceLine[1];
                        CustInvoiceTable.CustInvoiceLine[0] = new AxdEntity_CustInvoiceLine();
                        CustInvoiceTable.CustInvoiceLine[0].Description = dgvDatos.Rows[j].Cells[15].Value.ToString();
                        CustInvoiceTable.CustInvoiceLine[0].LedgerAccount = dgvDatos.Rows[j].Cells[16].Value.ToString();
                        CustInvoiceTable.CustInvoiceLine[0].TaxGroup = dgvDatos.Rows[j].Cells[17].Value.ToString();
                        CustInvoiceTable.CustInvoiceLine[0].TaxItemGroup = dgvDatos.Rows[j].Cells[18].Value.ToString();
                        CustInvoiceTable.CustInvoiceLine[0].AmountCurSpecified = true;
                        CustInvoiceTable.CustInvoiceLine[0].AmountCur = Convert.ToDecimal(dgvDatos.Rows[j].Cells[19].Value.ToString());
                    }

                    FreeTextInvoice.CustInvoiceTable = new FTIS.AxdEntity_CustInvoiceTable[1] { CustInvoiceTable };

                    try
                    {
                        testws.FTIS.EntityKey[] returned = service.create(FreeTextInvoice);
                        testws.FTIS.EntityKey returnedValues = (testws.FTIS.EntityKey)returned.GetValue(0);
                        Console.WriteLine(“Valor retornado: ” + returnedValues.KeyData[0].Value);
                        Console.ReadLine();

                        //SE ENVIA EL RECID DE LA FACTURA INGRESADA
                        if (Activo)
                        {

                            if (RegistroFactura(returnedValues.KeyData[0].Value) == true)
                            {
                                Console.WriteLine(“Factura Registrada”);
                                Console.ReadLine();
                            }
                            else
                            {
                                Console.WriteLine(“Factura NO Registrada”);
                                Console.ReadLine();
                            }

                        }

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(“Error: ” + ex.ToString());
                        Console.ReadLine();
                    }
                }
            }
        
            //PERMITE REALIZAR LA BUSQUEDA MEDIANTE CUADRO DE DIALOGO
            private void btnExaminar_Click(object sender, EventArgs e)
            {
                //abre el cuadro de dialogo en la ubicacion del c
                openFileDialog1.InitialDirectory = “c:\\”;
                //permite filtrar la busqueda por solo archivo que tengan extension txt
                openFileDialog1.Filter = “txt files (*.txt)|*.txt|All files (*.*)|*.*” ;
                openFileDialog1.FilterIndex = 2 ;
                openFileDialog1.RestoreDirectory = true ;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    int count = 2;           //Total de campos que se van a insertar en el grid
                    string[] splits = null;  //Arreglo que contendra los separadores del txt

                    txtDirFile.Text = openFileDialog1.FileName;

                    splits = txtDirFile.Text.Split(new Char[] { ‘.’ }, count);
                    string var = splits[1];

                    //validacion adicional para que los archivos que se suban solo sean tipo txt
                    if (var != “txt”)
                    {
                        MessageBox.Show(“Seleccione un archivo tipo texto con extension (.txt) “, “Advertencia”, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtDirFile.Text = “”;
                    }
                    splits = null;
                }
            }

            //PERMITE REALIZAR LA CARGA INICIAL DEL ARCHIVO PLANO AL GRID
            private void btnCargar_Click(object sender, EventArgs e)
            {
                 if (txtDirFile.Text != “”)
                {
                    string texto;           //Cadena de linea del archivo plano
                    string[] split = null;  //Arreglo que contendra los separadores del txt

                    try
                    {
                        StreamReader tr = new StreamReader(txtDirFile.Text);
                        while ((texto = tr.ReadLine()) != null)
                        {
                            //Permite leer el txt separado por tab:
                            split = texto.Split(new Char[] { ‘\t’ });
                            dgvDatos.Rows.Add(false,split[0], split[1], split[2], split[3], split[4], split[5], split[6], split[7], split[8], split[9], split[10], split[11], split[12], split[13], split[14], split[15], split[16], split[17], split[18]);
                            split = null;
                        }

                        //Mostrar el número de filas de un DataGridView en el Headers..
                        if (dgvDatos.Rows.Count > 0)
                        {
                            int i = 1;
                            foreach (DataGridViewRow dr in  dgvDatos.Rows)
                            {
                                dr.HeaderCell.Value = i.ToString();
                                i++;
                            }
                            //for (int r = 0; r < dgvDatos.Rows.Count; r++)
                            //{
                            //    this.dgvDatos.Rows[r].HeaderCell.Value = (r + 1).ToString();
                            //}
                        }
                        dgvDatos.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

                        MessageBox.Show(“El archivo se cargo correctamente” + dgvDatos.Rows.Count, “OK”, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show(“Seleccione un archivo a subir”, “Advertencia”, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            //PERMITE REGISTRAR LA FACTURA DE SERVICIO INGRESADA
            private bool RegistroFactura(string RecId)
            {
                bool Registrado = false;

                RegistroFacturaServiceClient servicio = new RegistroFacturaServiceClient();

                if (null == servicio)
                {
                    throw new Exception(“Cannot instantiate service.”);
                }

                AxdRegistroFacturas Registro = new AxdRegistroFacturas();

                //Record
                RFAC.AxdEntity_RegistroFactura RegistroFactura = new RFAC.AxdEntity_RegistroFactura();

                RegistroFactura.FacturaRecId = RecId;

                Registro.RegistroFactura = new RFAC.AxdEntity_RegistroFactura[] { RegistroFactura };

                try
                {
                    testws.RFAC.EntityKey[] returned = servicio.create(Registro);
                    Registrado = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(“Error: ” + ex.ToString());
                    Console.ReadLine();
                }

                return Registrado;
            }

            //PERMITE PONER TRUE A LA VARIABLE PARA SABER QUE LA FACTURA SE REGISTRA
            private void RegistrarToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Activo = true;
                IngresoFactura(Activo);
            }

            //PERMITE PONER FALSE A LA VARIABLE PARA SABER QUE LA FACTURA NO SE REGISTRA
            private void sinRegistrarToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Activo = false;
                IngresoFactura(Activo);
            }
        
            //EJEMPLO DE COMO SUBIR DATOS DEL WEB SERVICE A UN COMBO
            //private void Form1_Load(object sender, EventArgs e)
            //{
            //    ////CustCbo.CustCboServiceClient serCombo = new CustCbo.CustCboServiceClient();
            //    ////this.m_CustCboServiceClient = serCombo;

            //    ////if (null == serCombo)
            //    ////{
            //    ////    throw new Exception(“Cannot instantiate service.”);
            //    ////}

            //    ////CustCbo.QueryCriteria queryCriteria;
            //    ////CustCbo.CriteriaElement[] criteriaElements;
            //    ////criteriaElements = new CustCbo.CriteriaElement[1];
            //    ////criteriaElements[0] = new CustCbo.CriteriaElement();

            //    ////criteriaElements[0].DataSourceName = “Customers”;
            //    ////criteriaElements[0].FieldName = “AccountNum”;
            //    ////criteriaElements[0].Operator = CustCbo.Operator.NotEqual;
            //    ////criteriaElements[0].Value1 = “”;
            //    ////criteriaElements[0].Value2 = “”;

            //    ////queryCriteria = new CustCbo.QueryCriteria();
            //    ////queryCriteria.CriteriaElement = criteriaElements;

            //    ////CustCbo.AxdCustCbo axdCustCbo;
            //    ////CustCbo.AxdEntity_Customers axdEntity_Customer;
            //    ////SysColl.IEnumerator enumerCustomer;
            //    //////int iCountLoop1 = 0;

            //    //////Ejecutar Find
            //    ////axdCustCbo = this.m_CustCboServiceClient.find(queryCriteria);

            //    ////enumerCustomer = axdCustCbo.Customers.GetEnumerator();

            //    ////while (enumerCustomer.MoveNext())
            //    ////{
            //    ////    //++iCountLoop1;
            //    ////    axdEntity_Customer = (CustCbo.AxdEntity_Customers)enumerCustomer.Current;
            //    ////    //Console.Out.WriteLine (Environment.NewLine + “Customers[” + iCountLoop1 +”]: AccountNum = ” + axdEntity_Customer.AccountNum + ” Name = ” + axdEntity_Customer.Name + ” NameAlias = ” + axdEntity_Customer.NameAlias);

            //    ////    cbxCustomer.Items.Add(axdEntity_Customer.AccountNum + ” – ” + axdEntity_Customer.Name);
            //    ////}

    }

Viendo 6 entradas - de la 1 a la 6 (de un total de 6)
  • Debes estar registrado para responder a este debate.
Carrito de compra