E10 External program updating

Jose,

Perfect! Thank you for teaching me "how to fish" in the alternate style :)

-Dave

Hi All,

The following vb.net program fragment works fine updating a passed in Sales Order # in a Visual Studio 2012 windows form (interactive)project but does not work in a Console (no interaction expected) project.  I'm hoping to get the code to work in a console app to tie it to a AT scheduler job to periodically check for a flag(checkbox), do processing, then update to unset the checkbox.  Again, the logic works fine in a interactive forms app. 

Thank you for any advice,

Dave Beberman

ERP Manager

Ferguson Perforating

 

Imports Ice.Core.Session
Imports Ice.Lib.Deployment
Imports Ice.Lib.Framework
Imports Ice.Lib.Searches

Module modEpicorUpdate
    Friend EpiSession As Ice.Core.Session
    Friend EpiLaunch As Ice.Lib.Framework.ILauncher

    Sub Update_Single_Epicor_Order(ByVal lstrOrderNum As String)
            
        'Open Epicor Connection
        '
        Dim result As String = E10Connect("ERP100700")

        Dim orderAdapter As Erp.Adapters.SalesOrderAdapter = New Erp.Adapters.SalesOrderAdapter(EpiLaunch)
        orderAdapter.BOConnect()

        WriteAudit(Now().ToString + " - Updating SO# " + lstrOrderNum)

        'SalesOrder.GetByID
        Dim boolGoodFetch As Boolean = orderAdapter.GetByID(lstrOrderNum)
        WriteAudit(Now().ToString + " - GetByID Fetch boolean = " + boolGoodFetch.ToString)

        If orderAdapter.SalesOrderData.OrderHed.Rows.Count < 1 Then
            WriteAudit(Now().ToString + " - Logic Error - No rows found for SO# " + lstrOrderNum)
            Exit Sub
        End If

        'Update OrderHed Columns
        '  
        orderAdapter.SalesOrderData.OrderHed(0)("Checkbox01") = 0
        orderAdapter.SalesOrderData.OrderHed(0)("Date01") = Now
        orderAdapter.SalesOrderData.OrderHed(0)("RowMod") = "U"

        'Update
        '
        orderAdapter.Update()

        WriteAudit(Now().ToString + " - Completed Updating SO# " + lstrOrderNum)
        orderAdapter.Dispose()
        result = E10DisConnect()

    End Sub
    Private Function E10Connect(ByVal WhichDatabase As String) As String
        Dim retval As String = ""
        Try
            Dim WhoAmI As String = "AAAAAA"
            Dim MyPassword As String = "BBBBBB"
            EpiSession = New Ice.Core.Session(WhoAmI, MyPassword, LicenseType.Default, "\\PATH\ERP100700.sysconfig")
            'Initialize Launcher
            EpiLaunch = New ILauncher(EpiSession)
            retval = "Connected - Company =" & EpiSession.CompanyID.ToString
            WriteAudit(Now().ToString + " - Epicor connection Status  - " + retval)
        Catch ex As Exception
            retval = "ERROR: " & ex.Message
        End Try
        Return retval
    End Function
    Private Function E10DisConnect() As String
        Dim retval As String = ""
        Try
            EpiSession.Dispose()
            retval = "Disconnected"

        Catch ex As Exception
            retval = "ERROR: " & ex.Message
        End Try

        Return retval
    End Function

End Module

 

 

Dave

