Advertisement
Guest User

Untitled

a guest
Sep 17th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. /*
  2. Get an Epicor Client from WCF
  3.  
  4. Required Dll:
  5. Epicor.ServiceModel
  6. Erp.Contract.BO.Customer (or whatever BO you need)
  7. System.ServiceModel
  8.  
  9.  
  10. Usage:
  11. var wcfBinding = NetTcp.UsernameWindowsChannel();
  12. EndpointIdentity epid = EndpointIdentity.CreateSpnIdentity("dummy"); //Optional
  13. var soClient = GetEpicorClient<SalesOrderImpl>(wcfBinding, new Uri(string.Format("net.tcp://{0}/ERP/BO/SalesOrder.svc", Settings.Default.EpicorServer, "user","password")));
  14. */
  15. public static ImplBase<T> GetEpicorBOInstance<T>(CustomBinding binding, Uri appServer, string userName, string password, EndpointIdentity epi=null) where T : class
  16. {
  17. ImplBase<T> epicorClient = new ImplBase<T>(binding, appServer,epi);
  18. epicorClient.ClientCredentials.UserName.UserName = userName;
  19. epicorClient.ClientCredentials.UserName.Password = password;
  20. return epicorClient;
  21. }
  22.  
  23. //No Cast Needed for this one
  24. // Usage
  25. //SalesOrderImpl impl = GetEpicorBOInstance<SalesOrderImpl, SalesOrderSvcContract>(wcfBinding, new Uri(string.Format("net.tcp://{0}/ERP/BO/SalesOrder.svc", Settings.Default.EpicorServer)), Settings.Default.EpicorUser, Settings.Default.EpicorPassword);
  26. public static TImpl GetEpicorBOInstance<TImpl, TContract>(CustomBinding binding, Uri appServer, string userName, string password, EndpointIdentity epi = null)
  27. where TImpl : ImplBase<TContract>
  28. where TContract : class
  29. {
  30.  
  31. TImpl client=(TImpl)Activator.CreateInstance(typeof(TImpl), binding, appServer, epi);
  32. client.ClientCredentials.UserName.UserName = userName;
  33. client.ClientCredentials.UserName.Password = password;
  34.  
  35. return client;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement