示例#1
0
        public JsonResult ApplyFileDownload(string files, string SpaceID)
        {
            ArrayList dirDownloads = new ArrayList();
            var       space        = DocConfigHelper.CreateConfigSpaceByID(SpaceID);

            if (space == null)
            {
                throw new Formula.Exceptions.BusinessException("为找到【ID】为【" + SpaceID + "】的图档实例库");
            }
            var list        = JsonHelper.ToList(files);
            var ArchiveType = System.Configuration.ConfigurationManager.AppSettings["ArchiveType"];

            if (string.IsNullOrEmpty(ArchiveType))
            {
                ArchiveType = "PdfFile";
            }
            ArchiveType = ArchiveType.Replace("PdfFile", "PDFFile");
            foreach (var file in list)
            {
                S_FileInfo fileInfo = new S_FileInfo(file.GetValue("ID"), space);
                if (fileInfo.ConfigInfo == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到文件【" + fileInfo.ID + "】的配置对象信息");
                }
                if (fileInfo.DataEntity.GetValue("StorageType") != StorageType.Electronic.ToString())
                {
                    throw new Formula.Exceptions.BusinessException("实物文件不能下载!");
                }
                if (fileInfo.CurrentAttachment == null)
                {
                    throw new Formula.Exceptions.BusinessException("【" + fileInfo.Name + "】还没有主文件,不能下载!");
                }
                if (String.IsNullOrEmpty(fileInfo.ConfigInfo.DownloadFlowKey))
                {
                    dirDownloads.Add(fileInfo.CurrentAttachment.DataEntity);
                    var           entities = FormulaHelper.GetEntities <DocConstEntities>();
                    var           user     = FormulaHelper.GetUserInfo();
                    S_DocumentLog log      = entities.S_DocumentLog.Create();
                    log.ID             = FormulaHelper.CreateGuid();
                    log.LogType        = "DownLoad";
                    log.Name           = fileInfo.Name;
                    log.NodeID         = fileInfo.NodeID;
                    log.SpaceID        = fileInfo.Space.ID;
                    log.ConfigID       = fileInfo.ConfigInfo.ID;
                    log.CreateDate     = DateTime.Now;
                    log.CreateUserID   = user.UserID;
                    log.CreateUserName = user.UserName;
                    log.FileID         = fileInfo.ID;
                    log.FullNodeID     = fileInfo.FullNodeID;
                    entities.S_DocumentLog.Add(log);
                }
                else
                {
                    CarFO.CreateCarItem(fileInfo, ItemType.DownLoad.ToString());
                }
            }
            this.entities.SaveChanges();
            return(Json(dirDownloads));
        }
示例#2
0
        public void AddBorrowLog(T_Download_FileInfo item)
        {
            var           entities = FormulaHelper.GetEntities <DocConstEntities>();
            var           user     = FormulaHelper.GetUserInfo();
            S_DocumentLog log      = entities.S_DocumentLog.Create();

            log.ID             = FormulaHelper.CreateGuid();
            log.LogType        = "Borrow";
            log.Name           = item.FileName;
            log.NodeID         = item.NodeID;
            log.SpaceID        = item.SpaceID;
            log.ConfigID       = item.ConfigID;
            log.CreateDate     = DateTime.Now;
            log.CreateUserID   = user.UserID;
            log.CreateUserName = user.UserName;
            log.FileID         = item.FileID;
            log.FullNodeID     = "";
            entities.S_DocumentLog.Add(log);
        }