"Doesn't work"....Â
Do you mean it works when you debug it in VS but not when you run it in production?
what exactly isn't working? Are you getting an error if so what's the error?



Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Dec 16, 2015 at 3:28 PM, dbeberman@... [vantage] <vantage@yahoogroups.com> wrote:
Â
<div>
  
  
  <p></p><p><span>Hi All,</span></p><p><span>The following <a rel="nofollow" target="_blank" href="http://vb.net">vb.net</a> program fragment works fine updating a passed in Sales Order # in a Visual Studio 2012 windows form (interactive)project but does not work in a Console (no interaction expected) project.  I&#39;m hoping to get the code to work in a console app to tie it to a AT scheduler job to periodically check for a flag(checkbox), do processing, then update to unset the checkbox.  Again, the logic works fine in a interactive forms app.  </span></p><p><span>Thank you for any advice,</span></p><p><span>Dave Beberman</span></p><p><span>ERP Manager</span></p><p><span>Ferguson Perforating</span></p><p><span></span> </p><p><span>Imports Ice.Core.Session<br>Imports Ice.Lib.Deployment<br>Imports Ice.Lib.Framework<br>Imports Ice.Lib.Searches</span></p><p><span>Module modEpicorUpdate<br>    Friend EpiSession As Ice.Core.Session<br>    Friend EpiLaunch As Ice.Lib.Framework.ILauncher</span></p><p><span>    Sub Update_Single_Epicor_Order(ByVal lstrOrderNum As String)<br>             <br>        &#39;Open Epicor Connection<br>        &#39;<br>        Dim result As String = E10Connect(&quot;ERP100700&quot;)</span></p><p><span>        Dim orderAdapter As Erp.Adapters.SalesOrderAdapter = New Erp.Adapters.SalesOrderAdapter(EpiLaunch)<br>        orderAdapter.BOConnect()</span></p><p><span>        WriteAudit(Now().ToString + &quot; - Updating SO# &quot; + lstrOrderNum)</span></p><p><span>        &#39;SalesOrder.GetByID<br>        Dim boolGoodFetch As Boolean = orderAdapter.GetByID(lstrOrderNum)<br>        WriteAudit(Now().ToString + &quot; - GetByID Fetch boolean = &quot; + boolGoodFetch.ToString)</span></p><p><span>        If orderAdapter.SalesOrderData.OrderHed.Rows.Count &lt; 1 Then<br>            WriteAudit(Now().ToString + &quot; - Logic Error - No rows found for SO# &quot; + lstrOrderNum)<br>            Exit Sub<br>        End If</span></p><p><span>        &#39;Update OrderHed Columns<br>        &#39;   <br>        orderAdapter.SalesOrderData.OrderHed(0)(&quot;Checkbox01&quot;) = 0<br>        orderAdapter.SalesOrderData.OrderHed(0)(&quot;Date01&quot;) = Now<br>        orderAdapter.SalesOrderData.OrderHed(0)(&quot;RowMod&quot;) = &quot;U&quot;</span></p><p><span>        &#39;Update<br>        &#39;<br>        orderAdapter.Update()</span></p><p><span>        WriteAudit(Now().ToString + &quot; - Completed Updating SO# &quot; + lstrOrderNum)<br>        orderAdapter.Dispose()<br>        result = E10DisConnect()</span></p><p><span>    End Sub<br>    Private Function E10Connect(ByVal WhichDatabase As String) As String<br>        Dim retval As String = &quot;&quot;<br>        Try<br>            Dim WhoAmI As String = &quot;AAAAAA&quot;<br>            Dim MyPassword As String = &quot;BBBBBB&quot;<br>            EpiSession = New Ice.Core.Session(WhoAmI, MyPassword, LicenseType.Default, &quot;&#92;&#92;PATH&#92;ERP100700.sysconfig&quot;)<br>            &#39;Initialize Launcher<br>            EpiLaunch = New ILauncher(EpiSession)<br>            retval = &quot;Connected - Company =&quot; &amp; EpiSession.CompanyID.ToString<br>            WriteAudit(Now().ToString + &quot; - Epicor connection Status  - &quot; + retval)<br>        Catch ex As Exception<br>            retval = &quot;ERROR: &quot; &amp; ex.Message<br>        End Try<br>        Return retval<br>    End Function<br>    Private Function E10DisConnect() As String<br>        Dim retval As String = &quot;&quot;<br>        Try<br>            EpiSession.Dispose()<br>            retval = &quot;Disconnected&quot;</span></p><p><span>        Catch ex As Exception<br>            retval = &quot;ERROR: &quot; &amp; ex.Message<br>        End Try</span></p><p><span>        Return retval<br>    End Function</span></p><p><span>End Module<br></span></p><p><span></span> </p><p><span></span> </p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>

Thanks for the question,

It fails when run from a Vis Studio Run logging the errors:

12/16/2015 3:39:26 PM - Epicor connection Status  - Connected - Company =FERGUSON
12/16/2015 3:39:26 PM - Updating SO# 85539
12/16/2015 3:39:26 PM - GetByID good fetch = True
12/16/2015 3:39:26 PM - Logic Error - No rows found for SO# 85539

