예제 #1
0
        public ActionResult Register()
        {
            //--> Add Lahar
            Thread threadLahar;

            threadLahar = new Thread(delegate()
            {
                try
                {
                    Lead lead  = new Lead();
                    lead.Name  = "JAIME EUGENIO";
                    lead.Email = "*****@*****.**";
                    lead.Stage = eStageLead.Lead;
                    lead.Tags  = new string[] { "Trial", "Library.NET" };
                    //TODO: Fill the remaining properties
                    lead.FormNameOrigin = "Register Account";
                    lead.UrlOrigin      = "www.mysite.com";

                    if (laharServices.SaveLead(lead))
                    {
                        //TODO: Success
                    }
                }
                catch (Exception ex)
                {
                    log.LogError(ex);
                }
            });
            threadLahar.IsBackground = true;
            threadLahar.Start();

            return(RedirectToAction("Index", "Home"));
        }
예제 #2
0
        public bool SaveLead(Lead obj)
        {
            bool result = false;

            if (obj == null)
            {
                throw new Exception("Object Lead can not be null");
            }
            else if (string.IsNullOrEmpty(obj.Email))
            {
                throw new Exception("Property E-mail can not be null or empty");
            }
            else
            {
                logServices.LogTrace("===================================================");
                logServices.LogTrace("START METHOD SAVELEAD");
                logServices.LogTrace("===================================================");
                try
                {
                    string response = ComunicationWihApi(RequestMethodType.POST, RequestSignature.CONVERSIONS, ConvertDataToPost(obj));

                    if (!string.IsNullOrEmpty(response))
                    {
                        logServices.LogTrace("DESERIALIZE RETURN TO CHECK");
                        JavaScriptSerializer serializer = new JavaScriptSerializer();
                        dynamic json   = serializer.Deserialize(response, typeof(object));
                        var     status = (string)json["status"];

                        if (status.Equals("sucesso"))
                        {
                            logServices.LogTrace("SUCCESS");
                            result = true;
                        }
                        else
                        {
                            logServices.LogTrace("OPS! CHECK RESPONSE");
                            logServices.LogTrace(response);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logServices.LogError(ex, "Error call Lahar API");
                    throw new Exception("Error call ComunicationWihApi", ex);
                }
            }

            logServices.LogTrace("END METHOD SAVELEAD");
            return(result);
        }