示例#1
0
        private APICredentials LoadAPICredentials()
        {
            APICredentials TR = null;

            if (File.Exists(APICredentialsStorageFileName))
            {
                try
                {
                    string Data = File.ReadAllText(APICredentialsStorageFileName, Encoding.UTF8);
                    using (var MS = new MemoryStream(Encoding.UTF8.GetBytes(Data)))
                    {
                        var JsonSerializer = new DataContractJsonSerializer(typeof(APICredentials));
                        TR = JsonSerializer.ReadObject(MS) as APICredentials;
                        MS.Close();
                    }
                }
                catch
                {
                    // Just delete the current storage file on any error loading it.
                    File.Delete(APICredentialsStorageFileName);
                    TR = null;
                }
            }
            if (TR == null)
            {
                TR = new APICredentials("0000000000000000", "0", "");
            }
            return(TR);
        }
示例#2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ResultsClear();
     _APICredInfo        = LoadAPICredentials();
     TextBoxAPIKey.Text  = _APICredInfo.APIKey;
     TextBoxActCode.Text = _APICredInfo.ActivationCode;
     TextBoxBadgeID.Text = _APICredInfo.BadgeID;
 }
        /// <summary>
        /// Query the web service for a list of all fields for the show associated
        /// with the API Credentials.
        /// </summary>
        public string QueryFieldsJSON(APICredentials apiCred)
        {
            string URL = string.Format("{0}?apikey={1}&actcode={2}&badgeid={3}",
                LeadInfoURL,
                HttpUtility.UrlEncode(apiCred.APIKey, Encoding.UTF8),
                HttpUtility.UrlEncode(apiCred.ActivationCode, Encoding.UTF8),
                HttpUtility.UrlEncode(apiCred.BadgeID, Encoding.UTF8));

            return SubmitGet(new Uri(URL));
        }
        /// <summary>
        /// Query the web service for a list of all fields for the show associated
        /// with the API Credentials.
        /// </summary>
        public string QueryFieldsJSON(APICredentials apiCred)
        {
            string URL = string.Format("{0}?apikey={1}&actcode={2}&badgeid={3}",
                                       LeadInfoURL,
                                       HttpUtility.UrlEncode(apiCred.APIKey, Encoding.UTF8),
                                       HttpUtility.UrlEncode(apiCred.ActivationCode, Encoding.UTF8),
                                       HttpUtility.UrlEncode(apiCred.BadgeID, Encoding.UTF8));

            return(SubmitGet(new Uri(URL)));
        }
示例#5
0
        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);
                });
            }
        }
        public string GetLeadInfoJSON(APICredentials apiCred, string qrCodeData)
        {
            if ( string.IsNullOrWhiteSpace(qrCodeData) )
                throw new ArgumentException("QRCode Data must be supplied.");

            string URL = string.Format("{0}?apikey={1}&actcode={2}&badgeid={3}&barcode={4}",
                LeadInfoURL,
                HttpUtility.UrlEncode(apiCred.APIKey, Encoding.UTF8),
                HttpUtility.UrlEncode(apiCred.ActivationCode, Encoding.UTF8),
                HttpUtility.UrlEncode(apiCred.BadgeID, Encoding.UTF8),
                HttpUtility.UrlEncode(qrCodeData, Encoding.UTF8));

            string Response = SubmitGet(new Uri(URL));
            return Response;
        }
