/// <summary>
        /// Integra un documento xml sDocXml a GP.
        /// </summary>
        public void integraTransactionXml()
        {
            iError = 0;
            string          eConnResult;
            eConnectMethods eConnObject = new eConnectMethods();

            try
            {
                //El método que integra eConnect_EntryPoint retorna True si fue exitoso
                //eConnResult = eConnObject.eConnect_EntryPoint(_DatosConexionDB.Elemento.ConnStr, EnumTypes.ConnectionStringType.SqlClient, _sDocXml, EnumTypes.SchemaValidationType.None);
                eConnResult = eConnObject.CreateTransactionEntity(_DatosConexionDB.Elemento.ConnStr, _sDocXml);

                this.sMensaje = "--> Integrado a GP";
                //sMensaje += _sDocXml;
            }
            catch (eConnectException eConnErr)
            {
                this.sMensaje = "Excepción eConnect: " + eConnErr.Message + " " + eConnErr.TargetSite.ToString() + " [integraTransactionXml] " + _sDocXml;
                this.iError++;
            }
            catch (ApplicationException ex)
            {
                this.sMensaje = "Excepción de aplicación: " + ex.Message + "[integraTransactionXml]";
                this.iError++;
            }
            catch (Exception errorGral)
            {
                this.sMensaje = "Excepción desconocida: " + errorGral.Message + "[integraTransactionXml]";
                this.iError++;
            }
        }
        public static bool InsertTransaction(ref string response, string transactionXML, string gpDatabase)
        {
            string connString = DataAccess.ConnectionStringWindows;
            string returnValue;

            response = "";

            eConnectMethods eConnCall = new eConnectMethods();

            try
            {
                returnValue = eConnCall.CreateTransactionEntity(connString, transactionXML);
                return(true);
            }
            catch (eConnectException ex)
            {
                response = ex.Message;
                return(false);
            }
            catch (SqlException ex)
            {
                foreach (SqlError sqlErr in ex.Errors)
                {
                    response += sqlErr.Message + "\r\n";
                }
                return(false);
            }
            catch (Exception ex)
            {
                response = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// Crea el xml de una factura sop a partir de una vista sql.
        /// </summary>
        private taSopHdrIvcInsert IntegraFacturaSOP(vwIntegracionesVentas preFacturasAIntegrar, string sTimeStamp)
        {
            string       eConnResult                = String.Empty;
            eConnectType docEConnectSOP             = new eConnectType();
            eConnectType entEconnect                = new eConnectType();
            FacturaDeVentaSOPBandejaDB documentoSOP = new FacturaDeVentaSOPBandejaDB(parametrosDB);
            eConnectMethods            eConnObject  = new eConnectMethods();

            var    dpf = getPrefacturasDetalle(preFacturasAIntegrar.NUMDOCARN, preFacturasAIntegrar.TIPODOCARN);
            string tipoContribuyente = LocArgentina_GetTipoContribuyente(preFacturasAIntegrar.IDCLIENTE);

            documentoSOP.preparaFacturaSOP(preFacturasAIntegrar, dpf, sTimeStamp, tipoContribuyente);
            docEConnectSOP.SOPTransactionType = new SOPTransactionType[] { documentoSOP.FacturaSop };
            serializa(docEConnectSOP);
            eConnResult = eConnObject.CreateTransactionEntity(parametrosDB.ConnStringTarget, this.SDocXml);
            return(documentoSOP.FacturaSop.taSopHdrIvcInsert);
        }
Beispiel #4
0
        public void createNewItem(part newpart)
        {
            using (eConnectMethods eConCall = new eConnectMethods())
            {
                try
                {
                    // Create the eConnect document and store it in a file
                    serializeObject("C:\\newItem.xml", newpart);

                    // Load the eConnect XML document from the file into
                    // and XML document object
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load("C:\\newItem.xml");

                    // Create an XML string from the document object
                    string salesOrderDocument = xmldoc.OuterXml;

                    // Create a connection string
                    // Integrated Security is required. Integrated security=SSPI
                    // Update the data source and initial catalog to use the names of
                    // data server and company database
                    string sConnectionString = "data source=Sandbox-PC\\DTIGP;initial catalog=DTI;integrated security=SSPI;persist security info=False;packet size=4096";

                    // Use the CreateTransactionEntity method to create the sales document in Microsoft Dynamics GP
                    // The method returns a string that contains the doc ID number of the new sales document
                    string salesOrder = eConCall.CreateTransactionEntity(sConnectionString, salesOrderDocument);
                }
                // The eConnectException class will catch any business logic related errors from eConnect_EntryPoint.
                catch (eConnectException exp)
                {
                    Console.Write(exp.ToString());
                }
                // Catch any system error that might occurr. Display the error to the user
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                }
                finally
                {
                    // Use the Dipose method to release resources associated with the
                    // eConnectMethods objects
                    eConCall.Dispose();
                }
            }
        }
Beispiel #5
0
        public static void MySer()
        {
            using (eConnectMethods eConCall = new eConnectMethods())
            {
                try
                {
                    // Create the eConnect document and store it in a file
                    SerializeObject("SalesOrder.xml");

                    // Load the eConnect XML document from the file into
                    // and XML document object
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load("SalesOrder.xml");


                    string salesOrderDocument = xmldoc.OuterXml;


                    string sConnectionString = @"Data Source=LAPTOP-BUDQ9SBN\DYNAMICGP;Integrated Security = SSPI; Persist Security Info = false ; Initial Catalog = GP_DE;";


                    string salesOrder = eConCall.CreateTransactionEntity(sConnectionString, salesOrderDocument);

                    Console.WriteLine(salesOrder);
                    Console.ReadLine();
                }

                catch (eConnectException exp)
                {
                    Console.Write(exp.ToString());
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    Console.ReadLine();
                }
                finally
                {
                    eConCall.Dispose();
                }
            }
        }
        public Response CreateGPTransaction(string strCNX, string strXML)
        {
            var eConnCall = new eConnectMethods();
            var response  = new Response();

            try
            {
                response.MESSAGE = eConnCall.CreateTransactionEntity(strCNX, strXML);
                response.SUCCESS = true;
                return(response);
            }
            catch (eConnectException ex)
            {
                response.SUCCESS = false;
                response.MESSAGE = ex.Message + " - " + strXML;;
                response.STACK   = ex.StackTrace;

                if (ex.InnerException != null)
                {
                    response.STACK += ex.InnerException.Message;
                }
                return(response);
            }
            catch (Exception ex)
            {
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                if (ex.InnerException != null)
                {
                    response.STACK += ex.InnerException.Message;
                }
                return(response);
            }
            finally
            {
                eConnCall.Dispose();
            }
        }
        /// <summary>
        /// Crea el xml de una factura sop a partir de una fila de datos en una hoja excel.
        /// </summary>
        /// <param name="hojaXl">Hoja excel</param>
        /// <param name="filaXl">Fila de la hoja excel a procesar</param>
        public void IntegraFacturaSOP(ExcelWorksheet hojaXl, int filaXl, string sTimeStamp)
        {
            _iError  = 0;
            _mensaje = String.Empty;
            string            eConnResult    = String.Empty;
            eConnectType      docEConnectSOP = new eConnectType();
            eConnectType      entEconnect    = new eConnectType();
            FacturaDeVentaSOP documentoSOP   = new FacturaDeVentaSOP(_ParamExcel.ConnectionStringTargetEF);
            eConnectMethods   eConnObject    = new eConnectMethods();

            Cliente entidadCliente;

            try
            {
                _mensaje = " Número Doc: " + hojaXl.Cells[filaXl, _ParamExcel.FacturaSopnumbe].Value.ToString().Trim();

                entidadCliente = new Cliente(_ParamExcel.ConnectionStringTargetEF, _ParamExcel.FacturaSopTXRGNNUM.ToString(), _ParamExcel.FacturaSopCUSTNAME.ToString(), _ParamExcel.ClienteDefaultCUSTCLAS);
                if (entidadCliente.preparaClienteEconn(hojaXl, filaXl))
                {
                    entEconnect.RMCustomerMasterType = entidadCliente.ArrCustomerType;
                    serializa(entEconnect);
                    if (eConnObject.CreateEntity(_ParamExcel.ConnStringTarget, _sDocXml))
                    {
                        _mensaje += "--> Cliente Integrado a GP";
                    }
                }

                documentoSOP.preparaFacturaSOP(hojaXl, filaXl, sTimeStamp, _ParamExcel);
                docEConnectSOP.SOPTransactionType = new SOPTransactionType[] { documentoSOP.FacturaSop };
                serializa(docEConnectSOP);
                eConnResult  = eConnObject.CreateTransactionEntity(_ParamExcel.ConnStringTarget, _sDocXml);
                _sMensajeErr = "--> Integrado a GP";
            }
            catch (NullReferenceException nr)
            {
                string sInner = nr.InnerException == null ? String.Empty : nr.InnerException.Message;
                if (nr.InnerException != null)
                {
                    sInner += nr.InnerException.InnerException == null ? String.Empty : " " + nr.InnerException.InnerException.Message;
                }
                _sMensajeErr = "Excepción al validar datos de la factura SOP. " + nr.Message + " " + sInner + " [" + nr.TargetSite.ToString() + "]";
                _iError++;
            }
            catch (eConnectException eConnErr)
            {
                string sInner = eConnErr.InnerException == null ? String.Empty : eConnErr.InnerException.Message;
                _sMensajeErr = "Excepción eConnect al integrar factura SOP. " + eConnErr.Message + " " + sInner + " [" + eConnErr.TargetSite.ToString() + "]";
                _iError++;
            }
            catch (Exception errorGral)
            {
                string sInner = errorGral.InnerException == null ? String.Empty : errorGral.InnerException.Message;
                if (errorGral.InnerException != null)
                {
                    sInner += errorGral.InnerException.InnerException == null ? String.Empty : " " + errorGral.InnerException.InnerException.Message;
                }
                _sMensajeErr = "Excepción desconocida al integrar factura SOP. " + errorGral.Message + " " + sInner + " [" + errorGral.TargetSite.ToString() + "]";
                _iError++;
            }
            finally
            {
                _filaNuevaFactura = filaXl + 1;
                _mensaje          = "Fila: " + filaXl.ToString() + _mensaje;
            }
        }