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) { try { GetValuesFromSession(); topHeight = 165; //DJ: Added code for expiry message string appDomian = string.Empty; if (WebConfig.ApplicationMode.Equals("local")) { appDomian = WebConfig.AppBaseDomain.ToString(); } else { appDomian = "http://" + _tributeType.ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/"; } if (_tributeName != null) Page.Title = _tributeName + " | Photo Album"; //End UserIsAdminOrOwner(); aTributeHome.HRef = Session["APP_PATH"] + _tributeUrl + "/"; string tributeEndDate = _presenter.GetTributeEndDate(_tributeId); if (Request.QueryString["PhotoAlbumId"] != null) { int.TryParse(Request.QueryString["PhotoAlbumId"], out photoAlbumId); if (photoAlbumId > 0) Session["PhotoAlbumId"] = photoAlbumId.ToString(); } //MG:Expiry Notice //AG(20-jan-11): Added topheight for expiry page bool isCustomeHeaderOn = _presenter.GetCustomHeaderDetail(_tributeId); if (Equals(objSessionValue, null))//when not logged in { if (isCustomeHeaderOn) topHeight = 197; else topHeight = 91; } else { if (isCustomeHeaderOn) topHeight = 258; else topHeight = 131; } if (!this.IsPostBack) { this._presenter.GetPhotoAlbumData(GetPhotoObject()); } bool isAllowedPhotoCheck = false; MiscellaneousController objMisc = new MiscellaneousController(); 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])); } } _packageId = _presenter.GetPackIdonPhotoAlbumId(photoAlbumId); isAllowedPhotoCheck = objMisc.IsAllowedPhotoCheck(photoAlbumId); if (((_packageId == 5) && !isAllowedPhotoCheck && (date2 < DateTime.Now))) { //ScriptManager.RegisterStartupScript(Page, this.GetType(), "a", "fnExpiryNoticePopupClose();", true); //ScriptManager.RegisterStartupScript(Page, this.GetType(), "awe", "fnExpiryNoticePopup('location.href','document.title','NonMemo','" + _tributeId + "','" + appDomian + "','" + topHeight + "');", true); ScriptManager.RegisterStartupScript(Page, this.GetType(), "awe", "fnReachLimitExpiryPopup('location.href','document.title','UpgradeAlbum','" + _tributeUrl + "','" + _tributeId + "','" + appDomian + "','" + topHeight + "');", true); } } catch (Exception ex) { Response.Redirect(WebConfig.AppBaseDomain.ToString() + "Errors/Error404.aspx"); } }