private void ButtonDisplayFields_Click(object sender, EventArgs e)
        {
            ResultsClear();
            APICredentials TempActInfo = CreateAPICredentials();
            if ( TempActInfo == null )
                return;

            ServiceInvoke(() =>
            {
                ResultsWriteLine("Querying Fields");
                ResultsWriteLine();
                ExperientService Service = new ExperientService();
                if ( CheckBoxShowJsonFields.Checked )
                {
                    string ResponseJSON = Service.QueryFieldsJSON(TempActInfo);
                    if ( ResponseJSON == null )
                        ResultsWriteLine("Null response.");
                    else
                        ResultsWriteLine(ResponseJSON);
                }
                else
                {
                    LeadInfoResult Response = Service.QueryFields(TempActInfo);
                    if ( Response == null )
                        ResultsWriteLine("Null response.");
                    else
                    {
                        // Display any messages in the response.
                        ResultsWrite(Response.Messages);
                        if ( !Response.Success )
                            ResultsWriteLine("No data to display since the call was not successful");
                        else if ( (Response.Demographics == null) || (Response.Demographics.Length == 0) )
                            ResultsWriteLine("This show does not include any fields other than the core contact fields in the LeadInfo class.");
                        else
                        {
                            ResultsWriteLine("In addition to the core contact fields in the LeadInfo class, " +
                            "this show also contains the following Demographic fields.  Each field is shown below " +
                            "along with it's list of possible values.  Fields with no possible values may contain " +
                            "free-form text.");
                            ResultsWriteLine();
                            foreach ( var F in Response.Demographics )
                            {
                                ResultsWriteLine("Field Name: {0}", F.Key);
                                foreach ( var V in F.Value.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) )
                                    ResultsWriteLine("  {0}", V);
                                ResultsWriteLine();
                            }
                        }
                    }
                }
                // Update our local activation info storage.
                _APICredInfo = SaveAPICredentials(TempActInfo);
            });
        }
        private void ButtonLeadCaptureByKeyName_Click(object sender, EventArgs e)
        {
            ResultsClear();
            APICredentials TempActInfo = CreateAPICredentials();

            if (TempActInfo == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(TextBoxAttendeeConnectKey.Text))
            {
                DisplayErrorMessage("You must enter the Attendee's Connect Key.",
                                    "For samples from the Demo Show please use the \"Badge QRCode Samples\" link shown.");
            }
            else if (string.IsNullOrWhiteSpace(TextBoxAttendeeLastName.Text))
            {
                DisplayErrorMessage("You must enter at least one letter of the Attendee's Last Name.",
                                    "For samples from the Demo Show please use the \"Badge QRCode Samples\" link shown.");
            }
            else
            {
                ServiceInvoke(() =>
                {
                    ResultsWriteLine("Capturing Lead: {0} / {1}", TextBoxAttendeeConnectKey.Text, TextBoxAttendeeLastName.Text);
                    ResultsWriteLine();
                    ExperientService Service = new ExperientService();
                    if (CheckBoxLeadCaptureByKeyName.Checked)
                    {
                        string ResponseJSON = Service.GetLeadInfoJSON(TempActInfo, TextBoxAttendeeConnectKey.Text, TextBoxAttendeeLastName.Text);
                        if (ResponseJSON == null)
                        {
                            ResultsWriteLine("Null response.");
                        }
                        else
                        {
                            ResultsWriteLine(ResponseJSON);
                        }
                    }
                    else
                    {
                        LeadInfoResult Response = Service.GetLeadInfo(TempActInfo, TextBoxAttendeeConnectKey.Text, TextBoxAttendeeLastName.Text);
                        DisplayLeadInfoResults(Response);
                    }

                    // Update our local activation info storage.
                    _APICredInfo = SaveAPICredentials(TempActInfo);
                });
            }
        }
        private void ButtonDisplayFields_Click(object sender, EventArgs e)
        {
            ResultsClear();
            APICredentials TempActInfo = CreateAPICredentials();

            if (TempActInfo == null)
            {
                return;
            }

            ServiceInvoke(() =>
            {
                ResultsWriteLine("Querying Fields");
                ResultsWriteLine();
                ExperientService Service = new ExperientService();
                if (CheckBoxShowJsonFields.Checked)
                {
                    string ResponseJSON = Service.QueryFieldsJSON(TempActInfo);
                    if (ResponseJSON == null)
                    {
                        ResultsWriteLine("Null response.");
                    }
                    else
                    {
                        ResultsWriteLine(ResponseJSON);
                    }
                }
                else
                {
                    LeadInfoResult Response = Service.QueryFields(TempActInfo);
                    if (Response == null)
                    {
                        ResultsWriteLine("Null response.");
                    }
                    else
                    {
                        // Display any messages in the response.
                        ResultsWrite(Response.Messages);
                        if (!Response.Success)
                        {
                            ResultsWriteLine("No data to display since the call was not successful");
                        }
                        else if ((Response.Demographics == null) || (Response.Demographics.Length == 0))
                        {
                            ResultsWriteLine("This show does not include any fields other than the core contact fields in the LeadInfo class.");
                        }
                        else
                        {
                            ResultsWriteLine("In addition to the core contact fields in the LeadInfo class, " +
                                             "this show also contains the following Demographic fields.  Each field is shown below " +
                                             "along with it's list of possible values.  Fields with no possible values may contain " +
                                             "free-form text.");
                            ResultsWriteLine();
                            foreach (var F in Response.Demographics)
                            {
                                ResultsWriteLine("Field Name: {0}", F.Key);
                                foreach (var V in F.Value.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                                {
                                    ResultsWriteLine("  {0}", V);
                                }
                                ResultsWriteLine();
                            }
                        }
                    }
                }
                // Update our local activation info storage.
                _APICredInfo = SaveAPICredentials(TempActInfo);
            });
        }
        private void ButtonLeadCaptureByKeyName_Click(object sender, EventArgs e)
        {
            ResultsClear();
            APICredentials TempActInfo = CreateAPICredentials();
            if ( TempActInfo == null )
                return;

            if ( string.IsNullOrWhiteSpace(TextBoxAttendeeConnectKey.Text) )
                DisplayErrorMessage("You must enter the Attendee's Connect Key.",
                    "For samples from the Demo Show please use the \"Badge QRCode Samples\" link shown.");
            else if ( string.IsNullOrWhiteSpace(TextBoxAttendeeLastName.Text) )
                DisplayErrorMessage("You must enter at least one letter of the Attendee's Last Name.",
                    "For samples from the Demo Show please use the \"Badge QRCode Samples\" link shown.");
            else
            {
                ServiceInvoke(() =>
                {
                    ResultsWriteLine("Capturing Lead: {0} / {1}", TextBoxAttendeeConnectKey.Text, TextBoxAttendeeLastName.Text);
                    ResultsWriteLine();
                    ExperientService Service = new ExperientService();
                    if ( CheckBoxLeadCaptureByKeyName.Checked )
                    {
                        string ResponseJSON = Service.GetLeadInfoJSON(TempActInfo, TextBoxAttendeeConnectKey.Text, TextBoxAttendeeLastName.Text);
                        if ( ResponseJSON == null )
                            ResultsWriteLine("Null response.");
                        else
                            ResultsWriteLine(ResponseJSON);
                    }
                    else
                    {
                        LeadInfoResult Response = Service.GetLeadInfo(TempActInfo, TextBoxAttendeeConnectKey.Text, TextBoxAttendeeLastName.Text);
                        DisplayLeadInfoResults(Response);
                    }

                    // Update our local activation info storage.
                    _APICredInfo = SaveAPICredentials(TempActInfo);
                });
            }
        }