Beispiel #1
0
        public static Boolean SendData(string xmlDocument)
        {
            eConnectMethods eConCall = new eConnectMethods();

            try
            {
                //Create a connection string to the Microsoft Dynamics GP database server
                //string cnnString = ConfigurationManager.AppSettings["GPCnnString"];
                //string cnnString = "data source=WEBMASTERNT02;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
                //string cnnString = "Data Source=192.168.1.4;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
                //string cnnString = ConfigurationManager.AppSettings["GPCnnString"];



                //Use the eConnect_EntryPoint to create the document in Microsoft Dynamics GP
                eConCall.eConnect_EntryPoint(FactoryCompany.ErpConnection.CnnString, EnumTypes.ConnectionStringType.SqlClient, xmlDocument,
                                             EnumTypes.SchemaValidationType.None, "");

                return(true);
            }
            catch (eConnectException)
            {
                throw;
                //return false;
            }
            catch (Exception)
            {
                throw;
                //return false;
            }
        }
        private void saveToSOP(Transaction assessment, string documentID, string defaultSiteID)
        {
            try
            {
                using (eConnectMethods eConnect = new eConnectMethods())
                {
                    string      sAssessment;
                    string      sXSD;
                    XmlDocument XSDdoc = new XmlDocument();
                    XSDdoc.Load(@"eConnect.xsd");
                    sXSD = XSDdoc.OuterXml;
                    serializeSOPObject("assessment.xml", assessment, documentID, defaultSiteID);
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load("assessment.xml");
                    sAssessment = xmldoc.OuterXml;
                    eConnect.eConnect_EntryPoint(connString, EnumTypes.ConnectionStringType.SqlClient, sAssessment, EnumTypes.SchemaValidationType.XSD, sXSD);

                    rollback = false; //20100625
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
        }
Beispiel #3
0
        private void btnSend_Click(object sender, System.EventArgs e)
        {
            eConnectMethods eConnect = new eConnectMethods();
            XmlDocument     myXmlDoc = new XmlDocument();
            XmlNode         eConnectProcessInfoOutgoing;

            try
            {
                checkBox1.Checked = false;
                myXmlDoc.LoadXml(txtXml.Text);
                eConnectProcessInfoOutgoing = myXmlDoc.SelectSingleNode("//Outgoing");
                if ((eConnectProcessInfoOutgoing == null) || (string.IsNullOrEmpty(eConnectProcessInfoOutgoing.InnerText) == true))
                {
                    eConnect.eConnect_EntryPoint(txtConnString.Text, EnumTypes.ConnectionStringType.SqlClient, myXmlDoc.OuterXml, EnumTypes.SchemaValidationType.None, string.Empty);
                    this.txtResults.Text = "Message successfully entered into the BackOffice.";
                }
                else
                {
                    if (eConnectProcessInfoOutgoing.InnerText == "TRUE")
                    {
                        this.txtResults.Text = eConnect.eConnect_Requester(txtConnString.Text, EnumTypes.ConnectionStringType.SqlClient, myXmlDoc.OuterXml);
                    }
                }
            }
            catch (Exception ex)
            {
                this.txtResults.Text = ex.ToString();
            }
            finally
            {
                eConnect.Dispose();
            }
        }
        //    public static string InvoiceDOCID(string con)
        //    {

        //    SqlCommand command = new SqlCommand();
        //    string res = "";

        //    command.Connection = new SqlConnection(con);

        //    command.CommandType = System.Data.CommandType.Text;

        //    command.CommandText = "SELECT INVDOCID FROM SOP40100";

        //    try{
        //        if(command.Connection.State != ConnectionState.Open)
        //        {
        //            command.Connection.Open();
        //        }
        //        res = (string) command.ExecuteScalar();

        //    }catch(Exception ex)
        //    {
        //        IEvent e = new ErrorEvent("","",ex.Message);
        //        e.Publish();

        //    }finally
        //    {
        //        command.Connection.Close();
        //    }

        //    return res;
        //}

        //public static string returnDOCID(string con)
        //{

        //    SqlCommand command = new SqlCommand();
        //    string res = "";

        //    command.Connection = new SqlConnection(con);

        //    command.CommandType = System.Data.CommandType.Text;

        //    command.CommandText = "SELECT RETDOCID FROM SOP40100";

        //    try
        //    {
        //        if (command.Connection.State != ConnectionState.Open)
        //        {
        //            command.Connection.Open();
        //        }
        //        res = (string)command.ExecuteScalar();

        //    }
        //    catch (Exception ex)
        //    {
        //        IEvent e = new ErrorEvent("", "", ex.Message);
        //        e.Publish();

        //    }
        //    finally
        //    {
        //        command.Connection.Close();
        //    }

        //    return res;
        //}

        //public static bool insertFiscalInfo(string SOPNUMBE, string COO, string DATEGEN, string SERIALPRINTER,string con)
        //{
        //    SqlCommand command = new SqlCommand();
        //    bool res = false;

        //    command.Connection = new SqlConnection(con);

        //    command.CommandType = System.Data.CommandType.Text;

        //    command.Parameters.AddWithValue("@INVOICE", SOPNUMBE);
        //    command.Parameters.AddWithValue("@COO", COO);
        //    command.Parameters.AddWithValue("@DATEGEN", DATEGEN);
        //    command.Parameters.AddWithValue("@SERIALPRINTER", SERIALPRINTER);

        //    command.CommandText = "INSERT INTO CSG_FISCAL_PRINT (COO,INVOICE,DATEGEN,SERIALPRINTER) VALUES(@COO,@INVOICE,@DATEGEN,@SERIALPRINTER);";

        //    try
        //    {
        //        if (command.Connection.State != ConnectionState.Open)
        //        {
        //            command.Connection.Open();
        //        }
        //        res = command.ExecuteNonQuery()>0;

        //    }
        //    catch (Exception ex)
        //    {
        //        IEvent e = new ErrorEvent("", "", ex.Message);
        //        e.Publish();

        //    }
        //    finally
        //    {
        //        command.Connection.Close();
        //    }

        //    return res;
        //}

        public static bool eConnectSendToGP(string eConnectDocument, string TrustedConnStr)
        {
            //string status;
            bool res = true;

            // ((IEvent)(new InfoEvent("", "", "Documento a Procesar: " + eConnectDocument))).Publish();



            try
            {
                eConnectMethods eConCall = new eConnectMethods();
                //'Dim econnect As New eConnectType
                //' Dim serializer As New XmlSerializer(GetType(eConnectType))
                //' Dim memstream As New MemoryStream


                //'    Dim scServices = New ServiceController
                //'scServices = ServiceController.GetServices();
                //'    scService.ServiceName == "DynGP11eConnect"

                //'MsgBox(eConnect_ConnectionString)
                res = eConCall.eConnect_EntryPoint(TrustedConnStr, EnumTypes.ConnectionStringType.SqlClient, eConnectDocument, EnumTypes.SchemaValidationType.None, "");
                //'status = eConCall.CreateTransactionEntity(eConnect_ConnectionString, Xml)
            }catch (Exception ex)
            {
                // res = false;
                // IEvent e = new ErrorEvent("","","Error en la transacción: " + ex.Message);
                //e.Publish();
            }
            finally
            {}
            return(res);
        }
Beispiel #5
0
        static void Main()
        {
            string sCustomerDocument;
            string sXsdSchema;
            string sConnectionString;

            using (eConnectMethods e = new eConnectMethods())
            {
                try
                {
                    // Create the customer data file
                    SerializeCustomerObject("Customer.xml");

                    // Use an XML document to create a string representation of the customer
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load("Customer.xml");
                    sCustomerDocument = xmldoc.OuterXml;

                    // Specify the Microsoft Dynamics GP server and database in the connection string
                    sConnectionString = @"data source=MYSERVER;initial catalog=DATABASE;integrated security=SSPI;persist security info=False;packet size=4096";

                    // Create an XML Document object for the schema
                    XmlDocument XsdDoc = new XmlDocument();

                    // Default path to the eConnect.xsd file
                    // Change the filepath if the eConnect 10.0.0.0 SDK is installed in a location other than the default.
                    XsdDoc.Load(@"\Program files\Common Files\Microsoft Shared\eConnect 10\XML Schemas\Incoming XSD Schemas\eConnect.xsd");

                    // Create a string representing the eConnect schema
                    sXsdSchema = XsdDoc.OuterXml;

                    // Pass in xsdSchema to validate against.
                    e.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, sCustomerDocument, EnumTypes.SchemaValidationType.XSD, sXsdSchema);
                }
                // The eConnectException class will catch eConnect business logic errors.
                // display the error message on the console
                catch (eConnectException exc)
                {
                    Console.Write(exc.ToString());
                }
                // Catch any system error that might occurr.
                // display the error message on the console
                catch (System.Exception ex)
                {
                    Console.Write(ex.ToString());
                }
            } // end of using statement
        }
Beispiel #6
0
        public void PushtoGP(XElement payablex)
        {
            eConnectMethods e = new eConnectMethods();
            string          payableVoucher = payablex.ToString();

            // Specify the Microsoft Dynamics GP server and database in the connection string
            string sConnectionString = @"data source=sc-gpd;initial catalog=TMI;integrated security=SSPI;persist security info=False;packet size=4096";

            // Create an XML Document object for the schema
            XmlDocument XsdDoc = new XmlDocument();

            // Default path to the eConnect.xsd file
            // Change the filepath if the eConnect 10.0.0.0 SDK is installed in a location other than the default.
            XsdDoc.Load(@"C:\Program Files (x86)\Common Files\Microsoft Shared\eConnect 10\XML Sample Documents\Incoming XSD Schemas\eConnect.xsd");

            // Create a string representing the eConnect schema
            string sXsdSchema = XsdDoc.OuterXml;

            // Pass in xsdSchema to validate against.
            e.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, payableVoucher, EnumTypes.SchemaValidationType.XSD, sXsdSchema);
        }
        public void PushtoGP(XElement payablex)
        {
            eConnectMethods e = new eConnectMethods();
            string payableVoucher = payablex.ToString();

            // Specify the Microsoft Dynamics GP server and database in the connection string
            string sConnectionString = @"data source=sc-gpd;initial catalog=TMI;integrated security=SSPI;persist security info=False;packet size=4096";

            // Create an XML Document object for the schema
            XmlDocument XsdDoc = new XmlDocument();

            // Default path to the eConnect.xsd file
            // Change the filepath if the eConnect 10.0.0.0 SDK is installed in a location other than the default.
            XsdDoc.Load(@"C:\Program Files (x86)\Common Files\Microsoft Shared\eConnect 10\XML Sample Documents\Incoming XSD Schemas\eConnect.xsd");

            // Create a string representing the eConnect schema
            string sXsdSchema = XsdDoc.OuterXml;

            // Pass in xsdSchema to validate against.
            e.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, payableVoucher, EnumTypes.SchemaValidationType.XSD, sXsdSchema);
        }
        //    public static string InvoiceDOCID(string con)
        //    {

        //    SqlCommand command = new SqlCommand();
        //    string res = "";

        //    command.Connection = new SqlConnection(con);

        //    command.CommandType = System.Data.CommandType.Text;

        //    command.CommandText = "SELECT INVDOCID FROM SOP40100";

        //    try{
        //        if(command.Connection.State != ConnectionState.Open)
        //        {
        //            command.Connection.Open();
        //        }
        //        res = (string) command.ExecuteScalar();

        //    }catch(Exception ex)
        //    {
        //        IEvent e = new ErrorEvent("","",ex.Message);
        //        e.Publish();

        //    }finally
        //    {
        //        command.Connection.Close();
        //    }

        //    return res;
        //}

        //public static string returnDOCID(string con)
        //{

        //    SqlCommand command = new SqlCommand();
        //    string res = "";

        //    command.Connection = new SqlConnection(con);

        //    command.CommandType = System.Data.CommandType.Text;

        //    command.CommandText = "SELECT RETDOCID FROM SOP40100";

        //    try
        //    {
        //        if (command.Connection.State != ConnectionState.Open)
        //        {
        //            command.Connection.Open();
        //        }
        //        res = (string)command.ExecuteScalar();

        //    }
        //    catch (Exception ex)
        //    {
        //        IEvent e = new ErrorEvent("", "", ex.Message);
        //        e.Publish();

        //    }
        //    finally
        //    {
        //        command.Connection.Close();
        //    }

        //    return res;
        //}

        //public static bool insertFiscalInfo(string SOPNUMBE, string COO, string DATEGEN, string SERIALPRINTER,string con)
        //{
        //    SqlCommand command = new SqlCommand();
        //    bool res = false;

        //    command.Connection = new SqlConnection(con);

        //    command.CommandType = System.Data.CommandType.Text;

        //    command.Parameters.AddWithValue("@INVOICE", SOPNUMBE);
        //    command.Parameters.AddWithValue("@COO", COO);
        //    command.Parameters.AddWithValue("@DATEGEN", DATEGEN);
        //    command.Parameters.AddWithValue("@SERIALPRINTER", SERIALPRINTER);

        //    command.CommandText = "INSERT INTO CSG_FISCAL_PRINT (COO,INVOICE,DATEGEN,SERIALPRINTER) VALUES(@COO,@INVOICE,@DATEGEN,@SERIALPRINTER);";

        //    try
        //    {
        //        if (command.Connection.State != ConnectionState.Open)
        //        {
        //            command.Connection.Open();
        //        }
        //        res = command.ExecuteNonQuery()>0;

        //    }
        //    catch (Exception ex)
        //    {
        //        IEvent e = new ErrorEvent("", "", ex.Message);
        //        e.Publish();

        //    }
        //    finally
        //    {
        //        command.Connection.Close();
        //    }

        //    return res;
        //}

        public static bool eConnectSendToGP(string eConnectDocument, string TrustedConnStr)
        {
            //string status;
            bool res = true;

            try
            {
                eConnectMethods eConCall = new eConnectMethods();

                res = eConCall.eConnect_EntryPoint(TrustedConnStr, EnumTypes.ConnectionStringType.SqlClient,
                                                   eConnectDocument, EnumTypes.SchemaValidationType.None, "");
                //'status = eConCall.CreateTransactionEntity(eConnect_ConnectionString, Xml)
            }
            catch (Exception ex)
            {
                string sSource;
                string sLog;
                string sEvent;

                sSource = "GP Integration TShirt";
                sLog    = "Application";
                sEvent  = ex.Message;

                if (!EventLog.SourceExists(sSource))
                {
                    EventLog.CreateEventSource(sSource, sLog);
                }

                EventLog.WriteEntry(sSource, sEvent);
                EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
            }
            finally
            {
            }
            return(res);
        }
