Advertisement
Guest User

Untitled

a guest
Sep 17th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1.  
  2. The service contract (Erp.Contracts.BO.OrderAlloc) passes a plain old class object (POCO) which Epicor derives from our own Tableset base class. We did this because it is faster to serialize these objects and there is better interoperability across platforms than with Datasets. Tablesets are just lists of lists of objects that make up the same content as a Dataset. But instead of calling Dataset methods to query or sort the data, you can use Linq to C#, which opens up a lot of other options for reuse.
  3.  
  4. All that said, our client application still data binds to Dataset fields. So the “Impl” classes (Erp.Proxy.BO.OrderAllocImpl) convert the Tableset representation to a Dataset. Both assemblies require a reference to Epicor.ServiceModel. The Impl classes have some helpers for communications (like retries) and security. The Contract classes are a little closer to the metal and use some Windows Communications Foundation libraries to execute. Here a console app example of using both…
  5.  
  6. static void TestUsingPartImpl()
  7. {
  8. var wcfBinding = NetTcp.UsernameWindowsChannel();
  9. var appServer = new Uri("net.tcp://localhost/epicor10/erp/bo/part.svc");
  10. using (var partClient = new PartImpl(wcfBinding, appServer))
  11. {
  12. partClient.ClientCredentials.UserName.UserName = "Manager";
  13. partClient.ClientCredentials.UserName.Password = "Epicor123";
  14. bool morePages;
  15. var myPartDataset = partClient.GetList("", 10, 1, out morePages);
  16. foreach (var partRec in myPartDataset.PartList.Rows.Cast<PartListDataSet.PartListRow>())
  17. {
  18. Console.WriteLine(partRec.PartNum);
  19. }
  20. partClient.Close();
  21. }
  22. }
  23.  
  24. static void TestUsingPartContract()
  25. {
  26. var wcfBinding = NetTcp.UsernameWindowsChannel();
  27. var appServer = new Uri("net.tcp://localhost/epicor10/erp/bo/part.svc");
  28. using (ChannelFactory<PartSvcContract> cf = new ChannelFactory<PartSvcContract>(wcfBinding))
  29. {
  30. cf.Credentials.UserName.UserName = "Manager";
  31. cf.Credentials.UserName.Password = "Epicor123";
  32.  
  33. var partClient = cf.CreateChannel(new EndpointAddress(appServer));
  34. bool morePages;
  35. var myPartTableset = partClient.GetList("", 10, 1, out morePages);
  36.  
  37. foreach (var partRec in myPartTableset.PartList)
  38. {
  39. Console.WriteLine(partRec.PartNum);
  40. }
  41. cf.Close();
  42. }
  43. }
  44.  
  45. Both approaches can be used in a BPM directive – it’s really a choice of which programming approach you want – basic object graphs or Datasets. Both approaches send the call through the network stack and into the server just like a call coming from a client app. Each call will have to authenticate/authorize the call, which adds some overhead.
  46.  
  47. There is apparently a better way using an internal Epicor class called the ServiceRenderer<T> where T is (I think) the actual service type (e.g. Erp.Services.BO.OrderAlloc). Using this would bypass the network stack and much of the setup/teardown code that happens when a call comes into the system. But I need some confirmation from R&D that this is actually an option and that it can work. I’m working with someone on the question, but he is on the road today. Hopefully we can get some better advice out by early next week.
  48.  
  49. -Erik
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement