public FileDto(FileVO fileVO) { this.FileId = fileVO.FileId; this.FileNo = fileVO.FileNo; this.Content1 = fileVO.Content1; this.Content2 = fileVO.Content2; this.ShowDate = fileVO.ShowDate; this.FileName = fileVO.FileName; this.FileName2 = fileVO.FileName2; this.FileName3 = fileVO.FileName3; this.Flag = fileVO.Flag; this.Type = fileVO.Type; this.UpdateId = fileVO.UpdateId; this.ServerId = fileVO.ServerId; this.NeedUpdate = fileVO.NeedUpdate; this.CreatedBy = fileVO.CreatedBy; this.UpdatedBy = fileVO.UpdatedBy; this.CreatedDate = fileVO.CreatedDate; this.UpdatedDate = fileVO.UpdatedDate; }
protected void btnAdd_Click(object sender, EventArgs e) { FileVO fileVO = new FileVO(); UIHelper.FillVO(pnlContent, fileVO); fileVO.FileName = m_FileName; fileVO.Flag = 1; if (!string.IsNullOrEmpty(txtShowDate.Text.Trim())) { fileVO.ShowDate = DateTime.Parse(txtShowDate.Text.Trim()); } fileVO.FileNo = GetFileNo(fileVO); fileVO.NeedUpdate = true; fileVO.CreatedBy = m_SessionHelper.LoginUser.FullNameInChinese; fileVO.UpdatedBy = m_SessionHelper.LoginUser.FullNameInChinese; fileVO.CreatedDate = DateTime.Now; fileVO.UpdatedDate = DateTime.Now; m_PostFileService.CreateFile(fileVO); m_WebLogService.AddSystemLog(MsgVO.Action.新增, fileVO); new Thread(new ThreadStart(() => ApiUtil.UpdateFileToServer(Server.MapPath("../../upload/")))).Start(); ClearUI(); fillGridView(); }
/// <summary> /// 更新File /// </summary> /// <param name="fileVO">被更新的File</param> /// <returns>更新後的File</returns> public FileVO UpdateFile(FileVO fileVO) { return PostFileDao.UpdateFile(fileVO); }
/// <summary> /// 刪除File /// </summary> /// <param name="fileVO">被刪除的File</param> public void DeleteFile(FileVO fileVO) { PostFileDao.DeleteFile(fileVO); }
/// <summary> /// 新增File /// </summary> /// <param name="fileVO">File</param> /// <returns>新增後的File</returns> public FileVO CreateFile(FileVO fileVO) { fileVO = PostFileDao.CreateFile(fileVO); return fileVO; }
private string GetFileNo(FileVO fileVO) { IList<NodeVO> storeList = m_PostService.GetNodeListByParentName("店家"); string fileNo = ""; string code = ""; switch (fileVO.Type) { case "1": code = string.Format("{0}C{1}{2}{3}", storeList[0].Name, fileVO.ShowDate.Value.ToString("yyyyMMdd"), fileVO.Content2, fileVO.Content1); fileNo = code; break; case "2": code = string.Format("{0}I{1}", storeList[0].Name, fileVO.ShowDate.Value.ToString("yyyyMMdd")); fileNo = m_CommonService.CreateSer_Code_And_Num(code, 3); break; case "3": code = string.Format("{0}B{1}{2}", storeList[0].Name, fileVO.ShowDate.Value.ToString("yyyyMMdd"), fileVO.Content1); fileNo = code; break; } return fileNo; }
private void FixTimeZone(FileVO fileVO) { int addHours = m_ConfigHelper.AddHours; if (fileVO.ShowDate.HasValue) { fileVO.ShowDate = fileVO.ShowDate.Value.AddHours(addHours); } }
// POST api/<controller> public HttpResponseMessage Post(FileDto fileDto) { if (fileDto != null) { try { FileVO fileVO = null; //檢查是否有ServerId 有的話把狀態改成刪除, 重新建立一筆 if (fileDto.ServerId != 0) { FileVO oldFileVO = m_PostFileService.GetFileById(fileDto.ServerId); if (oldFileVO != null) { oldFileVO.NeedUpdate = false; oldFileVO.Flag = 0; oldFileVO.UpdateId = "系統API"; m_PostFileService.UpdateFile(oldFileVO); } } fileVO = new FileVO(fileDto); fileVO.FileId = 0; fileVO.ServerId = 0; fileVO.NeedUpdate = false; fileVO.UpdateId = "系統API"; FixTimeZone(fileVO); fileVO = m_PostFileService.CreateFile(fileVO); fileVO.ServerId = fileVO.FileId; return Request.CreateResponse<FileDto>(HttpStatusCode.Created, new FileDto(fileVO)); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.NoContent, ex.ToString()); } } else { return Request.CreateResponse(HttpStatusCode.NoContent); } }
/// <summary> /// 更新File /// </summary> /// <param name="fileVO">被更新的File</param> /// <returns>更新後的File</returns> public FileVO UpdateFile(FileVO fileVO) { NHibernateDao.Update(fileVO); return fileVO; }
/// <summary> /// 刪除File /// </summary> /// <param name="fileVO">被刪除的File</param> public void DeleteFile(FileVO fileVO) { NHibernateDao.Delete(fileVO); }
/// <summary> /// 新增File /// </summary> /// <param name="fileVO">File</param> /// <returns>新增後的File</returns> public FileVO CreateFile(FileVO fileVO) { NHibernateDao.Insert(fileVO); return fileVO; }