Hmm odd.. I assume that's a valid order for that Company? And you are certain you are loggin into the correct company?


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Dec 16, 2015 at 3:43 PM, dbeberman@... [vantage] <vantage@yahoogroups.com> wrote:
Â
<div>
  
  
  <p></p><p>Thanks for the question,</p><p>It fails when run from a Vis Studio Run logging the errors:</p><p>12/16/2015 3:39:26 PM - Epicor connection Status  - Connected - Company =FERGUSON<br>12/16/2015 3:39:26 PM - Updating SO# 85539<br>12/16/2015 3:39:26 PM - GetByID good fetch = True<br>12/16/2015 3:39:26 PM - Logic Error - No rows found for SO# 85539<br></p><p></p>

</div><span class="ygrps-yiv-1415335716">
 


<div style="color:#fff;min-height:0;"></div>

Yes Jose to both points,

I can perform the operations without issue using the B/L Tester also.

I'd try using the services and skipping the ILauncher stuff. That's mostly from within the client
try this
var wcfBinding = NetTcp.UsernameWindowsChannel();
  var appServer = new Uri("net.tcp://localhost/epicor10/erp/bo/part.svc");
  using (var partClient = new PartImpl(wcfBinding, appServer))
  {
    partClient.ClientCredentials.UserName.UserName = "Manager";
    partClient.ClientCredentials.UserName.Password = "Epicor123";
    bool morePages;
    var myPartDataset = partClient.GetList("", 10, 1, out morePages);
    foreach (var partRec in myPartDataset.PartList.Rows.Cast<PartListDataSet.PartListRow>())
    {
      Console.WriteLine(partRec.PartNum);
    }
    partClient.Close();
  }


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Dec 16, 2015 at 4:36 PM, dbeberman@... [vantage] <vantage@yahoogroups.com> wrote:
Â
<div>
  
  
  <p></p><p>Yes Jose to both points,</p><p>I can perform the operations without issue using the B/L Tester also.<br></p><p></p>

</div><span class="ygrps-yiv-440103430">
 


<div style="color:#fff;min-height:0;"></div>

OK I'll rework my example.

What are the references I'll need for that code to work ?

Just the Contracts and the Service Model I believe.


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Dec 16, 2015 at 4:58 PM, dbeberman@... [vantage] <vantage@yahoogroups.com> wrote:
Â
<div>
  
  
  <p></p><p>Ok, I&#39;ll rework my code.</p><p>What references do I need to use to use those objects ?</p><p><br>Â </p><p></p>

</div><span class="ygrps-yiv-1077901766">
 


<div style="color:#fff;min-height:0;"></div>

Any Web Service references needed using this technique ?

No the Contracts already contain those.


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Dec 16, 2015 at 5:24 PM, dbeberman@... [vantage] <vantage@yahoogroups.com> wrote:
Â
<div>
  
  
  <p></p><p>Any Web Service references needed using this technique ?<br></p><p></p>

</div><span class="ygrps-yiv-1324747429">
 


<div style="color:#fff;min-height:0;"></div>

Thank you for all your help - I'll have to give this a fresher go in the AM

Good morning,

Created a standalone console net 4.5 app with this code and received this error on the line shown.  Any hints ?

 

Imports Erp.Proxy.BO.PartImpl
Imports Epicor.ServiceModel

Module Module1

    Sub Main()
        Dim wcfBinding = StandardBindings.NetTcp.UsernameWindowsChannel()

        Dim appServer = New Uri("net.tcp://*localhost*/server/erp/bo/part.svc")

        Using partClient = New Erp.Proxy.BO.PartImpl(wcfBinding, appServer)

            partClient.ClientCredentials.UserName.UserName = "AAA"

            partClient.ClientCredentials.UserName.Password = "BBB"

            Dim morePages As Boolean

            Dim myPartDataset = partClient.GetList("", 10, 1, morePages)   <<<Error Line

            For Each partRec As Erp.BO.PartListDataSet.PartListRow In myPartDataset.PartList.Rows.Cast(Of Erp.BO.PartListDataSet.PartListRow)()

                Console.WriteLine(partRec.PartNum)
            Next


            partClient.Close()
        End Using

 

    End Sub

End Module

