string GetCareerChoicesJson()
        {
            if (Request.Cookies["careerchoicescount"] == null)
            {
                return("[]");
            }

            List <object> results       = new List <object>();
            string        sChoicesCount = Request.Cookies["careerchoicescount"].Value;
            int           cnt;

            if (!int.TryParse(sChoicesCount, out cnt))
            {
                return("[]");
            }

            for (int i = 0; i < cnt; i++)
            {
                if (Request.Cookies["careerchoice" + i] != null)
                {
                    string   cval   = CookieDecoder.DecodeCookieCharacters(Request.Cookies["careerchoice" + i].Value);
                    string[] tokens = cval.Split("|".ToCharArray(), 3);
                    if (tokens.Length >= 3)
                    {
                        results.Add(new
                        {
                            priority = tokens[0],
                            careerid = tokens[1],
                            name     = tokens[2]
                        });
                    }
                }
            }

            return(results.ToArray().ToJSON());
        }
Exemple #2
0
        public static bool Send(HttpRequestBase Request, string firstname, string email, bool isexternal)
        {
            EmailManager        em  = new EmailManager();
            EmailTemplateHelper eth = new EmailTemplateHelper();

            string body = eth.GetTemplate("welcome");

            body = body.Replace("@FirstName", firstname.ToProperCase());
            body = body.Replace("@Email", email);

            StringBuilder sbadditionalinfo = new StringBuilder();

            string testresults     = CookieDataTestResults.BulletListForEmail(Request);
            string importantthings = CookieDataImportantThings.BulletListForEmail(Request);

            if (testresults != "")
            {
                sbadditionalinfo.Append("<div class=\"panel\">");
                sbadditionalinfo.Append("Your top professions:");
                sbadditionalinfo.Append(testresults);
                sbadditionalinfo.Append("</div>");
            }
            if (importantthings != "")
            {
                sbadditionalinfo.Append("<div class=\"panel\">");
                sbadditionalinfo.Append("Things that are important to you:");
                sbadditionalinfo.Append(importantthings);
                sbadditionalinfo.Append("</div>");
            }

            body = body.Replace("@AdditionalInfo", sbadditionalinfo.ToString());

            string        vmcategories = CookieDecoder.DecodeCookieCharacters(Request.Cookies["topvmcategories"].Value);
            StringBuilder sbvm         = new StringBuilder();

            if (vmcategories != null && vmcategories != "")
            {
                sbvm.Append("In the meantime, check out these schools that can help you achieve your goals in the areas where you excel.<br /><br />");
                sbvm.Append("<table border=\"0\" width=\"100%\">");

                string[] tokens = vmcategories.Split(',');
                int      cnt    = 0;
                foreach (string vmpid in tokens)
                {
                    sbvm.Append("<tr>" +
                                "<td style=\"color: #ccc; font-size: 16pt; font-weight: normal; width: 40px; text-align: center\">" + (++cnt) + "</td>" +
                                "<td style=\"padding: 5px;\"><a style=\"font-size: 16pt; font-weight: bold; color: #0099ff; text-decoration: none; margin-bottom: 100px;\" href=\"http://www.SkillCow.com/vm/index?p=" + vmpid + (isexternal ? "&m=e" : "") + "\">" +
                                VMMapper.MapName(vmpid) + " &raquo;</a></td>" +
                                "</tr>");
                    if (cnt > 5)
                    {
                        break;
                    }
                }

                sbvm.Append("</table>");
            }

            body = body.Replace("@VMListings", sbvm.ToString());


            em.SendMail("*****@*****.**", "SkillCow", email, "Your Test Results", body);

            return(true);
        }
        private string SubmitForm(FormCollection collection, string target)
        {
            string submissionResult;
            string campaignid;
            string url;
            string ipaddress = RandomHelper.Instance.Next(1, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(1, 256);

            if (target == "school")
            {
                campaignid = "13601764";
                url        = "http://explore-schools.com/affiliate/submit/";
            }
            else
            {
                campaignid = "13601765";
                url        = "http://explore-schools.com/affiliate/submit/";
            }
            string        submit = collection["submit"] != "true" ? "false" : "true";
            List <string> output = new List <string>();

            foreach (var key in collection.AllKeys)
            {
                if (key.ToLower() == "educationlevel")
                {
                    output.Add(new StringBuilder("education_level" + "=" + HttpUtility.UrlEncode(collection[key])).ToString());
                }
                else if (key.ToLower() == "client")
                {
                    output.Add(new StringBuilder("client_id" + "=" + HttpUtility.UrlEncode(collection[key])).ToString());
                }
                else if (key.ToLower() == "submit")
                {
                    continue;
                }
                output.Add(new StringBuilder(key + "=" + HttpUtility.UrlEncode(collection[key])).ToString());
            }
            string result = new StringBuilder("campaign_id=" + campaignid + "&id=1727" + "&ip=" + ipaddress + "&" + string.Join("&", output)).ToString();

            if (submit == "true")
            {
                //submissionResult = "test";
                submissionResult = SubmitLead(result, url);
            }
            else
            {
                submissionResult = "Filtered";
            }
            //return submissionResult;
            //=================================================================================================================================================================================

            String strPost = result;

            string clientid   = FormValue(collection, "client", "");
            string formid     = FormValue(collection, "form_id", "");
            string clienttype = clientid.StartsWith("SC") ? "Direct" : "Network";
            string campuskey  = FormValue(collection, "campus_key", "");
            string programkey = FormValue(collection, "program_key", "");

            string salutation = FormValue(collection, "salutation", "").Trim().ToProperCase();
            string gender     = salutation.ToLower() == "mr" ? "M" : "F";
            string firstname  = FormValue(collection, "firstname", "GET THIS");
            string lastname   = FormValue(collection, "lastname", "GET THIS");

            string email    = FormValue(collection, "email", "GET THIS").Trim().ToLower();
            string zip      = FormValue(collection, "zip", "GET THIS");
            string phone    = FormValue(collection, "phone", "GET THIS").Replace(".", "").Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
            string address1 = FormValue(collection, "address1", "GET THIS");
            string city     = FormValue(collection, "city", "");
            string state    = FormValue(collection, "state", "");

            string educationlevel = FormValue(collection, "education_level", "SC");
            string eduintent      = FormValue(collection, "edu_intent", "YES");
            string military       = FormValue(collection, "military", "None");
            string gradyear       = FormValue(collection, "gradyear", "GET THIS");
            string sourceform     = FormValue(collection, "sourceform", "");

            string dobyear = FormValue(collection, "dobyear", "");

            Random rnd      = new Random(DateTime.Now.Millisecond);
            int    dobmonth = rnd.Next(1, 13);
            int    dobday   = rnd.Next(1, 29);

            string schoolvariables = "";

            if (Request.Cookies["schoolvariables"] != null)
            {
                schoolvariables = HttpUtility.UrlDecode(Request.Cookies["schoolvariables"].Value);
            }

            //GA variable
            string utmsource   = FromCookie("utm_source"),
                   utmcampaign = FromCookie("utm_campaign"),
                   utmcontent  = FromCookie("utm_content"),
                   utmterm     = FromCookie("utm_term");

            //Advertise.com variables
            string advertise_affsub        = FromCookie("AFFSUB"),
                   advertise_affiliate     = FromCookie("AFFILIATE"),
                   advertise_country       = FromCookie("COUNTRY"),
                   advertise_countrycode   = FromCookie("COUNTRYCODE"),
                   advertise_geo           = FromCookie("GEO"),
                   advertise_subid         = FromCookie("SUBID"),
                   advertise_terms_html_kw = FromCookie("TERMS_HTML_KW"),
                   advertise_terms         = FromCookie("TERMS");
            StringBuilder sbtestresults    = new StringBuilder();
            string        testresults      = "";

            if (Request.Cookies["testresults"] != null)
            {
                testresults = CookieDecoder.DecodeCookieCharacters(Request.Cookies["testresults"].Value);
            }

            string recommendations = "";

            if (Request.Cookies["recommendations"] != null)
            {
                recommendations = CookieDecoder.DecodeCookieCharacters(Request.Cookies["recommendations"].Value);
            }

            string careerChoicesJson = GetCareerChoicesJson();
            string data = "{\"careerchoices\":" + careerChoicesJson + "}";

            //Update the record with address
            DelayedRecordClient drc = new DelayedRecordClient();
            //First check if delayed record already exists for this email
            DelayedRecord dr = drc.GetByRowKey(email.FormatEmailAsProgrammaticId());

            if (dr != null)
            {
                if (dr.Address1 != address1)
                {
                    dr.Address1  = address1;
                    dr.EduIntent = "YES";
                    drc.Update(dr);
                }
            }
            SkillCowRequestSubmissionClient rsc = new SkillCowRequestSubmissionClient();

            rsc.AddNewItem(new SkillCowRequestSubmission
            {
                Salutation       = salutation,
                Name             = (firstname + " " + lastname).Trim(),
                Zip              = zip,
                Email            = email,
                Address1         = address1,
                City             = city,
                State            = state,
                Phone            = phone,
                IP               = ipaddress,
                Mode             = "CareerThesaurus",
                CampaignId       = campaignid,
                TestResults      = testresults,
                SourceForm       = target,
                GradYear         = gradyear,
                EduIntent        = "YES",
                Recommendations  = recommendations,
                ClientId         = clientid,
                FormId           = formid,
                CampusKey        = campuskey,
                ProgramKey       = programkey,
                Gender           = gender,
                SubmissionResult = submissionResult,
                Data             = data,
                UtmSource        = utmsource,
                UtmCampaign      = utmcampaign,
                UtmContent       = utmcontent,
                UtmTerm          = utmterm,
                PostedString     = strPost,
                ClientType       = clienttype
            });

            AddresseeClient adc            = new AddresseeClient();
            string          emailpartition = AddresseeClient.GetPartitionKeyForEmail(email);
            Addressee       a = adc.GetByPartitionAndRowKey(emailpartition, email);

            if (a == null)
            {
                adc.AddNewItem(new Addressee(email.ToLower())
                {
                    Name = firstname, Email = email.ToLower()
                });

                UserProfileClient upc     = new UserProfileClient();
                UserProfile       profile = new UserProfile(email.ToLower())
                {
                    Gender       = gender,
                    Salutation   = salutation,
                    FirstName    = firstname,
                    LastName     = lastname,
                    Email        = email,
                    Unsubscribed = false,
                    Zip          = zip,
                    Address1     = address1,
                    City         = city,
                    State        = state,
                    Phone        = phone,
                    CampaignId   = campaignid,
                    GradYear     = gradyear,
                    EduIntent    = "YES"
                };
                profile.PopulateCityAndState();
                profile.SetTestResults(Request);
                profile.SetImportantThings(Request);
                upc.AddNewItem(profile);
            }

            //============================================================================================================================================================================================
            return(submissionResult);
        }