public void ProcessRequest(HttpContext context)
        {
            var pendingImg = ((byte[])context.Session["PendingAvatar"]);

            if (pendingImg != null && pendingImg.Length > 0)
            {
                //pending avatar change present to return it for the image
                context.Response.ContentType = "image/jpg";

                context.Response.BinaryWrite(pendingImg);
                return;
            }

            LoginRow = (GTService.Common.sp_GetLoginRow)context.Session["LoggedInUser"];

            using (QueriesTableAdapters.sp_GetUserImageTableAdapter ta = new QueriesTableAdapters.sp_GetUserImageTableAdapter())
            {
                using (Queries.sp_GetUserImageDataTable userImage = new Queries.sp_GetUserImageDataTable())
                {
                    ta.Fill(userImage, LoginRow.user_id);

                    if (userImage.FirstOrDefault().IsimageNull())
                    {
                        //no image in database
                        context.Response.ContentType = "image/jpg";
                        var webClient = new System.Net.WebClient();
                        var bytes = webClient.DownloadData(new Uri(context.Request.Url, "/Images/master/blankavatar.jpg").AbsoluteUri);
                        context.Response.BinaryWrite(bytes);
                    }
                    else
                    {
                        //image found
                        context.Response.ContentType = "image/jpg";
                        context.Response.BinaryWrite(userImage.FirstOrDefault().image);
                    }
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            var pendingImg = ((byte[])context.Session["PendingAvatar"]);

            if (pendingImg != null && pendingImg.Length > 0)
            {
                //pending avatar change present to return it for the image
                context.Response.ContentType = "image/jpg";

                context.Response.BinaryWrite(pendingImg);
                return;
            }

            LoginRow = (GTService.Common.sp_GetLoginRow)context.Session["LoggedInUser"];

            using (QueriesTableAdapters.sp_GetUserImageTableAdapter ta = new QueriesTableAdapters.sp_GetUserImageTableAdapter())
            {
                using (Queries.sp_GetUserImageDataTable userImage = new Queries.sp_GetUserImageDataTable())
                {
                    ta.Fill(userImage, LoginRow.user_id);

                    if (userImage.FirstOrDefault().IsimageNull())
                    {
                        //no image in database
                        context.Response.ContentType = "image/jpg";
                        var webClient = new System.Net.WebClient();
                        var bytes     = webClient.DownloadData(new Uri(context.Request.Url, "/Images/master/blankavatar.jpg").AbsoluteUri);
                        context.Response.BinaryWrite(bytes);
                    }
                    else
                    {
                        //image found
                        context.Response.ContentType = "image/jpg";
                        context.Response.BinaryWrite(userImage.FirstOrDefault().image);
                    }
                }
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //redirect if not logged in
            if (Session["LoggedInUser"] == null)
            {
                Response.Redirect("~/Account/Login.aspx");
            }
            else
            {
                LoginRow = (GTService.Common.sp_GetLoginRow)Session["LoggedInUser"];

                if (Session["LoggedInUserId"] != null)
                {
                    Session["LoggedInUserId"] = LoginRow.user_id;
                }
                else
                {
                    Session.Add("LoggedInUserId", LoginRow.user_id);
                }
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (!IsPostBack)
            {
                SetResources();

                Populate_YearDropdown(ddBirthdate_Year);
                Populate_MonthDropdown(ddBirthdate_Month);

                //get current settings
                using (QueriesTableAdapters.sp_GetUserSettingsTableAdapter ta = new QueriesTableAdapters.sp_GetUserSettingsTableAdapter())
                {
                    using (Queries.sp_GetUserSettingsDataTable dt = new Queries.sp_GetUserSettingsDataTable())
                    {
                        ta.Fill(dt, LoginRow.user_id);

                        PopulateTimeDropdown(ddMorningStart, Convert.ToInt32(dt[0]["start_morning"]));
                        PopulateTimeDropdown(ddAfternoonStart, Convert.ToInt32(dt[0]["start_afternoon"]));
                        PopulateTimeDropdown(ddNightStart, Convert.ToInt32(dt[0]["start_night"]));

                        this.txtFirstName.Text  = dt[0]["firstname"].ToString();
                        this.txtMiddleName.Text = dt[0]["middlename"].ToString();
                        this.txtLastName.Text   = dt[0]["lastname"].ToString();
                        this.txtAddress1.Text   = dt[0]["address1"].ToString();
                        this.txtAddress2.Text   = dt[0]["address2"].ToString();
                        this.txtCity.Text       = dt[0]["city"].ToString();

                        this.txtZipcode.Text           = dt[0]["zipcode"].ToString();
                        this.lblLastSyncValue.Text     = dt[0]["last_sync"].ToString();
                        this.lblLastWebLoginValue.Text = dt[0]["last_weblogin"].ToString();
                        this.txtEmail.Text             = dt[0]["email"].ToString();
                        this.txtOtherState.Text        = dt[0]["other_state"].ToString();

                        ddState.DataBind();
                        ddUserType.DataBind();
                        ddCountry.DataBind();
                        ddIncome.DataBind();
                        ddSex.DataBind();
                        ddRace.DataBind();
                        ddTimezone.DataBind();
                        ddDiabetesType.DataBind();

                        SelectInDropDown(ddState, dt[0]["state_id"].ToString().Trim());
                        SelectInDropDown(ddUserType, dt[0]["usertype_id"].ToString().Trim());
                        SelectInDropDown(ddCountry, dt[0]["country_id"].ToString().Trim());
                        SelectInDropDown(ddIncome, dt[0]["income_id"].ToString().Trim());
                        SelectInDropDown(ddSex, dt[0]["sex_id"].ToString().Trim());
                        SelectInDropDown(ddRace, dt[0]["race_id"].ToString().Trim());
                        SelectInDropDown(ddTimezone, dt[0]["timezone_id"].ToString().Trim());
                        SelectInDropDown(ddDiabetesType, dt[0]["diabetestypes_id"].ToString().Trim());

                        DateTime dtBirthDate = Convert.ToDateTime(dt[0]["birthdate"].ToString().Trim());
                        SelectInDropDown(ddBirthdate_Month, dtBirthDate.Month.ToString().Trim());
                        this.txtBirthdate_Day.Text = dtBirthDate.Day.ToString();
                        SelectInDropDown(ddBirthdate_Year, dtBirthDate.Year.ToString().Trim());
                    }
                }

                //shows the correct state/province field based on country settings (must be after population of fields)
                ShowStateSelection();

                //get user image
                using (QueriesTableAdapters.sp_GetUserImageTableAdapter ta = new QueriesTableAdapters.sp_GetUserImageTableAdapter())
                {
                    using (Queries.sp_GetUserImageDataTable dt = new Queries.sp_GetUserImageDataTable())
                    {
                        ta.Fill(dt, LoginRow.user_id);

                        if (dt.Rows.Count > 0)
                        {
                            PendingAvatar = dt[0].image;
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //redirect if not logged in
            if (Session["LoggedInUser"] == null)
            {
                Response.Redirect("~/Account/Login.aspx");
            }
            else
            {
                LoginRow = (GTService.Common.sp_GetLoginRow)Session["LoggedInUser"];

                if (Session["LoggedInUserId"] != null)
                    Session["LoggedInUserId"] = LoginRow.user_id;
                else
                    Session.Add("LoggedInUserId", LoginRow.user_id);
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            
            if (!IsPostBack)
            {
                SetResources();

                Populate_YearDropdown(ddBirthdate_Year);
                Populate_MonthDropdown(ddBirthdate_Month);

                //get current settings
                using (QueriesTableAdapters.sp_GetUserSettingsTableAdapter ta = new QueriesTableAdapters.sp_GetUserSettingsTableAdapter())
                {
                    using (Queries.sp_GetUserSettingsDataTable dt = new Queries.sp_GetUserSettingsDataTable())
                    {
                        ta.Fill(dt, LoginRow.user_id);

                        PopulateTimeDropdown(ddMorningStart, Convert.ToInt32(dt[0]["start_morning"]));
                        PopulateTimeDropdown(ddAfternoonStart, Convert.ToInt32(dt[0]["start_afternoon"]));
                        PopulateTimeDropdown(ddNightStart, Convert.ToInt32(dt[0]["start_night"]));

                        this.txtFirstName.Text = dt[0]["firstname"].ToString();
                        this.txtMiddleName.Text = dt[0]["middlename"].ToString();
                        this.txtLastName.Text = dt[0]["lastname"].ToString();
                        this.txtAddress1.Text = dt[0]["address1"].ToString();
                        this.txtAddress2.Text = dt[0]["address2"].ToString();
                        this.txtCity.Text = dt[0]["city"].ToString();

                        this.txtZipcode.Text = dt[0]["zipcode"].ToString();
                        this.lblLastSyncValue.Text = dt[0]["last_sync"].ToString();
                        this.lblLastWebLoginValue.Text = dt[0]["last_weblogin"].ToString();
                        this.txtEmail.Text = dt[0]["email"].ToString();
                        this.txtOtherState.Text = dt[0]["other_state"].ToString();

                        ddState.DataBind();
                        ddUserType.DataBind();
                        ddCountry.DataBind();
                        ddIncome.DataBind();
                        ddSex.DataBind();
                        ddRace.DataBind();
                        ddTimezone.DataBind();
                        ddDiabetesType.DataBind();

                        SelectInDropDown(ddState, dt[0]["state_id"].ToString().Trim());
                        SelectInDropDown(ddUserType, dt[0]["usertype_id"].ToString().Trim());
                        SelectInDropDown(ddCountry, dt[0]["country_id"].ToString().Trim());
                        SelectInDropDown(ddIncome, dt[0]["income_id"].ToString().Trim());
                        SelectInDropDown(ddSex, dt[0]["sex_id"].ToString().Trim());
                        SelectInDropDown(ddRace, dt[0]["race_id"].ToString().Trim());
                        SelectInDropDown(ddTimezone, dt[0]["timezone_id"].ToString().Trim());
                        SelectInDropDown(ddDiabetesType, dt[0]["diabetestypes_id"].ToString().Trim());

                        DateTime dtBirthDate = Convert.ToDateTime(dt[0]["birthdate"].ToString().Trim());
                        SelectInDropDown(ddBirthdate_Month, dtBirthDate.Month.ToString().Trim());
                        this.txtBirthdate_Day.Text = dtBirthDate.Day.ToString();
                        SelectInDropDown(ddBirthdate_Year, dtBirthDate.Year.ToString().Trim());
                    }
                }

                //shows the correct state/province field based on country settings (must be after population of fields)
                ShowStateSelection();

                //get user image
                using (QueriesTableAdapters.sp_GetUserImageTableAdapter ta = new QueriesTableAdapters.sp_GetUserImageTableAdapter())
                {
                    using (Queries.sp_GetUserImageDataTable dt = new Queries.sp_GetUserImageDataTable())
                    {
                        ta.Fill(dt, LoginRow.user_id);

                        if (dt.Rows.Count > 0)
                        {
                            PendingAvatar = dt[0].image;
                        }
                    }
                }
            }
        }