public static IRightNowConnectService GetService() { if (_rightnowConnectService != null) { return(_rightnowConnectService); } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = SalesCloudAutoClientAddIn.GlobalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(url); //EndpointAddress endpoint = new EndpointAddress("https://osc-svc-integration-qb1--dvp.qb.lan/cgi-bin/osc_svc_integration_qb1.cfg/services/soap"); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); // Initialize credentials for rightnow client /*var rightNowConnectUser = ConfigurationManager.AppSettings["rightnow_user"]; * var rightNowConnectPassword = ConfigurationManager.AppSettings["rightnow_password"]; * * _rightNowClient.ClientCredentials.UserName.UserName = rightNowConnectUser; * _rightNowClient.ClientCredentials.UserName.Password = rightNowConnectPassword;*/ BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; MessageBox.Show(OSCExceptionMessages.RightNowConnectServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(_rightnowConnectService); }
internal static bool Config() { lock (_sync) { if (!_isConfigured) { try { // Register config verbs RegisterConfigVerb(); // Get right now connect service _rightNowService = RightNowConnectService.GetService(); // Initialized Configverbs var isCfgReceived = InitializedConfigVerbs(); if (isCfgReceived) { // Parse 'CUSTOM_CFG_Sales_Accel_Integrations' config verb _isConfigured = ParseCustomCfgAccelExtIntegrations(); if (!_isConfigured) { MessageBox.Show(OSCExceptionMessages.ConfigVerbIsNotSetOrIncorrect, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception e) { _isConfigured = false; MessageBox.Show(OSCExceptionMessages.ConfigurationNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } return(_isConfigured); }
public static IRightNowConnectService GetService() { if (_rightnowConnectService != null) { return _rightnowConnectService; } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = SalesCloudAutoClientAddIn.GlobalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(url); //EndpointAddress endpoint = new EndpointAddress("https://osc-svc-integration-qb1--dvp.qb.lan/cgi-bin/osc_svc_integration_qb1.cfg/services/soap"); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); // Initialize credentials for rightnow client /*var rightNowConnectUser = ConfigurationManager.AppSettings["rightnow_user"]; var rightNowConnectPassword = ConfigurationManager.AppSettings["rightnow_password"]; _rightNowClient.ClientCredentials.UserName.UserName = rightNowConnectUser; _rightNowClient.ClientCredentials.UserName.Password = rightNowConnectPassword;*/ BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find<SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; MessageBox.Show(OSCExceptionMessages.RightNowConnectServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return _rightnowConnectService; }