/// <summary> /// Post form to Click Dimensions /// </summary> private string AddClick(Enquiry FormEnquiry) { if (!FormEnquiry.hp.Equals(String.Empty)) { throw new ApplicationException("Robot check failed. hp field was not empty."); } #region Build Form Data Request string formCaptureUrl = null; string visitorKey = FormEnquiry.visitkey; string postData = null; switch (FormEnquiry.enquiry_type) { case "CustomForm Form": //Form Capture String Generated formCaptureUrl = Properties.Settings.Default.CustomForm_FormCaptureURL; postData = String.Format($"{FormEnquiry.ToPostDataString()}"); break; default: throw new ApplicationException("Unexpected Enquiry Type."); } TraceProcessor.Verbose(string.Format("formCaptureUrl = \"{0}\"", formCaptureUrl)); TraceProcessor.Verbose(string.Format("postData = \"{0}\"", postData)); #endregion Build Form Data Request // Post data to Click Dimensions Server string serverResponse = this.PostToServer(formCaptureUrl, postData); return(serverResponse); }
public void ProcessRequest(HttpContext context) { string url = String.Empty; this.WriteTraceHeader(); Enquiry enquiry = new Enquiry(context); string responsefromfc = String.Empty; TraceProcessor.Verbose(string.Format("hp = \"{0}\"", enquiry.hp)); if (enquiry.hp.Equals(String.Empty)) { try { // Post form to Click Dimensions responsefromfc = AddClick(enquiry); } #region Error Trapping catch (ApplicationException ex) { //Non fatal error, ignore. TraceProcessor.Warning(string.Format("WARNING: {0}", ex.Message)); } catch (Exception ex) { TraceProcessor.Error(string.Format("EXCEPTION: {0}", ex.ToString())); responsefromfc = string.Format("EXCEPTION: {0}", ex.Message); } #endregion Error Trapping TraceProcessor.Information(string.Format("responsefromfc = \"{0}\"", responsefromfc)); #region Compose redirect URL if (responsefromfc.Equals("success") && enquiry.enquiry_type.Equals("CustomForm Form")) { url = string.Format("{0}?success=1", enquiry.return_url); } else if (responsefromfc.Equals("error") && enquiry.enquiry_type.Equals("CustomForm Form")) { url = string.Format("{0}?success=0", enquiry.return_url); } // Default case else { url = string.Format("{0}?success=0", enquiry.return_url); } #endregion Compose redirect URL } else { // Copmpose redirect URL url = string.Format("{0}?success=spam", enquiry.return_url); } // Redirect. TraceProcessor.Information(string.Format("Redirect: {0}", url), true); context.Response.Redirect(url); }