protected void lbtnAdd_Click(object sender, EventArgs e) { try { MiscellaneousController objMisc = new MiscellaneousController(); StateManager stateTribute = StateManager.Instance; SessionValue objSessvalue = (SessionValue)stateTribute.Get("objSessionvalue", StateManager.State.Session); #region TributeNotes if (_typeName == "TributeNotes") { Response.Redirect("~/" + Session["TributeURL"] + "/managenote.aspx", false); } #endregion #region VideoGallery else if (_typeName == "VideoGallery") { Response.Redirect("~/" + Session["TributeURL"] + "/addvideo.aspx", false); } #endregion #region Event else if (_typeName == PortalEnums.TributeContentEnum.Event.ToString()) { Response.Redirect("~/" + Session["TributeURL"] + "/manageevent.aspx", false); } #endregion #region EventFullView else if (_typeName == PortalEnums.TributeContentEnum.EventFullView.ToString()) { Response.Redirect(Session["APP_BASE_DOMAIN"].ToString() + Session["TributeURL"].ToString() + "/manageevent.aspx" + "?EventID=" + Session["EventIdForEdit"].ToString()); } #endregion #region PhotoGallery else if (_typeName == "PhotoGallery") { if (Equals(objSessionValue, null))//when not logged in { if (IsCustomHeaderOn) topHeight = 197; else topHeight = 78; } else { if (IsCustomHeaderOn) topHeight = 258; else topHeight = 131; } 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.IsAllowedPhotoCheck(_photoAlbumId); if ((_packageId == 6) || (_packageId == 7) || (_packageId == 3) || (_packageId == 8) | ((_packageId == 5) && !isAllowedPhotoCheck && (date2 < DateTime.Now))) { int CurrentAlbums = objMisc.GetCurrentPhotoAlbums(_tributeId); if (CurrentAlbums >= (int.Parse(WebConfig.PhotoAlbumLimit))) { if (Equals(objSessionValue, null))//when not logged in { if (IsCustomHeaderOn) topHeight = 197; else topHeight = 78; } else { if (IsCustomHeaderOn) topHeight = 258; else topHeight = 131; } ScriptManager.RegisterStartupScript(Page, this.GetType(), "awe", "fnReachLimitExpiryPopup('location.href','document.title','Photos','" + _tributeUrl + "','" + _tributeId + "','" + appDomian + "','" + topHeight + "');", true); } else { StateManager stateManager = StateManager.Instance; Tributes objTrb = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session); if (objTrb != null) { if (WebConfig.ApplicationMode.Equals("local")) { Response.Redirect("~/" + Session["TributeURL"] + "/managephotoalbum.aspx?albummode=Create&Type=" + objTrb.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby"), false); } else { appDomian = "~/" + Session["TributeURL"] + "/managephotoalbum.aspx?albummode=Create&Type=" + objTrb.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby"); Response.Redirect(appDomian, false); } } } } else { StateManager stateManager = StateManager.Instance; Tributes objTrb = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session); if (objTrb != null) { if (WebConfig.ApplicationMode.Equals("local")) { Response.Redirect("~/" + Session["TributeURL"] + "/managephotoalbum.aspx?albummode=Create&Type=" + objTrb.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby"), false); } else { appDomian = "~/" + Session["TributeURL"] + "/managephotoalbum.aspx?albummode=Create&Type=" + objTrb.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby"); Response.Redirect(appDomian, false); } } } } #endregion #region PhotoAlbum else if (_typeName == "PhotoAlbum") { StateManager stateManager = StateManager.Instance; Tributes objTrb = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session); if (objTrb != null) { if (WebConfig.ApplicationMode.Equals("local")) { Response.Redirect("~/" + Session["TributeURL"] + "/managephotoalbum.aspx" + "?mode=addphotos&photoAlbumId=" + _photoAlbumId + "&Type=" + objTrb.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby"), false); } else { appDomian = "~/" + Session["TributeURL"] + "/managephotoalbum.aspx" + "?mode=addphotos&photoAlbumId=" + _photoAlbumId + "&Type=" + objTrb.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby"); Response.Redirect(appDomian, false); } } } #endregion } catch (Exception ex) { throw ex; } }
protected void lBtnDownloadAlbum_Click(object sender, EventArgs e) { MiscellaneousController objMisc = new MiscellaneousController(); string[] getPath = CommonUtilities.GetPath(); StateManager objStateManager = StateManager.Instance; //to get logged in user name from session as user is logged in user objSessionValue = (SessionValue)objStateManager.Get("objSessionvalue", StateManager.State.Session); if (Request.QueryString["PhotoAlbumId"] != null) { if (int.TryParse(Request.QueryString["PhotoAlbumId"], out _photoAlbumId)) { DownloadPhotoAlbumId = _photoAlbumId; Session["PhotoAlbumId"] = _photoAlbumId.ToString(); string imagePath = string.Empty; Tributes objTributes = objTribute = (Tributes)objStateManager.Get(PortalEnums.SessionValueEnum.TributeSession.ToString(), StateManager.State.Session); if (objTributes != null) { if (string.IsNullOrEmpty(objTributes.TributePackageType)) { _packageId = objMisc.GetTributePackageId(_tributeId); } } 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.IsAllowedPhotoCheck(_photoAlbumId); if (((_packageId == 3) || (_packageId == 6) || (_packageId == 7) || (_packageId == 8)) || ((_packageId == 5) && !isAllowedPhotoCheck && (date2 < DateTime.Now))) { #region popup 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["PhotoAlbumId"] != null) { if (_photoAlbumId > 0) Session["PhotoAlbumId"] = _photoAlbumId.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','UpgradeAlbum','" + _tributeUrl + "','" + _tributeId + "','" + appDomian + "','" + topHeight + "');", true); #endregion } else { #region allowFunctionality List<Photos> objListPhotos = new List<Photos>(); Photos objPhotos = new Photos(); if (Request.QueryString["PhotoAlbumId"] != null) { int.TryParse(Request.QueryString["PhotoAlbumId"], out DownloadPhotoAlbumId); objPhotos.PhotoAlbumId = DownloadPhotoAlbumId; } objListPhotos = objMisc.GetPhotoImagesList(objPhotos); if ((DownloadPhotoAlbumId > 0) && (objListPhotos.Count > 0)) { // zip up the files try { string sTargetFolderPath = getPath[0] + "/" + getPath[1] + "/" + _tributeUrl.Replace(" ", "_") + "_" + _tributeType.Replace(" ", "_"); //to create directory for image. string galleryPath = getPath[0] + "/" + getPath[1] + "/" + getPath[6]; string sZipFileName = "Album_" + DownloadPhotoAlbumId.ToString(); string[] filenames = Directory.GetFiles(sTargetFolderPath); // Zip up the files - From SharpZipLib Demo Code using (ZipOutputStream s = new ZipOutputStream(File.Create(galleryPath + "\\" + sZipFileName + ".zip"))) { s.SetLevel(9); // 0-9, 9 being the highest level of compression byte[] buffer = new byte[4096]; foreach (Photos objPhoto in objListPhotos) { bool Foundflag = true; string ImageFile = string.Empty; string smallFile = string.Empty; ImageFile = sTargetFolderPath + "\\" + "/Big_" + objPhoto.PhotoImage; smallFile = sTargetFolderPath + "\\" + objPhoto.PhotoImage; foreach (string file in filenames) { if ((file.EndsWith("Big_" + objPhoto.PhotoImage)) && (File.Exists(ImageFile))) { Foundflag = false; //FlagsAttribute set false for small image //Code to zip ZipEntry entry = new ZipEntry(Path.GetFileName(ImageFile)); entry.DateTime = DateTime.Now; s.PutNextEntry(entry); using (FileStream fs = File.OpenRead(ImageFile)) { int sourceBytes; do { sourceBytes = fs.Read(buffer, 0, buffer.Length); s.Write(buffer, 0, sourceBytes); } while (sourceBytes > 0); } //Code to zip till here } } if (Foundflag) // if big image is not found. { foreach (string file in filenames) { if ((file.EndsWith(objPhoto.PhotoImage)) && (File.Exists(smallFile)) && (!(file.EndsWith("Big_" + objPhoto.PhotoImage)))) //(File.Exists(smallFile)) { ZipEntry entry = new ZipEntry(Path.GetFileName(file)); entry.DateTime = DateTime.Now; s.PutNextEntry(entry); using (FileStream fs = File.OpenRead(file)) { int sourceBytes; do { sourceBytes = fs.Read(buffer, 0, buffer.Length); s.Write(buffer, 0, sourceBytes); } while (sourceBytes > 0); } } } } } s.Finish(); s.Close(); } Response.ContentType = "zip"; string sfile = sZipFileName + ".zip"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + sfile); Response.TransmitFile(galleryPath + "\\" + sfile); Response.End(); } catch //Exception ex) // by Ud { } } #endregion } } } }
protected void lBtnVieFullPhoto_Click(object sender, EventArgs e) { MiscellaneousController objMisc = new MiscellaneousController(); Photos objPhotos = new Photos(); string[] getPath = CommonUtilities.GetPath(); StateManager objStateManager = StateManager.Instance; objSessionValue = (SessionValue)objStateManager.Get("objSessionvalue", StateManager.State.Session); if (Request.QueryString["PhotoId"] != null) { if (int.TryParse(Request.QueryString["PhotoId"], out _photoId)) { string strOriginalImage = string.Empty; string DirBigImage = string.Empty; string imagePath = string.Empty; objPhotos.PhotoId = _photoId; objPhotos = objMisc.GetPhotoDetail(objPhotos); Tributes objTributes = objTribute = (Tributes)objStateManager.Get(PortalEnums.SessionValueEnum.TributeSession.ToString(), StateManager.State.Session); if (objTributes != null) { if (string.IsNullOrEmpty(objTributes.TributePackageType)) { _packageId = objMisc.GetTributePackageId(_tributeId); } } 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.IsAllowedPhotoCheck(_photoAlbumId); if (((_packageId == 3) || (_packageId == 6) || (_packageId == 7) || (_packageId == 8)) || ((_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 (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 != null) { if (Request.QueryString["TributeUrl"] != null) _tributeUrl = Request.QueryString["TributeUrl"].ToString(); string DefaultPath = getPath[0] + "/" + getPath[1] + "/" + _tributeUrl + "_" + objTributes.TypeDescription; //DirectoryInfo objDir = new DirectoryInfo(DirBigImage); DirBigImage = "Big_" + objPhotos.PhotoImage; if (!File.Exists(Path.Combine(DefaultPath, DirBigImage))) { //show big image imagePath = getPath[2] + "/" + _tributeUrl + "_" + objTributes.TypeDescription + "/" + objPhotos.PhotoImage; Page.ClientScript.RegisterStartupScript(GetType(), "open window", "function f(){ window.open('" + imagePath + "'); return false; } f();", true); } else { //show small image imagePath = getPath[2] + "/" + _tributeUrl + "_" + objTributes.TypeDescription + "/" + DirBigImage; Page.ClientScript.RegisterStartupScript(GetType(), "open window", "function f(){ window.open('" + imagePath + "'); return false; } f();", true); } } } } }
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"); } }