Beispiel #9
0
        public bool createOrUpdateCustomer(Customer c)
        {
            bool status = false;
            if ((c.CustomerName == null) || (c.CustomerID == null) || (c.CustomerClass == null)) return false;
            eConnectMethods eConnect = new eConnectMethods();
            try
            {
                StringBuilder xml = new StringBuilder();
                xml.Append("<eConnect>");
                xml.Append("<RMCustomerMasterType>");
                xml.Append("<taUpdateCreateCustomerRcd>");
                xml.Append("<CUSTNMBR><![CDATA[" + c.CustomerID + "]]></CUSTNMBR>");
                xml.Append("<CUSTNAME><![CDATA[" + c.CustomerName + "]]></CUSTNAME>");
                xml.Append("<CUSTCLAS><![CDATA[" + c.CustomerClass + "]]></CUSTCLAS>");
                xml.Append("<INACTIVE><![CDATA[" + c.Inactive.GetHashCode() + "]]></INACTIVE>");

                if (c.ShortName != null) xml.Append("<SHRTNAME><![CDATA[" + c.ShortName + "]]></SHRTNAME>");
                if (c.StatementName != null) xml.Append("<STMTNAME><![CDATA[" + c.StatementName + "]]></STMTNAME>");
                if (c.ShipTo != null) xml.Append("<PRSTADCD><![CDATA[" + c.ShipTo + "]]></PRSTADCD>");
                if (c.StatementTo != null) xml.Append("<STADDRCD><![CDATA[" + c.StatementTo + "]]></<STADDRCD>");
                if (c.BillTo != null) xml.Append("<PRBTADCD><![CDATA[" + c.BillTo + "]]></PRBTADCD>");
                if (c.Type != null) xml.Append("<USERDEF1><![CDATA[" + c.Type + "]]></USERDEF1>");
                if (c.StudentStatus != null) xml.Append("<USERDEF2><![CDATA[" + c.StudentStatus + "]]></USERDEF2>");

            /*
             *  This data is part of the address
             */
                if (c.CustomerAddress.AddressString != null)
                {
                    if (c.CustomerAddress.AddressString.Length < 50)
                    {
                        xml.Append("<ADDRESS1><![CDATA[" + c.CustomerAddress.AddressString + "]]></ADDRESS1>");
                    }
                    else
                    {
                        xml.Append("<ADDRESS1><![CDATA[" + c.CustomerAddress.AddressString.Substring(0, 50) + "]]></ADDRESS1>");
                        xml.Append("<ADDRESS2><![CDATA[" + c.CustomerAddress.AddressString.Substring(50, c.CustomerAddress.AddressString.Length - 50) + "]]></ADDRESS2>");
                    }
                }
                if (c.CustomerAddress.AddressCode != null) xml.Append("<ADRSCODE><![CDATA[" + c.CustomerAddress.AddressCode + "]]></ADRSCODE>");
                if (c.CustomerAddress.AddressContact != null) xml.Append("<CNTCPRSN><![CDATA[" + c.CustomerAddress.AddressContact + "]]></CNTCPRSN>");
                if (c.CustomerAddress.City != null) xml.Append("<CITY><![CDATA[" + c.CustomerAddress.City + "]]></CITY>");
                if (c.CustomerAddress.State != null) xml.Append("<STATE><![CDATA[" + c.CustomerAddress.State + "]]></STATE>");
                if (c.CustomerAddress.Country != null) xml.Append("<COUNTRY><![CDATA[" + c.CustomerAddress.Country + "]]></COUNTRY>");
                if (c.CustomerAddress.Zipcode != null) xml.Append("<ZIPCODE><![CDATA[" + c.CustomerAddress.Zipcode + "]]></ZIPCODE>");
                if (c.CustomerAddress.PhoneNumber1 != null) xml.Append("<PHNUMBR1><![CDATA[" + c.CustomerAddress.PhoneNumber1 + "]]></PHNUMBR1>");
                if (c.CustomerAddress.PhoneNumber2 != null) xml.Append("<PHNUMBR2><![CDATA[" + c.CustomerAddress.PhoneNumber2 + "]]></PHNUMBR2>");
                if (c.CustomerAddress.FaxNumber != null) xml.Append("<FAX><![CDATA[" + c.CustomerAddress.FaxNumber + "]]></FAX>");
                //CAUSES ERRORS IF COUNTRYCODE DOESNT EXIST
                //if (c.CustomerAddress.CountryCode != null) xml.Append("<CCODE>" + c.CustomerAddress.CountryCode + "</CCODE>");

                xml.Append("<UseCustomerClass>1</UseCustomerClass>");
                xml.Append("<UpdateIfExists>1</UpdateIfExists>");
                xml.Append("</taUpdateCreateCustomerRcd>");
                xml.Append("</RMCustomerMasterType>");
                xml.Append("</eConnect>");

                status = eConnect.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient,
                    xml.ToString(), EnumTypes.SchemaValidationType.None, "");
            }
            catch (eConnectException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return status;
        }
Beispiel #10
0
        public void Execute(string xml)
        {
            eConnectMethods eConnectObject = new eConnectMethods();

            eConnectObject.eConnect_EntryPoint(connectionString, EnumTypes.ConnectionStringType.SqlClient, xml, EnumTypes.SchemaValidationType.None);
        }
Beispiel #11
0
        //public void watcher_Created()
        public void watcher_Created(object sender, FileSystemEventArgs e)
        {
            string sSource;
            string sLog;
            string sEvent;
            string documentType;
            string sName = "RCT2001";

            string pathFile = e.FullPath;



            try
            {
                Thread.Sleep(70000);
                //Then we need to check file is exist or not which is created.


                if (CheckFileExistance(wathO, e.Name))
                {
                    bool res = true;
                    try
                    {
                        XDocument xml   = XDocument.Load(pathFile);   //lee xml para obtener datos y llenar lineas de tablas SElSI
                        string    value = File.ReadAllText(pathFile); //lee contenido XML para enviar a GP

                        eConnectMethods eConCall = new eConnectMethods();

                        documentType = e.Name.Substring(0, 3);

                        if (documentType == "AJP" || documentType == "RCT" || documentType == "TXI" || documentType == "CMB" || documentType == "MST")
                        {
                            res = eConCall.eConnect_EntryPoint(pathBD, EnumTypes.ConnectionStringType.SqlClient,
                                                               value, EnumTypes.SchemaValidationType.None, "");



                            if (res)
                            {
                                System.IO.File.Move(pathFile, wathD + e.Name);

                                //Update codigo
                                int    number         = 0;
                                int    totalQty       = 0;
                                string qry            = string.Empty;
                                bool   _result        = false;
                                int    numberDocument = 0;
                                string DocumentCode   = string.Empty;
                                switch (documentType)
                                {
                                case "AJP":

                                    var q = (from b in xml.Descendants("taIVTransactionHeaderInsert")
                                             select new { code = (string)b.Element("IVDOCNBR") ?? string.Empty })
                                            .FirstOrDefault();

                                    if (q != null)
                                    {
                                        DocumentCode = q.code;
                                    }

                                    numberDocument = GetNumber(DocumentCode);
                                    number         = numberDocument + 1;
                                    //obtine numero de la secuencia y lo incremente en 1

                                    qry = "UPDATE selSI_IV40100 SET selSI_NextNumber ='" + "00000" +
                                          number.ToString() + "' WHERE selSI_IV_Type_ID ='AJP'";
                                    _result = InsertLineInTSGLV(qry);     //actualiza secuencia de numero


                                    //qry = string.Empty;
                                    //qry +=
                                    //    "INSERT INTO SElSI_IV_TRX_DATE (ivdoctyp,docnumbr,docdate,inuser) VALUES ";
                                    //qry += "('1', 'AJP" + "00000" + numberDocument + "','" + DateTime.Now +
                                    //       "','dbo')";
                                    //_result = InsertLineInTSGLV(qry); //guarda Header


                                    //var _line = (from b in xml.Descendants("taIVTransactionLotInsert")
                                    //    select new
                                    //    {
                                    //        totalUnits = (string) b.Element("SERLTQTY") ?? string.Empty,

                                    //    }).ToList();

                                    //totalQty += _line.Sum(item => Convert.ToInt32(item.totalUnits));
                                    //    //suma totalUnits


                                    //qry = "";
                                    //qry += "INSERT INTO selSI_IV_TRX_HDR (IVDOCTYP,DOCNUMBR,TotalUnits) VALUES ";
                                    //qry += "('1', 'AJP" + "00000" + numberDocument + "','" + totalQty + "')";

                                    //_result = InsertLineInTSGLV(qry); //guarda Linea


                                    break;

                                case "RCT":

                                    var y = (from b in xml.Descendants("taPopRcptHdrInsert")
                                             select new { code = (string)b.Element("POPRCTNM") ?? string.Empty })
                                            .FirstOrDefault();

                                    if (y != null)
                                    {
                                        DocumentCode = y.code;
                                    }

                                    numberDocument = GetNumber(DocumentCode);
                                    number         = numberDocument + 1;

                                    qry = "UPDATE pop40100 SET POPRCTNM ='" + "RCT" +
                                          number.ToString() + "' WHERE INDEX1 = 1";
                                    _result = InsertLineInTSGLV(qry);     //actualiza secuencia de numero

                                    break;

                                case "TXI":

                                    var z = (from b in xml.Descendants("taIVTransferHeaderInsert")
                                             select new { code = (string)b.Element("IVDOCNBR") ?? string.Empty })
                                            .FirstOrDefault();

                                    if (z != null)
                                    {
                                        DocumentCode = z.code;
                                    }

                                    numberDocument = GetNumber(DocumentCode);
                                    number         = numberDocument + 1;
                                    //obtine numero de la secuencia y lo incremente en 1

                                    qry = "UPDATE selSI_IV40100 SET selSI_NextNumber ='" + "000" +
                                          number.ToString() + "' WHERE selSI_IV_Type_ID ='TXI'";
                                    _result = InsertLineInTSGLV(qry);     //actualiza secuencia de numero
                                    break;

                                case "MST":

                                    var x = (from b in xml.Descendants("taIVTransactionHeaderInsert")
                                             select new { code = (string)b.Element("IVDOCNBR") ?? string.Empty })
                                            .FirstOrDefault();

                                    if (x != null)
                                    {
                                        DocumentCode = x.code;
                                    }

                                    numberDocument = GetNumber(DocumentCode);
                                    number         = numberDocument + 1;
                                    //obtine numero de la secuencia y lo incremente en 1

                                    qry = "UPDATE selSI_IV40100 SET selSI_NextNumber ='" + "000" +
                                          number.ToString() + "' WHERE selSI_IV_Type_ID ='MST'";
                                    _result = InsertLineInTSGLV(qry);     //actualiza secuencia de numero
                                    break;

                                case "CMB":

                                    var w = (from b in xml.Descendants("taIVTransactionHeaderInsert")
                                             select new { code = (string)b.Element("IVDOCNBR") ?? string.Empty })
                                            .FirstOrDefault();

                                    if (w != null)
                                    {
                                        DocumentCode = w.code;
                                    }

                                    numberDocument = GetNumber(DocumentCode);
                                    number         = numberDocument + 1;
                                    //obtine numero de la secuencia y lo incremente en 1

                                    qry = "UPDATE selSI_IV40100 SET selSI_NextNumber ='" + "00000" +
                                          number.ToString() + "' WHERE selSI_IV_Type_ID ='CMB'";
                                    _result = InsertLineInTSGLV(qry);     //actualiza secuencia de numero

                                    break;
                                }
                            }
                            else
                            {
                                System.IO.File.Move(pathFile, wathE + e.Name);
                            }
                        }
                        else
                        {
                            sSource = "GP Services TShirt";
                            sLog    = "Application";
                            sEvent  = "Archivo no Reconocido, las tres primera iniciales del nombre del archivo deben coincidir con el tipo de documento";


                            if (!EventLog.SourceExists(sSource))
                            {
                                EventLog.CreateEventSource(sSource, sLog);
                            }

                            EventLog.WriteEntry(sSource, sEvent);
                        }
                    }
                    catch (Exception ex)
                    {
                        sSource = "GP Services TShirt";
                        sLog    = "Application";
                        sEvent  = ex.Message;


                        if (!EventLog.SourceExists(sSource))
                        {
                            EventLog.CreateEventSource(sSource, sLog);
                        }

                        EventLog.WriteEntry(sSource, sEvent);

                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #12
0
        public static Boolean SendData(string xmlDocument)
        {
            eConnectMethods eConCall = new eConnectMethods();

            try
            {
                //Create a connection string to the Microsoft Dynamics GP database server
                //string cnnString = ConfigurationManager.AppSettings["GPCnnString"];
                //string cnnString = "data source=WEBMASTERNT02;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
                //string cnnString = "Data Source=192.168.1.4;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
                //string cnnString = ConfigurationManager.AppSettings["GPCnnString"];
                


                //Use the eConnect_EntryPoint to create the document in Microsoft Dynamics GP
                eConCall.eConnect_EntryPoint(FactoryCompany.ErpConnection.CnnString, EnumTypes.ConnectionStringType.SqlClient, xmlDocument,
                    EnumTypes.SchemaValidationType.None, "");

                return true;
            }
            catch (eConnectException)
            {
                throw;
                //return false; 
            }
            catch (Exception)
            {
                throw;
                //return false; 
            }
        }
Beispiel #13
0
        private void saveToSOP(Transaction assessment, string documentID, string defaultSiteID)
        {
            try
            {
                using (eConnectMethods eConnect = new eConnectMethods())
                {
                    string sAssessment;
                    string sXSD;
                    XmlDocument XSDdoc = new XmlDocument();
                    XSDdoc.Load(@"eConnect.xsd");
                    sXSD = XSDdoc.OuterXml;
                    serializeSOPObject("assessment.xml", assessment, documentID, defaultSiteID);
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load("assessment.xml");
                    sAssessment = xmldoc.OuterXml;
                    eConnect.eConnect_EntryPoint(connString, EnumTypes.ConnectionStringType.SqlClient, sAssessment, EnumTypes.SchemaValidationType.XSD, sXSD);

                    rollback = false; //20100625
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
        }
Beispiel #14
0
        public bool createOrUpdateCustomer(Customer c)
        {
            bool status = false;

            if ((c.CustomerName == null) || (c.CustomerID == null) || (c.CustomerClass == null))
            {
                return(false);
            }
            eConnectMethods eConnect = new eConnectMethods();

            try
            {
                StringBuilder xml = new StringBuilder();
                xml.Append("<eConnect>");
                xml.Append("<RMCustomerMasterType>");
                xml.Append("<taUpdateCreateCustomerRcd>");
                xml.Append("<CUSTNMBR><![CDATA[" + c.CustomerID + "]]></CUSTNMBR>");
                xml.Append("<CUSTNAME><![CDATA[" + c.CustomerName + "]]></CUSTNAME>");
                xml.Append("<CUSTCLAS><![CDATA[" + c.CustomerClass + "]]></CUSTCLAS>");
                xml.Append("<INACTIVE><![CDATA[" + c.Inactive.GetHashCode() + "]]></INACTIVE>");

                if (c.ShortName != null)
                {
                    xml.Append("<SHRTNAME><![CDATA[" + c.ShortName + "]]></SHRTNAME>");
                }
                if (c.StatementName != null)
                {
                    xml.Append("<STMTNAME><![CDATA[" + c.StatementName + "]]></STMTNAME>");
                }
                if (c.ShipTo != null)
                {
                    xml.Append("<PRSTADCD><![CDATA[" + c.ShipTo + "]]></PRSTADCD>");
                }
                if (c.StatementTo != null)
                {
                    xml.Append("<STADDRCD><![CDATA[" + c.StatementTo + "]]></<STADDRCD>");
                }
                if (c.BillTo != null)
                {
                    xml.Append("<PRBTADCD><![CDATA[" + c.BillTo + "]]></PRBTADCD>");
                }
                if (c.Type != null)
                {
                    xml.Append("<USERDEF1><![CDATA[" + c.Type + "]]></USERDEF1>");
                }
                if (c.StudentStatus != null)
                {
                    xml.Append("<USERDEF2><![CDATA[" + c.StudentStatus + "]]></USERDEF2>");
                }

/*
 *  This data is part of the address
 */
                if (c.CustomerAddress.AddressString != null)
                {
                    if (c.CustomerAddress.AddressString.Length < 50)
                    {
                        xml.Append("<ADDRESS1><![CDATA[" + c.CustomerAddress.AddressString + "]]></ADDRESS1>");
                    }
                    else
                    {
                        xml.Append("<ADDRESS1><![CDATA[" + c.CustomerAddress.AddressString.Substring(0, 50) + "]]></ADDRESS1>");
                        xml.Append("<ADDRESS2><![CDATA[" + c.CustomerAddress.AddressString.Substring(50, c.CustomerAddress.AddressString.Length - 50) + "]]></ADDRESS2>");
                    }
                }
                if (c.CustomerAddress.AddressCode != null)
                {
                    xml.Append("<ADRSCODE><![CDATA[" + c.CustomerAddress.AddressCode + "]]></ADRSCODE>");
                }
                if (c.CustomerAddress.AddressContact != null)
                {
                    xml.Append("<CNTCPRSN><![CDATA[" + c.CustomerAddress.AddressContact + "]]></CNTCPRSN>");
                }
                if (c.CustomerAddress.City != null)
                {
                    xml.Append("<CITY><![CDATA[" + c.CustomerAddress.City + "]]></CITY>");
                }
                if (c.CustomerAddress.State != null)
                {
                    xml.Append("<STATE><![CDATA[" + c.CustomerAddress.State + "]]></STATE>");
                }
                if (c.CustomerAddress.Country != null)
                {
                    xml.Append("<COUNTRY><![CDATA[" + c.CustomerAddress.Country + "]]></COUNTRY>");
                }
                if (c.CustomerAddress.Zipcode != null)
                {
                    xml.Append("<ZIPCODE><![CDATA[" + c.CustomerAddress.Zipcode + "]]></ZIPCODE>");
                }
                if (c.CustomerAddress.PhoneNumber1 != null)
                {
                    xml.Append("<PHNUMBR1><![CDATA[" + c.CustomerAddress.PhoneNumber1 + "]]></PHNUMBR1>");
                }
                if (c.CustomerAddress.PhoneNumber2 != null)
                {
                    xml.Append("<PHNUMBR2><![CDATA[" + c.CustomerAddress.PhoneNumber2 + "]]></PHNUMBR2>");
                }
                if (c.CustomerAddress.FaxNumber != null)
                {
                    xml.Append("<FAX><![CDATA[" + c.CustomerAddress.FaxNumber + "]]></FAX>");
                }
                //CAUSES ERRORS IF COUNTRYCODE DOESNT EXIST
                //if (c.CustomerAddress.CountryCode != null) xml.Append("<CCODE>" + c.CustomerAddress.CountryCode + "</CCODE>");

                xml.Append("<UseCustomerClass>1</UseCustomerClass>");
                xml.Append("<UpdateIfExists>1</UpdateIfExists>");
                xml.Append("</taUpdateCreateCustomerRcd>");
                xml.Append("</RMCustomerMasterType>");
                xml.Append("</eConnect>");

                status = eConnect.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient,
                                                      xml.ToString(), EnumTypes.SchemaValidationType.None, "");
            }
            catch (eConnectException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(status);
        }