// 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));
            }
        }
Exemplo n.º 2
0
    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();
    }