示例#1
1
        public Customer getCustomer(String customerId)
        {
            eConnectMethods eConnect = new eConnectMethods();
            String address1 = "";
            String address2 = "";
            Customer result = new Customer();
            result.CustomerID = customerId;
            try
            {

                eConnectType myEConnectType = new eConnectType();
                RQeConnectOutType myReqType = new RQeConnectOutType();
                eConnectOut myeConnectOut = new eConnectOut();
                myeConnectOut.ACTION = 1;
                myeConnectOut.DOCTYPE = "Customer";
                myeConnectOut.OUTPUTTYPE = 2;
                myeConnectOut.INDEX1FROM = customerId;
                myeConnectOut.INDEX1TO = customerId;
                myeConnectOut.FORLIST = 1;
                // Add the eConnectOut XML node object to the RQeConnectOutType schema object
                myReqType.eConnectOut = myeConnectOut;

                // Add the RQeConnectOutType schema object to the eConnect document object
                RQeConnectOutType[] myReqOutType = { myReqType };
                myEConnectType.RQeConnectOutType = myReqOutType;

                // Serialize the eConnect document object to a memory stream
                MemoryStream myMemStream = new MemoryStream();
                XmlSerializer mySerializer = new XmlSerializer(myEConnectType.GetType());
                mySerializer.Serialize(myMemStream, myEConnectType);
                myMemStream.Position = 0;

                // Load the serialized eConnect document object into an XML document object
                XmlTextReader xmlreader = new XmlTextReader(myMemStream);
                XmlDocument myXmlDocument = new XmlDocument();
                myXmlDocument.Load(xmlreader);

                // Call the eConnect_Requester method of the eConnectMethods object to retrieve specified XML data
                string reqDoc = eConnect.eConnect_Requester(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, myXmlDocument.OuterXml);
                XmlDocument resultDocument = new XmlDocument();
                resultDocument.LoadXml(reqDoc);

                XmlNodeList customerNodeList = resultDocument.GetElementsByTagName("Customer");

                if (customerNodeList.Count == 0) return null;
                else
                {
                    //Here we have retrieved the customer document
                    foreach (XmlNode node in customerNodeList[0])
                    {
                        if (node.Name.Equals("ADDRESS1"))
                            address1 = node.InnerText;
                        if (node.Name.Equals("ADDRESS2"))
                            address2 = node.InnerText;
                        else if (node.Name.Equals("ADRSCODE"))
                            result.CustomerAddress.AddressCode = node.InnerText;
                        else if (node.Name.Equals("CITY"))
                            result.CustomerAddress.City = node.InnerText;
                        else if (node.Name.Equals("CNTCPRSN"))
                            result.CustomerAddress.AddressContact = node.InnerText;
                        else if (node.Name.Equals("COUNTRY"))
                            result.CustomerAddress.Country = node.InnerText;
                        else if (node.Name.Equals("CUSTCLAS"))
                            result.CustomerClass = node.InnerText;
                        else if (node.Name.Equals("CUSTNAME"))
                            result.CustomerName = node.InnerText;
                        else if (node.Name.Equals("PHONE1"))
                            result.CustomerAddress.PhoneNumber1 = node.InnerText;
                        else if (node.Name.Equals("PHONE2"))
                            result.CustomerAddress.PhoneNumber2 = node.InnerText;
                        else if (node.Name.Equals("FAX"))
                            result.CustomerAddress.FaxNumber = node.InnerText;
                        else if (node.Name.Equals("STATE"))
                            result.CustomerAddress.State = node.InnerText;
                        else if (node.Name.Equals("ZIP"))
                            result.CustomerAddress.Zipcode = node.InnerText;
                        else if (node.Name.Equals("STMTNAME"))
                            result.StatementName = node.InnerText;
                        else if (node.Name.Equals("SHRTNAME"))
                            result.ShortName = node.InnerText;
                        else if (node.Name.Equals("PRBTADCD"))
                            result.BillTo = node.InnerText;
                        else if (node.Name.Equals("PRSTADCD"))
                            result.ShipTo = node.InnerText;
                        else if (node.Name.Equals("STADDRCD"))
                            result.StatementTo = node.InnerText;
                        else if (node.Name.Equals("USERDEF1"))
                            result.Type = node.InnerText;
                        else if (node.Name.Equals("USERDEF2"))
                            result.StudentStatus = node.InnerText;
                        else if (node.Name.Equals("INACTIVE"))
                            if (node.InnerText.Equals("1")) result.Inactive = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            result.CustomerAddress.AddressString = address1 + address2;
            return result;
        }
        private string SerializeSalesPerson(taCreateSalesperson salesperson)
        {
            try
            {
                RMSalespersonMasterType salespersonType = new RMSalespersonMasterType();
                eConnectType            eConnect        = new eConnectType();
                salespersonType.taCreateSalesperson = salesperson;

                RMSalespersonMasterType[] rmsalesperson = { salespersonType };

                eConnect.RMSalespersonMasterType = rmsalesperson;

                MemoryStream ms = new MemoryStream();

                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(ms, eConnect);
                ms.Position = 0;
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(ms);

                string SalespersonEntity = xmldoc.OuterXml;
                return(SalespersonEntity);
            }
            catch (XmlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
        //public Decimal getImpuestos(string id)
        //{
        //    tx00201 impuestos = new tx00201(DatosConexionDB.Elemento.ConnStr);
        //    try
        //    {
        //        if (impuestos.LoadByPrimaryKey(id))
        //        {
        //            return impuestos.TXDTLPCT;
        //        }
        //        else
        //            return 0;
        //    }
        //    catch
        //    {
        //        return 0;
        //    }
        //}

        /// <summary>
        /// Construye documento xml en un xmlDocument.
        /// </summary>
        /// <param name="eConnect"></param>
        public void serializa(eConnectType eConnect)
        {
            try
            {
                iError   = 0;
                _sDocXml = "";
                _xDocXml = new XmlDocument();
                StringBuilder sbDocXml = new StringBuilder();

                XmlSerializer     serializer = new XmlSerializer(eConnect.GetType());
                XmlWriterSettings sett       = new XmlWriterSettings();
                sett.Encoding = new UTF8Encoding();  //UTF8Encoding.UTF8; // Encoding.UTF8;
                using (XmlWriter writer = XmlWriter.Create(sbDocXml, sett))
                {
                    serializer.Serialize(writer, eConnect);
                    _sDocXml = sbDocXml.ToString();
                    _xDocXml.LoadXml(_sDocXml);
                }
            }
            catch (Exception errorGral)
            {
                sMensaje = "Error al serializar el documento. " + errorGral.Message + " [Serializa]";
                iError++;
            }
        }
        private string SerializeCustomerChild(taUpdateCreateCustomerRcd rmcustomer, taParentIDChild_ItemsTaParentIDChild[] rmchildren)
        {
            try
            {
                RMCustomerMasterType customerMasterType = new RMCustomerMasterType();
                eConnectType         eConnect           = new eConnectType();
                customerMasterType.taUpdateCreateCustomerRcd = rmcustomer;
                //customerMasterType.taCreateParentID = rmparent;
                customerMasterType.taParentIDChild_Items = rmchildren;

                RMCustomerMasterType[] Customers = { customerMasterType };

                eConnect.RMCustomerMasterType = Customers;
                MemoryStream ms = new MemoryStream();

                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(ms, eConnect);
                ms.Position = 0;
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(ms);

                string CustomerEntity = xmldoc.OuterXml;
                return(CustomerEntity);
            }
            catch (XmlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#5
0
        /*
         * /// <summary>
         * ///
         * /// </summary>
         * /// <param name="vendor"></param>
         * /// <returns></returns>
         * private string SerializeVendor(taUpdateCreateVendorRcd vendor)
         * {
         *  try
         *  {
         *      PMVendorMasterType VendorMasterType = new PMVendorMasterType();
         *      eConnectType eConnect = new eConnectType();
         *      VendorMasterType.taUpdateCreateVendorRcd = vendor;
         *      PMVendorMasterType[] VendorsMasterType = { VendorMasterType };
         *
         *      eConnect.PMVendorMasterType = VendorsMasterType;
         *
         *      //MemoryStream ms = new MemoryStream();
         *      FileStream FS = new FileStream(@"C:\DOCS\eConnectVendor.xml", FileMode.Create);
         *
         *      XmlTextWriter writer = new XmlTextWriter(FS, new UTF8Encoding());
         *
         *      XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
         *      serializer.Serialize(writer, eConnect);
         *      writer.Close();
         *
         *      XmlDocument xmldoc = new XmlDocument();
         *
         *
         *      xmldoc.Load(@"C:\DOCS\eConnectVendor.xml");
         *
         *      string VendorEntity = xmldoc.OuterXml;
         *
         *      File.Delete(@"C:\DOCS\eConnectVendor.xml");
         *
         *      return VendorEntity;
         *
         *  }
         *  catch (XmlException)
         *  {
         *      throw;
         *  }
         *  catch (Exception)
         *  {
         *
         *      throw;
         *  }
         *
         *
         * }
         */


        /// <summary>
        ///
        /// </summary>
        /// <param name="vendor"></param>
        /// <returns></returns>
        private string SerializeVendor(taUpdateCreateVendorRcd vendor)
        {
            try
            {
                PMVendorMasterType VendorMasterType = new PMVendorMasterType();
                eConnectType       eConnect         = new eConnectType();
                VendorMasterType.taUpdateCreateVendorRcd = vendor;
                PMVendorMasterType[] VendorsMasterType = { VendorMasterType };

                eConnect.PMVendorMasterType = VendorsMasterType;

                MemoryStream ms = new MemoryStream();

                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(ms, eConnect);
                ms.Position = 0;
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(ms);
                string VendorEntity = xmldoc.OuterXml;
                return(VendorEntity);
            }
            catch (XmlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#6
0
        private string SerializeCustomerClass(taCreateCustomerClass customerClass)
        {
            try
            {
                RMCustomerClassType classType = new RMCustomerClassType();
                eConnectType        eConnect  = new eConnectType();
                classType.taCreateCustomerClass = customerClass;
                RMCustomerClassType[] rmClassType = { classType };

                eConnect.RMCustomerClassType = rmClassType;

                MemoryStream ms = new MemoryStream();

                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(ms, eConnect);
                ms.Position = 0;
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(ms);

                string CustomerClassEntity = xmldoc.OuterXml;

                return(CustomerClassEntity);
            }
            catch (XmlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
        private string SerializeRMVoid(RMVoidTransactionType rmvoid)
        {
            try
            {
                eConnectType            eConnect = new eConnectType();
                RMVoidTransactionType[] TranType = { rmvoid };
                eConnect.RMVoidTransactionType = TranType;

                MemoryStream ms = new MemoryStream();

                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(ms, eConnect);
                ms.Position = 0;
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(ms);

                string TransactionXML = xmldoc.OuterXml;

                return(TransactionXML);
            }
            catch (Exception)
            {
                // logW.LogExeption("Econnect", 2, ex);
                throw;
            }
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="TransactionType"></param>
        /// <returns></returns>
        private string SerializeGLTransacion(GLTransactionType TransactionType)
        {
            try
            {
                eConnectType eConnect = new eConnectType();

                GLTransactionType[] tranType = { TransactionType };
                eConnect.GLTransactionType = tranType;
                MemoryStream ms = new MemoryStream();

                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(ms, eConnect);
                ms.Position = 0;
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(ms);

                string TransactionXML = xmldoc.OuterXml;

                return(TransactionXML);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public APInvoiceResponseDto ImportGPInvoice(taPMTransactionInsert pmTransaction)
        {
            var response = new APInvoiceResponseDto();

            try
            {
                var PMTransaction = new PMTransactionType();
                PMTransaction.taPMTransactionInsert = pmTransaction;

                PMTransactionType[] PMTransType = { PMTransaction };

                eConnectType eConnect = new eConnectType();
                eConnect.PMTransactionType = PMTransType;

                MemoryStream  memStream  = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(memStream, eConnect);
                memStream.Position = 0;

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(memStream);
                memStream.Close();

                string finalXML = xmlDocument.OuterXml;

                string responseMessage = string.Empty;
                string errorMessage    = string.Empty;

                string voucher   = pmTransaction.VCHNUMWK;
                string docNumber = pmTransaction.DOCNUMBR;
                string vendorID  = pmTransaction.VENDORID;

                bool success = eConn.CreateTransactionEntity(ref responseMessage, finalXML, _config.Value.GPCompanyDB);

                response.Success   = success;
                response.ErrorCode = 0;

                if (success)
                {
                    response.Message = "Vendor " + vendorID + " invoice " + docNumber + " imported as voucher " + voucher;
                }
                else
                {
                    errorMessage       = "Failed to import vendor " + vendorID + " invoice " + docNumber + ": " + responseMessage;
                    response.Message   = errorMessage;
                    response.ErrorCode = LoggingEvents.INSERT_INVOICE_FAILED;
                }

                return(response);
            }
            catch (Exception ex)
            {
                response.Success   = false;
                response.ErrorCode = LoggingEvents.INSERT_INVOICE_EXCEPTION;
                response.Message   = "An unexpected error occured in ImportGPInvoice: " + ex.Message;
                return(response);
            }
        }
示例#10
0
		static void Main()
		{
			try
			{
				// Create an eConnect document type object
                eConnectType myEConnectType = new eConnectType();

                // Create a RQeConnectOutType schema object
				RQeConnectOutType myReqType = new RQeConnectOutType();
				
                // Create an eConnectOut XML node object
                eConnectOut myeConnectOut = new eConnectOut();

                // Populate the eConnectOut XML node elements
				myeConnectOut.ACTION = 1;
				myeConnectOut.DOCTYPE = "Customer";
				myeConnectOut.OUTPUTTYPE = 2;
				myeConnectOut.INDEX1FROM = "AARONFIT0001";
				myeConnectOut.INDEX1TO = "AARONFIT0001";
				myeConnectOut.FORLIST = 1;
			
				// Add the eConnectOut XML node object to the RQeConnectOutType schema object
                myReqType.eConnectOut = myeConnectOut;

                // Add the RQeConnectOutType schema object to the eConnect document object
				RQeConnectOutType [] myReqOutType = {myReqType};
				myEConnectType.RQeConnectOutType = myReqOutType;

                // Serialize the eConnect document object to a memory stream
				MemoryStream myMemStream = new MemoryStream();
				XmlSerializer mySerializer = new XmlSerializer(myEConnectType.GetType());
				mySerializer.Serialize(myMemStream, myEConnectType);
				myMemStream.Position = 0;

				// Load the serialized eConnect document object into an XML document object
                XmlTextReader xmlreader = new XmlTextReader(myMemStream);
                XmlDocument myXmlDocument = new XmlDocument();
                myXmlDocument.Load(xmlreader);

				// Create a connection string to specify the Microsoft Dynamics GP server and database
                // Change the data source and initial catalog to specify your server and database
                string sConnectionString = @"data source=MYSERVER;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
				
                // Create an eConnectMethods object
                eConnectMethods requester = new eConnectMethods();
				
                // Call the eConnect_Requester method of the eConnectMethods object to retrieve specified XML data
                string reqDoc = requester.eConnect_Requester(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, myXmlDocument.OuterXml);

                // Display the result of the eConnect_Requester method call
                Console.Write(reqDoc);
			}
			catch (Exception ex)
			{// Dislay any errors that occur to the console
				Console.Write(ex.ToString());
			}
		}
示例#11
0
        private static void serializeObject(string filename, part newpart)
        {
            // Create a datetime format object
            DateTimeFormatInfo dateFormat = new CultureInfo("en-US").DateTimeFormat;

            try
            {
                //create an eConnect schema object
                IVItemMasterType iv = new IVItemMasterType();

                taUpdateCreateItemRcd newItem = new taUpdateCreateItemRcd();


                newItem.ITEMNMBR          = newpart.itemNumber;  //Item number
                newItem.ITEMDESC          = newpart.description; //Item description
                newItem.ITMSHNAM          = "temp";              //short desc
                newItem.ITMGEDSC          = "temp";              //general desc
                newItem.UseItemClass      = 1;
                newItem.ITMCLSCD          = newpart.category;    //Part or Assembly
                newItem.ITEMTYPESpecified = true;                //Say custom itemtype is being used
                newItem.ITEMTYPE          = 1;                   //Sales item
                newItem.UOMSCHDL          = newpart.units;
                newItem.DECPLCURSpecified = true;                //Say a custom decplcur is being used
                newItem.DECPLCUR          = 3;                   //Needed to make item in IVR10015
                newItem.NOTETEXT          = newpart.purchasing;
                newItem.UpdateIfExists    = 0;

                //Populate schema object with newItem info
                iv.taUpdateCreateItemRcd = newItem;

                // Create an array that holds ItemMasterType objects
                // Populate the array with the ItemMasterType schema object
                IVItemMasterType[] myItemType = { iv };

                // Create an eConnect XML document object and populate it
                // with the ItemMasterType schema object
                eConnectType eConnect = new eConnectType();
                eConnect.IVItemMasterType = myItemType;

                // Create a file to hold the serialized eConnect XML document
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnect document object to the file using the XmlTextWriter.
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            //If an eConnect exception occurs, notify the user
            catch (eConnectException ex)
            {
                Console.Write(ex.ToString());
            }
        }
示例#12
0
        /// <summary>
        /// serialize customer address
        /// </summary>
        /// <param name="filename"></param>
        public static void SerializeCustomerAddressObject(string filename)
        {
            try
            {
                // Instantiate an eConnectType schema object
                eConnectType eConnect = new eConnectType();

                // Instantiate a RMCustomerAddressType schema object
                RMCustomerAddressType addressType = new RMCustomerAddressType();

                // Instantiate a taCreateCustomerAddress_ItemsTaCreateCustomerAddress XML node object
                taCreateCustomerAddress_ItemsTaCreateCustomerAddress address = new taCreateCustomerAddress_ItemsTaCreateCustomerAddress();

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                // Populate elements of the taUpdateCreateCustomerRcd XML node object
                address.CUSTNMBR = "Customer001";
                //address.CUSTNAME = "Customer 1";
                //address.ADDRESS1 = "2002 60th St SW";
                //address.ADRSCODE = "Primary";
                //address.CITY = "NewCity";
                //address.ZIPCODE = "52302";

                // Populate the RMCustomerAddressType schema with the taCreateCustomerAddress_ItemsTaCreateCustomerAddress XML node
                addressType.taCreateCustomerAddress_Items = new taCreateCustomerAddress_ItemsTaCreateCustomerAddress[1] {
                    address
                };
                RMCustomerAddressType[] customerAddress = { addressType };

                // Populate the eConnectType object with the RMCustomerAddressType schema object
                eConnect.RMCustomerAddressType = customerAddress;

                // Create objects to create file and write the customer XML to the file
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            // catch any errors that occur and display them to the console
            catch (System.Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }
示例#13
0
        /// <summary>
        /// serialize payables object
        /// </summary>
        /// <param name="filename"></param>
        public static void SerializePayablesObject(string filename)
        {
            try
            {
                // Instantiate an eConnectType schema object
                eConnectType eConnect = new eConnectType();

                // Instantiate a PMTransactionType  schema object
                PMTransactionType transactionType = new PMTransactionType();

                // Instantiate a taPMTransactionInsert XML node object
                taPMTransactionInsert transaction = new taPMTransactionInsert();

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                // Populate elements of the taPMTransactionInsert XML node object
                //transaction.CUSTNMBR = "Customer001";
                //transaction.CUSTNAME = "Customer 1";
                //transaction.ADDRESS1 = "2002 60th St SW";
                //transaction.ADRSCODE = "Primary";
                //transaction.CITY = "NewCity";
                //transaction.ZIPCODE = "52302";

                // Populate the PMTransactionType schema with the taPMTransactionInsert XML node
                transactionType.taPMTransactionInsert = transaction;
                PMTransactionType[] payablesTransaction = { transactionType };

                // Populate the eConnectType object with the PMTransactionType schema object
                eConnect.PMTransactionType = payablesTransaction;

                // Create objects to create file and write the customer XML to the file
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            // catch any errors that occur and display them to the console
            catch (System.Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }
示例#14
0
        /// <summary>
        /// serialize item
        /// </summary>
        /// <param name="filename"></param>
        public static void SerializeItemObject(string filename)
        {
            try
            {
                // Instantiate an eConnectType schema object
                eConnectType eConnect = new eConnectType();

                // Instantiate a IVItemMasterType  schema object
                IVItemMasterType itemType = new IVItemMasterType();

                // Instantiate a taUpdateCreateItemRcd XML node object
                taUpdateCreateItemRcd item = new taUpdateCreateItemRcd();

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                // Populate elements of the taUpdateCreateVendorRcd XML node object
                //item.CUSTNMBR = "Customer001";
                //item.CUSTNAME = "Customer 1";
                //item.ADDRESS1 = "2002 60th St SW";
                //item.ADRSCODE = "Primary";
                //item.CITY = "NewCity";
                //item.ZIPCODE = "52302";

                // Populate the IVItemMasterType schema with the taUpdateCreateItemRcd XML node
                itemType.taUpdateCreateItemRcd = item;
                IVItemMasterType[] itemMaster = { itemType };

                // Populate the eConnectType object with the IVItemMasterType schema object
                eConnect.IVItemMasterType = itemMaster;

                // Create objects to create file and write the customer XML to the file
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            // catch any errors that occur and display them to the console
            catch (System.Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }
示例#15
0
        /// <summary>
        /// serialize vendor
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="foundry"></param>
        public static void SerializeVendorObject(string filename, PM00200_Foundry foundry)
        {
            try
            {
                // Instantiate an eConnectType schema object
                eConnectType eConnect = new eConnectType();

                // Instantiate a PMVendorMasterType schema object
                PMVendorMasterType vendortype = new PMVendorMasterType();

                // Instantiate a taUpdateCreateCustomerRcd XML node object
                taUpdateCreateVendorRcd vendor = new taUpdateCreateVendorRcd();

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                //Populate elements of the taUpdateCreateVendorRcd XML node object
                vendor.VENDORID       = foundry.VENDORID;
                vendor.VENDNAME       = foundry.VENDNAME;
                vendor.VENDSHNM       = foundry.VENDSHNM;
                vendor.UseVendorClass = 1;
                vendor.VNDCLSID       = "SUO";

                // Populate the PMVendorMasterType schema with the taUpdateCreateVendorRcd XML node
                vendortype.taUpdateCreateVendorRcd = vendor;
                PMVendorMasterType[] vendorMaster = { vendortype };

                // Populate the eConnectType object with the PMVendorMasterType schema object
                eConnect.PMVendorMasterType = vendorMaster;

                // Create objects to create file and write the customer XML to the file
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            // catch any errors that occur and display them to the console
            catch (System.Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }
        public XmlDocument Serializa(eConnectType eConnect)
        {
            try
            {
                MemoryStream  memoryStream  = new MemoryStream();
                XmlSerializer xmlSerializer = new XmlSerializer(eConnect.GetType());

                xmlSerializer.Serialize(memoryStream, eConnect);

                memoryStream.Position = 0;

                // Create an XmlDocument from the serialized eConnectType in memory.
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(memoryStream);
                memoryStream.Close();

                return(xmlDocument);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Construye documento xml en un xmlDocument.
        /// </summary>
        /// <param name="eConnect"></param>
        public void serializa(eConnectType eConnect)
        {
            try
            {
                _sDocXml = "";
                _xDocXml = new XmlDocument();
                StringBuilder sbDocXml = new StringBuilder();

                XmlSerializer     serializer = new XmlSerializer(eConnect.GetType());
                XmlWriterSettings sett       = new XmlWriterSettings();
                sett.Encoding = new UTF8Encoding();  //UTF8Encoding.UTF8; // Encoding.UTF8;
                using (XmlWriter writer = XmlWriter.Create(sbDocXml, sett))
                {
                    serializer.Serialize(writer, eConnect);
                    _sDocXml = sbDocXml.ToString();
                    _xDocXml.LoadXml(_sDocXml);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#18
0
        /// <summary>
        /// save new receipt
        /// </summary>
        /// <param name="receipt"></param>
        /// <param name="receiptLines"></param>
        /// <returns></returns>
        public OperationResult SaveReceipt(POP10300_Receipt_Work receipt, List <POP10310> receiptLines)
        {
            var operationResult = new OperationResult();

            logger.Debug("Receipt is being created...");

            using (eConnectMethods e = new eConnectMethods())
            {
                try
                {
                    if (receiptLines != null && receiptLines.Count > 0)
                    {
                        taPopRcptLotInsert_ItemsTaPopRcptLotInsert[] lotItems = new taPopRcptLotInsert_ItemsTaPopRcptLotInsert[receiptLines.Count];

                        taPopRcptLineInsert_ItemsTaPopRcptLineInsert[] lineItems = new taPopRcptLineInsert_ItemsTaPopRcptLineInsert[receiptLines.Count];

                        var receiptLineNumber = 16384;
                        var lineNumber        = 0;

                        foreach (var receiptLine in receiptLines)
                        {
                            // Instantiate a taUpdateCreateItemRcd XML node object
                            taPopRcptLotInsert_ItemsTaPopRcptLotInsert receiptLotLine = new taPopRcptLotInsert_ItemsTaPopRcptLotInsert();

                            receiptLotLine.POPRCTNM  = receiptLine.POPRCTNM;
                            receiptLotLine.RCPTLNNM  = receiptLineNumber;
                            receiptLotLine.ITEMNMBR  = receiptLine.ITEMNMBR;
                            receiptLotLine.SERLTNUM  = receiptLine.SERLTNUM;
                            receiptLotLine.SERLTQTY  = receiptLine.QTYSHPPD;
                            receiptLotLine.CREATEBIN = 0;

                            lotItems[lineNumber] = receiptLotLine;

                            // Instantiate a taUpdateCreateItemRcd XML node object
                            taPopRcptLineInsert_ItemsTaPopRcptLineInsert receiptLineItem = new taPopRcptLineInsert_ItemsTaPopRcptLineInsert();

                            //Populate elements of the taUpdateCreateItemRcd XML node object
                            receiptLineItem.POPTYPE  = receiptLine.POPTYPE;
                            receiptLineItem.POPRCTNM = receiptLine.POPRCTNM;
                            receiptLineItem.RCPTLNNM = receiptLineNumber;
                            receiptLineItem.ITEMNMBR = receiptLine.ITEMNMBR;
                            receiptLineItem.VENDORID = receiptLine.VENDORID;
                            receiptLineItem.PONUMBER = receiptLine.PONUMBER;
                            receiptLineItem.VNDITNUM = receiptLine.VNDITNUM;
                            receiptLineItem.QTYSHPPD = receiptLine.QTYSHPPD;
                            receiptLineItem.AUTOCOST = 1;

                            lineItems[lineNumber] = receiptLineItem;

                            receiptLineNumber = receiptLineNumber * 2;

                            lineNumber++;
                        }

                        // Instantiate a taUpdateCreateItemRcd XML node object
                        taPopRcptHdrInsert receiptHeader = new taPopRcptHdrInsert();

                        //Populate elements of the taUpdateCreateItemRcd XML node object
                        receiptHeader.POPRCTNM    = receipt.POPRCTNM;
                        receiptHeader.POPTYPE     = receipt.POPTYPE;
                        receiptHeader.receiptdate = receipt.receiptdate;
                        receiptHeader.BACHNUMB    = receipt.BACHNUMB;
                        receiptHeader.VENDORID    = receipt.VENDORID;

                        // Instantiate a IVItemMasterType schema object
                        POPReceivingsType receipttype = new POPReceivingsType();

                        // Populate the IVItemMasterType schema with the taUpdateCreateItemRcd XML node
                        receipttype.taPopRcptLotInsert_Items  = lotItems;
                        receipttype.taPopRcptLineInsert_Items = lineItems;
                        receipttype.taPopRcptHdrInsert        = receiptHeader;
                        POPReceivingsType[] receiptEntry = { receipttype };

                        // Instantiate an eConnectType schema object
                        eConnectType eConnect = new eConnectType();

                        // Instantiate a Memory Stream object
                        MemoryStream memoryStream = new MemoryStream();

                        // Create an XML serializer object
                        XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                        // Populate the eConnectType object with the IVItemMasterType schema object
                        eConnect.POPReceivingsType = receiptEntry;

                        ///////////////////////////////////////////////////////////////////////////////

                        // Serialize the eConnectType.
                        serializer.Serialize(memoryStream, eConnect);

                        // Reset the position of the memory stream to the start.
                        memoryStream.Position = 0;

                        // Create an XmlDocument from the serialized eConnectType in memory.
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.Load(memoryStream);
                        memoryStream.Close();

                        /////////////////////////////////////////////////////////////////////////////////

                        //string xmldocument;

                        //SerializeReceiptHeaderObject("C:\\receipt.xml", receipt, receiptLines);

                        ////Use an XML document to create a string representation of the customer
                        //XmlDocument xmldoc = new XmlDocument();
                        //xmldoc.Load("C:\\receipt.xml");
                        //xmldocument = xmldoc.OuterXml;

                        ////Call eConnect to process the xmldocument.
                        //e.CreateEntity(_dynamicsConnection, xmldocument);

                        //////////////////////////////////////////////////////////////////////////////////

                        // Call eConnect to process the XmlDocument.
                        e.CreateEntity(_dynamicsConnection, xmlDocument.OuterXml);

                        operationResult.Success = true;
                        operationResult.Message = "Success";
                    }
                    else
                    {
                        operationResult.Success = false;
                        operationResult.Message = "No items are attached to receive.";
                    }
                }
                // The eConnectException class will catch eConnect business logic errors.
                // display the error message on the console
                catch (eConnectException exc)
                {
                    Console.Write(exc.ToString());
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error saving new receipt: {0} ", exc.ToString());
                }
                // Catch any system error that might occurr.
                // display the error message on the console
                catch (System.Exception ex)
                {
                    Console.Write(ex.ToString());
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error saving new receipt: {0} ", ex.ToString());
                }
                finally
                {
                    // Call the Dispose method to release the resources
                    // of the eConnectMethds object
                    e.Dispose();
                }
            } // end of using statement

            return(operationResult);
        }
示例#19
0
        /// <summary>
        /// serialize recipt
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="receipt"></param>
        /// <param name="receiptLines"></param>
        private static void SerializeReceiptObject(string filename, POP10300_Receipt_Work receipt, List <POP10310> receiptLines)
        {
            try
            {
                // Instantiate an eConnectType schema object
                eConnectType eConnect = new eConnectType();

                taPopRcptLineInsert_ItemsTaPopRcptLineInsert[] lineItems = new taPopRcptLineInsert_ItemsTaPopRcptLineInsert[receiptLines.Count];

                taPopRcptLotInsert_ItemsTaPopRcptLotInsert[] lotItems = new taPopRcptLotInsert_ItemsTaPopRcptLotInsert[receiptLines.Count];

                var receiptLineNumber = 16384;
                var lineNumber        = 0;

                foreach (var receiptLine in receiptLines)
                {
                    // Instantiate a taUpdateCreateItemRcd XML node object
                    taPopRcptLotInsert_ItemsTaPopRcptLotInsert receiptLotLine = new taPopRcptLotInsert_ItemsTaPopRcptLotInsert();

                    receiptLotLine.POPRCTNM  = receiptLine.POPRCTNM;
                    receiptLotLine.RCPTLNNM  = receiptLineNumber;
                    receiptLotLine.ITEMNMBR  = receiptLine.ITEMNMBR;
                    receiptLotLine.SERLTNUM  = receiptLine.SERLTNUM;
                    receiptLotLine.SERLTQTY  = receiptLine.QTYSHPPD;
                    receiptLotLine.CREATEBIN = 0;

                    lotItems[lineNumber] = receiptLotLine;

                    // Instantiate a taUpdateCreateItemRcd XML node object
                    taPopRcptLineInsert_ItemsTaPopRcptLineInsert receiptLineItem = new taPopRcptLineInsert_ItemsTaPopRcptLineInsert();

                    //Populate elements of the taUpdateCreateItemRcd XML node object
                    receiptLineItem.POPTYPE  = receiptLine.POPTYPE;
                    receiptLineItem.POPRCTNM = receiptLine.POPRCTNM;
                    receiptLineItem.RCPTLNNM = receiptLineNumber;
                    receiptLineItem.ITEMNMBR = receiptLine.ITEMNMBR;
                    receiptLineItem.VENDORID = receiptLine.VENDORID;
                    receiptLineItem.PONUMBER = receiptLine.PONUMBER;
                    receiptLineItem.VNDITNUM = receiptLine.VNDITNUM;
                    receiptLineItem.QTYSHPPD = receiptLine.QTYSHPPD;
                    receiptLineItem.AUTOCOST = 1;

                    lineItems[lineNumber] = receiptLineItem;

                    receiptLineNumber = receiptLineNumber * 2;

                    lineNumber++;
                }

                // Instantiate a taUpdateCreateItemRcd XML node object
                taPopRcptHdrInsert receiptHeader = new taPopRcptHdrInsert();

                //Populate elements of the taUpdateCreateItemRcd XML node object
                receiptHeader.POPRCTNM    = receipt.POPRCTNM;
                receiptHeader.POPTYPE     = receipt.POPTYPE;
                receiptHeader.receiptdate = receipt.receiptdate;
                receiptHeader.BACHNUMB    = receipt.BACHNUMB;
                receiptHeader.VENDORID    = receipt.VENDORID;

                // Instantiate a IVItemMasterType schema object
                POPReceivingsType receipttype = new POPReceivingsType();

                // Populate the IVItemMasterType schema with the taUpdateCreateItemRcd XML node
                receipttype.taPopRcptLotInsert_Items  = lotItems;
                receipttype.taPopRcptLineInsert_Items = lineItems;
                receipttype.taPopRcptHdrInsert        = receiptHeader;
                POPReceivingsType[] receiptEntry = { receipttype };

                // Instantiate a Memory Stream object
                MemoryStream memoryStream = new MemoryStream();

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                // Populate the eConnectType object with the IVItemMasterType schema object
                eConnect.POPReceivingsType = receiptEntry;

                // Create objects to create file and write the customer XML to the file
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            // catch any errors that occur and display them to the console
            catch (System.Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }
示例#20
0
        public static bool DeleteSaleTransactionEntry(string gpDatabase, string gpVendorID, ref int errorNumber, ref string errorMessage)
        {
            try
            {
                SOPDeleteLineType deleteLineType = new SOPDeleteLineType();

                taSopLineDelete salesLine = new taSopLineDelete();

                taSopDeleteDocument sopDeleteDocument = new taSopDeleteDocument();
                salesLine.SOPTYPE          = 2;
                salesLine.SOPNUMBE         = "ORDST2236";
                salesLine.ITEMNMBR         = "3-B3813A";
                sopDeleteDocument.SOPNUMBE = "ORDST2236";

                deleteLineType.taSopLineDelete = salesLine;

                eConnectType        eConnect             = new eConnectType();
                SOPDeleteLineType[] MySopTransactionType = new SOPDeleteLineType[1] {
                    deleteLineType
                };

                eConnect.SOPDeleteLineType = MySopTransactionType;

                // Serialize the master vendor type in memory.
                MemoryStream  memoryStream  = new MemoryStream();
                XmlSerializer xmlSerializer = new XmlSerializer(eConnect.GetType());


                // Serialize the eConnectType.
                xmlSerializer.Serialize(memoryStream, eConnect);

                // Reset the position of the memory stream to the start.
                memoryStream.Position = 0;

                // Create an XmlDocument from the serialized eConnectType in memory.
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(memoryStream);
                memoryStream.Close();

                //XmlDocument xmlDocument = new XmlDocument();
                //xmlDocument.LoadXml("\"D:\\\\DEVELOPMENT\\\\DOT_NET\\\\Connexus\\\\GP_API\\\\GP.API\\\\SOPDeleteDocument.xsd\"");
                string response = string.Empty;

                bool returnValue = DeleteEntity(ref response, xmlDocument.OuterXml, gpDatabase);

                if (returnValue == true)
                {
                    errorNumber  = 0;
                    errorMessage = string.Empty;
                    return(true);
                }
                else
                {
                    errorNumber  = 520;
                    errorMessage = "Failed to delete eConnect test Sale Transaction: " + response;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                gpVendorID   = string.Empty;
                errorNumber  = 529;
                errorMessage = "An unexpected error occurred in CheckeConnect: " + ex.Message;
                return(false);
            }
        }
示例#21
0
        /// <summary>
        /// Function to Retreive Data from GP Tables using eConnect, Return a string in XML Format
        /// </summary>
        /// <param name="DocumentType">Purchase_Order_Transaction, Sales_Order_Transaction</param>
        /// <param name="fromShadowTable">Direct From GP Tables or From EConnect Out</param>
        /// <param name="OutputType">0=List,1=Master document, 2=Complete document,3=Remove only</param>
        /// <param name="Action">Use this element when you request data from the shadow table. The value controls the type of data that is returned.
        /// 0=All documents
        /// 1=Insertions
        /// 2=Updates
        /// 3=Deletions
        /// 4=Returns all insertions and updates as separate documents for each item.
        /// 5=Combines all insertions and updates into one document for each item </param>
        /// <param name="WhereCondition">Custom Condition</param>
        /// <returns></returns>

        public static string RetreiveData(string DocumentType, bool fromShadowTable,
                                          int OutputType, int Action, string WhereCondition, bool RemoveShadow)
        {
            // Create a connection string to specify the Microsoft Dynamics GP server and database
            //string cnnString = "data source=(local);initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
            //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"];

            try
            {
                // Create an eConnect document type object
                eConnectType myEConnectType = new eConnectType();
                // Create a RQeConnectOutType schema object
                RQeConnectOutType myReqType = new RQeConnectOutType();
                // Create an eConnectOut XML node object
                eConnectOut myeConnectOut = new eConnectOut();

                // Populate the eConnectOut XML node elements
                myeConnectOut.ACTION      = Action;
                myeConnectOut.DOCTYPE     = DocumentType;
                myeConnectOut.OUTPUTTYPE  = OutputType;
                myeConnectOut.FORLIST     = fromShadowTable ? 0 : 1;
                myeConnectOut.REMOVE      = RemoveShadow ? 1 : 0;
                myeConnectOut.WhereClause = WhereCondition;


                // Add the eConnectOut XML node object to the RQeConnectOutType schema object
                myReqType.eConnectOut = myeConnectOut;

                // Add the RQeConnectOutType schema object to the eConnect document object
                RQeConnectOutType[] myReqOutType = { myReqType };
                myEConnectType.RQeConnectOutType = myReqOutType;

                // Serialize the eConnect document object to a memory stream
                MemoryStream  myMemStream  = new MemoryStream();
                XmlSerializer mySerializer = new XmlSerializer(myEConnectType.GetType());
                mySerializer.Serialize(myMemStream, myEConnectType);
                myMemStream.Position = 0;

                // Load the serialized eConnect document object into an XML document object
                XmlTextReader xmlreader     = new XmlTextReader(myMemStream);
                XmlDocument   myXmlDocument = new XmlDocument();
                myXmlDocument.Load(xmlreader);

                // Create an eConnectMethods object
                eConnectMethods requester = new eConnectMethods();

                //string outerXml = myXmlDocument.OuterXml;
                //int rem = 0x02;
                //outerXml = outerXml.Replace((char)rem, ' ');

                // Call the eConnect_Requester method of the eConnectMethods object to retrieve specified XML data
                return(requester.eConnect_Requester(FactoryCompany.ErpConnection.CnnString, EnumTypes.ConnectionStringType.SqlClient, myXmlDocument.OuterXml)); // outerXml);
            }

            catch (eConnectException ex)
            {
                // Dislay any errors that occur to the console
                throw new Exception(ex.Message);
            }
            catch (Exception e)
            {
                // Dislay any errors that occur to the console
                throw new Exception(e.Message);
            }
        }
示例#22
0
        /// <summary>
        /// Function to Retreive Data from GP Tables using eConnect, Return a string in XML Format
        /// </summary>
        /// <param name="DocumentType">Purchase_Order_Transaction, Sales_Order_Transaction</param>
        /// <param name="fromShadowTable">Direct From GP Tables or From EConnect Out</param>
        /// <param name="OutputType">0=List,1=Master document, 2=Complete document,3=Remove only</param>
        /// <param name="Action">Use this element when you request data from the shadow table. The value controls the type of data that is returned.
        /// 0=All documents
        /// 1=Insertions
        /// 2=Updates
        /// 3=Deletions
        /// 4=Returns all insertions and updates as separate documents for each item.
        /// 5=Combines all insertions and updates into one document for each item </param>
        /// <param name="WhereCondition">Custom Condition</param>
        /// <returns></returns>

        public static string RetreiveData(string DocumentType, bool fromShadowTable,
                int OutputType, int Action, string WhereCondition, bool RemoveShadow)
        {

            // Create a connection string to specify the Microsoft Dynamics GP server and database
            //string cnnString = "data source=(local);initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";
            //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"];

            try
            {
                // Create an eConnect document type object
                eConnectType myEConnectType = new eConnectType();
                // Create a RQeConnectOutType schema object
                RQeConnectOutType myReqType = new RQeConnectOutType();
                // Create an eConnectOut XML node object
                eConnectOut myeConnectOut = new eConnectOut();

                // Populate the eConnectOut XML node elements
                myeConnectOut.ACTION = Action;
                myeConnectOut.DOCTYPE = DocumentType;
                myeConnectOut.OUTPUTTYPE = OutputType;
                myeConnectOut.FORLIST = fromShadowTable ? 0 : 1;
                myeConnectOut.REMOVE = RemoveShadow ? 1 : 0;
                myeConnectOut.WhereClause = WhereCondition;


                // Add the eConnectOut XML node object to the RQeConnectOutType schema object
                myReqType.eConnectOut = myeConnectOut;

                // Add the RQeConnectOutType schema object to the eConnect document object
                RQeConnectOutType[] myReqOutType = { myReqType };
                myEConnectType.RQeConnectOutType = myReqOutType;

                // Serialize the eConnect document object to a memory stream
                MemoryStream myMemStream = new MemoryStream();
                XmlSerializer mySerializer = new XmlSerializer(myEConnectType.GetType());
                mySerializer.Serialize(myMemStream, myEConnectType);
                myMemStream.Position = 0;

                // Load the serialized eConnect document object into an XML document object
                XmlTextReader xmlreader = new XmlTextReader(myMemStream);
                XmlDocument myXmlDocument = new XmlDocument();
                myXmlDocument.Load(xmlreader);

                // Create an eConnectMethods object
                eConnectMethods requester = new eConnectMethods();

                //string outerXml = myXmlDocument.OuterXml;
                //int rem = 0x02;
                //outerXml = outerXml.Replace((char)rem, ' ');

                // Call the eConnect_Requester method of the eConnectMethods object to retrieve specified XML data
                return requester.eConnect_Requester(FactoryCompany.ErpConnection.CnnString, EnumTypes.ConnectionStringType.SqlClient, myXmlDocument.OuterXml); // outerXml);

            }

            catch (eConnectException ex)
            {
                // Dislay any errors that occur to the console
                throw new Exception(ex.Message);
            }
            catch (Exception e)
            {
                // Dislay any errors that occur to the console
                throw new Exception(e.Message);
            }

        }
示例#23
0
        /// <summary>
        /// save new receivable transaction
        /// </summary>
        /// <param name="receivable"></param>
        /// <returns></returns>
        public OperationResult SaveReceivableTransaction(RM20101 receivable)
        {
            var operationResult = new OperationResult();

            logger.Debug("Receivable is being created...");

            using (eConnectMethods e = new eConnectMethods())
            {
                try
                {
                    // Instantiate a taPMTransactionInsert XML node object
                    taRMTransaction transaction = new taRMTransaction();

                    //Populate elements of the taUpdateCreateItemRcd XML node object
                    transaction.RMDTYPAL = receivable.RMDTYPAL;
                    transaction.DOCNUMBR = receivable.DOCNUMBR;
                    transaction.DOCDATE  = receivable.DOCDATE.ToShortDateString();
                    transaction.BACHNUMB = receivable.BACHNUMB;
                    transaction.CUSTNMBR = receivable.CUSTNMBR;
                    transaction.DOCAMNT  = receivable.DOCAMNT;
                    transaction.SLSAMNT  = receivable.SLSAMNT;

                    // Instantiate a PMTransactionType schema object
                    RMTransactionType transactiontype = new RMTransactionType();

                    // Populate the PMTransactionType schema with the taPMTransactionInsert XML node
                    transactiontype.taRMTransaction = transaction;
                    RMTransactionType[] receivableTransaction = { transactiontype };

                    // Instantiate an eConnectType schema object
                    eConnectType eConnect = new eConnectType();

                    // Instantiate a Memory Stream object
                    MemoryStream memoryStream = new MemoryStream();

                    // Create an XML serializer object
                    XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                    // Populate the eConnectType object with the PMTransactionType schema object
                    eConnect.RMTransactionType = receivableTransaction;

                    // Serialize the eConnectType.
                    serializer.Serialize(memoryStream, eConnect);

                    // Reset the position of the memory stream to the start.
                    memoryStream.Position = 0;

                    // Create an XmlDocument from the serialized eConnectType in memory.
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(memoryStream);
                    memoryStream.Close();

                    // Call eConnect to process the XmlDocument.
                    e.CreateEntity(_dynamicsConnection, xmlDocument.OuterXml);

                    operationResult.Success = true;
                    operationResult.Message = "Success";
                }
                // The eConnectException class will catch eConnect business logic errors.
                // display the error message on the console
                catch (eConnectException exc)
                {
                    Console.Write(exc.ToString());
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error saving new payables transaction: {0} ", exc.ToString());
                }
                // Catch any system error that might occurr.
                // display the error message on the console
                catch (System.Exception ex)
                {
                    Console.Write(ex.ToString());
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error saving new payables transaction: {0} ", ex.ToString());
                }
                finally
                {
                    // Call the Dispose method to release the resources
                    // of the eConnectMethds object
                    e.Dispose();
                }
            } // end of using statement

            return(operationResult);
        }
示例#24
0
        public static bool CheckeConnectCustomer(string gpDatabase, string gpCustomerID, ref int errorNumber, ref string errorMessage)
        {
            try
            {
                //Create / update test customer to check eConnect status
                taUpdateCreateCustomerRcd customer = new taUpdateCreateCustomerRcd();

                customer.CUSTNMBR          = gpCustomerID;
                customer.HOLD              = 1;
                customer.HOLDSpecified     = true;
                customer.INACTIVE          = 1;
                customer.INACTIVESpecified = true;
                customer.CUSTNAME          = "eConnect Status Test GP Web API";
                customer.CNTCPRSN          = "eConnect Status Test";
                customer.ADRSCODE          = "MAILING";
                customer.ADDRESS1          = "eConnect Status Test";
                customer.ADDRESS2          = "eConnect Status Test";
                customer.ADDRESS3          = "eConnect Status Test";
                customer.CITY              = "eConnect Test";
                customer.STATE             = "TEST";
                customer.ZIPCODE           = "00000";
                customer.COMMENT1          = "Updated " + DateTime.Now;

                customer.UpdateIfExists = 1;

                RMCustomerMasterType RMCust = new RMCustomerMasterType();
                RMCust.taUpdateCreateCustomerRcd = customer;
                RMCustomerMasterType[] RMCustType = { RMCust };

                eConnectType eConnect = new eConnectType();
                eConnect.RMCustomerMasterType = RMCustType;

                MemoryStream  memoryStream  = new MemoryStream();
                XmlSerializer xmlSerializer = new XmlSerializer(eConnect.GetType());
                xmlSerializer.Serialize(memoryStream, eConnect);
                memoryStream.Position = 0;

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(memoryStream);
                memoryStream.Close();

                string response = string.Empty;

                bool returnValue = CreateEntity(ref response, xmlDocument.OuterXml, gpDatabase);

                if (returnValue == true)
                {
                    errorNumber  = 0;
                    errorMessage = string.Empty;
                    return(true);
                }
                else
                {
                    gpCustomerID = string.Empty;
                    errorNumber  = 520;
                    errorMessage = "Failed to import eConnect test customer: " + response;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                gpCustomerID = string.Empty;
                errorNumber  = 529;
                errorMessage = "An unexpected error occurred in CheckeConnect: " + ex.Message;
                return(false);
            }
        }
示例#25
0
        /// <summary>
        /// save new inventory transaction
        /// </summary>
        /// <param name="transaction"></param>
        /// <param name="transactionLines"></param>
        /// <returns></returns>
        public OperationResult SaveInventoryTransaction(IV10000_IventoryTransaction_Work transaction, List <IV10000_IventoryTransaction_Work> transactionLines)
        {
            var operationResult = new OperationResult();

            logger.Debug("Receipt is being created...");

            using (eConnectMethods e = new eConnectMethods())
            {
                try
                {
                    if (transactionLines != null && transactionLines.Count > 0)
                    {
                        taIVTransactionLotInsert_ItemsTaIVTransactionLotInsert[] lotItems = new taIVTransactionLotInsert_ItemsTaIVTransactionLotInsert[transactionLines.Count];

                        taIVTransactionLineInsert_ItemsTaIVTransactionLineInsert[] lineItems = new taIVTransactionLineInsert_ItemsTaIVTransactionLineInsert[transactionLines.Count];

                        var transactionLineNumber = 16384;
                        var lineNumber            = 0;

                        foreach (var transactionLine in transactionLines)
                        {
                            //// Instantiate a taUpdateCreateItemRcd XML node object
                            taIVTransactionLotInsert_ItemsTaIVTransactionLotInsert transactionLotItem = new taIVTransactionLotInsert_ItemsTaIVTransactionLotInsert();

                            //Populate elements of the taUpdateCreateItemRcd XML node object
                            transactionLotItem.IVDOCNBR = transactionLine.IVDOCNBR;
                            transactionLotItem.IVDOCTYP = transactionLine.IVDOCTYP;
                            transactionLotItem.LOTNUMBR = transactionLine.LOTNUMBR;
                            transactionLotItem.ITEMNMBR = transactionLine.ITEMNMBR;
                            transactionLotItem.SERLTQTY = transactionLine.TRXQTY;
                            transactionLotItem.LOCNCODE = transactionLine.TRXLOCTN;
                            //transactionLotItem.EXPNDATE = transactionLine.EXPNDATE;
                            //transactionLotItem.DATERECD = transactionLine.DATERECD;

                            lotItems[lineNumber] = transactionLotItem;

                            // Instantiate a taUpdateCreateItemRcd XML node object
                            taIVTransactionLineInsert_ItemsTaIVTransactionLineInsert transactionLineItem = new taIVTransactionLineInsert_ItemsTaIVTransactionLineInsert();

                            //Populate elements of the taUpdateCreateItemRcd XML node object
                            transactionLineItem.IVDOCNBR = transactionLine.IVDOCNBR;
                            transactionLineItem.IVDOCTYP = transactionLine.IVDOCTYP;
                            //transactionLineItem.LNSEQNBR = transactionLine.LNSEQNBR;
                            transactionLineItem.ITEMNMBR = transactionLine.ITEMNMBR;
                            transactionLineItem.TRXLOCTN = transactionLine.TRXLOCTN;
                            transactionLineItem.TRXQTY   = transactionLine.TRXQTY;
                            //transactionLineItem.Reason_Code = transactionLine.Reason_Code;

                            lineItems[lineNumber] = transactionLineItem;

                            transactionLineNumber = transactionLineNumber * 2;

                            lineNumber++;
                        }

                        // Instantiate a taUpdateCreateItemRcd XML node object
                        taIVTransactionHeaderInsert transactionHeader = new taIVTransactionHeaderInsert();

                        //Populate elements of the taUpdateCreateItemRcd XML node object
                        transactionHeader.BACHNUMB = transaction.BACHNUMB;
                        transactionHeader.IVDOCNBR = transaction.IVDOCNBR;
                        transactionHeader.IVDOCTYP = transaction.IVDOCTYP;
                        transactionHeader.DOCDATE  = transaction.DOCDATE;

                        // Instantiate a IVItemMasterType schema object
                        IVInventoryTransactionType transactiontype = new IVInventoryTransactionType();

                        // Populate the IVItemMasterType schema with the taUpdateCreateItemRcd XML node
                        transactiontype.taIVTransactionLotInsert_Items  = lotItems;
                        transactiontype.taIVTransactionLineInsert_Items = lineItems;
                        transactiontype.taIVTransactionHeaderInsert     = transactionHeader;
                        IVInventoryTransactionType[] transactionEntry = { transactiontype };

                        // Instantiate an eConnectType schema object
                        eConnectType eConnect = new eConnectType();

                        // Instantiate a Memory Stream object
                        MemoryStream memoryStream = new MemoryStream();

                        // Create an XML serializer object
                        XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                        // Populate the eConnectType object with the IVItemMasterType schema object
                        eConnect.IVInventoryTransactionType = transactionEntry;

                        ///////////////////////////////////////////////////////////////////////////////

                        // Serialize the eConnectType.
                        serializer.Serialize(memoryStream, eConnect);

                        // Reset the position of the memory stream to the start.
                        memoryStream.Position = 0;

                        // Create an XmlDocument from the serialized eConnectType in memory.
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.Load(memoryStream);
                        memoryStream.Close();

                        // Call eConnect to process the XmlDocument.
                        e.CreateEntity(_dynamicsConnection, xmlDocument.OuterXml);

                        /////////////////////////////////////////////////////////////////////////////////

                        //string xmldocument;

                        //SerializeTransactionObject("C:\\inventoryTransaction.xml", transaction, transactionLines);

                        ////Use an XML document to create a string representation of the customer
                        //XmlDocument xmldoc = new XmlDocument();
                        //xmldoc.Load("C:\\inventoryTransaction.xml");
                        //xmldocument = xmldoc.OuterXml;

                        ////Call eConnect to process the xmldocument.
                        //e.CreateEntity(_dynamicsConnection, xmldocument);

                        //////////////////////////////////////////////////////////////////////////////////

                        operationResult.Success = true;
                        operationResult.Message = "Success";
                    }
                    else
                    {
                        operationResult.Success = false;
                        operationResult.Message = "No items are attached to receive.";
                    }
                }
                // The eConnectException class will catch eConnect business logic errors.
                // display the error message on the console
                catch (eConnectException exc)
                {
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error saving new receipt: {0} ", exc.ToString());
                }
                // Catch any system error that might occurr.
                // display the error message on the console
                catch (System.Exception ex)
                {
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error saving new receipt: {0} ", ex.ToString());
                }
                finally
                {
                    // Call the Dispose method to release the resources
                    // of the eConnectMethds object
                    e.Dispose();
                }
            } // end of using statement

            return(operationResult);
        }
示例#26
0
        public Customer getCustomer(String customerId)
        {
            eConnectMethods eConnect = new eConnectMethods();
            String          address1 = "";
            String          address2 = "";
            Customer        result   = new Customer();

            result.CustomerID = customerId;
            try
            {
                eConnectType      myEConnectType = new eConnectType();
                RQeConnectOutType myReqType      = new RQeConnectOutType();
                eConnectOut       myeConnectOut  = new eConnectOut();
                myeConnectOut.ACTION     = 1;
                myeConnectOut.DOCTYPE    = "Customer";
                myeConnectOut.OUTPUTTYPE = 2;
                myeConnectOut.INDEX1FROM = customerId;
                myeConnectOut.INDEX1TO   = customerId;
                myeConnectOut.FORLIST    = 1;
                // Add the eConnectOut XML node object to the RQeConnectOutType schema object
                myReqType.eConnectOut = myeConnectOut;

                // Add the RQeConnectOutType schema object to the eConnect document object
                RQeConnectOutType[] myReqOutType = { myReqType };
                myEConnectType.RQeConnectOutType = myReqOutType;

                // Serialize the eConnect document object to a memory stream
                MemoryStream  myMemStream  = new MemoryStream();
                XmlSerializer mySerializer = new XmlSerializer(myEConnectType.GetType());
                mySerializer.Serialize(myMemStream, myEConnectType);
                myMemStream.Position = 0;

                // Load the serialized eConnect document object into an XML document object
                XmlTextReader xmlreader     = new XmlTextReader(myMemStream);
                XmlDocument   myXmlDocument = new XmlDocument();
                myXmlDocument.Load(xmlreader);

                // Call the eConnect_Requester method of the eConnectMethods object to retrieve specified XML data
                string      reqDoc         = eConnect.eConnect_Requester(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, myXmlDocument.OuterXml);
                XmlDocument resultDocument = new XmlDocument();
                resultDocument.LoadXml(reqDoc);

                XmlNodeList customerNodeList = resultDocument.GetElementsByTagName("Customer");

                if (customerNodeList.Count == 0)
                {
                    return(null);
                }
                else
                {
                    //Here we have retrieved the customer document
                    foreach (XmlNode node in customerNodeList[0])
                    {
                        if (node.Name.Equals("ADDRESS1"))
                        {
                            address1 = node.InnerText;
                        }
                        if (node.Name.Equals("ADDRESS2"))
                        {
                            address2 = node.InnerText;
                        }
                        else if (node.Name.Equals("ADRSCODE"))
                        {
                            result.CustomerAddress.AddressCode = node.InnerText;
                        }
                        else if (node.Name.Equals("CITY"))
                        {
                            result.CustomerAddress.City = node.InnerText;
                        }
                        else if (node.Name.Equals("CNTCPRSN"))
                        {
                            result.CustomerAddress.AddressContact = node.InnerText;
                        }
                        else if (node.Name.Equals("COUNTRY"))
                        {
                            result.CustomerAddress.Country = node.InnerText;
                        }
                        else if (node.Name.Equals("CUSTCLAS"))
                        {
                            result.CustomerClass = node.InnerText;
                        }
                        else if (node.Name.Equals("CUSTNAME"))
                        {
                            result.CustomerName = node.InnerText;
                        }
                        else if (node.Name.Equals("PHONE1"))
                        {
                            result.CustomerAddress.PhoneNumber1 = node.InnerText;
                        }
                        else if (node.Name.Equals("PHONE2"))
                        {
                            result.CustomerAddress.PhoneNumber2 = node.InnerText;
                        }
                        else if (node.Name.Equals("FAX"))
                        {
                            result.CustomerAddress.FaxNumber = node.InnerText;
                        }
                        else if (node.Name.Equals("STATE"))
                        {
                            result.CustomerAddress.State = node.InnerText;
                        }
                        else if (node.Name.Equals("ZIP"))
                        {
                            result.CustomerAddress.Zipcode = node.InnerText;
                        }
                        else if (node.Name.Equals("STMTNAME"))
                        {
                            result.StatementName = node.InnerText;
                        }
                        else if (node.Name.Equals("SHRTNAME"))
                        {
                            result.ShortName = node.InnerText;
                        }
                        else if (node.Name.Equals("PRBTADCD"))
                        {
                            result.BillTo = node.InnerText;
                        }
                        else if (node.Name.Equals("PRSTADCD"))
                        {
                            result.ShipTo = node.InnerText;
                        }
                        else if (node.Name.Equals("STADDRCD"))
                        {
                            result.StatementTo = node.InnerText;
                        }
                        else if (node.Name.Equals("USERDEF1"))
                        {
                            result.Type = node.InnerText;
                        }
                        else if (node.Name.Equals("USERDEF2"))
                        {
                            result.StudentStatus = node.InnerText;
                        }
                        else if (node.Name.Equals("INACTIVE"))
                        {
                            if (node.InnerText.Equals("1"))
                            {
                                result.Inactive = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            result.CustomerAddress.AddressString = address1 + address2;
            return(result);
        }
示例#27
0
        private void serializeSOPObject(string filename, Transaction assessment, string documentID, string defaultSiteID)
        {
            try
            {
                taSopLineIvcInsert_ItemsTaSopLineIvcInsert itemLine;

                taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] lineItems =
                    new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[assessment.Items.Count];


                int r = 0;
                //populate item lines
                foreach (Item item in assessment.Items)
                {
                    itemLine =
                        new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();

                    //item pks
                    itemLine.SOPTYPE  = (short)assessment.TransactionType;
                    itemLine.CUSTNMBR = assessment.StudentID;
                    itemLine.SOPNUMBE = assessment.DocumentNumber;
                    itemLine.PRCLEVEL = assessment.PriceLevel; //20100527

                    itemLine.DOCID = documentID;
                    //item details
                    itemLine.ITEMNMBR = item.ItemNo;
                    itemLine.UOFM     = item.Uofm;
                    if (assessment.TransactionType == Transaction_Type.Drop)
                    {
                        itemLine.QUANTITY = item.Qty;
                        itemLine.QTYINSVC = item.Qty;
                    }
                    else if (assessment.TransactionType == Transaction_Type.Assessment)
                    {
                        itemLine.QUOTEQTYTOINV = item.Qty;
                    }
                    else if (assessment.TransactionType == Transaction_Type.Add)
                    {
                        itemLine.QUANTITY = item.Qty;
                    }
                    itemLine.ITEMDESC          = item.ItemDescription;
                    itemLine.UNITPRCE          = item.Unitprice;
                    itemLine.MRKDNPCTSpecified = true;
                    itemLine.MRKDNPCT          = item.MarkDown;

                    itemLine.XTNDPRCE = item.ExtendedPrice;
                    itemLine.LOCNCODE = defaultSiteID;
                    itemLine.DOCDATE  = assessment.DocumentDate.ToShortDateString();

                    //itemLine.UpdateIfExists = 1;
                    lineItems[r] = itemLine;
                    r           += 1;
                }
                //add items

                SOPTransactionType salesOrder = new SOPTransactionType();
                Array.Resize(ref salesOrder.taSopLineIvcInsert_Items, r);
                salesOrder.taSopLineIvcInsert_Items = lineItems;

                taSopHdrIvcInsert header = new taSopHdrIvcInsert();

                //populate header node
                header.SOPTYPE           = (short)assessment.TransactionType;
                header.SOPNUMBE          = assessment.DocumentNumber;
                header.DOCID             = documentID;
                header.PRCLEVEL          = assessment.PriceLevel; //20100527
                header.TRDISAMTSpecified = true;

                header.BACHNUMB = assessment.BatchID;
                header.LOCNCODE = defaultSiteID;
                header.CUSTNMBR = assessment.StudentID;
                header.CUSTNAME = assessment.StudentName;
                header.CURNCYID = assessment.CurrencyID;
                header.DOCDATE  = assessment.DocumentDate.ToShortDateString();
                if (assessment.TransactionType == Transaction_Type.Assessment)
                {
                    header.QUOEXPDA = assessment.ExpirationDate.ToShortDateString();
                    header.INVODATE = assessment.DocumentDate.ToShortDateString();
                }
                header.CMMTTEXT = assessment.Comments;
                header.SUBTOTAL = assessment.Subtotal;
                header.TRDISAMT = assessment.TotalDiscounts;
                header.MISCAMNT = assessment.InstallmentFee;
                header.DOCAMNT  = assessment.TotalAmount;
                header.USINGHEADERLEVELTAXES = 1;
                //header.DEFTAXSCHDS = 1;
                //header.UpdateExisting = 1;

                //add header

                salesOrder.taSopHdrIvcInsert = header;

                eConnectType eConnType = new eConnectType();
                Array.Resize(ref eConnType.SOPTransactionType, 1);
                eConnType.SOPTransactionType[0] = salesOrder;
                //serialization proper
                using (FileStream fs = new FileStream(filename, FileMode.Create))
                {
                    XmlTextWriter writer     = new XmlTextWriter(fs, new UTF8Encoding());
                    XmlSerializer serializer = new XmlSerializer(eConnType.GetType());
                    serializer.Serialize(writer, eConnType);
                    writer.Close();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
        }
示例#28
0
        /// <summary>
        /// update foundry
        /// </summary>
        /// <param name="foundry"></param>
        /// <returns></returns>
        public OperationResult UpdateFoundry(PM00200_Foundry foundry)
        {
            var operationResult = new OperationResult();

            var existingFoundry = _dynamicsContext.PM00200_Foundry.FirstOrDefault(x => x.VENDORID.Replace(" ", string.Empty) == foundry.VENDORID);

            if (existingFoundry != null)
            {
                logger.Debug("Foundry is being updated.");

                string sCustomerDocument;
                string sXsdSchema;
                string sConnectionString;

                using (eConnectMethods e = new eConnectMethods())
                {
                    try
                    {
                        // Instantiate a taUpdateCreateCustomerRcd XML node object
                        taUpdateCreateVendorRcd vendor = new taUpdateCreateVendorRcd();

                        //Populate elements of the taUpdateCreateVendorRcd XML node object
                        vendor.VENDORID       = foundry.VENDORID;
                        vendor.VENDNAME       = foundry.VENDNAME;
                        vendor.VENDSHNM       = foundry.VENDSHNM;
                        vendor.UseVendorClass = 0;
                        vendor.UpdateIfExists = 1;

                        // Instantiate a PMVendorMasterType schema object
                        PMVendorMasterType vendortype = new PMVendorMasterType();

                        // Populate the PMVendorMasterType schema with the taUpdateCreateVendorRcd XML node
                        vendortype.taUpdateCreateVendorRcd = vendor;
                        PMVendorMasterType[] vendorMaster = { vendortype };

                        // Instantiate an eConnectType schema object
                        eConnectType eConnect = new eConnectType();

                        // Instantiate a Memory Stream object
                        MemoryStream memoryStream = new MemoryStream();

                        // Create an XML serializer object
                        XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                        // Populate the eConnectType object with the PMVendorMasterType schema object
                        eConnect.PMVendorMasterType = vendorMaster;

                        // Serialize the eConnectType.
                        serializer.Serialize(memoryStream, eConnect);

                        // Reset the position of the memory stream to the start.
                        memoryStream.Position = 0;

                        // Create an XmlDocument from the serialized eConnectType in memory.
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.Load(memoryStream);
                        memoryStream.Close();

                        // Call eConnect to process the XmlDocument.
                        e.UpdateEntity(_dynamicsConnection, xmlDocument.OuterXml);

                        operationResult.Success = true;
                        operationResult.Message = "Success";
                    }
                    // The eConnectException class will catch eConnect business logic errors.
                    // display the error message on the console
                    catch (eConnectException exc)
                    {
                        Console.Write(exc.ToString());
                        operationResult.Success = false;
                        operationResult.Message = "Error";
                        logger.ErrorFormat("Error while updating foundry: {0} ", exc.ToString());
                    }
                    // Catch any system error that might occurr.
                    // display the error message on the console
                    catch (System.Exception ex)
                    {
                        Console.Write(ex.ToString());
                        operationResult.Success = false;
                        operationResult.Message = "Error";
                        logger.ErrorFormat("Error while updating foundry: {0} ", ex.ToString());
                    }
                    finally
                    {
                        // Call the Dispose method to release the resources
                        // of the eConnectMethds object
                        e.Dispose();
                    }
                } // end of using statement
            }
            else
            {
                operationResult.Success = false;
                operationResult.Message = "Unable to find selected foundry.";
            }

            return(operationResult);
        }
示例#29
0
        public static bool UpdateSaleTransactionEntry(string gpDatabase, string gpVendorID, ref int errorNumber, ref string errorMessage)
        {
            try
            {
                SOPTransactionType salesOrder = new SOPTransactionType();

                taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine  = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
                taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine2 = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
                taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();

                taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[2];

                salesLine.CUSTNMBR = "AARONFIT0001";
                salesLine.SOPTYPE  = 2;
                salesLine.DOCID    = "STDORD";
                salesLine.QUANTITY = 2;
                salesLine.ITEMNMBR = "3-B3813A";
                salesLine.UNITPRCE = 100;
                salesLine.XTNDPRCE = 200;
                //salesLine.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy");
                salesLine.DOCDATE        = "04/12/2027";
                salesLine.UpdateIfExists = 1;
                salesLine.SOPNUMBE       = "ORDST2236";

                salesLine2.CUSTNMBR = "AARONFIT0001";
                salesLine2.SOPTYPE  = 2;
                salesLine2.DOCID    = "STDORD";
                salesLine2.QUANTITY = 0;
                salesLine2.ITEMNMBR = "100XLG";
                salesLine2.UNITPRCE = (decimal)59.95;
                salesLine2.XTNDPRCE = (decimal)(0);
                //salesLine.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy");
                salesLine2.DOCDATE        = "04/12/2027";
                salesLine2.UpdateIfExists = 1;
                salesLine2.SOPNUMBE       = "ORDST2236";


                LineItems[0] = salesLine;
                LineItems[1] = salesLine2;

                salesOrder.taSopLineIvcInsert_Items = LineItems;

                salesHdr.SOPTYPE  = 2;
                salesHdr.DOCID    = "STDORD";
                salesHdr.SOPNUMBE = "ORDST2236";
                salesHdr.BACHNUMB = "B1";
                //salesHdr.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy");
                salesHdr.DOCDATE  = "04/12/2027";
                salesHdr.CUSTNMBR = "AARONFIT0001";
                salesHdr.SUBTOTAL = 200;
                salesHdr.DOCAMNT  = 200;
                salesHdr.USINGHEADERLEVELTAXES = 0;
                salesHdr.PYMTRMID       = "Net 30";
                salesHdr.MSTRNUMB       = 410;
                salesHdr.UpdateExisting = 1;

                salesOrder.taSopHdrIvcInsert = salesHdr;
                eConnectType         eConnect             = new eConnectType();
                SOPTransactionType[] MySopTransactionType = new SOPTransactionType[1] {
                    salesOrder
                };

                eConnect.SOPTransactionType = MySopTransactionType;

                // Serialize the master vendor type in memory.
                MemoryStream  memoryStream  = new MemoryStream();
                XmlSerializer xmlSerializer = new XmlSerializer(eConnect.GetType());


                // Serialize the eConnectType.
                xmlSerializer.Serialize(memoryStream, eConnect);

                // Reset the position of the memory stream to the start.
                memoryStream.Position = 0;

                // Create an XmlDocument from the serialized eConnectType in memory.
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(memoryStream);
                memoryStream.Close();

                string response = string.Empty;

                bool returnValue = UpdateEntity(ref response, xmlDocument.OuterXml, gpDatabase);

                if (returnValue == true)
                {
                    errorNumber  = 0;
                    errorMessage = string.Empty;
                    return(true);
                }
                else
                {
                    errorNumber  = 520;
                    errorMessage = "Failed to delete eConnect test Sale Transaction: " + response;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                gpVendorID   = string.Empty;
                errorNumber  = 529;
                errorMessage = "An unexpected error occurred in CheckeConnect: " + ex.Message;
                return(false);
            }
        }
示例#30
0
        /// <summary>
        /// save new customer
        /// </summary>
        /// <param name="newCustomer"></param>
        /// <returns></returns>
        public OperationResult SaveCustomer(RM00101_Customer newCustomer)
        {
            var operationResult = new OperationResult();

            var existingCustomer = _dynamicsContext.RM00101_Customer.FirstOrDefault(x => x.CUSTNMBR.Replace(" ", string.Empty) == newCustomer.CUSTNMBR);

            if (existingCustomer == null)
            {
                logger.Debug("Customer is being created...");

                string sCustomerDocument;
                string sXsdSchema;
                string sConnectionString;

                using (eConnectMethods e = new eConnectMethods())
                {
                    try
                    {
                        //// Create the vendor data file
                        //SerializeVendorObject("Vendor.xml", foundry);

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

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

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

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

                        //// Pass in xsdSchema to validate against.
                        //e.CreateEntity(sConnectionString, sCustomerDocument);

                        // Instantiate a taUpdateCreateCustomerRcd XML node object
                        taUpdateCreateCustomerRcd customer = new taUpdateCreateCustomerRcd();

                        //Populate elements of the taUpdateCreateVendorRcd XML node object
                        customer.CUSTNMBR         = newCustomer.CUSTNMBR;
                        customer.UseCustomerClass = 1;
                        customer.CUSTCLAS         = "blah";
                        customer.UpdateIfExists   = 0;

                        // Instantiate a RMCustomerMasterType schema object
                        RMCustomerMasterType customertype = new RMCustomerMasterType();

                        // Populate the RMCustomerMasterType schema with the taUpdateCreateCustomerRcd XML node
                        customertype.taUpdateCreateCustomerRcd = customer;
                        RMCustomerMasterType[] customerMaster = { customertype };

                        // Instantiate an eConnectType schema object
                        eConnectType eConnect = new eConnectType();

                        // Instantiate a Memory Stream object
                        MemoryStream memoryStream = new MemoryStream();

                        // Create an XML serializer object
                        XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                        // Populate the eConnectType object with the PMVendorMasterType schema object
                        eConnect.RMCustomerMasterType = customerMaster;

                        // Serialize the eConnectType.
                        serializer.Serialize(memoryStream, eConnect);

                        // Reset the position of the memory stream to the start.
                        memoryStream.Position = 0;

                        // Create an XmlDocument from the serialized eConnectType in memory.
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.Load(memoryStream);
                        memoryStream.Close();

                        // Call eConnect to process the XmlDocument.
                        e.CreateEntity(_dynamicsConnection, xmlDocument.OuterXml);

                        operationResult.Success = true;
                        operationResult.Message = "Success";
                    }
                    // The eConnectException class will catch eConnect business logic errors.
                    // display the error message on the console
                    catch (eConnectException exc)
                    {
                        Console.Write(exc.ToString());
                        operationResult.Success = false;
                        operationResult.Message = "Error";
                        logger.ErrorFormat("Error saving new customer: {0} ", exc.ToString());
                    }
                    // Catch any system error that might occurr.
                    // display the error message on the console
                    catch (System.Exception ex)
                    {
                        Console.Write(ex.ToString());
                        operationResult.Success = false;
                        operationResult.Message = "Error";
                        logger.ErrorFormat("Error saving new customer: {0} ", ex.ToString());
                    }
                    finally
                    {
                        // Call the Dispose method to release the resources
                        // of the eConnectMethds object
                        e.Dispose();
                    }
                } // end of using statement
            }
            else
            {
                operationResult.Success = false;
                operationResult.Message = "Duplicate Entry";
            }

            return(operationResult);
        }
示例#31
0
        private void serializeSOPObject(string filename, Transaction assessment, string documentID, string defaultSiteID)
        {
            try
            {
                taSopLineIvcInsert_ItemsTaSopLineIvcInsert itemLine;

                taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] lineItems =
                    new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[assessment.Items.Count];

                int r = 0;
                //populate item lines
                foreach (Item item in assessment.Items)
                {
                    itemLine =
                        new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();

                    //item pks
                    itemLine.SOPTYPE = (short)assessment.TransactionType;
                    itemLine.CUSTNMBR = assessment.StudentID;
                    itemLine.SOPNUMBE = assessment.DocumentNumber;
                    itemLine.PRCLEVEL = assessment.PriceLevel; //20100527

                    itemLine.DOCID = documentID;
                    //item details
                    itemLine.ITEMNMBR = item.ItemNo;
                    itemLine.UOFM = item.Uofm;
                    if (assessment.TransactionType == Transaction_Type.Drop)
                    {
                        itemLine.QUANTITY = item.Qty;
                        itemLine.QTYINSVC = item.Qty;
                    }
                    else if (assessment.TransactionType == Transaction_Type.Assessment)
                    {
                        itemLine.QUOTEQTYTOINV = item.Qty;
                    }
                    else if (assessment.TransactionType == Transaction_Type.Add)
                    {
                        itemLine.QUANTITY = item.Qty;
                    }
                    itemLine.ITEMDESC = item.ItemDescription;
                    itemLine.UNITPRCE = item.Unitprice;
                    itemLine.MRKDNPCTSpecified = true;
                    itemLine.MRKDNPCT = item.MarkDown;

                    itemLine.XTNDPRCE = item.ExtendedPrice;
                    itemLine.LOCNCODE = defaultSiteID;
                    itemLine.DOCDATE = assessment.DocumentDate.ToShortDateString();

                    //itemLine.UpdateIfExists = 1;
                    lineItems[r] = itemLine;
                    r += 1;
                }
                //add items

                SOPTransactionType salesOrder = new SOPTransactionType();
                Array.Resize(ref salesOrder.taSopLineIvcInsert_Items, r);
                salesOrder.taSopLineIvcInsert_Items = lineItems;

                taSopHdrIvcInsert header = new taSopHdrIvcInsert();

                //populate header node
                header.SOPTYPE = (short)assessment.TransactionType;
                header.SOPNUMBE = assessment.DocumentNumber;
                header.DOCID = documentID;
                header.PRCLEVEL = assessment.PriceLevel; //20100527
                header.TRDISAMTSpecified = true;

                header.BACHNUMB = assessment.BatchID;
                header.LOCNCODE = defaultSiteID;
                header.CUSTNMBR = assessment.StudentID;
                header.CUSTNAME = assessment.StudentName;
                header.CURNCYID = assessment.CurrencyID;
                header.DOCDATE = assessment.DocumentDate.ToShortDateString();
                if (assessment.TransactionType == Transaction_Type.Assessment)
                {
                    header.QUOEXPDA = assessment.ExpirationDate.ToShortDateString();
                    header.INVODATE = assessment.DocumentDate.ToShortDateString();
                }
                header.CMMTTEXT = assessment.Comments;
                header.SUBTOTAL = assessment.Subtotal;
                header.TRDISAMT = assessment.TotalDiscounts;
                header.MISCAMNT = assessment.InstallmentFee;
                header.DOCAMNT = assessment.TotalAmount;
                header.USINGHEADERLEVELTAXES = 1;
                //header.DEFTAXSCHDS = 1;
                //header.UpdateExisting = 1;

                //add header

                salesOrder.taSopHdrIvcInsert = header;

                eConnectType eConnType = new eConnectType();
                Array.Resize(ref eConnType.SOPTransactionType, 1);
                eConnType.SOPTransactionType[0] = salesOrder;
                //serialization proper
                using (FileStream fs = new FileStream(filename, FileMode.Create))
                {
                    XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());
                    XmlSerializer serializer = new XmlSerializer(eConnType.GetType());
                    serializer.Serialize(writer, eConnType);
                    writer.Close();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
        }
示例#32
0
        public VendorResponseDto ImportGPVendor(taUpdateCreateVendorRcd vendor)
        {
            var response = new VendorResponseDto();

            //var sw = new Stopwatch();
            //sw.Start();
            //decimal elapsedTime = 0;

            try
            {
                string clearValue = "~~~";
                string cdataValue = "<![CDATA[ ]]>";

                //Replace null or empty string properties with the clear data value
                vendor = Fn.ReplaceNullOrEmptyStringProperties(vendor, clearValue);

                var PMVendor = new PMVendorMasterType();
                PMVendor.taUpdateCreateVendorRcd = vendor;

                PMVendorMasterType[] PMVendorType = { PMVendor };

                eConnectType eConnect = new eConnectType();
                eConnect.PMVendorMasterType = PMVendorType;

                MemoryStream  memStream  = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
                serializer.Serialize(memStream, eConnect);
                memStream.Position = 0;

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(memStream);
                memStream.Close();

                string finalXML = xmlDocument.OuterXml;
                //After serialization, replace clearValue with the eConnect CDATA value to clear field values that should now be empty
                finalXML = finalXML.Replace(clearValue, cdataValue);

                string responseMessage = string.Empty;
                string errorMessage    = string.Empty;

                string vendorID   = vendor.VENDORID;
                string vendorName = vendor.VENDNAME;

                bool success = eConn.CreateEntity(ref responseMessage, finalXML, _config.Value.GPCompanyDB);

                response.Success   = success;
                response.ErrorCode = 0;

                if (success)
                {
                    response.Message = "Vendor " + vendorID + " imported successfully";
                }
                else
                {
                    errorMessage       = "Failed to import vendor " + vendorID + " - " + vendorName + ": " + responseMessage;
                    response.Message   = errorMessage;
                    response.ErrorCode = LoggingEvents.INSERT_VENDOR_FAILED;
                }

                //sw.Stop();
                //elapsedTime = Convert.ToDecimal(sw.ElapsedMilliseconds);
                //response.Elapsed = elapsedTime.ToString();

                //_logger.LogInformation(LoggingEvents.INSERT_VENDOR_COMPLETE, $"ImportVendor {vendorID} complete: " + response.Elapsed);

                return(response);
            }
            catch (Exception ex)
            {
                //sw.Stop();
                //elapsedTime = Convert.ToDecimal(sw.ElapsedMilliseconds);
                //response.Elapsed = elapsedTime.ToString();

                response.Success   = false;
                response.ErrorCode = LoggingEvents.INSERT_VENDOR_EXCEPTION;
                response.Message   = "An unexpected error occured in ImportGPVendor: " + ex.Message;
                return(response);
            }
        }
示例#33
0
        /// <summary>
        /// serialize site
        /// </summary>
        /// <param name="filename"></param>
        public static void SerializeSiteObject(string filename)
        {
            try
            {
                // Instantiate an eConnectType schema object
                eConnectType eConnect = new eConnectType();

                // Instantiate a RMSalespersonMasterType schema object
                IVInventorySiteType siteType = new IVInventorySiteType();

                // Instantiate a taCreateInventorySite XML node object
                taCreateInventorySite site = new taCreateInventorySite();

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                // Populate elements of the taCreateInventorySite XML node object
                site.LOCNCODE = "Test Site Compsys";
                site.LOCNDSCR = "Test Site Compsys";
                //site.NOTEINDX = "Test Site Compsys";
                site.ADDRESS1         = "Test Site Compsys";
                site.ADDRESS2         = "Test Site Compsys";
                site.ADDRESS3         = "Test Site Compsys";
                site.CITY             = "Test Site Compsys";
                site.STATE            = "Test Site Compsys";
                site.ZIPCODE          = "Test Site Compsys";
                site.COUNTRY          = "Test Site Compsys";
                site.PHONE1           = "Test Site Compsys";
                site.PHONE2           = "Test Site Compsys";
                site.PHONE3           = "Test Site Compsys";
                site.FAXNUMBR         = "Test Site Compsys";
                site.Location_Segment = "Test Site Compsys";
                site.STAXSCHD         = "Test Site Compsys";
                site.PCTAXSCH         = "Test Site Compsys";
                site.INCLDDINPLNNNG   = 1;
                site.PORECEIPTBIN     = "Test Site Compsys";
                site.PORETRNBIN       = "Test Site Compsys";
                site.SOFULFILLMENTBIN = "Test Site Compsys";
                site.SORETURNBIN      = "Test Site Compsys";
                site.BOMRCPTBIN       = "Test Site Compsys";
                site.MATERIALISSUEBIN = "Test Site Compsys";
                //site.WMSINT = "Test Site Compsys";
                //site.PICKTICKETSITEOPT = "Test Site Compsys";
                //site.BINBREAK = "Test Site Compsys";
                site.CCode = "Test Site Compsys";
                //site.DECLID = "Test Site Compsys";
                //site.INACTIVE = "Test Site Compsys";
                //site.DEX_ROW_ID = "Test Site Compsys";

                // Populate the IVInventorySiteType schema with the taCreateInventorySite XML node
                siteType.taCreateInventorySite = site;
                IVInventorySiteType[] siteMaster = { siteType };

                // Populate the eConnectType object with the IVInventorySiteType schema object
                eConnect.IVInventorySiteType = siteMaster;

                // Create objects to create file and write the customer XML to the file
                FileStream    fs     = new FileStream(filename, FileMode.Create);
                XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                writer.Close();
            }
            // catch any errors that occur and display them to the console
            catch (System.Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }