Site Search:
Sign in | Join | Help

Adding Multiple Customers

Last post 08-12-2008 8:24 AM by Steve Gray. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-29-2008 11:27 AM

    Adding Multiple Customers

    Hi all,

     I am new to econnect, and what I'm trying to do is take an xml file, loop through it, and add its customers to an econnect xml doc.

     I started by using their examples as a template, and trying to do all of this in the Serialization sub.  However as a result of this code, I get a econnect XML file, but its the final source record repeated the same number of times the loop ran (450 source records = 450 repeats of the final record).

     Any help would be appreciated, as I'm sure this is a fairly common thing to do.  Even pointing me in the direction of more documentation would be greatly appreciated.

     Regards,

    -bg

     

    Public Shared Sub SerializeCustomerObject(ByVal filename As String)

    Dim serializer As New XmlSerializer(GetType(eConnectType))

    Dim eConnect As New eConnectType

    Dim customer As New taUpdateCreateCustomerRcd

    Dim customertype As New RMCustomerMasterType

    Dim i As Integer

    Dim textDoc As StreamWriter

    Dim doc As XmlDocument

    Dim nodes As XmlNodeList Dim elem As XmlElement

    'Create logfile

    textDoc = New StreamWriter("C:\GPlogfile.txt")

    i = 0

     

    'Populate the taUpdateCreateCustomerRcd XML node with customer data

    Try

    ' Create a new XmlDocument

    doc = New XmlDocument()

    ' Load data

    doc.Load("C:\eConnect\Projects\VB DOT NET Console Application\bin\CustomerRaw.xml")

    elem = doc.DocumentElement

    nodes = doc.DocumentElement.ChildNodes

     

     

    For Each elem In nodes

     

     

    With customer

     

    .CUSTNMBR = elem(
    "CUSTNMBR").InnerText

    .CUSTNAME = elem("CUSTNAME").InnerText

    .ADDRESS1 = elem("ADDRESS1").InnerText

    .ADRSCODE = elem("ADRSCODE").InnerText

    .CITY = elem("CITY").InnerText

    .ZIPCODE = elem("ZIPCODE").InnerText

    textDoc.WriteLine("id =" & i & " customer = " & customer.CUSTNAME)

     

    End With

     

    'Populate the RMCustomerMasterType schema with the taUpdateCreateCustomerRcd XML node object

    customertype.taUpdateCreateCustomerRcd = customer

    'Populate the eConnect XML document object with the RMCustomerMasterType schema object

    ReDim Preserve eConnect.RMCustomerMasterType(i)

    eConnect.RMCustomerMasterType(i) = customertype

     

    'increase index

    i = i + 1

     

    Next

    'Create file and XML writer objects to serialize the eConnect XML document

    Dim fs As New FileStream(filename, FileMode.Create) Dim writer As New XmlTextWriter(fs, New UTF8Encoding)

    ' Use the XmlTextWriter to serialize the eConnect XML document object to the file

    serializer.Serialize(writer, eConnect)

    writer.Close()

     

    Catch ex As System.ApplicationExceptionConsole.Write("Error occurred while creating customer XML document and file")

    Console.Write(ex.ToString)

    End Try

    textDoc.Close()

    End Sub

     

     

    • 216.164.83.67
  • 07-29-2008 12:14 PM In reply to

    Re: Adding Multiple Customers

    Well, let's start with this -

    You're going to have timeout issues if you go sending large transactions like that, I think. Rewrite the code so that you send one customer at a time, get that working.

    If it fails, send me the XML document that you're trying to send to Dynamics and the error that Dynamics sends you.

    One more time: instead of sending one doc with 450 customers, send one customer 450 times.

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
  • 07-29-2008 1:07 PM In reply to

    Re: Adding Multiple Customers

    It worked fine.  I was trying to over complicate things I think.

     Thanks for your suggestion, and I'm on my way.

     

    • 216.164.83.67
  • 07-30-2008 12:26 AM In reply to

    Re: Adding Multiple Customers

    Can you share with me also how it works, because what steve said I am doing the same thing one by one. Because I found that once you load the huge transaction the timeout error come. I am not doing this with Customer but sales documents bringing from Microsoft Retail System to GP in detail level.

    Appreciate if you can share yours too. 

     

    MCSD,
    Certified Microsoft Retail Specialist
    Certified Microsoft Great Plains Specialist
    Certified Cognos BI Specialist
    • 88.84.104.99
  • 07-30-2008 8:20 AM In reply to

    Re: Adding Multiple Customers

    I'm not sure what your question is here. What do you want shared?

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
  • 08-12-2008 12:37 AM In reply to

    Re: Adding Multiple Customers

    Steve, I am keep asking for every request that you told that you have created the web service to send the data. I wanted to learn how to create this and how you send the data. If you have no issue do you mind to share or send me at alwani89 AT hotmail.com

     

     

    MCSD,
    Certified Microsoft Retail Specialist
    Certified Microsoft Great Plains Specialist
    Certified Cognos BI Specialist
    • 88.84.104.99
  • 08-12-2008 8:24 AM In reply to

    Re: Adding Multiple Customers

    You don't need a sample project. You need to learn to code eConnect. You do that by reading the help file. Really. Read it.

    This piece of code is from the help file. To make a web service, I create a web service and stick in this code.

    Dim ConnectionString As String
    Dim eConnectResult As Boolean
    Dim eConnectObject As New eConnectMethods
    Dim xmlDoc As XmlDocument
    
    
    'Set the connection string
    'This connection string uses integrated security to connect to the 
    'TWO database on the local computer
    ConnectionString = "DataSource=127.0.0.1;Integrated Security=SSPI;" _
        & "Persist Security Info=False;Initial Catalog=TWO;"
    
    
    'Load the contents of the textbox into the xmlDoc object
    xmlDoc.LoadXml(XmlDoc_TextBox.Text)
    
    
    'Instantiate an eConnectMethods object
    Dim eConnectObject As New eConnectMethods
    
    
    'If eConnectResult is TRUE, the XML document was successfully submitted
    eConnectResult = eConnectObject.eConnect_EntryPoint(ConnectionString, _
        EnumTypes.ConnectionStringType.SqlClient, _
        xmlDoc.OuterXml, _
        EnumTypes.SchemaValidationType.None)

    Works like a charm.

    You still have to work out the authentication, that is covered elsewhere on this forum.

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
Page 1 of 1 (7 items)