Ejemplo n.º 1
0
        /// <summary>
        /// Posts the PostLeadRequest object to the PulseLead service
        /// </summary>
        /// <param name="req"></param>
        /// <param name="import_trans_id"></param>
        /// <returns></returns>
        internal static ResponseHdr PostPulseLeadRequest(PostLeadRequest req, string import_trans_id)
        {
            try
            {
                // Post
                var         svc          = new PostLead();
                ResponseHdr response_hdr = svc.Post(req);

                // save the credit score
                if (response_hdr.Successful && req.CreditScore > 0)
                {
                    svc.SaveCreditScore(response_hdr._postArgs.ContactId, req.CreditScore);
                }

                // log the event
                if (response_hdr.Successful)
                {
                    NLogger.Info(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "Lead posted to Pulse. Zillow.ImporTransId = " + import_trans_id + ", ContactId = " + response_hdr._postArgs.ContactId.ToString());
                }
                else
                {
                    NLogger.Info(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "Could not post lead to Pulse.");
                }

                return(response_hdr);
            }
            catch (Exception ex)
            {
                NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message, ex);
                throw;
            }
        }
Ejemplo n.º 2
0
        public ResponseHdr Post(PostLeadRequest req_lead)
        {
            string      err     = string.Empty;
            ResponseHdr respHdr = new ResponseHdr();
            bool        status  = false;

            try
            {
                status = CheckData(ref req_lead, ref err);
                if (status == false)
                {
                    NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "CheckData error: " + err);
                    return(respHdr);
                }

                InternalLeadReq req = new InternalLeadReq();
                req.req           = req_lead;
                status            = ImportLead(ref req, ref err);
                respHdr._postArgs = req._postArgs;

                return(respHdr);
            }
            catch (Exception exception)
            {
                err = exception.ToString();
                NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, exception.Message, exception);
                return(respHdr);
            }
            finally
            {
                respHdr.Successful = status;
                respHdr.Error      = err;
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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;
            }
        }