public static RightNowConnectService GetService(IGlobalContext _globalContext) { if (_rightnowConnectService != null) { return(_rightnowConnectService); } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = _globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(_globalContext.GetInterfaceServiceUrl(ConnectServiceType.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); BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); WorkspaceAddIn._globalContext.PrepareConnectSession(_rightNowClient.ChannelFactory); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; // WorkspaceAddIn.InfoLog(e.Message); } return(_rightnowConnectService); }
/// <summary> /// Default constructor. /// </summary> /// <param name="inDesignMode">Flag which indicates if the control is being drawn on the Workspace Designer. (Use this flag to determine if code should perform any logic on the workspace record)</param> /// <param name="RecordContext">The current workspace record context.</param> public WorkspaceAddIn(bool inDesignMode, IRecordContext RecordContext, IGlobalContext GlobalContext) { _recordContext = RecordContext; _globalContext = GlobalContext; _rnConnectService = RightNowConnectService.GetService(_globalContext); }