示例#7
0
 /// <summary>
 /// Saves the current APICredentials into a text file
 /// for future reference.
 /// </summary>
 private APICredentials SaveAPICredentials(APICredentials apiCred)
 {
     if (apiCred != null)
     {
         var    JsonSerializer = new DataContractJsonSerializer(typeof(APICredentials));
         string JSONString;
         using (var MS = new MemoryStream())
         {
             JsonSerializer.WriteObject(MS, apiCred);
             JSONString = Encoding.UTF8.GetString(MS.ToArray());
             MS.Close();
         }
         File.WriteAllText(APICredentialsStorageFileName, JSONString, Encoding.UTF8);
     }
     return(apiCred);
 }
        public string GetLeadInfoJSON(APICredentials apiCred, string qrCodeData)
        {
            if (string.IsNullOrWhiteSpace(qrCodeData))
            {
                throw new ArgumentException("QRCode Data must be supplied.");
            }

            string URL = string.Format("{0}?apikey={1}&actcode={2}&badgeid={3}&barcode={4}",
                                       LeadInfoURL,
                                       HttpUtility.UrlEncode(apiCred.APIKey, Encoding.UTF8),
                                       HttpUtility.UrlEncode(apiCred.ActivationCode, Encoding.UTF8),
                                       HttpUtility.UrlEncode(apiCred.BadgeID, Encoding.UTF8),
                                       HttpUtility.UrlEncode(qrCodeData, Encoding.UTF8));

            string Response = SubmitGet(new Uri(URL));

            return(Response);
        }
        public string GetLeadInfoJSON(APICredentials apiCred, string connectKey, string lastName)
        {
            if ( string.IsNullOrWhiteSpace(connectKey) )
                throw new ArgumentException("Connect Key must be supplied.");
            if ( string.IsNullOrWhiteSpace(lastName) )
                throw new ArgumentException("Last Name must be supplied.");

            string URL = string.Format("{0}?apikey={1}&actcode={2}&badgeid={3}&connectkey={4}&lastinitial={5}",
                LeadInfoURL,
                HttpUtility.UrlEncode(apiCred.APIKey, Encoding.UTF8),
                HttpUtility.UrlEncode(apiCred.ActivationCode, Encoding.UTF8),
                HttpUtility.UrlEncode(apiCred.BadgeID, Encoding.UTF8),
                HttpUtility.UrlEncode(connectKey, Encoding.UTF8),
                HttpUtility.UrlEncode(lastName.Substring(0, 1), Encoding.UTF8));

            string Response = SubmitGet(new Uri(URL));
            return Response;
        }
示例#10
0
        private APICredentials CreateAPICredentials()
        {
            APICredentials NewAPICredentials = new APICredentials(TextBoxActCode.Text.Trim(), TextBoxBadgeID.Text.Trim(), TextBoxAPIKey.Text.Trim());

            if (string.IsNullOrWhiteSpace(NewAPICredentials.ActivationCode))
            {
                DisplayErrorMessage("Activation Code is a required part of the API Credentials.");
            }
            else if (string.IsNullOrWhiteSpace(NewAPICredentials.BadgeID))
            {
                DisplayErrorMessage("Badge ID is a required part of the API Credentials.");
            }
            else if (string.IsNullOrWhiteSpace(NewAPICredentials.APIKey))
            {
                DisplayErrorMessage("API Key is a required part of the API Credentials.");
            }
            else
            {
                return(NewAPICredentials);
            }
            return(null);
        }
        public string GetLeadInfoJSON(APICredentials apiCred, string connectKey, string lastName)
        {
            if (string.IsNullOrWhiteSpace(connectKey))
            {
                throw new ArgumentException("Connect Key must be supplied.");
            }
            if (string.IsNullOrWhiteSpace(lastName))
            {
                throw new ArgumentException("Last Name must be supplied.");
            }

            string URL = string.Format("{0}?apikey={1}&actcode={2}&badgeid={3}&connectkey={4}&lastinitial={5}",
                                       LeadInfoURL,
                                       HttpUtility.UrlEncode(apiCred.APIKey, Encoding.UTF8),
                                       HttpUtility.UrlEncode(apiCred.ActivationCode, Encoding.UTF8),
                                       HttpUtility.UrlEncode(apiCred.BadgeID, Encoding.UTF8),
                                       HttpUtility.UrlEncode(connectKey, Encoding.UTF8),
                                       HttpUtility.UrlEncode(lastName.Substring(0, 1), Encoding.UTF8));

            string Response = SubmitGet(new Uri(URL));

            return(Response);
        }
        /// <summary>
        /// Get the LeadInfo for single Lead, by supplying the QRCode data that was
        /// read from the barcodeon the Attendee's badge.
        /// </summary>
        public LeadInfoResult GetLeadInfo(APICredentials apiCred, string qrCodeData)
        {
            string Response = GetLeadInfoJSON(apiCred, qrCodeData);

            return(DeserializeJSON <LeadInfoResult>(Response));
        }
