Exemplo n.º 1
0
        private bool PostLead(string xml_data, out string response_text)
        {
            bool ret_status = false;

            try
            {
                DataSet ds = new DataSet();
                ZillowAttributeCollection zcol = new ZillowAttributeCollection();

                // Parse the xml and populate the ZillowAttributeCollection
                using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml_data)))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        // copy data into collection
                        ds.ReadXml(reader, XmlReadMode.Auto);
                        zcol = ImportManager.ImportLeadFromZillowv5(ds);

                        // re-read the xml
                        stream.Seek(0, SeekOrigin.Begin);
                        zcol.ZillowXml = reader.ReadToEnd();
                    }
                }

                // Read security token
                zcol.PulseSecurityToken = Helpers.ReadSecurityToken();

                // Get Pulse Lead Request object from ZillowAttributeCollection
                PostLeadRequest pulse_lead_req = PulseLeadClient.GetPulseLeadRequest(zcol);

                // post request
                ResponseHdr response_hdr = PulseLeadClient.PostPulseLeadRequest(pulse_lead_req, zcol.ImportTransId.ToString());
                if (response_hdr.Successful)
                {
                    zcol.ReturnStatus = "Success";
                    ret_status        = true;
                    zcol.BorrowerId   = response_hdr._postArgs.ContactId;
                    zcol.CoborrowerId = response_hdr._postArgs.CoBorrowerContactId;
                    zcol.LoanId       = response_hdr._postArgs.LoanId;
                }
                else
                {
                    zcol.ReturnStatus = "Failed.";
                }
                zcol.Save();
                response_text = zcol.ReturnStatus;
            }
            catch (Exception ex)
            {
                response_text = "Application Error<br/>" + ex.Message;
                NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message, ex);
            }

            return(ret_status);
        }
Exemplo n.º 2
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet ds = new DataSet();
                ZillowAttributeCollection zcol = new ZillowAttributeCollection();

                // Parse the xml and populate the ZillowAttributeCollection
                using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(TextBoxZillowXml.Text)))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        // copy data into collection
                        ds.ReadXml(reader, XmlReadMode.Auto);
                        zcol = ImportManager.ImportLeadFromZillowv5(ds);

                        // re-read the xml
                        stream.Seek(0, SeekOrigin.Begin);
                        zcol.ZillowXml = reader.ReadToEnd();
                    }
                }

                // Read security token
                zcol.PulseSecurityToken = Helpers.ReadSecurityToken();

                // Get Pulse Lead Request object from ZillowAttributeCollection
                PostLeadRequest pulse_lead_req = PulseLeadClient.GetPulseLeadRequest(zcol);

                // post request
                ResponseHdr response_hdr = PulseLeadClient.PostPulseLeadRequest(pulse_lead_req, zcol.ImportTransId.ToString());
                if (response_hdr.Successful)
                {
                    zcol.ReturnStatus = "Success";
                    zcol.BorrowerId   = response_hdr._postArgs.ContactId;
                    zcol.CoborrowerId = response_hdr._postArgs.CoBorrowerContactId;
                    zcol.LoanId       = response_hdr._postArgs.LoanId;
                }
                else
                {
                    zcol.ReturnStatus = "Failed.";
                }
                zcol.Save();

                // display html formatted
                LiteralResults.Text = "<p>Response Status: " + zcol.ReturnStatus + "</p><p>" + Helpers.FriendlyHtml(zcol) + "</p>";
            }
            catch (Exception ex)
            {
                LiteralResults.Text = "Application Error<br/>" + ex.Message;
            }
        }
Exemplo n.º 3
0
        internal static string FriendlyHtml(ZillowAttributeCollection zcol)
        {
            // Get Pulse Lead Request object from ZillowAttributeCollection
            PostLeadRequest pulse_lead_req = PulseLeadClient.GetPulseLeadRequest(zcol);

            // display results
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(@"<div class='col1'>Zillow Xml Attributes<br>");
            sb.AppendLine("<table class='imagetable'>");
            sb.AppendLine("<tr><th>GroupName</th><th>AttributeName</th><th>AttributeValue</th></tr>");
            foreach (ZillowAttribute attrib in zcol.ZillowAttributes)
            {
                sb.AppendLine("<tr><td>" + attrib.GroupName + "</td>" + "<td>" + attrib.AttributeName + "</td>" + "<td>" + attrib.AttributeValue + "</td></tr>");
            }
            sb.AppendLine("</table></div>");

            sb.AppendLine(@"<div class='col2'>Pulse Lead Request<br>");
            sb.AppendLine("<table class='imagetable'>");
            sb.AppendLine("<tr><th>Name</th><th>Value</th></tr>");
            foreach (FieldInfo f in pulse_lead_req.GetType().GetFields())
            {
                if (f.Name.Equals("Employment", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.Employment != null)
                {
                    continue;
                }
                if (f.Name.Equals("OtherIncome", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.OtherIncome != null)
                {
                    continue;
                }
                if (f.Name.Equals("LiquidAssets", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.LiquidAssets != null)
                {
                    continue;
                }
                if (f.Name.Equals("RequestHeader", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.RequestHeader != null)
                {
                    continue;
                }

                sb.AppendLine("<tr><td>" + f.Name + "</td>" + "<td>" + f.GetValue(pulse_lead_req) + "</td></tr>");
            }

            foreach (FieldInfo f in pulse_lead_req.GetType().GetFields())
            {
                if (f.Name.Equals("RequestHeader", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.RequestHeader != null)
                {
                    sb.AppendLine("<tr><th colspan=2><strong>Request Header</strong></th></tr>");
                    foreach (FieldInfo f1 in pulse_lead_req.RequestHeader.GetType().GetFields())
                    {
                        sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(pulse_lead_req.RequestHeader) + "</td></tr>");
                    }
                }
                else if (f.Name.Equals("Employment", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.Employment != null)
                {
                    sb.AppendLine("<tr><th colspan=2><strong>Employment</strong></th></tr>");
                    foreach (Employment employment in pulse_lead_req.Employment)
                    {
                        foreach (FieldInfo f1 in employment.GetType().GetFields())
                        {
                            sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(employment) + "</td></tr>");
                        }
                    }
                }
                else if (f.Name.Equals("OtherIncome", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.OtherIncome != null)
                {
                    sb.AppendLine("<tr><th colspan=2><strong>OtherIncome</strong></th></tr>");
                    foreach (OtherIncome other_income in pulse_lead_req.OtherIncome)
                    {
                        foreach (FieldInfo f1 in other_income.GetType().GetFields())
                        {
                            sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(other_income) + "</td></tr>");
                        }
                    }
                }
                else if (f.Name.Equals("LiquidAssets", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.LiquidAssets != null)
                {
                    sb.AppendLine("<tr><th colspan=2><strong>LiquidAssets</strong></th></tr>");
                    foreach (LiquidAssets liquid_assets in pulse_lead_req.LiquidAssets)
                    {
                        foreach (FieldInfo f1 in liquid_assets.GetType().GetFields())
                        {
                            sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(liquid_assets) + "</td></tr>");
                        }
                    }
                }
            }
            sb.AppendLine("</table></div>");

            return(sb.ToString());
        }