public bool IsCSPObjConnected(CSP.ConnectedServer checkedCSPServer_obj)
    {
        if (checkedCSPServer_obj != null && checkedCSPServer_obj.SystemChannel != null && checkedCSPServer_obj.SystemChannel.IsConnected == true)
        {
            try
            {
                checkedCSPServer_obj.CheckConnection();
            }
            catch
            {
                try
                {
                    foreach (CSP.ConnectedServer.AppliedServerChannel appliedServerChannel_obj in checkedCSPServer_obj.AppliedServerChannels)
                    {
                        appliedServerChannel_obj.Disconnect();

                        appliedServerChannel_obj.IsConnected = false;

                        appliedServerChannel_obj.Socket.Close();
                    }

                    checkedCSPServer_obj.SystemChannel.Socket.Close();

                    return(false);
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
    private void button_ChangeUINAccountState_ProcessNewAccountState_Click(object sender, EventArgs e)
    {
        string string_ConnectingServiceHost = this.textBox_ChangeUINAccountState_CustomCSPServiceIPAddress.Text,
               string_ConnectingServicePort = this.textBox_ChangeUINAccountState_CustomCSPServicePort.Text,
               string_LoginUIN       = this.textBox_ChangeUINAccountState_UIN.Text,
               string_Password       = this.textBox_ChangeUINAccountState_Password.Text,
               string_ActivationCode = this.textBox_ChangeUINAccountState_UINActivationCode.Text;


        #region CSP TCP\IP Port Parsing

        int int_ConnectingServicePort = 0;

        if (int.TryParse(string_ConnectingServicePort, out int_ConnectingServicePort) == true)
        {
            if (int_ConnectingServicePort < 1024 || int_ConnectingServicePort > 65535)
            {
                MessageBox.Show(ServerStringFactory.GetString(788, LocalObjCopy.obj_ServerSettingsEnvironment.RemotingWrapper_CurrentLanguage));
            }
        }
        else
        {
            MessageBox.Show(ServerStringFactory.GetString(787, LocalObjCopy.obj_ServerSettingsEnvironment.RemotingWrapper_CurrentLanguage));

            return;
        }

        #endregion

        #region Login UIN Parsing

        ulong ulong_LoginUIN = 0;

        if (ulong.TryParse(string_LoginUIN, out ulong_LoginUIN) == true)
        {
        }
        else
        {
            MessageBox.Show(ServerStringFactory.GetString(795, LocalObjCopy.obj_ServerSettingsEnvironment.RemotingWrapper_CurrentLanguage));

            return;
        }

        #endregion

        #region Activation Code Parsing

        ulong ulong_ActivationCode = 0;

        if (this.comboBox_ChangeUINAccountState_NewAccountState.SelectedIndex == 0)
        {
            if (ulong.TryParse(string_ActivationCode, out ulong_ActivationCode) == true)
            {
            }
            else
            {
                MessageBox.Show(ServerStringFactory.GetString(795, LocalObjCopy.obj_ServerSettingsEnvironment.RemotingWrapper_CurrentLanguage));

                return;
            }
        }
        #endregion

        CSP.ConnectedServer connectedServer_obj = null;

        CSP.ConnectingServiceProvider connectingServiceProvider_obj = new CSP.ConnectingServiceProvider();

        if (this.checkBox_ChangeUINAccountState_UseCommonJSCSPService.Checked == true)
        {
            string_ConnectingServiceHost = CSP.ConnectingServiceProvider.GetCommonCSPIPString();
        }

        ///////////////////////////////////////////////////////
        if (this.comboBox_ChangeUINAccountState_NewAccountState.SelectedIndex == 0)
        {
            connectedServer_obj = connectingServiceProvider_obj.ActivateServerUINRequest(string_ConnectingServiceHost, int_ConnectingServicePort, ulong_LoginUIN, string_Password, ulong_ActivationCode);

            CSP.CommonNetworkEvents.ServerUINActivatedEvent += ServerUINActivatedEventProcessing;
        }
        else
        {
            bool bool_RequestActivationCode = this.checkBox_ChangeUINAccountState_GetActivationCode.Checked;

            connectedServer_obj = connectingServiceProvider_obj.DeActivateServerUINRequest(string_ConnectingServiceHost, int_ConnectingServicePort, ulong_LoginUIN, string_Password, bool_RequestActivationCode);

            CSP.CommonNetworkEvents.ServerUINDeActivatedEvent += ServerUINDeActivatedEventProcessing;
        }
        if (IsCSPObjConnected(connectedServer_obj) == false)
        {
            MessageBox.Show(ServerStringFactory.GetString(796, LocalObjCopy.obj_ServerSettingsEnvironment.RemotingWrapper_CurrentLanguage));
        }
        else
        {
        }
    }