Example #1
0
        /// <summary>
        /// Get Lead Service object
        /// </summary>
        /// <returns></returns>
        public static ILeadService GetService()
        {
            if (_leadService != null)
            {
                return _leadService;
            }

            if (!RightNowConfigService.IsConfigured())
            {
                return null;
            }

            try
            {
                lock (_sync)
                {
                    if (_leadService == null)
                    {
                        var leadServiceUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.OSCLeadServiceUrl);

                        EndpointAddress endpoint = new EndpointAddress(leadServiceUrl);
                        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                        _leadService = new LeadService();
                        _leadService._leadClient = new LeadPublicServiceClient(binding, endpoint);
                        _leadService._leadClient.ClientCredentials.UserName.UserName = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
                        _leadService._leadClient.ClientCredentials.UserName.Password = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);
                        _leadService._leadClient.Endpoint.Behaviors.Add(new EmptyElementBehavior());

                        // TODO: Need to work on this while working on SCLog story.
                        //_inboundService._log = ToaLogService.GetLog();
                        
                    }
                }
            }
            catch (Exception e)
            {
                _leadService = null;
                MessageBox.Show(OSCExceptionMessages.LeadServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return _leadService;
        }
Example #2
0
        /// <summary>
        /// Get Lead Service object
        /// </summary>
        /// <returns></returns>
        public static ILeadService GetService()
        {
            if (_leadService != null)
            {
                return(_leadService);
            }

            if (!RightNowConfigService.IsConfigured())
            {
                return(null);
            }

            try
            {
                lock (_sync)
                {
                    if (_leadService == null)
                    {
                        var leadServiceUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.OSCLeadServiceUrl);

                        EndpointAddress  endpoint = new EndpointAddress(leadServiceUrl);
                        BasicHttpBinding binding  = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                        _leadService             = new LeadService();
                        _leadService._leadClient = new LeadIntegrationServiceClient(binding, endpoint);
                        _leadService._leadClient.ClientCredentials.UserName.UserName = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
                        _leadService._leadClient.ClientCredentials.UserName.Password = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);
                        _leadService._leadClient.Endpoint.Behaviors.Add(new EmptyElementBehavior());

                        // TODO: Need to work on this while working on SCLog story.
                        //_inboundService._log = ToaLogService.GetLog();
                    }
                }
            }
            catch (Exception e)
            {
                _leadService = null;
                MessageBox.Show(OSCExceptionMessages.LeadServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_leadService);
        }