예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Ajax.Utility.RegisterTypeForAjax(typeof(Photo_PhotoView));
        this.Form.Action = Request.RawUrl;
        try
        {
            //LHK: 3:59 PM 9/5/2011 - Wordpress topURL
            if (Request.QueryString["topurl"] != null)
            {
                _TopUrl = Request.QueryString["topurl"].ToString();
                Response.Cookies["topurl"].Value = _TopUrl;
                Response.Cookies["topurl"].Domain = _TopUrl;
                Response.Cookies["topurl"].Expires = DateTime.Now.AddHours(4);
            }
            lbtnPost.Attributes.Add("onclick", "setIsInTopurl();");

            GetValuesFromSession(); //to get values of logged in user and selected tribute from session.
            UserIsAdmin();
            SetValuesToControls();
            SetControlsVisibility();

            //Start - Modification on 9-Dec-09 for the enhancement 3 of the Phase 1
            if (_tributeName != null) Page.Title = _tributeName + " | Photo";
            //End

            if (!this.IsPostBack)
            {
                this._presenter.GetPhotoDetails();
                //Page.SetFocus(txtPhotoComment);
            }

            if (Request.QueryString["PhotoId"] != null)
            {
                if (int.TryParse(Request.QueryString["PhotoId"], out _photoId))
                    Session["PhotoId"] = _photoId.ToString();
            }
            MiscellaneousController objMisc = new MiscellaneousController();
            bool isAllowedPhotoCheck = false;
            string tributeEndDate = objMisc.GetTributeEndDate(_tributeId);
            DateTime date2 = new DateTime();
            //MG:Expiry Notice
            DateTime dt = new DateTime();
            if (!tributeEndDate.Equals("Never"))
            {
                if (tributeEndDate.Contains("/"))
                {
                    string[] date = tributeEndDate.Split('/');
                    date2 = new DateTime(int.Parse(date[2]), int.Parse(date[0]), int.Parse(date[1]));

                }
            }
            isAllowedPhotoCheck = objMisc.IsAllowedPhotoCheckonPhotoId(PhotoId);
            _packageId = objMisc.GetPackIdonPhotoId(PhotoId);
            StateManager objStateManager = StateManager.Instance;
            IsCustomHeaderOn = _presenter.GetCustomHeaderDetail(_tributeId);
            //to get user id from session as user is logged in user
            objSessionValue = (SessionValue)objStateManager.Get("objSessionvalue", StateManager.State.Session);
            if (((_packageId == 5) && !isAllowedPhotoCheck && (date2 < DateTime.Now)))
            {
                if (Equals(objSessionValue, null))//when not logged in
                {
                    if (IsCustomHeaderOn)
                        topHeight = 198;
                    else
                        topHeight = 88;
                }
                else
                {
                    if (IsCustomHeaderOn)
                        topHeight = 261;
                    else
                        topHeight = 133;
                }

                if (WebConfig.ApplicationMode.Equals("local"))
                {
                    appDomian = WebConfig.AppBaseDomain.ToString();
                }
                else
                {
                    StateManager stateManager = StateManager.Instance;
                    Tributes objTrib = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session);
                    appDomian = "http://" + objTrib.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/";
                }
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "awe", "fnReachLimitExpiryPopup('location.href','document.title','UpgradePhoto','" + _tributeUrl + "','" + _tributeId + "','" + appDomian + "','" + topHeight + "');", true);
            }

            if (Request.QueryString["View"] != null)
            {

                TributePackage objpackage = new TributePackage();
                Tributes objTributes = objTribute = (Tributes)objStateManager.Get(PortalEnums.SessionValueEnum.TributeSession.ToString(), StateManager.State.Session);
                if (objTributes != null)
                {
                    if (string.IsNullOrEmpty(objTributes.TributePackageType))
                    {
                        _packageId = _presenter.GetTributePackageId(_tributeId);
                    }
                    else
                    {
                        if (objTributes.TributePackageType.Equals("Tribute (Never)"))
                            _packageId = 4;
                        else if (objTributes.TributePackageType.StartsWith("Tribute ("))
                            _packageId = 5;
                    }
                }
                if (!this.IsPostBack)
                {

                    if (WebConfig.ApplicationMode.Equals("local"))
                    {
                        appDomian = WebConfig.AppBaseDomain.ToString();
                    }
                    else
                    {
                        appDomian = "http://" + _tributeType.ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/";
                    }
                    IsCustomHeaderOn = _presenter.GetCustomHeaderDetail(_tributeId);
                    if ((_packageId == 6) || (_packageId == 7) || (_packageId == 8))
                    {
                        if (Equals(objSessionValue, null))//when not logged in
                        {
                            if (IsCustomHeaderOn)
                                topHeight = 198;
                            else
                                topHeight = 81;
                        }
                        else
                        {
                            if (IsCustomHeaderOn)
                                topHeight = 261;
                            else
                                topHeight = 133;
                        }
                        if (Request.QueryString["PhotoId"] != null)
                        {
                            if (int.TryParse(Request.QueryString["PhotoId"], out _photoId))
                                Session["PhotoId"] = _photoId.ToString();
                        }
                        if (WebConfig.ApplicationMode.Equals("local"))
                        {
                            appDomian = WebConfig.AppBaseDomain.ToString();
                        }
                        else
                        {
                            StateManager stateManager = StateManager.Instance;
                            Tributes objTrib = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session);
                            appDomian = "http://" + objTrib.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/";
                        }
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "awe", "fnReachLimitExpiryPopup('location.href','document.title','UpgradePhoto','" + _tributeUrl + "','" + _tributeId + "','" + appDomian + "','" + topHeight + "');", true);
                    }
                    else if ((objTributes.TributePackageType.Equals("Tribute (Never)")) || (objTributes.TributePackageType.StartsWith("Tribute (")))
                    {
                        if (objTributes != null)
                        {

                            if (Request.QueryString["TributeUrl"] != null)
                                _tributeUrl = Request.QueryString["TributeUrl"].ToString();

                            if (!File.Exists(strBigImage))
                            {
                                //show big image
                                string redirectScript = "<script>window.open('" + strBigImage + "');</script>";
                                Response.Write(redirectScript);

                            }
                            else if (!File.Exists(SmallImage))
                            {
                                //show small image
                                string redirectScript = "<script>window.open('" + SmallImage + "');</script>";
                                Response.Write(redirectScript);
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Redirect(WebConfig.AppBaseDomain.ToString() + "Errors/Error404.aspx");
        }
    }