/// <summary> /// insert article file /// </summary> /// <param name="data"></param> /// <returns></returns> public int InsertArticleFile(ArticleFileT data) { using (ISession session = NHibernateHelper.OpenSession()) { int articleFileNo = (Int32)session.Save(data); session.Flush(); return articleFileNo; } }
//public JsonResult ImgUpload(FormCollection collection) public JsonResult ImgUpload(HttpPostedFileBase file, string temp, string fileIdx) { AjaxResponseModel response = new AjaxResponseModel(); response.Success = false; string fileName = string.Empty; //HttpPostedFileBase imgupload = Request.Files["file"]; if (file != null) { if (file.ContentLength > 0) { string[] extType = { ".jpg", ".png", ".gif" }; string extension = Path.GetExtension(file.FileName).ToLower(); if (extType.Contains(extension)) { fileName = new UploadFunc().FileUpload(file, ImageSize.GetArticleResize(), "Article", null); ArticleFileT articleFileT = new ArticleFileT(); articleFileT.FileGubun = "temp"; articleFileT.FileType = "img"; //articleFileT.MemberNo = profileModel.UserNo; articleFileT.MemberNo = 1; articleFileT.Seq = 5000; articleFileT.ImgUseYn = "U"; articleFileT.Ext = extension; articleFileT.ThumbYn = "Y"; articleFileT.MimeType = file.ContentType; articleFileT.Name = file.FileName; articleFileT.Size = file.ContentLength.ToString(); articleFileT.Rename = fileName; articleFileT.Path = "/Article/article_img/"; articleFileT.Width = "630"; articleFileT.Height = "470"; articleFileT.UseYn = "Y"; articleFileT.Temp = temp; articleFileT.RegIp = IPAddressHelper.GetIP(this); articleFileT.RegId = profileModel.UserId; articleFileT.RegDt = DateTime.Now; int articleFileNo = _articleFileDac.InsertArticleFile(articleFileT); response.Success = true; response.Result = articleFileNo.ToString(); } else { response.Message = "gif, jpg, png 형식 파일만 가능합니다."; } } } if (!string.IsNullOrEmpty(fileIdx)) { string[] idxArr = fileIdx.Split(','); if (idxArr.Length > 1) { _articleFileDac.UpdateArticleFileSeq(idxArr); } } return Json(response, JsonRequestBehavior.AllowGet); }
public JsonResult StlUpload(HttpPostedFileBase file, string temp, string fileIdx) { AjaxResponseModel response = new AjaxResponseModel(); response.Success = false; string fileName = string.Empty; //HttpPostedFileBase stlupload = Request.Files["stlupload"]; if (file != null) { if (file.ContentLength > 0) { if (file.ContentLength < 200 * 1024 * 1024) { string[] extType = { ".stl", ".obj" }; string extension = Path.GetExtension(file.FileName).ToLower(); if (extType.Contains(extension)) { string save3DFolder = "Article/article_3d"; string saveJSFolder = "Article/article_js"; fileName = new UploadFunc().FileUpload(file, null, save3DFolder, null); string file3Dpath = string.Format("\\\\localhost\\fileupload\\{0}\\", save3DFolder); string fileJSpath = string.Format("\\\\localhost\\fileupload\\{0}\\", saveJSFolder); Object3DModel _3dModel = new Modeling3DHelper().Get3DModel(file3Dpath + fileName, extension); //ArticleFileT sizeResult = GetSizeFor3DFile(file3Dpath + fileName, extension); var jsonBuff = JsonConvert.SerializeObject(_3dModel); string jsFileNm = fileJSpath + fileName + ".json"; new FileHelper().FileWriteAllText(jsFileNm, jsonBuff); ArticleFileT articleFileT = new ArticleFileT(); articleFileT.FileGubun = "temp"; articleFileT.FileType = "stl"; //articleFileT.MemberNo = profileModel.UserNo; articleFileT.MemberNo = 1; articleFileT.Seq = 5000; articleFileT.ImgUseYn = "N"; articleFileT.Ext = extension; articleFileT.ThumbYn = "N"; articleFileT.MimeType = file.ContentType; articleFileT.Name = file.FileName; articleFileT.Size = file.ContentLength.ToString(); articleFileT.Rename = fileName; articleFileT.Path = string.Format("/{0}/", save3DFolder); articleFileT.X = 0; articleFileT.Y = 0; articleFileT.Z = 0; articleFileT.Volume = 0; articleFileT.UseYn = "Y"; articleFileT.Temp = temp; articleFileT.RegIp = IPAddressHelper.GetIP(this); articleFileT.RegId = profileModel.UserId; articleFileT.RegDt = DateTime.Now; int articleFileNo = _articleFileDac.InsertArticleFile(articleFileT); response.Success = true; response.Result = articleFileNo.ToString(); } else { response.Message = "stl, obj 형식 파일만 가능합니다."; } } else { response.Message = "최대 사이즈 200MB 파일만 가능합니다."; } } } if (!string.IsNullOrEmpty(fileIdx)) { string[] idxArr = fileIdx.Split(','); if (idxArr.Length > 1) { _articleFileDac.UpdateArticleFileSeq(idxArr); } } return Json(response, JsonRequestBehavior.AllowGet); }
/// <summary> /// update article file /// </summary> /// <param name="data"></param> /// <returns></returns> public bool UpdateArticleFile(ArticleFileT data) { if (data == null) new ArgumentException("객체가 Null임"); using (ISession session = NHibernateHelper.OpenSession()) { try { session.Update(data); session.Flush(); return true; } catch (Exception) { return false; } } }