Пример #1
0
        public void DeleteUploadFileByID(int objectTypeId, int ID)
        {
            UploadFileInfo existingInfo = this.fileDao.GetFileByID(objectTypeId, ID);

            if (existingInfo == null)
            {
                return;
            }

            this.fileDao.DeleteFileByID(objectTypeId, existingInfo.ID);
            FileUtil.DeleteFile(ObjectTypes.GetFileFolder(objectTypeId), existingInfo.GetFileName());
        }
Пример #2
0
        public UploadFileInfo SaveUploadFile(UploadFileInfo info)
        {
            info.FileName = new FileInfo(info.FileName).Name;
            if (info.ID > 0)
            {
                UploadFileInfo existingInfo = this.fileDao.GetFileByID(info.ObjectTypeId, info.ID);
                FileUtil.DeleteFile(ObjectTypes.GetFileFolder(info.ObjectTypeId), existingInfo.GetFileName());

                fileDao.UpdateFile(info.ObjectTypeId, info);
            }
            else
            {
                info = fileDao.AddFile(info.ObjectTypeId, info);
            }

            byte[] fileContent = Convert.FromBase64String(info.FileContent);
            FileUtil.SaveFile(fileContent, ObjectTypes.GetFileFolder(info.ObjectTypeId), info.GetFileName());

            return(info);
        }
Пример #3
0
        /// <summary>
        ///  下载附件
        /// </summary>
        /// <param name="objectTypeId">附件对象类型ID</param>
        /// <param name="id">附件编号</param>
        /// <returns>附件信息</returns>
        public ActionResult DownloadUploadFile(int objectTypeId, int id)
        {
            if (CheckSession(false) == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }

            try
            {
                if (id < 0)
                {
                    UploadFileInfo file = GetUploadFileInSession(id);

                    string fileName    = new FileInfo(file.FileName).Name;
                    byte[] fileContent = Convert.FromBase64String(file.FileContent);

                    return(File(fileContent, System.Web.MimeMapping.GetMimeMapping(fileName), fileName));
                }
                else
                {
                    string         filePath = null;
                    UploadFileInfo file     = this.fileDao.GetFileByID(objectTypeId, id);
                    filePath = Path.Combine(ObjectTypes.GetFileFolder(objectTypeId), file.GetFileName());
                    Response.AddHeader("Set-Cookie", "fileDownload=true; path=/");
                    file.FileName = this.fileManager.GetDownloadFileName(file);
                    return(File(filePath, System.Web.MimeMapping.GetMimeMapping(file.FileName), file.FileName));
                }
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
            }

            return(null);
        }
Пример #4
0
        public DispatchJournalInfo SaveDispatchJournal(DispatchJournalInfo dispatchJournal, UserInfo user)
        {
            if (dispatchJournal.ID > 0)
            {
                this.dispatchJournalDao.UpdateDispatchJournal(dispatchJournal);
                FileUtil.DeleteFile(ObjectTypes.GetFileFolder(ObjectTypes.DispatchJournal), dispatchJournal.SignatureFileName);
            }
            else
            {
                dispatchJournal.ID = this.dispatchJournalDao.AddDispatchJournal(dispatchJournal);
            }


            byte[] fileContent = Convert.FromBase64String(dispatchJournal.FileContent);
            FileUtil.SaveFile(fileContent, Constants.DispatchJournalFolder, dispatchJournal.SignatureFileName);

            UpdateDispatchStatusByJournalAndReport(dispatchJournal.Dispatch.ID, user);
            //添加历史操作——服务凭证 提交
            HistoryInfo historyDisptach = new HistoryInfo(dispatchJournal.ID, ObjectTypes.DispatchJournal, user.ID, DispatchJournalInfo.Actions.Submit);

            this.historyDao.AddHistory(historyDisptach);

            return(dispatchJournal);
        }