示例#13
0
 private APICredentials LoadAPICredentials()
 {
     APICredentials TR = null;
     if ( File.Exists(APICredentialsStorageFileName) )
     {
         try
         {
             string Data = File.ReadAllText(APICredentialsStorageFileName, Encoding.UTF8);
             using ( var MS = new MemoryStream(Encoding.UTF8.GetBytes(Data)) )
             {
                 var JsonSerializer = new DataContractJsonSerializer(typeof(APICredentials));
                 TR = JsonSerializer.ReadObject(MS) as APICredentials;
                 MS.Close();
             }
         }
         catch
         {
             // Just delete the current storage file on any error loading it.
             File.Delete(APICredentialsStorageFileName);
             TR = null;
         }
     }
     if ( TR == null )
         TR = new APICredentials("0000000000000000", "0", "");
     return TR;
 }
 /// <summary>
 /// Get the LeadInfo for single Lead, by supplying the QRCode data that was
 /// read from the barcodeon the Attendee's badge.
 /// </summary>
 public LeadInfoResult GetLeadInfo(APICredentials apiCred, string qrCodeData)
 {
     string Response = GetLeadInfoJSON(apiCred, qrCodeData);
     return DeserializeJSON<LeadInfoResult>(Response);
 }
        /// <summary>
        /// Query the web service for a list of all fields for the show associated
        /// with the API Credentials.
        /// </summary>
        public LeadInfoResult QueryFields(APICredentials apiCred)
        {
            string Response = QueryFieldsJSON(apiCred);

            return(DeserializeJSON <LeadInfoResult>(Response));
        }
示例#16
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ResultsClear();
     _APICredInfo = LoadAPICredentials();
     TextBoxAPIKey.Text = _APICredInfo.APIKey;
     TextBoxActCode.Text = _APICredInfo.ActivationCode;
     TextBoxBadgeID.Text = _APICredInfo.BadgeID;
 }
示例#17
0
 /// <summary>
 /// Saves the current APICredentials into a text file
 /// for future reference.
 /// </summary>
 private APICredentials SaveAPICredentials(APICredentials apiCred)
 {
     if ( apiCred != null )
     {
         var JsonSerializer = new DataContractJsonSerializer(typeof(APICredentials));
         string JSONString;
         using ( var MS = new MemoryStream() )
         {
             JsonSerializer.WriteObject(MS, apiCred);
             JSONString = Encoding.UTF8.GetString(MS.ToArray());
             MS.Close();
         }
         File.WriteAllText(APICredentialsStorageFileName, JSONString, Encoding.UTF8);
     }
     return apiCred;
 }
 /// <summary>
 /// Query the web service for a list of all fields for the show associated
 /// with the API Credentials.
 /// </summary>
 public LeadInfoResult QueryFields(APICredentials apiCred)
 {
     string Response = QueryFieldsJSON(apiCred);
     return DeserializeJSON<LeadInfoResult>(Response);
 }
 /// <summary>
 /// Get the LeadInfo for single Lead, by supplying the ConnectKey from the badge
 /// (this is typically the Registrant ID) and at least one letter from the Attendee's
 /// Last Name.
 /// </summary>
 public LeadInfoResult GetLeadInfo(APICredentials apiCred, string connectKey, string lastName)
 {
     string Response = GetLeadInfoJSON(apiCred, connectKey, lastName);
     return DeserializeJSON<LeadInfoResult>(Response);
 }
        /// <summary>
        /// Get the LeadInfo for single Lead, by supplying the ConnectKey from the badge
        /// (this is typically the Registrant ID) and at least one letter from the Attendee's
        /// Last Name.
        /// </summary>
        public LeadInfoResult GetLeadInfo(APICredentials apiCred, string connectKey, string lastName)
        {
            string Response = GetLeadInfoJSON(apiCred, connectKey, lastName);

            return(DeserializeJSON <LeadInfoResult>(Response));
        }
示例#21
0
        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);
            });
        }
示例#22
0
        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);
            });
        }
示例#23
0
 private APICredentials CreateAPICredentials()
 {
     APICredentials NewAPICredentials = new APICredentials(TextBoxActCode.Text.Trim(), TextBoxBadgeID.Text.Trim(), TextBoxAPIKey.Text.Trim());
     if ( string.IsNullOrWhiteSpace(NewAPICredentials.ActivationCode) )
         DisplayErrorMessage("Activation Code is a required part of the API Credentials.");
     else if ( string.IsNullOrWhiteSpace(NewAPICredentials.BadgeID) )
         DisplayErrorMessage("Badge ID is a required part of the API Credentials.");
     else if ( string.IsNullOrWhiteSpace(NewAPICredentials.APIKey) )
         DisplayErrorMessage("API Key is a required part of the API Credentials.");
     else
         return NewAPICredentials;
     return null;
 }
示例#24
0
        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);
                });
            }
        }