Ejemplo n.º 1
0
 public SiteMasterHelper(AppCookies bprPreferences, DataAccessHelper dataAccessHelper)
 {
     _bprPreferences = bprPreferences;
     _dataAccessHelper = dataAccessHelper;
 }
Ejemplo n.º 2
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string category = context.RouteData.Values["category"] as string;
            string city = context.RouteData.Values["city"] as string;
            string area = context.RouteData.Values["area"] as string;
            string contractor = context.RouteData.Values["contractor"] as string;

            int concatareaid = 0;
            int concatid = 0;
            int cityid = 0;
            int areaid = 0;
            int catid = 0;
            int cid = 0;

            if (city != null && area != null && category != null && contractor != null)
            {
                //Get combination areaid/cityid/categoryid/contractorid
                string sql = "SELECT CityInfo.CityID, AreaInfo.AreaID, ContractorInfo.ContractorID, CategoryInfo.CategoryID, ContractorCategoryAreaRel.ContractorCategoryID, ContractorCategoryAreaRel.ContractorCategoryAreaID FROM ContractorCategory INNER JOIN " +
                    "CategoryInfo ON ContractorCategory.CategoryID = CategoryInfo.CategoryID INNER JOIN ContractorInfo ON ContractorCategory.ContractorID = ContractorInfo.ContractorID " +
                    "INNER JOIN CityInfo INNER JOIN ContractorCategoryAreaRel INNER JOIN AreaInfo ON ContractorCategoryAreaRel.AreaID = AreaInfo.AreaID ON CityInfo.CityID = AreaInfo.CityID ON " +
                    "ContractorCategory.ContractorCategoryID = ContractorCategoryAreaRel.ContractorCategoryID WHERE (CityInfo.UrlName = @CITY) AND (AreaInfo.UrlName = @AREA) AND " +
                    "(CategoryInfo.UrlName = @CAT) AND (ContractorInfo.UrlName = @CONT)";

                using (SqlConnection conn = new SqlConnection(dataAccessHelper.ConnString))
                {
                    conn.Open();

                    SqlDataReader rdr = dataAccessHelper.Data.ExecuteDatareader(conn, sql,
                        new SqlParameter("@AREA", area),
                        new SqlParameter("@CITY", city),
                        new SqlParameter("@CAT", category),
                        new SqlParameter("@CONT", contractor));

                    if (rdr.Read())
                    {
                        concatareaid = int.Parse(rdr["contractorcategoryareaid"].ToString());
                        concatid = int.Parse(rdr["contractorcategoryid"].ToString());
                        cityid = int.Parse(rdr["cityid"].ToString());
                        areaid = int.Parse(rdr["areaid"].ToString());
                        catid = int.Parse(rdr["categoryid"].ToString());
                        cid = int.Parse(rdr["contractorid"].ToString());
                    }
                    rdr.Close();

                    conn.Close();
                }
            }

            if (cityid == 0 || areaid == 0 || catid == 0 || cid == 0)
            {
                //Redirect to category page instead of error page
                HttpContext.Current.Response.Redirect("/" + category + "/" + city + "/" + area);

                //We have an error if a city or area was not found
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            else
            {
                HttpContext.Current.Items["contractorcategoryareaid"] = concatareaid;
                HttpContext.Current.Items["contractorcategoryid"] = concatid;
                HttpContext.Current.Items["categoryid"] = catid;
                HttpContext.Current.Items["cityid"] = cityid;
                HttpContext.Current.Items["areaid"] = areaid;
                HttpContext.Current.Items["city"] = city;
                HttpContext.Current.Items["area"] = area;
                HttpContext.Current.Items["contractorid"] = cid;
                HttpContext.Current.Items["isppc"] = "false";
                if (MobileBlogHelper.isMobileVersionRequested(context))
                {
                    if (MobileBlogHelper.isAdPageRequired(context))
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("/mobile/ad.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                    }
                    return BuildManager.CreateInstanceFromVirtualPath("/mobile/contractor.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                }
                return BuildManager.CreateInstanceFromVirtualPath("/contractor.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
        }
Ejemplo n.º 3
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string category = context.RouteData.Values["category"] as string;
            string city = context.RouteData.Values["city"] as string;
            string area = context.RouteData.Values["area"] as string;

            int cityid = 0;
            int areaid = 0;
            int catid = 0;
            int catareaid = 0;

            if (city != null && area != null && category != null)
            {
                string sql = "SELECT CategoryInfo.CategoryID, CategoryArea.CategoryAreaID, CityInfo.CityID, AreaInfo.AreaID " +
                        "FROM CategoryArea INNER JOIN CategoryInfo ON CategoryArea.CategoryID = CategoryInfo.CategoryID INNER JOIN " +
                        "AreaInfo ON CategoryArea.AreaID = AreaInfo.AreaID INNER JOIN CityInfo ON AreaInfo.CityID = CityInfo.CityID WHERE (AreaInfo.UrlName = @AREA) AND " +
                        "(CityInfo.UrlName = @CITY) AND (CategoryInfo.UrlName = @CAT)";

                using (SqlConnection conn = new SqlConnection(dataAccessHelper.ConnString))
                {
                    conn.Open();

                    SqlDataReader rdr = dataAccessHelper.Data.ExecuteDatareader(conn, sql,
                        new SqlParameter("@AREA", area),
                        new SqlParameter("@CITY", city),
                        new SqlParameter("@CAT", category));

                    if (rdr.Read())
                    {
                        cityid = int.Parse(rdr["cityid"].ToString());
                        areaid = int.Parse(rdr["areaid"].ToString());
                        catid = int.Parse(rdr["categoryid"].ToString());
                        catareaid = int.Parse(rdr["categoryareaid"].ToString());
                    }
                    rdr.Close();

                    conn.Close();
                }
            }

            if (cityid == 0 || areaid == 0 || catareaid == 0)
            {
                //We have an error if a city or area was not found
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            else
            {
                HttpContext.Current.Items["categoryareaid"] = catareaid;
                HttpContext.Current.Items["categoryid"] = catid;
                HttpContext.Current.Items["cityid"] = cityid;
                HttpContext.Current.Items["areaid"] = areaid;
                HttpContext.Current.Items["city"] = city;
                HttpContext.Current.Items["area"] = area;
                HttpContext.Current.Items["category"] = category;
                HttpContext.Current.Items["isppc"] = "true";
                if (MobileBlogHelper.isMobileVersionRequested(context))
                {
                    if (MobileBlogHelper.isAdPageRequired(context))
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("/mobile/ad.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                    }
                    return BuildManager.CreateInstanceFromVirtualPath("/mobile/Category.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                }
                return BuildManager.CreateInstanceFromVirtualPath("/category.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
        }
Ejemplo n.º 4
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string param1 = context.RouteData.Values["param1"] as string;
            string param2 = context.RouteData.Values["param2"] as string;

            int m = 0;
            int y = 0;
            int cityid = 0;
            int catid = 0;
            int areaid = 0;
            string strcat = String.Empty;
            string strcity = String.Empty;
            string strarea = String.Empty;

            //if (String.CompareOrdinal(param1, param2) != 0)
            //{
            string sql = "";

            //Check values

            if (!int.TryParse(param1, out m) || !int.TryParse(param2, out y))
            {
                //Check for city filter first
                cityid = CityDL.GetIDByUrl(param2);
                strcity = param2;

                //Check for category filter
                catid = CategoriesDL.GetCategoryIdByUrl(param1);
                strcat = param1;

                if (cityid == 0 || catid == 0)
                {
                    if (param1 != null && param2 != null)
                    {
                        //Get combination areaid/cityid
                        sql =
                            "SELECT Area.AreaID, Area.CityID FROM Area INNER JOIN CityInfo ON Area.CityID = CityInfo.CityID INNER JOIN AreaInfo ON Area.AreaID = AreaInfo.AreaID " +
                            "WHERE (AreaInfo.UrlName = @AREA) AND (CityInfo.UrlName = @CITY)";

                        using (SqlConnection conn = new SqlConnection(dataAccessHelper.ConnString))
                        {
                            conn.Open();

                            SqlDataReader rdr = dataAccessHelper.Data.ExecuteDatareader(conn, sql,
                                                                                new SqlParameter("@AREA", param2),
                                                                                new SqlParameter("@CITY", param1));

                            if (rdr.Read())
                            {
                                cityid = int.Parse(rdr["cityid"].ToString());
                                areaid = int.Parse(rdr["areaid"].ToString());
                            }
                            rdr.Close();

                            conn.Close();
                        }
                        strcity = (cityid != 0) ? param1 : String.Empty;
                        strarea = (areaid != 0) ? param2 : String.Empty;
                    }
                    else
                    {
                        return
                            BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page))
                            as
                            System.Web.UI.Page;
                    }
                }
            }
            else
            {
                if (m < 0 || m > 12)
                    return
                        BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as
                        System.Web.UI.Page;
            }
            //}

            HttpContext.Current.Items["cityid"] = cityid;
            HttpContext.Current.Items["catid"] = catid;
            HttpContext.Current.Items["city"] = strcity;
            HttpContext.Current.Items["cat"] = strcat;
            HttpContext.Current.Items["areaid"] = areaid;
            HttpContext.Current.Items["area"] = strarea;
            HttpContext.Current.Items["month"] = m;
            HttpContext.Current.Items["year"] = y;

            if (MobileBlogHelper.isMobileVersionRequested(context))
            {
                return BuildManager.CreateInstanceFromVirtualPath("/blogfiles/mobile/default.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            return BuildManager.CreateInstanceFromVirtualPath("/blogfiles/default.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
        }
Ejemplo n.º 5
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string metro = context.RouteData.Values["metro"] as string;
            string sql = "";

            //Check for filter match
            int cityid = 0;

            //Check for city
            sql = "SELECT CityID FROM CityInfo WHERE (UrlName = @CITY)";
            object o = dataAccessHelper.Data.ExecuteScalar(sql,
                new SqlParameter("@CITY", SqlDbType.VarChar, 500, ParameterDirection.Input, false, 0, 0, "UrlName", DataRowVersion.Default, metro));

            if (o != null)
                cityid = int.Parse(o.ToString());
            else
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;

            HttpContext.Current.Items["cityid"] = cityid;
            HttpContext.Current.Items["city"] = metro;

            return BuildManager.CreateInstanceFromVirtualPath("/blogfiles/rss.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
        }
Ejemplo n.º 6
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string articlename = context.RouteData.Values["articlename"] as string;
            string category = context.RouteData.Values["category"] as string;

            // *** query database for page
            int articleid = 0;
            int catid = 0;

            using (SqlConnection conn = new SqlConnection(dataAccessHelper.ConnString))
            {
                conn.Open();

                string sql = "SELECT TipArticle.ArticleID, CategoryInfo.CategoryID FROM TipArticle INNER JOIN CategoryInfo ON TipArticle.CategoryID = CategoryInfo.CategoryID " +
                    "WHERE (TipArticle.UrlTitle = @TITLE) AND (CategoryInfo.UrlName = @CAT)";

                SqlDataReader rdr = dataAccessHelper.Data.ExecuteDatareader(conn, sql,
                    new SqlParameter("@TITLE", SqlDbType.VarChar, 150, ParameterDirection.Input, false, 0, 0, "UrlTitle", DataRowVersion.Default, articlename),
                    new SqlParameter("@CAT", SqlDbType.VarChar, 150, ParameterDirection.Input, false, 0, 0, "UrlName", DataRowVersion.Default, category));

                if (rdr.Read())
                {
                    articleid = int.Parse(rdr["ArticleID"].ToString());
                    catid = int.Parse(rdr["CategoryID"].ToString());
                }

                rdr.Close();
                conn.Close();
            }

            if (articleid == 0)
            {
                //We have an error if a page was not found
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            else
            {
                HttpContext.Current.Items["articleid"] = articleid;
                HttpContext.Current.Items["categoryid"] = catid;
                if (MobileBlogHelper.isMobileVersionRequested(context))
                {
                    if (MobileBlogHelper.isAdPageRequired(context))
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("/mobile/ad.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                    }
                    return BuildManager.CreateInstanceFromVirtualPath("/mobile/article.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                }
                return BuildManager.CreateInstanceFromVirtualPath("/article.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
        }
Ejemplo n.º 7
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string month = context.RouteData.Values["month"] as string;
            string year = context.RouteData.Values["year"] as string;
            string category = context.RouteData.Values["category"] as string;
            string metro = context.RouteData.Values["metro"] as string;
            string area;

            //Check values
            int m = 0;
            int y = 0;
            if (month != null && year != null)
            {
                if (!int.TryParse(month, out m) || !int.TryParse(year, out y))
                {
                    return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                }
                else
                {
                    if (m < 0 || m > 12)
                        return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
                }
            }

            //Check for filter match
            int cityid = 0;
            int catid = 0;
            int areaid = 0; //TODO get area info for city

            //Check for city filter first
            string sql = "SELECT CityID FROM CityInfo WHERE (URLName = @METRO)";
            object o = dataAccessHelper.Data.ExecuteScalar(sql,
                new SqlParameter("@METRO", SqlDbType.VarChar, 250, ParameterDirection.Input, false, 0, 0, "URLName", DataRowVersion.Default, metro));

            if (o != null)
                cityid = int.Parse(o.ToString());

            //Check for category filter
            sql = "SELECT BlogCatID FROM BlogCategories WHERE (BlogCatUrlName = @CAT)";
            object j = dataAccessHelper.Data.ExecuteScalar(sql,
                new SqlParameter("@CAT", SqlDbType.VarChar, 250, ParameterDirection.Input, false, 0, 0, "BlogCatUrlName", DataRowVersion.Default, category));

            if (j != null)
                catid = int.Parse(j.ToString());

            if (cityid == 0 || catid == 0 || m == 0 || y == 0 || areaid == 0)
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;

            //Check for area filter
            areaid = AreaDL.GetAreaIdByCityId(cityid.ToString());
            area = AreaDL.GetAreaUrlByID(areaid);

            HttpContext.Current.Items["cityid"] = cityid;
            HttpContext.Current.Items["catid"] = catid;
            HttpContext.Current.Items["areaid"] = areaid;
            HttpContext.Current.Items["city"] = metro;
            HttpContext.Current.Items["cat"] = category;
            HttpContext.Current.Items["area"] = area;
            HttpContext.Current.Items["month"] = m;
            HttpContext.Current.Items["year"] = y;

            if (MobileBlogHelper.isMobileVersionRequested(context))
            {
                return BuildManager.CreateInstanceFromVirtualPath("/blogfiles/mobile/default.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            return BuildManager.CreateInstanceFromVirtualPath("/blogfiles/default.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
        }
Ejemplo n.º 8
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string category = context.RouteData.Values["category"] as string;
            string city = context.RouteData.Values["city"] as string;
            string ppcname = context.RouteData.Values["ppcname"] as string;

            int ppcid = 0;
            int cityid = 0;
            int catid = 0;

            if (city != null && ppcname != null && category != null)
            {
                string sql = "SELECT PPCCategories.PPCCategoryID, PPCCategories.CityID, PPCCategories.CategoryID FROM CategoryCityRel INNER JOIN CategoryInfo ON CategoryCityRel.CategoryID = CategoryInfo.CategoryID INNER JOIN " +
                      "PPCCategories ON CategoryCityRel.CategoryID = PPCCategories.CategoryID AND CategoryCityRel.CityID = PPCCategories.CityID WHERE " +
                      "(CategoryInfo.UrlName = @CAT) AND (CategoryCityRel.UrlName = @CITY) AND (PPCCategories.PPCUrlTitle = @URL)";

                using (SqlConnection conn = new SqlConnection(dataAccessHelper.ConnString))
                {
                    conn.Open();

                    SqlDataReader rdr = dataAccessHelper.Data.ExecuteDatareader(conn, sql,
                        new SqlParameter("@URL", ppcname),
                        new SqlParameter("@CITY", city),
                        new SqlParameter("@CAT", category));

                    if (rdr.Read())
                    {
                        cityid = int.Parse(rdr["cityid"].ToString());
                        ppcid = int.Parse(rdr["ppccategoryid"].ToString());
                        catid = int.Parse(rdr["categoryid"].ToString());
                    }
                    rdr.Close();

                    conn.Close();
                }
            }

            if (cityid == 0 || ppcid == 0 || catid == 0)
            {
                //We have an error if a city or area was not found
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            else
            {
                HttpContext.Current.Items["categoryid"] = catid;
                HttpContext.Current.Items["cityid"] = cityid;
                HttpContext.Current.Items["ppcid"] = ppcid;
                HttpContext.Current.Items["city"] = city;
                HttpContext.Current.Items["ppcname"] = ppcname;
                HttpContext.Current.Items["category"] = category;
                return BuildManager.CreateInstanceFromVirtualPath("/ppclanding.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
        }
Ejemplo n.º 9
0
        public IHttpHandler GetHttpHandler(RequestContext context)
        {
            var dataAccessHelper = new DataAccessHelper();

            string city = context.RouteData.Values["city"] as string;

            int cityid = 0;

            if (city != null)
            {
                //Get cityid
                string sql = "SELECT CityID FROM CityInfo WHERE (CityInfo.UrlName = @CITY)";

                using (SqlConnection conn = new SqlConnection(dataAccessHelper.ConnString))
                {
                    conn.Open();

                    SqlDataReader rdr = dataAccessHelper.Data.ExecuteDatareader(conn, sql,
                        new SqlParameter("@CITY", city));

                    if (rdr.Read())
                    {
                        cityid = int.Parse(rdr["cityid"].ToString());
                    }
                    rdr.Close();

                    conn.Close();
                }
            }

            if (cityid == 0)
            {
                //We have an error if a city or area was not found
                return BuildManager.CreateInstanceFromVirtualPath("/error.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
            else
            {
                HttpContext.Current.Items["cityid"] = cityid;
                HttpContext.Current.Items["city"] = city;
                return BuildManager.CreateInstanceFromVirtualPath("/city.aspx", typeof(System.Web.UI.Page)) as System.Web.UI.Page;
            }
        }
Ejemplo n.º 10
0
        public BlogServiceResponse SubmitEmailForm(EmailFormContract emailForm)
        {
            string sql = "";
            var dataAccessHelper = new DataAccessHelper();

            bool error = false;

            #region Error Checking

            bool isFirstNameValid = true,
                isLastNameValid = true,
                isStreetAddressValid = true,
                isZipValid = true,
                isEmailValid = true,
                isPrimaryPhoneValid = true,
                isWorkTypeValid = true,
                isMessageValid = true;

            if (String.IsNullOrEmpty(emailForm.FirstName))
                isFirstNameValid = false;
            if (String.IsNullOrEmpty(emailForm.LastName))
                isLastNameValid = false;
            if (String.IsNullOrEmpty(emailForm.StreetAddress))
                isStreetAddressValid = false;
            if (String.IsNullOrEmpty(emailForm.ZipCode) || !Global.IsZipCode(emailForm.ZipCode))
                isZipValid = false;
            if (String.IsNullOrEmpty(emailForm.Email) || !Global.IsEmail(emailForm.Email))
                isEmailValid = false;
            if (String.IsNullOrEmpty(emailForm.PrimaryPhone) || !Global.IsPhoneNumber(emailForm.PrimaryPhone))
                isPrimaryPhoneValid = false;
            if (String.IsNullOrEmpty(emailForm.TypeOfWork))
                isWorkTypeValid = false;
            if (String.IsNullOrEmpty(emailForm.Message))
                isMessageValid = false;

            error =
                !(isFirstNameValid && isLastNameValid && isStreetAddressValid && isZipValid && isEmailValid &&
                  isPrimaryPhoneValid && isWorkTypeValid && isMessageValid);

            #endregion

            if (!error)
            {
                string contractorMsg = "";
                contractorMsg += "<span style=\"font-family:Arial; font-size:12px;\"><strong>Name: </strong>" +
                                 emailForm.FirstName + " " + emailForm.LastName + "<br/><strong>Address: </strong>" +
                                 emailForm.StreetAddress + "<br/><strong>City: </strong>" + emailForm.City +
                                 "<br/><strong>Zip Code: </strong>" + emailForm.ZipCode +
                                 "<br/><strong>Email: </strong>" + emailForm.Email + "<br>";
                contractorMsg += "<strong>Phone: </strong>" + emailForm.PrimaryPhone + "<br/><strong>Phone 2: </strong>" +
                                 emailForm.AlternatePhone + "<br/><strong>Work Type: </strong>" + emailForm.TypeOfWork +
                                 "<br/><strong>Message: </strong>" + emailForm.Message;
                contractorMsg += "</span>";
                //string adminMsg = "<font face='Arial' size='2'>Someone showed interest in <strong>" + ContractorName.Value + "</strong><br/><br/>" + contractorMsg + "</font>";

                string subjectMsg = "";

                //Parse comma separated list of emails - check if we are sending to multiples first
                if (emailForm.ContractorEmails != null && !BWSession.emailStartedAndSent)
                {
                    BWSession.emailStartedAndSent = true;

                    string localconid = "";

                    try
                    {
                        foreach (string strid in emailForm.ContractorEmails)
                        {
                            subjectMsg = "Best Pick Reports Website Lead";

                            //Lookup emails from contractorcategoryareaid
                            InfoLevel conInfoLevel = InfoLevel.Area;
                            bool isPrimary = false;
                            // if contractorCategoryId is Primary
                            DataRow conRow = dataAccessHelper.FindInfoRecord(InfoType.ContractorCategoryArea, int.Parse(strid), ref conInfoLevel, ref isPrimary);
                            if (conRow != null)
                            {
                                //Lookup contractor id
                                sql =
                                    "SELECT ContractorID FROM ContractorCategoryInfo WHERE ContractorCategoryID = @CCID";
                                object o = dataAccessHelper.Data.ExecuteScalar(sql,
                                    new SqlParameter("@CCID", conRow["contractorcategoryid"].ToString()));
                                if (o != null)
                                    localconid = o.ToString();

                                string[] emails = conRow["email"].ToString().Trim().Split(',');
                                foreach (string stremail in emails)
                                {
                                    if (Global.IsEmail(stremail.Trim()))
                                    {
                                        try
                                        {
                                            // Send email to contractor
                                            //!!!!HARD CODED FOR TLC DECKS
                                            if (localconid == "215")
                                                subjectMsg = "Home Reports – Dispatch 6106";

                                            Global.SendEmailNotification(stremail.Trim(), subjectMsg,
                                                ConfigurationManager.AppSettings["EmailNotification"], contractorMsg,
                                                true);
                                        }
                                        catch (Exception)
                                        {
                                            // TODO: log error in database that email couldn't be sent???
                                        }
                                    }
                                }

                                // commit contractorMsg to database
                                string insertsql =
                                    "INSERT INTO EmailData (DateSent, AreaID, CityID, CategoryID, ContractorID, FirstName, LastName, Address, City, Zip, Email, Phone, Phone2, WorkType, Message, IsPPC) " +
                                    "VALUES (@DATESENT, @AREAID, @CITYID, @CATEGORYID, @CONTRACTORID, @FIRSTNAME, @LASTNAME, @ADDRESS, @CITY, @ZIP, @EMAIL, @PHONE, @PHONE2, @WORKTYPE, @MESSAGE, @PPC)";
                                dataAccessHelper.Data.ExecuteNonQuery(insertsql,
                                    new SqlParameter("@DATESENT", DateTime.Now),
                                    new SqlParameter("@AREAID", emailForm.AreaId), //TODO get rest of the values
                                    new SqlParameter("@CITYID", emailForm.CityId),
                                    new SqlParameter("@CATEGORYID", emailForm.CategoryId),
                                    new SqlParameter("@CONTRACTORID", int.Parse(localconid)),
                                    new SqlParameter("@FIRSTNAME", emailForm.FirstName),
                                    new SqlParameter("@LASTNAME", emailForm.LastName),
                                    new SqlParameter("@ADDRESS", emailForm.StreetAddress),
                                    new SqlParameter("@CITY", emailForm.City),
                                    new SqlParameter("@ZIP", emailForm.ZipCode.Trim()),
                                    new SqlParameter("@EMAIL", emailForm.Email),
                                    new SqlParameter("@PHONE", emailForm.PrimaryPhone),
                                    new SqlParameter("@PHONE2", emailForm.AlternatePhone),
                                    new SqlParameter("@WORKTYPE", emailForm.TypeOfWork),
                                    new SqlParameter("@PPC", emailForm.IsPpc),
                                    new SqlParameter("@MESSAGE", emailForm.Message.Trim()));
                            }
                        }
                    }
                    catch (Exception)
                    {

                    }
                    finally
                    {
                        BWSession.emailStartedAndSent = false;
                    }
                }
                /*
                //Don't need to use separated fields for single and multiple contractors
                else if (ContractorEmail.Value.Trim() != "" && !BWSession.emailStartedAndSent)
                {
                    string[] emails = ContractorEmail.Value.Trim().Split(',');
                    foreach (string stremail in emails)
                    {
                        subjectMsg = "Best Pick Reports Website Lead";

                        if (Global.IsEmail(stremail.Trim()))
                        {
                            try
                            {
                                // Send email to contractor
                                //!!!!HARD CODED FOR TLC DECKS
                                if (EmailContractorID.Value == "215")
                                    subjectMsg = "Home Reports – Dispatch 6106";

                                Global.SendEmailNotification(stremail.Trim(), subjectMsg, ConfigurationManager.AppSettings["EmailNotification"], contractorMsg, true);
                                BWSession.emailStartedAndSent = true;
                            }
                            catch (Exception)
                            {
                                // TODO: log error in database that email couldn't be sent???
                            }
                        }
                    }

                    // commit contractorMsg to database
                    string insertsql = "INSERT INTO EmailData (DateSent, AreaID, CityID, CategoryID, ContractorID, FirstName, LastName, Address, City, Zip, Email, Phone, Phone2, WorkType, Message, IsPPC) " +
                        "VALUES (@DATESENT, @AREAID, @CITYID, @CATEGORYID, @CONTRACTORID, @FIRSTNAME, @LASTNAME, @ADDRESS, @CITY, @ZIP, @EMAIL, @PHONE, @PHONE2, @WORKTYPE, @MESSAGE, @PPC)";
                    basePage.Data.ExecuteNonQuery(insertsql,
                        new SqlParameter("@DATESENT", DateTime.Now),
                        new SqlParameter("@AREAID", areaID),
                        new SqlParameter("@CITYID", cityID),
                        new SqlParameter("@CATEGORYID", catid),
                        new SqlParameter("@CONTRACTORID", int.Parse(EmailContractorID.Value)),
                        new SqlParameter("@FIRSTNAME", name),
                        new SqlParameter("@LASTNAME", lastname),
                        new SqlParameter("@ADDRESS", addr),
                        new SqlParameter("@CITY", City.Text.Trim()),
                        new SqlParameter("@ZIP", Zip.Text.Trim()),
                        new SqlParameter("@EMAIL", email),
                        new SqlParameter("@PHONE", phone),
                        new SqlParameter("@PHONE2", phone2),
                        new SqlParameter("@WORKTYPE", worktype),
                        new SqlParameter("@PPC", isppc),
                        new SqlParameter("@MESSAGE", Message.Text.Trim()));
                }
                */

                //// Hide the email form and show the "Email Sent" div
                //ModalEmailForm.Visible = false;
                //ReqPanel.Visible = false;
                //EmailComplete.Visible = true;
                return new BlogServiceResponse(true, "Email sent.");
            }
            else
            {
                //// If this style isn't set, the modal popup won't display
                //ModalEmailForm.Style.Value = "display:block";
                //ReqPanel.Visible = true;
                //SendEmail.Show();
                return new BlogServiceResponse(false, "Email send failed.");
            }
        }
Ejemplo n.º 11
0
 public SiteMobileMaster()
 {
     _dataAccessHelper = new DataAccessHelper();
     _bprPreferences = AppCookies.CreateInstance();
     _siteMasterHelper = new SiteMasterHelper(_bprPreferences, _dataAccessHelper);
 }
Ejemplo n.º 12
0
        public static void SaveFormData(string firstname, string mi, string lastname, string email, string address, string city, string state, string zip, bool updates, bool future, int type, int areaid, int cityid)
        {
            var dataSetHepler = new DataAccessHelper();
            string sql = "INSERT INTO FormData (DataType, AreaID, CityID, FirstName, MI, LastName, Email, Address, City, State, Zip, Updates, FutureEditions) VALUES (@TYPE, @AREAID, @CITYID, @FNAME, @MI, @LNAME, @EMAIL, @ADDRESS, @CITY, @STATE, @ZIP, @UPDATES, @FUTURE)";
            dataSetHepler.Data.ExecuteNonQuery(sql,
                new SqlParameter("@TYPE", type),
                new SqlParameter("@CITYID", cityid),
                new SqlParameter("@AREAID", areaid),
                new SqlParameter("@FNAME", firstname),
                new SqlParameter("@LNAME", lastname),
                new SqlParameter("@MI", mi),
                new SqlParameter("@EMAIL", email),
                new SqlParameter("@ADDRESS", address),
                new SqlParameter("@CITY", city),
                new SqlParameter("@STATE", state),
                new SqlParameter("@ZIP", zip),
                new SqlParameter("@FUTURE", future),
                new SqlParameter("@UPDATES", updates));

            //Send email
            string msg = "<span style=\"font-family:Arial; font-size:12px;\">";
            string subject = "";

            msg += "<p>This form submission was made on <strong>" + DateTime.Now.ToString() + "</strong></p>";

            if (type == 1)
            {
                subject = "Newsletter Sign Up Submission";
                msg += "<p>A user has signed up for monthly home care tips and articles via <a href=\"www.bestpickreports.com\">www.bestpickreports.com</a></p><p>Details are below:</p>";
            }
            else if (type == 2)
            {
                subject = "Request a Guide Submission";
                msg += "<p>A user has requested a guide via <a href=\"www.bestpickreports.com\">www.bestpickreports.com</a></p><p>Details are below:</p>";
            }

            msg += "<strong>First Name: </strong>" + firstname + "<br />";
            msg += "<strong>Middle Initial: </strong>" + mi + "<br />";
            msg += "<strong>Last Name: </strong>" + lastname + "<br />";
            msg += "<strong>Email Address: </strong>" + email + "<br />";

            if (type == 2)
            {
                msg += "<strong>Address: </strong>" + address + "<br />";
                msg += "<strong>City: </strong>" + city + "<br />";
                msg += "<strong>State: </strong>" + state + "<br />";
                msg += "<strong>Zip Code: </strong>" + zip + "<br />";
                msg += "<strong>Receive Updates: </strong>" + updates + "<br />";
            }

            msg += "</span>";

            try
            {
                SendEmailNotification("*****@*****.**", subject, ConfigurationManager.AppSettings["EmailRequest"], msg, true);
            }
            catch (Exception)
            {
            }
        }