public ActionResult pictureEdit ( [Bind (Include = "pictureId," + "pictureTitle," + "pictureAlternateTitle," + "pictureDescription," + "pictureStandardUrl," + "pictureRatingValue," + "pictureViewsNumber," + "categoryId" ) ] picture updatePicture ) { if (ModelState.IsValid) { db.Entry(updatePicture).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("pictureUpdate")); } Selection(); return(View(updatePicture)); }
public ActionResult DeleteConfirmed(int PictureID) { picture picture = PictureRepository.GetPictureByID(PictureID); PictureRepository.DeleteRecord(picture); return(RedirectToAction("List")); }
public FileContentResult GetMemberImageByID(int memberID = 0) { member member = MemberRepository.GetMemberByID(memberID); picture pic = PictureRepository.GetDefaultPersonPicture(member.memberID); return(File(pic.ImageData, pic.ImageMimeType)); }
public ActionResult Delete(int PictureID) { ViewBag.PictureID = PictureID; picture picture = PictureRepository.GetPictureByID(PictureID); return(PartialView(picture)); }
void OnMouseDown() { fcount = Directory.GetFiles(Application.dataPath + "/galleryData", "*.png", SearchOption.AllDirectories).Length; // Count the number of file(파일개수) if (state == 0) // When push the delete button firstly { state = 1; // Because of execute deletion, when button is pushed again next time. GameObject.Find("deletepresent").renderer.enabled = true; // Present deletion's guide because of select picture about deletion } else if (state == 1) // When push delete button again, execute deletion { for (int i = 1; i <= fcount; i++) // Examine selected picture as fcount { picture picturecode = GameObject.Find("picture" + i.ToString()).GetComponent <picture>(); // Get object's script(picture.cs) if (picturecode.delOn == 1) // If object is selected as deletion { picturecode.DeletePic(); // Execute delete function picturecode.delOn = 0; // Because deletion was executed } } state = 0; // Deletion was completed GameObject.Find("deletepresent").renderer.enabled = false; // Hide deletion's guide because of delete's completion Application.LoadLevel("gallery"); // Restart gallery scene because of realignment // galleryObjGenerator frameScript = GameObject.Find("frame").GetComponent<galleryObjGenerator>(); // frameScript.updateGallery(); } }
public picture GetStaffPicture(int pictureID = 0) { //record = myRecords.FirstOrDefault(e => e.pictureID == pictureID); record = context.pictures.FirstOrDefault(e => e.pictureID == pictureID); if (record == null) { record = myRecords.FirstOrDefault(e => e.PictureType == "Default People"); } return(record); }
public FileContentResult GetDefaultPeoplePicture() { picture pic = null; if (PictureRepository.IsDefaultPeoplePicture()) { pic = PictureRepository.GetDefaultPeoplePicture(); } return(File(pic.ImageData, pic.ImageMimeType)); }
public FileContentResult GetImageByDesc(string Description) { picture pic = PictureRepository.GetPictureByDescription(Description); if (pic != null) { return(File(pic.ImageData, pic.ImageMimeType)); } return(File(pic.ImageData, pic.ImageMimeType)); }
public FileContentResult GetImageByID(int PictureID = 0) { picture pic = PictureRepository.GetPictureByID(PictureID); if (pic != null) { return(File(pic.ImageData, pic.ImageMimeType)); } return(File(pic.ImageData, pic.ImageMimeType)); }
public override OperationResult execute(CimetEntities entities) { picture slika = new picture(); slika.src = this.Slika.Src; slika.picture_id = this.Slika.PictureId; slika.alt = this.Slika.Alt; entities.picture.Add(slika); entities.SaveChanges(); return(base.execute(entities)); }
public picture GetMemberPicture(int memberID) { string picCode = string.Format("MP&{0}", memberID); //record = myRecords.FirstOrDefault(e => e.PictureType == "Member Picture" && e.Description == picCode); record = context.pictures.FirstOrDefault(e => e.PictureType == "Member Picture" && e.Description == picCode); if (record == null) { record = GetDefaultPersonPicture(memberID); } return(record); }
public void DeleteRecord(picture record) { /* using (churchdatabaseEntities context2 = new churchdatabaseEntities()) * { * List<picture> myRecords = new List<picture>(); * myRecords.Add(context2.pictures.FirstOrDefault(e => e.pictureID == record.pictureID)); * myRecords.Remove(record); * context2.SaveChanges(); * } * */ myRecords.Remove(record); context.pictures.Remove(record); context.SaveChanges(); }
void OnMouseDown() { this.transform.position = new Vector3(0.051f, 2.89f, -0.09f); for (int i = 1; i <= 6; i++) { GameObject pictures = GameObject.Find("picture" + i.ToString()); if (pictures != null) { picture picScript = pictures.GetComponent <picture>(); picScript.setTimer(); } } }
/// <summary> /// 修改辅助 /// </summary> /// <param name="request"></param> /// <param name="Model"></param> /// <param name="id"></param> /// <param name="guid"></param> /// <param name="workreport"></param> /// <param name="table_id"></param> /// <returns></returns> private void edit_report_helper(long id, string guid, workreport _newworkreport, string t_picture, string m_picture) { try { //工作报告,当前用户 List <workreport> workreport_selfs = dic_Self[guid]; workreport workreport = workreport_selfs.FirstOrDefault(item => item.id == id); if (workreport != null) { workreport.report_type = _newworkreport.report_type; workreport.report_startdate = _newworkreport.report_startdate; workreport.report_enddate = _newworkreport.report_enddate; workreport.report_plan = _newworkreport.report_plan; workreport.report_isdelete = _newworkreport.report_isdelete; workreport.report_remark = _newworkreport.report_remark; //成功提示 jsonModel = Constant.get_jsonmodel(0, "success", 1); //开启线程操作数据库 new Thread(() => { Constant.bbc.edit_workreport(workreport, t_picture, m_picture); //今日总结的图片 picture edit_t_picture = Constant.list_picture_All.FirstOrDefault(item => item.pic_table_id == id); if (edit_t_picture != null) { edit_t_picture.pic_url = t_picture; } //明日计划的图片 picture edit_m_picture = Constant.list_picture_All.FirstOrDefault(item => item.pic_table_id == id); if (edit_m_picture != null) { edit_m_picture.pic_url = m_picture; } //抄送人 //if ((request["report_reader"] != null) && request["report_sender"] != null) //{ // Constant.bbc.edit_report_sender(id, request["report_reader"].ToString(), request["report_sender"].ToString()); //} }) { }.Start(); } } catch (Exception ex) { LogHelper.Error(ex); } }
public ActionResult pictureEdit(int?id) { if (id == null) { return(RedirectToAction("picture404")); } picture picture = db.picture.Find(id); if (picture == null) { return(RedirectToAction("pictureError")); } Selection(); return(View(picture)); }
public ActionResult DeleteConfirmed(int PropertyInventoryID) { propertyinventory inventory = PropertyInventoryRepository.GetInventoryByID(PropertyInventoryID); if (inventory.PictureID > 0) { picture picture = PictureRepository.GetPictureByID((int)inventory.PictureID); PictureRepository.DeleteRecord(picture); } if (inventory.DocumentID > 0) { document document = DocumentRepository.GetDocumentByID((int)inventory.DocumentID); DocumentRepository.DeleteRecord(document); } PropertyInventoryRepository.DeleteRecord(inventory); return(RedirectToAction("Details")); }
public ActionResult Edit(property property) { string ReturnUrl = Request.UrlReferrer.ToString(); try { if (ModelState.IsValid) { //add property picture picture pic = new picture(); foreach (var image in property.files) { if (image != null) { pic.ImageMimeType = image.ContentType; pic.ImageData = new byte[image.ContentLength]; image.InputStream.Read(pic.ImageData, 0, image.ContentLength); } pic.ministryID = 0; pic.PictureDate = System.DateTime.Today; pic.Status = "Active"; pic.Description = string.Format("Picture:{0}", property.Title); pic.DateEntered = System.DateTime.Today; pic.EnteredBy = User.Identity.Name.ToString(); db.pictures.Add(pic); db.SaveChanges(); } property.PictureID = pic.pictureID; db.Entry(property).State = EntityState.Modified; db.SaveChanges(); TempData["Message2"] = string.Format("{0} record update successfully.", property.Title); GetData(); //return RedirectToAction("Edit", new { PropertyID = property.propertyID }); // return Content(string.Format("{0} record update successfully.", property.Title)); return(Redirect(ReturnUrl)); } } catch (Exception ex) { TempData["Message2"] = string.Format("Error editing {0} record.", property.Title); } GetData(); return(PartialView(property)); }
public ActionResult DeleteConfirmed(int StaffID) { staff staff = StaffRepository.GetStaffByID(StaffID); if (staff.pictureID > 0) { picture pic = PictureResponsibility.GetPictureByID((int)staff.pictureID); PictureResponsibility.DeleteRecord(pic); } IEnumerable <responsibility> duties = ResponsibilityRepository.GetResponsibilityByStaff(StaffID); foreach (responsibility r in duties) { ResponsibilityRepository.DeleteRecord(r); } StaffRepository.DeleteRecord(staff); return(RedirectToAction("Details")); }
public override OperationResult execute(CimetEntities entities) { picture slika = entities.picture.Where(r => r.picture_id == Slika.PictureId).FirstOrDefault(); if (slika != null) { slika.src = Slika.Src; slika.alt = Slika.Alt; entities.SaveChanges(); return(base.execute(entities)); } OperationResult result = new OperationResult(); result.Status = false; result.Message = "Slika ne postoji."; return(result); }
// note: it's possible to create a valid formatter, and have an error. Like, when the syntax is partially right // In that case, I will just use what is valid private static column_formatter_base create_formatter(string name, string syntax, ref string error) { error = ""; column_formatter_base result = null; switch (name) { case "cell": result = new cell(); break; case "format": result = new column_formatters.format(); break; case "picture": result = new picture(); break; case "stack_trace": case "stack-trace": result = new stack_trace(); break; case "xml": result = new xml(); break; default: error = "Invalid formatter name: " + name; break; } // load_syntax if (result != null) { try { result.load_syntax(new settings_as_string(syntax), ref error); } catch (Exception e) { logger.Error("can't load formatter " + e.Message); error = "Cannot load " + name + ". Invalid syntax"; } } return(result); }
public override OperationResult execute(CimetEntities entities) { base.criteria.Id = Id; picture slika = entities.picture.Where(r => r.picture_id == Id).FirstOrDefault(); if (slika != null) { entities.picture.Remove(slika); entities.SaveChanges(); return(base.execute(entities)); } else { OperationResult result = new OperationResult(); result.Status = false; result.Message = "Slika ne postoji !"; return(result); } }
public void AddUploadHistory(picture pic) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = 3000; connectString.conn.Open(); cmd.Connection = connectString.conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_AddUploadHistory"; cmd.Parameters.Add("@FileName", SqlDbType.VarChar, 50); cmd.Parameters["@FileName"].Value = pic.fileName; cmd.Parameters.Add("@Url", SqlDbType.VarChar, 250); cmd.Parameters["@Url"].Value = pic.urlWeb; cmd.Parameters.Add("@Size", SqlDbType.VarChar, 20); cmd.Parameters["@Size"].Value = pic.sizeWeb; cmd.Parameters.Add("@UploadType", SqlDbType.TinyInt); cmd.Parameters["@UploadType"].Value = pic.uploadType; cmd.Parameters.Add("@IP", SqlDbType.VarChar, 40); cmd.Parameters["@IP"].Value = pic.ip; cmd.Parameters.Add("@Status", SqlDbType.Int); cmd.Parameters["@Status"].Value = 1; cmd.Parameters.Add("@UserId", SqlDbType.Int); cmd.Parameters["@UserId"].Value = pic.userId; cmd.Parameters.Add("@Key", SqlDbType.VarChar, 100); cmd.Parameters["@Key"].Value = KEY_SQL; cmd.Parameters.Add("@Code", SqlDbType.BigInt); cmd.Parameters["@Code"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); long code = long.Parse(cmd.Parameters["@Code"].Value.ToString()); pic.id = code; } catch (Exception ex) { Logs.SaveError("ERROR AddUploadHistory: " + ex); pic.id = -1; } finally { connectString.conn.Close(); } }
/// <summary> /// Delete picture. /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult pictureDelete(int?id) { if (id == null) { return(RedirectToAction("picture404")); } picture pictureToRemove = db.picture.Find(id); if (pictureToRemove == null) { return(RedirectToAction("pictureError")); } // Get picture url to remove : var pictureToRemoveUrl = Path.Combine ( Server.MapPath(pictureControls.pictureFileDirectory), pictureToRemove.pictureStandardUrl ); // Check if picture url exists & remove the picture from the directory & database : if (System.IO.File.Exists(pictureToRemoveUrl)) { // Remove physical picture from directory : System.IO.File.Delete(pictureToRemoveUrl); // Remove data picture from databse : db.picture.Remove(pictureToRemove); // Saving : db.SaveChanges(); return(RedirectToAction("pictureRemoved")); } // Redirect to error view if picture url not found : else { return(RedirectToAction("pictureError")); } }
public override OperationResult execute(CimetEntities entities) { blog blog = new blog(); blog.name = this.BlogDto.Name; blog.text = this.BlogDto.Text; blog.date_created = DateTime.Now; blog.user_id = this.BlogDto.User_id; blog.picture_id = this.BlogDto.Picture.PictureId; picture p = new picture { src = BlogDto.Picture.Src, alt = BlogDto.Picture.Alt }; entities.blog.Add(blog); entities.SaveChanges(); return(base.execute(entities)); }
public ActionResult Create(picture picture) { string ReturnUrl = Request.UrlReferrer.ToString(); try { if (picture.Description == null) { picture.Description = ""; } if (ModelState.IsValid) { foreach (var image in picture.files) { if (image != null) { picture.ImageMimeType = image.ContentType; picture.ImageData = new byte[image.ContentLength]; image.InputStream.Read(picture.ImageData, 0, image.ContentLength); } db.pictures.Add(picture); db.SaveChanges(); PictureRepository.AddRecord(picture); } TempData["Message2"] = "Picture added successfully."; GetData(); //return Content("Picture added successfully."); return(Redirect(ReturnUrl)); } } catch (Exception ex) { TempData["Message2"] = "Error adding picture"; } GetData(); return(PartialView(picture)); }
public ActionResult Edit(picture picture) { try { //if (contribution.CheckNumber == null) { contribution.CheckNumber = ""; } if (ModelState.IsValid) { db.Entry(picture).State = EntityState.Modified; db.SaveChanges(); TempData["Message2"] = string.Format("Picture update successfully."); GetData(); return(RedirectToAction("Edit", new { PictureID = picture.pictureID })); } } catch (Exception ex) { TempData["Message2"] = string.Format("Error editing picture."); } GetData(); return(PartialView(picture)); }
/// <summary> /// 缓存添加图片 /// </summary> /// <param name="newfollow_up"></param> /// <param name="_pictures"></param> private static picture AddPicture_helper(follow_up newfollow_up, string _pictures) { picture picturemodel = null; try { //图片之前已经用存储过程和跟进记录一起插入 if (!string.IsNullOrEmpty(_pictures)) { string[] _pics = _pictures.Split(','); for (int i = 0; i < _pics.Length; i++) { picturemodel = new picture() { pic_en_table = "follow_up", pic_cn_table = "跟进记录", pic_table_id = Convert.ToInt32(newfollow_up.id), pic_url = _pics[i], pic_createdate = DateTime.Now, pic_creator = 1, pic_updatedate = DateTime.Now, pic_updateuser = 1, pic_isdelete = "0", pic_remark = "新增跟进记录", }; Constant.list_picture_All.Add(picturemodel); } } } catch (Exception ex) { LogHelper.Error(ex); } return(picturemodel); }
/// <summary> /// 编辑图片,若没有则添加 /// </summary> /// <param name="id"></param> /// <param name="_pictures"></param> /// <param name="edit_follow_up"></param> private static void editpicture_helper(long id, string _pictures, follow_up edit_follow_up) { try { picture edit_picture = Constant.list_picture_All.FirstOrDefault(item => item.id == id); if (edit_picture != null) { edit_picture.pic_updatedate = DateTime.Now; edit_picture.pic_url = _pictures; Constant.follow_up_S.Update(edit_follow_up); Constant.picture_S.Update(edit_picture); } else { picture pictureModel = AddPicture_helper(edit_follow_up, _pictures); Constant.picture_S.Add(pictureModel); } } catch (Exception ex) { LogHelper.Error(ex); } }
public ActionResult DeleteConfirmed(int CalendarID, DateTime ReturnBeginDate, DateTime ReturnEndDate, string ReturnSearchType = "", int ReturnCodeID = 0, string ReturnCodeName = "", string ReturnCallerType = "", string ReturnMethod = "") { calendar calendar = CalendarRepository.GetCalendarByID(CalendarID); if (calendar.PictureID != null) { picture pic = PictureRepository.GetPictureByID((int)calendar.PictureID); PictureRepository.DeleteRecord(pic); } CalendarRepository.DeleteRecord(calendar); TempData["Message2"] = string.Format("Calendar record deleted successfully."); if (ReturnMethod == "Ministry") { return(RedirectToAction("Details", new { ministryID = calendar.ministryID, CallerType = "Ministry" })); } else if (calendar.ReturnMethod == "AdminList") { return(RedirectToAction("ListAdmin", new { bDate = ReturnBeginDate, eDate = ReturnEndDate, SearchType = ReturnSearchType, codeID = ReturnCodeID, codeName = ReturnCodeName, CallerType = ReturnCallerType })); } else { return(RedirectToAction("Details", new { })); } }
//检索文件夹中所有的图片,返回地址 /* * 创建日期:2016年9月26日10:37 * 对应pic_show.ashx 需要连接数据库,以便后续的图片选择的操作 * */ public string pic_show() { string pic_text = ""; try { //遍历文件夹 //foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories()) // this.listBox1.Items.Add(NextFolder.Name); //显示文件夹所拥有的图片 string name = ""; int pic_number = 0; int width = 200; pic_text = "$(\"#pic_upload\").html('"; //遍历文件 foreach (FileInfo NextFile in TheFolder.GetFiles()) { name = NextFile.Name; pic_text += "<a href=\"#myModal\" role=\"button\" data-toggle=\"modal\" onclick=\"pic_upload(" + pic_number + ")\" >"; pic_text += "<img src=\"../upload/" + name + "\" class=\"img-polaroid\" style=\"max-width:" + width + "px;myimg:expression_r(onload=function(){this.style.width=(this.offsetWidth > " + width + ")?\"" + width + "px\":\"auto\"});\" alt=\"null\"></a> ";//宽度可调 pic_number++; if(picDal.Get_pictureBypicture(NextFile.Name) == null) {//添加图片进数据库 try { picture pic = new picture(); pic.pic_name = name; pic.changetime = DateTime.Now; picDal.Insert_picture(pic); } catch (Exception ex) { return ex.ToString(); } } } pic_text += "');$(\"#images_number\").html('" + pic_number + "');"; if (pic_text.Length < 1) { pic_text = "null"; } } catch (Exception ex) { return ex.ToString(); } return pic_text; }
public ActionResult pictureCreate ( [Bind (Include = "pictureId," + "pictureTitle," + "pictureAlternateTitle," + "pictureDescription," + "pictureStandardUrl," + "categoryId" ) ] picture newPicture, HttpPostedFileBase newPictureToUpload ) { #region DROPDOWNLIST Selection(); #endregion DROPDOWNLIST #region CHECK PICTURE & CREATE A TEMP SAVE // Initialise the temp picture file : FileInfo tempPictureFile = null; // Picture is already in temp directory ? if (newPictureToUpload == null) { // Check the temp directory : DirectoryInfo tempDirectory = new DirectoryInfo ( Server.MapPath(pictureControls.tempFileDirectory) ); // Get the picture in temp directory : tempPictureFile = tempDirectory.GetFiles() .ToList() .SingleOrDefault(); } if (newPictureToUpload == null && tempPictureFile == null) { ModelState.AddModelError ( "newPictureToUpload", pictureControls.ErrorMessageForPictureEmptyUpload ); } var newPictureSourcePath = string.Empty; var newPictureTempPath = string.Empty; // Get size in octets of uploaded picture : var uploadedPictureLength = newPictureToUpload?.ContentLength ?? tempPictureFile?.Length; // 1° Check if the size is correct with the limit: var isTooHigh = (uploadedPictureLength >= pictureControls.pictureFileToUploadMaxSize) || false; // Add error message if size is over limitations : if (isTooHigh) { ModelState.AddModelError ( "newPictureToUpload", pictureControls.ErrorMessageForPictureOutOfSize ); } // Get extension of uploaded picture : var uploadedPictureExtension = newPictureToUpload?.ContentType ?? tempPictureFile?.Extension; // 2° Check if the extension is authorized : // 2-1 Check file extension : var isOutExt = (!pictureControls.pictureFileToUploadExtension .Contains(uploadedPictureExtension)) || false; // 2-2 Check input extension : var inputName = newPicture?.pictureStandardUrl; var inputExt = Path.GetExtension(inputName); var inputExtIsOut = false; if ( inputExt != pictureControls.pictureFileToUploadExtension[2] && inputExt != pictureControls.pictureFileToUploadExtension[3] ) { inputExtIsOut = true; } var extensionNotValid = isOutExt || inputExtIsOut; // Add error message if extension is not authorized : if (extensionNotValid) { ModelState.AddModelError ( "newPictureToUpload", pictureControls.errorMessageForPictureOutOfExt ); } // 3° Picture name - Get input value by user or default filename : var nameFromInput = newPicture?.pictureStandardUrl; var nameFromUpload = Path.GetFileName(newPictureToUpload?.FileName); var nameFromTemp = Path.GetFileName(tempPictureFile?.Name); var newPictureSourceName = string.Empty; if (!extensionNotValid) { newPictureSourceName = (!string.IsNullOrEmpty(nameFromInput)) ? nameFromInput : ( (!string.IsNullOrEmpty(nameFromUpload)) ? nameFromUpload : nameFromTemp ); } // 4° Combine directory path & picture name to make the temp picture : if (!string.IsNullOrEmpty(newPictureSourceName)) { newPictureTempPath = Path.Combine ( Server.MapPath(pictureControls.tempFileDirectory), newPictureSourceName ); // 5° Picture Temp is uploaded and saved in the temp directory : newPictureToUpload?.SaveAs(newPictureTempPath); tempPictureFile?.MoveTo(newPictureTempPath); } // 6° Set relative picture path : var relativePicturePath = newPictureTempPath .Replace ( Server.MapPath("~/"), "/" ) .Replace(@"\", "/"); // 7° Set a viewbag to keep & display preview picture when submit : ViewBag.picturePreviewSrc = relativePicturePath ?? pictureGlobalLabels.DefaultPictureUrl; // 8° Combine directory path & picture name to make the source picture : if (!string.IsNullOrEmpty(newPictureSourceName)) { newPictureSourcePath = Path.Combine ( Server.MapPath(pictureControls.pictureFileDirectory), newPictureSourceName ); } // 9° Check if source picture already exists: if (System.IO.File.Exists(newPictureSourcePath)) { ModelState.AddModelError ( "newPictureToUpload", pictureControls.ErrorMessageForPictureFileUnicity ); } #endregion CHECK PICTURE & CREATE A TEMP SAVE #region SAVE PICTURE IN DIRECTORY & INFOS IN DATABASE if (ModelState.IsValid) { // Picture Source is uploaded and saved in the directory : newPictureToUpload?.SaveAs(newPictureSourcePath); tempPictureFile?.CopyTo(newPictureSourcePath); // Check the temp directory : var tempDirToCheck = Server.MapPath(pictureControls.tempFileDirectory); // Pictures Temp are removed from the temp directory : var tempFilesToClean = System.IO.Directory.GetFiles(tempDirToCheck); // Temp directory is not empty : if (tempFilesToClean.Length > 0) { foreach (string fileToRemove in tempFilesToClean) { System.IO.File.Delete(fileToRemove); } } // Add picture data properties in database : db.picture.Add(newPicture); // Save picture creation : db.SaveChanges(); // Redirect to success page : return(RedirectToAction("pictureSuccess")); } #endregion SAVE PICTURE IN DIRECTORY & INFOS IN DATABASE return(View(newPicture)); }