public int DelAnnex(PrjInfoPhotoModel annexInfo) { FileUpload upload = new FileUpload(); if (upload.Delete(annexInfo.PhotoPath + annexInfo.PhotoName)) { return(publicDbOpClass.ExecSqlString("delete from PT_PrjInfo_PhotoList where uid = '" + annexInfo.UID.ToString() + "'")); } return(0); }
public PrjInfoPhotoModel GetSinglePhotoInfo(Guid NoteID) { PrjInfoPhotoModel model = new PrjInfoPhotoModel(); using (DataTable table = publicDbOpClass.DataTableQuary("select * from PT_PrjInfo_PhotoList where UID = '" + NoteID + "'")) { if (table.Rows.Count == 1) { return(this.GetPhotosInfoFromDataRow(table.Rows[0])); } } return(model); }
public int AddIntendancePhotoListAction(HttpPostedFile postedFile, PrjInfoPhotoModel annexInfo) { if (this.intendancePhotoListAction.AddpHoteInfo(postedFile, annexInfo) == 1) { PrjInfoPhotoModel singlePhotoInfo = this.intendancePhotoListAction.GetSinglePhotoInfo(annexInfo.UID); string thumbnailPath = HttpContext.Current.Server.MapPath(singlePhotoInfo.PhotoPath); string originalImagePath = thumbnailPath + singlePhotoInfo.PhotoName; string thumbnailName = Guid.NewGuid().ToString() + ".jpg"; if (this.MakeToThumbnail(originalImagePath, thumbnailPath, thumbnailName, 150, 150, "HW") && this.SavePhotoToDataBase(singlePhotoInfo.UID, singlePhotoInfo.PhotoPath, thumbnailName)) { return(1); } } return(0); }
private bool SavePhotoToDataBase(Guid annexCode, string thumbnailPath, string thumbnaName) { PrjInfoPhotoModel singlePhotoInfo = this.intendancePhotoListAction.GetSinglePhotoInfo(annexCode); Thumbnai thumbnai = new Thumbnai { ThumbnaiCode = new Guid(annexCode.ToString()), ShowContent = DateTime.Now.ToString("yyyyMMdd"), ThumbnaImgPath = thumbnailPath + "thumbnail/", ThumbnaName = thumbnaName, AddDate = DateTime.Now, Remark = singlePhotoInfo.Remark, ImgPath = singlePhotoInfo.PhotoPath + singlePhotoInfo.PhotoName }; HttpContext.Current.Session["PrjInfo-thuPhoto-success"] = thumbnai; return(this.AddThumbnai(thumbnai)); }
public int AddpHoteInfo(HttpPostedFile postedFile, PrjInfoPhotoModel annexInfo) { FileUpload upload = new FileUpload { FileSize = 0x800000, UploadPath = "/UploadFiles/Image/PrjPhoto/" }; if (upload.UploadValidator(postedFile)) { annexInfo.PhotoName = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(@"\") + 1); string fileName = ""; fileName = ((DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString().PadLeft(2, '0') + DateTime.Today.Day.ToString().PadLeft(2, '0')) + "_" + DateTime.Now.ToLongTimeString().Replace(":", "")) + annexInfo.PhotoName; annexInfo.PhotoName = fileName; annexInfo.PhotoPath = "/UploadFiles/Image/PrjPhoto/" + fileName.Substring(0, 6) + "/"; HttpContext.Current.Session["PrjInfo-photo-success"] = annexInfo; StringBuilder builder = new StringBuilder(); builder.Append("insert into PT_PrjInfo_PhotoList("); builder.Append("UID,PrjGuid,PhotoCode,PhotoPath,PhotoName,PhotoType,I_xh,IsValid,AddUser,AddTime,Remark)"); builder.Append(" values ("); builder.Append("@UID,@PrjGuid,@PhotoCode,@PhotoPath,@PhotoName,@PhotoType,@I_xh,@IsValid,@AddUser,@AddTime,@Remark)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@UID", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@PrjGuid", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@PhotoCode", SqlDbType.VarChar, 50), new SqlParameter("@PhotoPath", SqlDbType.VarChar, 200), new SqlParameter("@PhotoName", SqlDbType.VarChar, 200), new SqlParameter("@PhotoType", SqlDbType.Int, 4), new SqlParameter("@I_xh", SqlDbType.Int, 4), new SqlParameter("@IsValid", SqlDbType.Char, 1), new SqlParameter("@AddUser", SqlDbType.VarChar, 50), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar) }; commandParameters[0].Value = annexInfo.UID; commandParameters[1].Value = annexInfo.PrjGuid; commandParameters[2].Value = (annexInfo.PhotoCode == null) ? "" : annexInfo.PhotoCode; commandParameters[3].Value = annexInfo.PhotoPath; commandParameters[4].Value = annexInfo.PhotoName; commandParameters[5].Value = annexInfo.PhotoType; commandParameters[6].Value = !annexInfo.I_xh.HasValue ? 0 : annexInfo.I_xh; commandParameters[7].Value = annexInfo.IsValid; commandParameters[8].Value = annexInfo.AddUser; commandParameters[9].Value = DateTime.Now; commandParameters[10].Value = annexInfo.Remark; if (publicDbOpClass.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters) != 1) { return(-2); } if (upload.Upload(postedFile, fileName, true)) { return(1); } } return(-1); }