System.ServiceModel.EndpointNotFoundException was unhandled
  HResult=-2146233087
  Message=There was no endpoint listening at net.tcp://*localhost*/server/erp/bo/part.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
  Source=mscorlib
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.LayeredChannel`1.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open()
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.ICommunicationObject.Open()
       at Epicor.ServiceModel.Channels.ChannelEntry`1.CreateChannel()
       at Epicor.ServiceModel.Channels.ChannelEntry`1.GetContract()
       at Epicor.ServiceModel.Channels.ImplBase`1.GetChannel()
       at Epicor.ServiceModel.Channels.ImplBase`1.HandleContractBeforeCall()
       at Erp.Proxy.BO.PartImpl.GetList(String whereClause, Int32 pageSize, Int32 absolutePage, Boolean& morePages)
       at Con_TestEpiService.Module1.Main() in J:\VBProjectSource\Projects\Con_TestEpiService\Con_TestEpiService\Module1.vb:line 20
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


 

The URL needs to be  net.tcp://<YOURSERVER>/<YOURAPPSERVERINSTANCE>/ERP/BO/Part.svc


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Thu, Dec 17, 2015 at 10:23 AM, dbeberman@... [vantage] <vantage@yahoogroups.com> wrote:
Â
<div>
  
  
  <p></p><p>Good morning,</p><p>Created a standalone console net 4.5 app with this code and received this error on the line shown.  Any hints ?</p><p> </p><p>Imports Erp.Proxy.BO.PartImpl<br>Imports Epicor.ServiceModel</p><p>Module Module1</p><p>    Sub Main()<br>        Dim wcfBinding = StandardBindings.NetTcp.UsernameWindowsChannel()</p><p>        Dim appServer = New Uri(&quot;net.tcp://*localhost*/server/erp/bo/part.svc&quot;)</p><p>        Using partClient = New Erp.Proxy.BO.PartImpl(wcfBinding, appServer)</p><p>            partClient.ClientCredentials.UserName.UserName = &quot;AAA&quot;</p><p>            partClient.ClientCredentials.UserName.Password = &quot;BBB&quot;</p><p>            Dim morePages As Boolean</p><p>            Dim myPartDataset = partClient.GetList(&quot;&quot;, 10, 1, morePages)   &lt;&lt;&lt;Error Line</p><p>            For Each partRec As Erp.BO.PartListDataSet.PartListRow In myPartDataset.PartList.Rows.Cast(Of Erp.BO.PartListDataSet.PartListRow)()</p><p>                Console.WriteLine(partRec.PartNum)<br>            Next</p><p><br>            partClient.Close()<br>        End Using</p><p> </p><p>    End Sub</p><p>End Module</p><p>System.ServiceModel.EndpointNotFoundException was unhandled<br>  HResult=-<a rel="nofollow">2146233087</a><br>  Message=There was no endpoint listening at net.tcp://*localhost*/server/erp/bo/part.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.<br>  Source=mscorlib<br>  StackTrace:<br>    Server stack trace: <br>       at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper&amp; timeoutHelper)<br>       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper&amp; timeoutHelper)<br>       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper&amp; timeoutHelper)<br>       at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)<br>       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)<br>       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)<br>       at System.ServiceModel.Channels.LayeredChannel`1.OnOpen(TimeSpan timeout)<br>       at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)<br>       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)<br>       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)<br>       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)<br>       at System.ServiceModel.Channels.CommunicationObject.Open()<br>    Exception rethrown at [0]: <br>       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)<br>       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)<br>       at System.ServiceModel.ICommunicationObject.Open()<br>       at Epicor.ServiceModel.Channels.ChannelEntry`1.CreateChannel()<br>       at Epicor.ServiceModel.Channels.ChannelEntry`1.GetContract()<br>       at Epicor.ServiceModel.Channels.ImplBase`1.GetChannel()<br>       at Epicor.ServiceModel.Channels.ImplBase`1.HandleContractBeforeCall()<br>       at Erp.Proxy.BO.PartImpl.GetList(String whereClause, Int32 pageSize, Int32 absolutePage, Boolean&amp; morePages)<br>       at Con_TestEpiService.Module1.Main() in J:&#92;VBProjectSource&#92;Projects&#92;Con_TestEpiService&#92;Con_TestEpiService&#92;Module1.vb:line 20<br>       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)<br>       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br>       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br>       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br>       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)<br>       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)<br>       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br>       at System.Threading.ThreadHelper.ThreadStart()<br>  InnerException: <br></p><p><br> </p><p></p>

</div><span class="ygrps-yiv-1233789838">
 


<div style="color:#fff;min-height:0;"></div>