コード例 #1
0
        public static IRightNowConnectService GetService()
        {
            if (_rightnowConnectService != null)
            {
                return(_rightnowConnectService);
            }

            try
            {
                lock (_sync)
                {
                    if (_rightnowConnectService == null)
                    {
                        // Initialize client with current interface soap url
                        string          url      = IOTClouddAutoClientAddIn.GlobalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap);
                        EndpointAddress endpoint = new EndpointAddress(url);
                        //EndpointAddress endpoint = new EndpointAddress("https://day04-16500-sql-80h.qb.lan/cgi-bin/day04_16500_sql_80h.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 = "******";
                         * _rightNowClient.ClientCredentials.UserName.Password = "******";*/

                        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(ExceptionMessages.RIGHTNOW_CONNECT_SERVICE_NOT_INITIALIZED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(_rightnowConnectService);
        }
コード例 #2
0
        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)
                            {
                                LogService.GetLog().Error(ExceptionMessages.CONFIG_VERB_IS_NOT_SET_OR_INCORRECT);
                                MessageBox.Show("_isConfigured is false");
                                MessageBox.Show(ExceptionMessages.CONFIG_VERB_IS_NOT_SET_OR_INCORRECT, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        _isConfigured = false;
                        LogService.GetLog().Error(ExceptionMessages.CONFIGURATION_NOT_INITIALIZED, e.StackTrace);
                        MessageBox.Show(ExceptionMessages.CONFIGURATION_NOT_INITIALIZED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            return(_isConfigured);
        }