public void LoadStudentImages(Guid AccessCode) { Photo photo = new Photo(); string ProfileCoverImagePath = ""; string ProfileImagePath = ""; List<Photo> PhotoList = Photo.SelectAllByContextId(AccessCode); if (PhotoList.Count > 0) { foreach (Photo _List in PhotoList) { if (_List.PhotoCategoryId == (int)Enums.PhotoCategory.Cover_Picture) { ProfileCoverImagePath = _List.FilePath; } if (_List.PhotoCategoryId == (int)Enums.PhotoCategory.Profile_Picture) { ProfileImagePath = _List.FilePath; } } } }
public void LoadImage() { Photo photo = new Photo(); ProfileImage_.ImageUrl = photo.LoadImage(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()), Enums.PhotoCategory.Profile_Picture); CoverImage.ImageUrl = photo.LoadImage(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()), Enums.PhotoCategory.Cover_Picture); }
public static List<Photo> GetAllByFieldValue(string fieldName, Guid fieldValue, string fieldName2, Guid fieldValue2,Enums.ContextSubType ContextSubTypeId, Enums.PhotoCategory PhotoCategoryId) { List<Photo> returnEntityCollection = new List<Photo>(); Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_PhotoSelectAllBy" + fieldName2); db.AddInParameter(dbCommand, fieldName, DbType.Guid, fieldValue); db.AddInParameter(dbCommand, fieldName2, DbType.Guid, fieldValue2); db.AddInParameter(dbCommand, "ContextSubTypeId", DbType.Int32, (int)ContextSubTypeId); db.AddInParameter(dbCommand, "PhotoCategoryId", DbType.Int32, (int)PhotoCategoryId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Photo entity = new Photo(); Utility.Generic.AssignDataReaderToEntity(dataReader, entity); returnEntityCollection.Add(entity); } } return returnEntityCollection; }
public void LoadProfileImage(Guid AccessCode) { Photo photo = new Photo(); imgStudentProfileImage.ImageUrl = photo.LoadImage(AccessCode, Enums.PhotoCategory.Profile_Picture); jmgHeaderImage.ImageUrl = photo.LoadImage(AccessCode, Enums.PhotoCategory.Cover_Picture); }
public void loadimage(Guid AccessCode) { Photo photo = new Photo(); try { List<String> images = photo.LoadImageList(AccessCode, Enums.PhotoCategory.House_Life_Picture); if (images != null) { int imagescount = images.Count; if (imagescount <= 1) { RepeaterImages.DataSource = images; RepeaterImages.DataBind(); } else { int check = 0; int length = 5; if (imagescount < 5) { length = imagescount; } int[] NumberList = new int[length]; Random rand = new Random(); List<String> imageList = new List<string>(length); for (int i = 0; i < length; ) { check = rand.Next(1, imagescount); if (!NumberList.Contains(check)) { imageList.Add(images[check].ToString()); NumberList[i] = check; i++; } } RepeaterImages.DataSource = imageList; RepeaterImages.DataBind(); } } //if (images != null) //{ // RepeaterImages.DataSource = images; // RepeaterImages.DataBind(); //} } catch (Exception ec) { } }
protected void ItemDataBound(object sender, DataListItemEventArgs e) { Photo photo = new Photo(); HiddenField HiddenField_ = (HiddenField)e.Item.FindControl("hdUserId"); HyperLink Image_ = (HyperLink)e.Item.FindControl("HyperLinkimage"); Image_.ImageUrl = photo.LoadImage(Guid.Parse(HiddenField_.Value.ToString()), Enums.PhotoCategory.Profile_Picture); }
public void LoadImage(Guid AccessCode, Guid AccessCode2) { User user = User.Select(AccessCode2); if (user.UserId.HasValue) { ProfileUserName.Text = user.FirstName + " " + user.LastName; // ProfileUserName.NavigateUrl = "~/Student/Student_Public_Profile.aspx?AccessCode=" + AccessCode2; } Photo photo = new Photo(); imgLandloadProfileImage.ImageUrl = photo.LoadImage(AccessCode2, Enums.PhotoCategory.Profile_Picture); jmgHeaderImage.ImageUrl = photo.LoadImage(AccessCode2, Enums.PhotoCategory.Cover_Picture); }
//public void LoadImageTemp() //{ // Photo photo = new Photo(); // string ProfileCoverImagePath = ""; // string ProfileImagePath = ""; // List<Photo> PhotoList = Photo.SelectAllByContextId(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); // if (PhotoList.Count > 0) // { // foreach (Photo _List in PhotoList) // { // if (_List.PhotoCategoryId == (int)Enums.PhotoCategory.Cover_Picture) // { // ProfileCoverImagePath = _List.FilePath; // } // if (_List.PhotoCategoryId == (int)Enums.PhotoCategory.Profile_Picture) // { // ProfileImagePath = _List.FilePath; // } // } // } // if (ProfileImagePath != string.Empty) // { // try // { // string images = photo.LoadProfileImage(ProfileImagePath); // if (images != string.Empty) // { // ProfileImage_.ImageUrl = images; // } // } // catch (Exception ec) // { } // } // if (ProfileCoverImagePath != string.Empty) // { // try // { // string CoverImages = photo.LoadProfileCoverImage(ProfileCoverImagePath); // if (CoverImages != string.Empty) // { // CoverImage.ImageUrl = CoverImages; // } // } // catch (Exception ec) // { } // } // else // { // } //} protected void btn_Photos_Click(object sender, EventArgs e) { Photo photo = new Photo(); string path = "~/uploads/" + Membership.GetUser().ProviderUserKey.ToString(); bool IsUpload = photo.ImageResize(FileUploads, path, photo); if (IsUpload == true) { photo.ContextId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); photo.ContextTypeId = (int)Enums.ContextType.Student; photo.PhotoCategoryId = (int)Enums.PhotoCategory.Profile_Picture; photo.Insert(photo); } Response.Redirect("~/Student/Student_Profile.aspx"); }
public void loadimage() { Photo photo = new Photo(); try { List<String> images = photo.LoadImageList(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()), Enums.PhotoCategory.House_Life_Picture); if (images != null) { RepeaterImages.DataSource = images; RepeaterImages.DataBind(); } } catch (Exception ec) { } }
public void loadimage(Guid AccessCode) { Photo photo = new Photo(); try { List<String> images = photo.LoadImageList(AccessCode, Enums.PhotoCategory.House_Life_Picture); if (images != null) { RepeaterImages.DataSource = images; RepeaterImages.DataBind(); } } catch (Exception ec) { } }
private void LoadHouseData(Guid UserId) { User user = User.Select(UserId); Photo photo = new Photo(); ProfileUserName.Text = user.FirstName + " " + user.LastName; ProfileUserName.NavigateUrl = "~/Student/Student_Public_Profile.aspx?AccessCode=" + UserId; imgStudentProfileImage.NavigateUrl = "~/Student/Student_Public_Profile.aspx?AccessCode=" + UserId; if (user.HouseId.HasValue) { House house = House.Select(user.HouseId.Value); imgCurrentHouseImage.NavigateUrl = "~/Land_load/Land_load_Public_Profile.aspx?AccessCode=" + house.LandlordId.ToString() + "&AccessCode2=" + user.HouseId.Value.ToString(); imgCurrentHouseImage.ImageUrl = photo.LoadHouseImage(house.LandlordId, user.HouseId.Value, Enums.ContextSubType.House, Enums.PhotoCategory.House_Picture); User user_ = new User(); user_ = User.Select(house.LandlordId); ProfileLandlordName.Text = user_.FirstName + " " + user_.LastName; ProfileLandlordName.NavigateUrl = "~/Land_load/Land_load_Public_Profile.aspx?AccessCode=" + user.HouseId.Value.ToString() + "&AccessCode2=" + house.LandlordId.ToString(); } }
protected void btn_Photos_Click(object sender, EventArgs e) { if (Page.IsValid) { Photo photo = new Photo(); string path = "~/uploads/" + Membership.GetUser().ProviderUserKey.ToString(); bool IsUpload = photo.ImageUpload(FileUploads, path, photo); if (IsUpload == true) { photo.ContextId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); photo.ContextTypeId = (int)Enums.ContextType.Student; photo.PhotoCategoryId = (int)Enums.PhotoCategory.House_Life_Picture; photo.Insert(photo); } loadimage(); } }
public bool Update(Photo photo) { bool result; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { result = new PhotoDAO().Update(photo, db, transaction); transaction.Commit(); } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return result; }
protected void UploadButton_Click(object sender, EventArgs e) { if (Page.IsValid == true) { Photo photo = new Photo(); string path = "~/uploads/" + Membership.GetUser().ProviderUserKey.ToString(); bool IsUpload = photo.DocumentUpload(DocumentUpload, path, photo); if (IsUpload == true) { comment.CommentText = DocumentUploadComment.Text.Trim(); comment.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); comment.ContextTypeId = (int)Enums.ContextType.Landlord; comment.CommentTypeId = (int)Enums.CommentType.Document; comment.FilePath = photo.FilePath; comment.RatingValue = 0; save(comment); string AccessCode = Utility.GetQueryStringValueByKey(Request, "AccessCode"); string AccessCode2 = Utility.GetQueryStringValueByKey(Request, "AccessCode2"); Response.Redirect("~/Land_load/Land_load_Public_Profile.aspx?AccessCode=" + AccessCode + "&AccessCode2=" + AccessCode2); } } }
public bool Delete(Photo photo, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_PhotoDelete"); db.AddInParameter(command, "PhotoId", DbType.Guid, photo.PhotoId); if (transaction == null) { db.ExecuteNonQuery(command); } else { db.ExecuteNonQuery(command, transaction); } return true; }
protected void ItemDataBound(object sender, DataListItemEventArgs e) { Photo photo = new Photo(); HiddenField HiddenField_ = (HiddenField)e.Item.FindControl("hdUserId"); HiddenField hdHouseId_ = (HiddenField)e.Item.FindControl("hdHouseId"); HiddenField hdBaseHouseRoomId_ = (HiddenField)e.Item.FindControl("hdBaseHouseRoomId"); HyperLink Image_ = (HyperLink)e.Item.FindControl("HyperLinkimage"); LinkButton RequestLeaveCurrentHouse_ = (LinkButton)e.Item.FindControl("RequestLeaveCurrentHouse"); Label LabelItsMe_ = (Label)e.Item.FindControl("LabelItsMe"); Image_.ImageUrl = photo.LoadImage(Guid.Parse(HiddenField_.Value.ToString()), Enums.PhotoCategory.Profile_Picture); if (Guid.Parse(HiddenField_.Value) == Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())) { RequestLeaveCurrentHouse_.Visible = false; LabelItsMe_.Visible = true; LabelItsMe_.Text = "It's Me"; } else { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); if (hdHouseId_.Value.Trim() != string.Empty) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(Guid.Parse(hdHouseId_.Value), Guid.Parse(HiddenField_.Value)); } else if (hdBaseHouseRoomId_.Value.Trim() != string.Empty) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(Guid.Parse(hdBaseHouseRoomId_.Value), Guid.Parse(HiddenField_.Value)); } if ((studentHouseLeave.RequestBy != null && studentHouseLeave.RequestBy != Guid.Empty) && studentHouseLeave.status == 0) { if (studentHouseLeave.RequestBy == Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())) { RequestLeaveCurrentHouse_.Visible = false; LabelItsMe_.Visible = true; LabelItsMe_.Text = "Request Already Sent"; } } } }
public bool Update(Photo photo, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_PhotoUpdate"); db.AddInParameter(command, "PhotoId", DbType.Guid, photo.PhotoId); db.AddInParameter(command, "FileName", DbType.String, photo.FileName); db.AddInParameter(command, "FilePath", DbType.String, photo.FilePath); db.AddInParameter(command, "ContextId", DbType.Guid, photo.ContextId); db.AddInParameter(command, "ContextSubId", DbType.Guid, photo.ContextSubId); db.AddInParameter(command, "Description", DbType.String, photo.Description); db.AddInParameter(command, "ContextTypeId", DbType.Int32, (int)photo.ContextType); db.AddInParameter(command, "ContextSubTypeId", DbType.Int32, photo.ContextSubTypeId); db.AddInParameter(command, "PhotoCategoryId", DbType.Int32, photo.PhotoCategoryId); db.AddInParameter(command, "UpdatedBy", DbType.Guid, photo.UpdatedBy); db.AddOutParameter(command, "UpdatedDate", DbType.DateTime, 30); if (transaction == null) { db.ExecuteNonQuery(command); } else { db.ExecuteNonQuery(command, transaction); } photo.UpdatedDate = Convert.ToDateTime(db.GetParameterValue(command, "UpdatedDate").ToString()); return true; }
public void LoadImage(Guid HouseId) { Photo photo = new Photo(); ProfileImage_.ImageUrl = photo.LoadHouseImage(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()), HouseId,Enums.ContextSubType.House, Enums.PhotoCategory.House_Picture); }
protected void ItemDataBound(object sender, DataListItemEventArgs e) { Photo photo = new Photo(); HiddenField HiddenField_ = (HiddenField)e.Item.FindControl("hdnHouseId"); HyperLink Image_ = (HyperLink)e.Item.FindControl("HyperLinkimage"); // Image_.ImageUrl = photo.LoadImage(Guid.Parse(HiddenField_.Value.ToString()), Enums.PhotoCategory.Profile_Picture); Image_.ImageUrl = photo.LoadHouseImage(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()), Guid.Parse(HiddenField_.Value.ToString()), Enums.ContextSubType.House, Enums.PhotoCategory.House_Picture); }
public bool ImageUpload(FileUpload FileUploadImage, string FolderPath, Photo photo) { FileUpload UploadImage = FileUploadImage; bool isupload = false; if (UploadImage.HasFile) { if (UploadImage.PostedFile.ContentLength <= 6291456) { FileInfo finfo = new FileInfo(UploadImage.FileName); string fileExtension = finfo.Extension.ToLower(); if (fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension != ".png" || fileExtension != ".gif" || fileExtension != ".bmp") { try { if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(FolderPath))) Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(FolderPath)); //create the path to save the file to photo.PhotoId = Guid.NewGuid(); string imagename = photo.PhotoId + fileExtension; string fileName = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(FolderPath), imagename); //save the file to our local path UploadImage.SaveAs(fileName); isupload = true; photo.FileName = imagename; photo.FilePath = FolderPath + "/" + imagename; photo.Description = imagename; photo.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); photo.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); } catch (Exception ex) { isupload = false; } } else { isupload = false; // extention // Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Allowed_fileExtension + "'); }", true); } } else { isupload = false; // max size // Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Allowed_MaxImageSize + "'); }", true); } } return isupload; }
public bool ImageResize(FileUpload UploadImage, string FolderPath, Photo photo) { bool isupload = false; // The uploaded file should not be a blank file if (UploadImage.FileBytes.Length == 0) { isupload = false; } else { // The uploaded file should be having one of the allowed extensions string fileExtension = System.IO.Path.GetExtension(UploadImage.FileName).TrimStart(".".ToCharArray()).ToLower(); if ((fileExtension != "jpeg") && (fileExtension != "jpg") && (fileExtension != "png") && (fileExtension != "gif") && (fileExtension != "bmp")) { isupload = false; } else { try { // Validation successful // Load the image into Bitmap Object Bitmap uploadedImage = new Bitmap(UploadImage.FileContent); // Set the maximum width and height here. // You can make this versatile by getting these values from // QueryString or textboxes int maxWidth = 175; int maxHeight = 175; // Resize the image Bitmap resizedImage = GetScaledPicture(uploadedImage, maxWidth, maxHeight); //create the path to save the file to photo.PhotoId = Guid.NewGuid(); string imagename = photo.PhotoId +"."+ fileExtension; if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(FolderPath))) Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(FolderPath)); //Save the image String tempFileName = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(FolderPath), imagename); //System.Web.HttpContext.Current.Server.MapPath(virtualPath); resizedImage.Save(tempFileName, uploadedImage.RawFormat); isupload = true; photo.FileName = imagename; photo.FilePath = FolderPath + "/" + imagename; photo.Description = imagename; photo.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); photo.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); } catch(Exception ex) { isupload = false; } } } return isupload; }
protected void ItemDataBound(object sender, DataListItemEventArgs e) { Photo photo = new Photo(); HiddenField HiddenField_ = (HiddenField)e.Item.FindControl("hdUserId"); HyperLink Image_ = (HyperLink)e.Item.FindControl("HyperLinkimage"); Image_.ImageUrl = photo.LoadImage(Guid.Parse(HiddenField_.Value.ToString()), Enums.PhotoCategory.Profile_Picture); HiddenField HdIsPartialUser = (HiddenField)e.Item.FindControl("hdIsPartialUser"); HiddenField hdAspnetUserId_ = (HiddenField)e.Item.FindControl("hdAspnetUserId"); LinkButton EditPartialUser_ = (LinkButton)e.Item.FindControl("EditPartialUser"); bool IsPartialUser = bool.Parse(HdIsPartialUser.Value); if (IsPartialUser == true && (hdAspnetUserId_.Value == string.Empty || hdAspnetUserId_.Value == null)) { EditPartialUser_.Visible = true; } else { EditPartialUser_.Visible = false; } }
protected void ButtonCoverImage_Click(object sender, EventArgs e) { Photo photo = new Photo(); string path = "~/uploads/" + Membership.GetUser().ProviderUserKey.ToString(); bool IsUpload = photo.ImageUpload(FileUploadCoverImage, path, photo); if (IsUpload == true) { photo.ContextId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); photo.ContextTypeId = (int)Enums.ContextType.Landlord; photo.PhotoCategoryId = (int)Enums.PhotoCategory.Cover_Picture; photo.Insert(photo); } Response.Redirect("~/Land_load/Land_load_Profile.aspx"); }
private void LoadHouseImages() { Photo photo = new Photo(); user = User.Select(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); ProfileUserName.Text = user.FirstName + " " + user.LastName; ProfileUserName.NavigateUrl = "~/Student/Student_Profile.aspx"; if (user.HouseId.HasValue) { hdnHouseId.Value = user.HouseId.Value.ToString(); imgCurrentHouseImage.NavigateUrl = "~/Land_load/Land_load_Public_Profile.aspx?AccessCode=" + user.HouseId.Value.ToString() + "&AccessCode2=" + house.LandlordId.ToString(); imgCurrentHouseImage.ImageUrl = photo.LoadHouseImage(house.LandlordId, user.HouseId.Value, Enums.ContextSubType.House, Enums.PhotoCategory.House_Picture); imgLandloadProfileImage.NavigateUrl = "~/Land_load/Land_load_Public_Profile.aspx?AccessCode=" + user.HouseId.Value.ToString() + "&AccessCode2=" + house.LandlordId.ToString(); imgLandloadProfileImage.ImageUrl = photo.LoadImage(house.LandlordId, Enums.PhotoCategory.Profile_Picture); User user_ = new User(); user_ = User.Select(house.LandlordId); ProfileLandlordName.Text = user_.FirstName + " " + user_.LastName; ProfileLandlordName.NavigateUrl = "~/Land_load/Land_load_Public_Profile.aspx?AccessCode=" + user.HouseId.Value.ToString() + "&AccessCode2=" + house.LandlordId.ToString(); } }