Example #1
0
        /*
         * public class MyServiceCallback : IAvventoServiceCallback
         * {
         *
         *
         *  public void OnDisplayUpdate(string response)
         *  {
         *      MessageBox.Show(string.Format("> Received callback at {0}-{1}", DateTime.Now, response));
         *  }
         *
         * }
         */
        private void button2_Click_1(object sender, EventArgs e)
        {
            //  var callback = new ClientLoginForm.MyServiceCallback();
            // var instanceContext = new InstanceContext(callback);


            avventoServiceClient = new AvventoServiceClient();
            ActionResponse actionResponse = new ActionResponse();

            try
            {
                if (comboBox1.SelectedValue != null)
                {
                    EndpointAddress endpointAddress = new EndpointAddress(comboBox1.SelectedValue.ToString());
                    avventoServiceClient.Endpoint.Address = endpointAddress;
                    string response = avventoServiceClient.LoginAction(txtUserName.Text, txtPassword.Text);
                    actionResponse = XmlParser.FromXml <ActionResponse>(response);
                }
                else
                {
                    avventoServiceClient = new AvventoServiceClient();
                    string response = avventoServiceClient.LoginAction(txtUserName.Text, txtPassword.Text);
                    actionResponse = XmlParser.FromXml <ActionResponse>(response);
                }

                if (actionResponse.ResponseCode == "0")
                {
                    //MessageBox.Show(actionResponse.Message);
                    lblLoginStatus.Text = string.Format("Connected to: {0}", actionResponse.Message);
                    isConnected         = true;
                }
                else
                {
                    MessageBox.Show(actionResponse.Message);
                    isConnected = false;
                }
            }
            catch (Exception)
            {
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            aventServiceClient = new AvventoServiceClient();
            ActionResponse actionResponse;

            try

            {
                if (comboBox1.SelectedValue != null)
                {
                    EndpointAddress endpointAddress = new EndpointAddress(comboBox1.SelectedValue.ToString());
                    aventServiceClient.Endpoint.Address = endpointAddress;
                    string response = aventServiceClient.LoginAction(txtUserName.Text, txtPassword.Text);

                    actionResponse = XmlParser.FromXml <ActionResponse>(response);
                }
                else
                {
                    aventServiceClient = new AvventoServiceClient();
                    string response = aventServiceClient.LoginAction(txtUserName.Text, txtPassword.Text);
                    actionResponse = XmlParser.FromXml <ActionResponse>(response);
                }

                if (actionResponse.ResponseCode == "0")
                {
                    Form1 form1 = new Form1();
                    form1.Show();
                    form1.lblConnection.Text = string.Format("User: {0} Connected To: {1}", txtUserName.Text, aventServiceClient.Endpoint.Address.ToString());
                    this.Hide();
                }
                else
                {
                    MessageBox.Show(actionResponse.Message);
                }
            }

            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }