Exemplo n.º 1
0
        public JsonResult ApplyReDownload()
        {
            string fileID  = this.GetQueryString("files");
            string SpaceID = this.GetQueryString("SpaceID");
            var    space   = DocConfigHelper.CreateConfigSpaceByID(SpaceID);

            if (space == null)
            {
                throw new Formula.Exceptions.BusinessException("为找到【ID】为【" + SpaceID + "】的图档实例库");
            }
            S_FileInfo fileInfo = new S_FileInfo(fileID, space);

            if (fileInfo.ConfigInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到文件【" + fileInfo.ID + "】的配置对象信息");
            }
            if (fileInfo.CurrentAttachment == null)
            {
                throw new Formula.Exceptions.BusinessException("附件不存在");
            }
            if (fileInfo.DataEntity.GetValue("StorageType") != StorageType.Electronic.ToString())
            {
                throw new Formula.Exceptions.BusinessException("实物文件不能下载!");
            }
            CarFO.CreateCarItem(fileInfo, ItemType.DownLoad.ToString());
            this.entities.SaveChanges();
            return(Json(new { }));
        }
Exemplo n.º 2
0
        public JsonResult ArchiveReorganize(string FileList, string SpaceID, string TargetNodeID)
        {
            //直接归档
            var        docSpace = DocConfigHelper.CreateConfigSpaceByID(SpaceID);
            S_NodeInfo node     = S_NodeInfo.GetNode(TargetNodeID, SpaceID);

            var           list = JsonHelper.ToList(FileList);
            StringBuilder sb   = new StringBuilder();

            foreach (var item in list)
            {
                var archFileID = item.GetValue("ArchiveFileID");
                if (string.IsNullOrEmpty(archFileID))
                {
                    //新增档案文件记录
                    S_FileInfo fileInfo = archFile(item, node, item.GetValue("ConfigID"));
                    archFileID = fileInfo.ID;
                    item.SetValue("ArchiveFileID", archFileID);
                }
                else
                {
                    //移动文件
                    S_FileInfo fileInfo = new S_FileInfo(archFileID, docSpace);
                    fileInfo.MoveTo(TargetNodeID, item.GetValue("ConfigID"));
                }
                var sql = "update S_R_Reorganize_DocumentList set ReorganizePath='{1}',ReorganizeFullID='{2}',ArchiveFileID='{3}',ReorganizeConfigID='{4}' where id='{0}'";
                sql = string.Format(sql, item.GetValue("ID"), item.GetValue("ReorganizePath"), item.GetValue("ReorganizeFullID"), archFileID, item.GetValue("ConfigID"));
                sb.AppendLine(sql);
            }
            if (sb.Length > 0)
            {
                this.SqlHelper.ExecuteNonQuery(sb.ToString());
            }
            return(Json(list));
        }
Exemplo n.º 3
0
        public JsonResult ApplyFileBorrow(string files, string SpaceID)
        {
            var space = DocConfigHelper.CreateConfigSpaceByID(SpaceID);

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

            foreach (var file in list)
            {
                S_FileInfo fileInfo = new S_FileInfo(file.GetValue("ID"), space);
                if (fileInfo == null)
                {
                    continue;
                }
                if (fileInfo.ConfigInfo == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到文件【" + fileInfo.ID + "】的配置对象信息");
                }
                if (fileInfo.DataEntity.GetValue("StorageType") != StorageType.Physical.ToString())
                {
                    throw new Formula.Exceptions.BusinessException("电子版文件不能借阅!");
                }
                CarFO.CreateCarItem(fileInfo, ItemType.Borrow.ToString());
            }
            this.entities.SaveChanges();
            return(Json(new { }));
        }
Exemplo n.º 4
0
        public JsonResult GetFileAttachments(string ListData)
        {
            var configEntities = FormulaHelper.GetEntities <DocConfigEntities>();
            var spaceList      = configEntities.Set <S_DOC_Space>().ToList();

            var fileType = new string[] { "Attachments", "SWFFile", "MainFile", "PDFFile", "PlotFile", "XrefFile", "DwfFile", "TiffFile", "SignPdfFile" };
            var result   = new List <string>();
            var list     = JsonHelper.ToList(ListData);

            foreach (var row in list)
            {
                var space = spaceList.FirstOrDefault(a => a.ID == row.GetValue("SpaceID"));
                if (space != null)
                {
                    var fileInfo = new S_FileInfo(row["FileID"].ToString(), space);
                    foreach (var type in fileType)
                    {
                        var fileData = fileInfo.CurrentAttachment.DataEntity.GetValue(type);
                        if (!string.IsNullOrEmpty(fileData))
                        {
                            foreach (var item in fileData.Split(','))
                            {
                                var fileID = item.Split('_')[0];
                                if (!result.Contains(fileID))
                                {
                                    result.Add(fileID);
                                }
                            }
                        }
                    }
                }
            }
            return(Json(new { FileIDs = string.Join(",", result) }));
        }
Exemplo n.º 5
0
        public JsonResult BrownFile(string FileID, string SpaceID)
        {
            var space = DocConfigHelper.CreateConfigSpaceByID(SpaceID);
            var file  = new S_FileInfo(FileID, space);

            if (file.CurrentAttachment == null || String.IsNullOrEmpty(file.CurrentAttachment.DataEntity.GetValue("MainFile")))
            {
                throw new Formula.Exceptions.BusinessException("没有上传附件,无法进行浏览!");
            }
            var fileDB  = SQLHelper.CreateSqlHelper(ConnEnum.FileStore);
            var docType = file.CurrentAttachment.DataEntity.GetValue("FileType");
            var fileID  = file.CurrentAttachment.DataEntity.GetValue("PDFFile").Split('_')[0];

            if (String.IsNullOrEmpty(fileID))
            {
                fileID = file.CurrentAttachment.DataEntity.GetValue("MainFile").Split('_')[0];
            }
            var constEntities = FormulaHelper.GetEntities <DocConstEntities>();
            var log           = constEntities.S_DocumentLog.Create();

            log.ID             = FormulaHelper.CreateGuid();
            log.Name           = file.Name;
            log.LogType        = "Browse";
            log.NodeID         = file.NodeID;
            log.SpaceID        = file.Space.ID;
            log.FileID         = file.ID;
            log.FullNodeID     = file.FullNodeID;
            log.ConfigID       = file.ConfigInfo.ID;
            log.CreateDate     = DateTime.Now;
            log.CreateUserID   = this.CurrentUserInfo.UserID;
            log.CreateUserName = this.CurrentUserInfo.UserName;
            constEntities.S_DocumentLog.Add(log);
            constEntities.SaveChanges();
            return(Json(new { DocType = docType, SWFFileID = fileID }));
        }
Exemplo n.º 6
0
        public JsonResult DeleteReorganizeFile(string FileList, string SpaceID)
        {
            var           docSpace = DocConfigHelper.CreateConfigSpaceByID(SpaceID);
            var           list     = JsonHelper.ToList(FileList);
            StringBuilder sb       = new StringBuilder();

            foreach (var item in list)
            {
                var        archFileID = item.GetValue("ArchiveFileID");
                S_FileInfo fileInfo   = new S_FileInfo(archFileID, docSpace);
                fileInfo.Delete();
                item.SetValue("ReorganizePath", "");
                item.SetValue("ReorganizeFullID", "");
                item.SetValue("ReorganizeConfigID", "");
                item.SetValue("ArchiveFileID", "");
                item.SetValue("ArchiveFileAttrs", "");
                var sql = "update S_R_Reorganize_DocumentList set ReorganizePath='',ReorganizeFullID='',ReorganizeConfigID='',ArchiveFileID='',ArchiveFileAttrs='' where id='{0}'";
                sql = string.Format(sql, item.GetValue("ID"));
                sb.AppendLine(sql);
            }
            if (sb.Length > 0)
            {
                this.SqlHelper.ExecuteNonQuery(sb.ToString());
            }
            return(Json(list));
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
 public void savelog()
 {
     var        result  = new Hashtable();
     string     spaceID = this.Request["SpaceID"];
     string     FileID  = this.Request["FileID"];
     var        space   = DocConfigHelper.CreateConfigSpaceByID(spaceID);
     S_FileInfo file    = new S_FileInfo(FileID, space);
     // S_DocumentLog.Svae(file, this.PageDomainSession, DocInstance.Logic.ApplyType.Browse);
 }
Exemplo n.º 9
0
        private void Return(Dictionary <string, object> row)
        {
            var returnNumber = 0;

            int.TryParse(row.GetValue("ReturnNumber"), out returnNumber);
            var id           = row.GetValue("ID");
            var borrowDetail = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == id);

            if (returnNumber > 0 && borrowDetail != null)
            {
                borrowDetail.ReturnUserID   = row.GetValue("ReturnUserID");
                borrowDetail.ReturnUser     = row.GetValue("ReturnUser");
                borrowDetail.ReturnDeptID   = row.GetValue("ReturnDeptID");
                borrowDetail.ReturnDeptName = row.GetValue("ReturnDeptName");
                borrowDetail.ReturnNumber   = (borrowDetail.ReturnNumber ?? 0) + returnNumber;
                borrowDetail.ReturnDate     = Convert.ToDateTime(row.GetValue("ReturnDate"));

                var isFinish = ((borrowDetail.LendNumber ?? 0) - (borrowDetail.ReturnNumber ?? 0) - (borrowDetail.LostNumber ?? 0)) == 0;
                if (isFinish)
                {
                    borrowDetail.BorrowState = BorrowDetailState.Finish.ToString();
                }

                if (borrowDetail.DetailType == NodeType.Node.ToString())
                {
                    var space    = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID);
                    var nodeInfo = new S_NodeInfo(borrowDetail.RelateID, space);
                    InventoryFO.CreateInventoryLedger(nodeInfo, InventoryType.Return, 0, returnNumber,
                                                      borrowDetail.ID, borrowDetail.ReturnUserID, borrowDetail.ReturnUser, EnumBaseHelper.GetEnumDescription(InventoryType.Return.GetType(), InventoryType.Return.ToString()) + "份数:" + returnNumber + "份");

                    if (isFinish)
                    {
                        nodeInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Return.ToString());
                    }

                    nodeInfo.Save(false);
                }
                else
                {
                    var space    = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID);
                    var fileInfo = new S_FileInfo(borrowDetail.RelateID, space);
                    InventoryFO.CreateInventoryLedger(fileInfo, InventoryType.Return, 0, returnNumber,
                                                      borrowDetail.ID, borrowDetail.ReturnUserID, borrowDetail.ReturnUser, EnumBaseHelper.GetEnumDescription(InventoryType.Return.GetType(), InventoryType.Return.ToString()) + "份数:" + returnNumber + "份");

                    if (isFinish)
                    {
                        fileInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Return.ToString());
                    }

                    fileInfo.Save(false);
                }
            }
        }
Exemplo n.º 10
0
        public virtual JsonResult Delete()
        {
            string listIDs = Request["ListIDs"];

            foreach (var ID in listIDs.Split(','))
            {
                var file = new S_FileInfo(ID, this.Space);
                BeforeDelete(file);
                file.Delete();
                AfterDelete(file);
            }
            return(Json(""));
        }
Exemplo n.º 11
0
        protected override void BeforeSave(S_FileInfo file, Dictionary <string, object> row, bool isNew)
        {
            if (isNew)
            {
                var isPhys = row.GetValue("StorageType") == "Physical";
                var node   = S_NodeInfo.GetNode(row.GetValue("NodeID"), row.GetValue("SpaceID"));
                if (isPhys && node.ConfigInfo.IsPhysicalBox != "True")
                {
                    throw new Formula.Exceptions.BusinessException("当前编目节点不能保存实物文件");
                }
                if (!isPhys && node.ConfigInfo.IsElectronicBox != "True")
                {
                    throw new Formula.Exceptions.BusinessException("当前编目节点不能保存电子档文件");
                }
            }
            else
            {
                string     detail    = string.Empty;
                S_FileInfo oldFile   = new S_FileInfo(file.ID, file.Space);
                var        fileAttrs = file.ConfigInfo.S_DOC_FileAttr.Select(a => a);
                foreach (S_DOC_FileAttr fileAttr in fileAttrs)
                {
                    if (fileAttr.InputType.Equals("ButtonEdit"))//弹出选择
                    {
                        detail += file.DataEntity.GetValue(fileAttr.FileAttrField + "Name") == oldFile.DataEntity.GetValue(fileAttr.FileAttrField + "Name") ? "" : "\"" + fileAttr.FileAttrName + ":" + oldFile.DataEntity.GetValue(fileAttr.FileAttrField + "Name") + "\"修改为\"" + file.DataEntity.GetValue(fileAttr.FileAttrField + "Name") + "\";";
                    }

                    else if (fileAttr.InputType.Equals("Combobox"))//枚举
                    {
                        var    enums       = EnumBaseHelper.GetEnumDef(fileAttr.EnumKey).EnumItem;
                        var    enumNameOld = enums.FirstOrDefault(a => a.Code.Equals(oldFile.DataEntity.GetValue(fileAttr.FileAttrField)));
                        string oldName     = enumNameOld != null?enumNameOld.Name:"";
                        var    enumName    = enums.FirstOrDefault(a => a.Code.Equals(file.DataEntity.GetValue(fileAttr.FileAttrField)));
                        detail += file.DataEntity.GetValue(fileAttr.FileAttrField) == oldFile.DataEntity.GetValue(fileAttr.FileAttrField) ? "" : "\"" + fileAttr.FileAttrName + ":" + oldName + "\"修改为\"" + enumName.Name + "\";";
                    }
                    else
                    {
                        if (fileAttr.FileAttrField.Equals("SortIndex") || fileAttr.FileAttrField.Equals("DocIndexID"))
                        {
                            continue;
                        }
                        detail += file.DataEntity.GetValue(fileAttr.FileAttrField) == oldFile.DataEntity.GetValue(fileAttr.FileAttrField) ? "" : "\"" + fileAttr.FileAttrName + ":" + oldFile.DataEntity.GetValue(fileAttr.FileAttrField) + "\"修改为\"" + file.DataEntity.GetValue(fileAttr.FileAttrField) + "\";";
                    }
                }
                if (!string.IsNullOrEmpty(detail))
                {
                    //修改,详情说明
                    InventoryFO.CreateNewInventoryLedger(oldFile, detail, InventoryType.Update);
                }
            }
        }
Exemplo n.º 12
0
        public void applyfileborrow(List <Dictionary <string, object> > files)
        {
            var list             = files;
            var docConstEntities = FormulaHelper.GetEntities <DocConstEntities>();
            var user             = FormulaHelper.GetUserInfo();

            foreach (var file in list)
            {
                var space = DocConfigHelper.CreateConfigSpaceByID(file.GetValue("SpaceID"));
                //var FileInfo = docConstEntities.T_Borrow_FileInfo.FirstOrDefault(d => d.T_BorrowID == file.GetValue("BorrowID") && d.FileName == file.GetValue("Name"));
                S_FileInfo fileInfo = new S_FileInfo(file.GetValue("RelateID"), space);
                if (fileInfo.ConfigInfo == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到文件【" + fileInfo.ID + "】的配置对象信息");
                }
                if (fileInfo.DataEntity.GetValue("BorrowState") == "Borrow")
                {
                    throw new Formula.Exceptions.BusinessException("已经借出,不能借阅!");
                }
                if (fileInfo.DataEntity.GetValue("Media") == "电子版")
                {
                    throw new Formula.Exceptions.BusinessException("载体是电子版,不能借阅!");
                }
                var carItem = this.entities.Set <S_CarInfo>().FirstOrDefault(d => d.FileID == fileInfo.ID &&
                                                                             d.State == "New" && d.UserID == this.CurrentUserInfo.UserID && d.Type == "Borrow");
                if (carItem == null)
                {
                    carItem              = new S_CarInfo();
                    carItem.ID           = FormulaHelper.CreateGuid();
                    carItem.NodeID       = fileInfo.NodeID;
                    carItem.Type         = ItemType.Borrow.ToString();
                    carItem.UserID       = user.UserID;
                    carItem.UserName     = user.UserName;
                    carItem.CreateDate   = DateTime.Now;
                    carItem.DataType     = fileInfo.ConfigInfo.Name;
                    carItem.FileID       = fileInfo.ID;
                    carItem.SpaceID      = file.GetValue("SpaceID");
                    carItem.ConfigID     = fileInfo.ConfigInfo.ID;
                    carItem.Name         = fileInfo.CreateCarName();// fileInfo.Name;
                    carItem.State        = ItemState.New.ToString();
                    carItem.CreateUser   = user.UserName;
                    carItem.CreateUserID = user.UserID;
                    this.entities.Set <S_CarInfo>().Add(carItem);
                }
                else if (list.Count == 1)
                {
                    throw new Formula.Exceptions.BusinessException("该文件已在借阅车中,请前往借阅车申请借阅");
                }
            }
            this.entities.SaveChanges();
        }
Exemplo n.º 13
0
        void SetFileAttr(S_FileInfo file, string Attr)
        {
            var dic = JsonHelper.ToObject(Attr);

            foreach (string key in dic.Keys)
            {
                if (key == "ID" || key == "NodeID" || key == "SpaceID" || key == "ConfigID" || key == "FullNodeID" || key == "State" || key == "BorrowState" ||
                    key == "BorrowUserID" || key == "BorrowUserName")
                {
                    continue;
                }
                file.DataEntity.SetValue(key, dic.GetValue(key));
            }
        }
Exemplo n.º 14
0
        public virtual void forbidden()
        {
            string listIDs = Request["ID"];

            foreach (var ID in listIDs.Split(','))
            {
                if (Tool.IsNullOrEmpty(ID))
                {
                    continue;
                }
                var file = S_FileInfo.GetFile(ID, this.SpaceID);
                file.Recover();
            }
        }
Exemplo n.º 15
0
        public virtual void movefile()
        {
            string nodeID  = Request["NodeID"];
            string listIDs = Request["ListIDs"];

            foreach (var ID in listIDs.Split(','))
            {
                if (!string.IsNullOrEmpty(ID))
                {
                    var FileNode = new S_FileInfo(ID, this.Space);
                    FileNode.MoveTo(nodeID);
                }
            }
        }
Exemplo n.º 16
0
        public virtual JsonResult GetModel(string id)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            bool isNew = false;

            if (String.IsNullOrEmpty(id))
            {
                isNew = true;
                var nodeID = this.Request["NodeID"];
                if (String.IsNullOrEmpty(nodeID))
                {
                    nodeID = this.GetQueryString("NodeID");
                }
                result.SetValue("NodeID", nodeID);
                result.SetValue("ConfigID", this.ConfigID);
                var node  = S_NodeInfo.GetNode(nodeID, this.SpaceID);
                var attrs = this.Config.S_DOC_FileAttr.Where(d => !String.IsNullOrEmpty(d.DefaultValue));
                foreach (var attr in attrs)
                {
                    if (attr.DefaultValue.Split(',').Length > 0 && attr.InputType.IndexOf(ControlType.ButtonEdit.ToString()) >= 0)
                    {
                        SetDefualtValue(result, attr.FileAttrField, attr.DefaultValue.Split(',')[0], node);
                        SetDefualtValue(result, attr.FileAttrField + "Name", attr.DefaultValue.Split(',')[1], node);
                    }
                    else
                    {
                        SetDefualtValue(result, attr.FileAttrField, attr.DefaultValue, node);
                    }
                }
            }
            else
            {
                var file = new S_FileInfo(id, this.Space);
                result = file.DataEntity;
                if (file.CurrentAttachment != null)
                {
                    result["MainFile"]    = file.CurrentAttachment.DataEntity.GetValue("MainFile");
                    result["Attachments"] = file.CurrentAttachment.DataEntity.GetValue("Attachments");
                    result["PdfFile"]     = file.CurrentAttachment.DataEntity.GetValue("PDFFile");
                    result["PlotFile"]    = file.CurrentAttachment.DataEntity.GetValue("PlotFile");
                    result["XrefFile"]    = file.CurrentAttachment.DataEntity.GetValue("XrefFile");
                    result["DwfFile"]     = file.CurrentAttachment.DataEntity.GetValue("DwfFile");
                    result["TiffFile"]    = file.CurrentAttachment.DataEntity.GetValue("TiffFile");
                    result["SignPdfFile"] = file.CurrentAttachment.DataEntity.GetValue("SignPdfFile");
                    result["AtlasFile"]   = JsonHelper.ToList(file.CurrentAttachment.DataEntity.GetValue("AtlasFile"));
                }
            }
            this.AfterGetMode(result, isNew);
            return(Json(result));
        }
Exemplo n.º 17
0
        protected override void OnFlowEnd(T_D_DownloadApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            var carIds   = entity.T_D_DownloadApply_DetailInfo.Select(a => a.CarInfoID).ToArray();
            var carItems = this.BusinessEntities.Set <S_CarInfo>().Where(a => carIds.Contains(a.ID));

            foreach (var item in entity.T_D_DownloadApply_DetailInfo.ToList())
            {
                var carItem = carItems.FirstOrDefault(a => a.ID == item.CarInfoID);
                carItem.State = ItemState.Finish.ToString();

                #region 创建S_DownloadDetail
                int downloadExpireDate    = 7;
                var DocDownloadExpireDays = System.Configuration.ConfigurationManager.AppSettings["DocDownloadExpireDays"];
                if (!string.IsNullOrEmpty(DocDownloadExpireDays))
                {
                    downloadExpireDate = Convert.ToInt32(DocDownloadExpireDays);
                }
                S_DownloadDetail downloadDetail = new S_DownloadDetail
                {
                    ID                 = FormulaHelper.CreateGuid(),
                    DownloadID         = entity.ID,
                    Name               = item.Name,
                    Code               = item.Code,
                    SpaceID            = carItem.SpaceID,
                    ConfigID           = carItem.ConfigID,
                    FileID             = carItem.FileID,
                    CreateUserID       = entity.ApplyUser,
                    CreateUserName     = entity.ApplyUserName,
                    CreateDate         = DateTime.Now,
                    UserDeptID         = entity.ApplyDept,
                    UserDeptName       = entity.ApplyDeptName,
                    PassDate           = DateTime.Now,
                    DownloadState      = ItemState.Finish.ToString(),
                    DownloadExpireDate = Convert.ToDateTime(DateTime.Now.AddDays(downloadExpireDate).ToShortDateString() + " 23:59:59")
                };
                this.BusinessEntities.Set <S_DownloadDetail>().Add(downloadDetail);
                #endregion

                S_FileInfo file = new S_FileInfo(carItem.FileID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(carItem.SpaceID)));
                InventoryFO.CreateNewInventoryLedger(file, "", InventoryType.DownLoad);
            }
            this.BusinessEntities.SaveChanges();
        }
        protected override void OnFlowEnd(S_SU_DocumentRelieveSeal entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing)
        {
            var detailIst = entity.S_SU_DocumentRelieveSeal_DetailList.ToList();
            var spaceList = new List <S_DOC_Space>();
            var spaceIDs  = detailIst.Where(a => !string.IsNullOrEmpty(a.SpaceID)).Select(a => a.SpaceID).ToList();

            foreach (var spaceID in spaceIDs)
            {
                var           nodeIds = detailIst.Where(a => a.SpaceID == spaceID && !string.IsNullOrEmpty(a.RelateID)).Select(a => a.RelateID);
                StringBuilder sb      = new StringBuilder();
                var           space   = spaceList.FirstOrDefault(a => a.ID == spaceID);
                if (space == null)
                {
                    space = DocConfigHelper.CreateConfigSpaceByID(spaceID);
                    spaceList.Add(space);
                }
                var db = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString);
                foreach (var nodeid in nodeIds)
                {
                    sb.AppendLine("update S_NodeInfo set State = '" + DocState.Normal.ToString() + "',RackNumber='" + entity.RelieveSealRackNumber + "',RackNumberName='" + entity.RelieveSealRackNumberName + "',StorageRoom='" + entity.RelieveSealStorageRoom + "',StorageRoomName='" + entity.RelieveSealStorageRoomName + "' where FullPathID like '%" + nodeid + "%'");
                    sb.AppendLine("update S_FileInfo set State = '" + DocState.Normal.ToString() + "' where FullNodeID like '%" + nodeid + "%'");
                }
                if (sb.Length > 0)
                {
                    db.ExecuteNonQuery(sb.ToString());
                }
            }
            foreach (var detail in detailIst)
            {
                if (detail.RelateType.Equals("Node"))
                {
                    S_NodeInfo node = new S_NodeInfo(detail.RelateID, Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(detail.SpaceID)));
                    InventoryFO.CreateNewInventoryLedger(node, "\"库房\"修改为:\"" + entity.RelieveSealStorageRoomName + "\";\"货架号\"修改为:\"" + entity.RelieveSealRackNumberName + "\"", InventoryType.RelieveSeal);
                }
                else
                {
                    S_FileInfo file = new S_FileInfo(detail.RelateID, Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(detail.SpaceID)));
                    InventoryFO.CreateNewInventoryLedger(file, "\"库房\"修改为:\"" + entity.RelieveSealStorageRoomName + "\";\"货架号\"修改为:\"" + entity.RelieveSealRackNumberName + "\"", InventoryType.RelieveSeal);
                }
            }
        }
Exemplo n.º 19
0
        protected override void OnFlowEnd(T_B_BorrowApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            var carIds   = entity.T_B_BorrowApply_DetailInfo.Select(a => a.CarInfoID).ToArray();
            var carItems = this.BusinessEntities.Set <S_CarInfo>().Where(a => carIds.Contains(a.ID));

            foreach (var item in entity.T_B_BorrowApply_DetailInfo.ToList())
            {
                var carItem = carItems.FirstOrDefault(a => a.ID == item.CarInfoID);
                if (carItem != null)
                {
                    carItem.State = ItemState.Finish.ToString();

                    #region 创建S_BorrowDetail
                    S_BorrowDetail borrowDetail = new S_BorrowDetail
                    {
                        ID             = FormulaHelper.CreateGuid(),
                        BorrowID       = entity.ID,
                        SpaceID        = carItem.SpaceID,
                        SpaceName      = item.SpaceName,
                        DataType       = carItem.DataType,
                        DetailType     = string.IsNullOrEmpty(item.FileID) ? NodeType.Node.ToString() : NodeType.File.ToString(),
                        RelateID       = string.IsNullOrEmpty(item.FileID) ? item.NodeID : item.FileID,
                        ConfigID       = carItem.ConfigID,
                        Name           = item.Name,
                        Code           = item.Code,
                        CreateUserID   = entity.ApplyUser,
                        CreateUserName = entity.ApplyUserName,
                        CreateDeptID   = entity.ApplyDept,
                        CreateDeptName = entity.ApplyDeptName,
                        CreateDate     = DateTime.Now,
                        ApplyNumber    = item.ApplyAmount,
                        BorrowState    = BorrowDetailState.ToLend.ToString()
                    };
                    this.BusinessEntities.Set <S_BorrowDetail>().Add(borrowDetail);
                    #endregion
                }
                S_FileInfo file = new S_FileInfo(item.FileID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(item.SpaceID)));
                InventoryFO.CreateNewInventoryLedger(file, "", InventoryType.BorrowFile);
            }
            this.BusinessEntities.SaveChanges();
        }
Exemplo n.º 20
0
        public static void CreateInventoryLedger(S_FileInfo file, InventoryType type, int totalAmount, int inventoryAmount,
                                                 string relateDetailInfoID, string targetUserID = "", string targetUserName = "", string detail = "")
        {
            DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>();
            var currentUser           = FormulaHelper.GetUserInfo();
            var InventoryLedger       = new S_A_InventoryLedger
            {
                CarItemName        = "",
                CreateDate         = System.DateTime.Now,
                CreateUserID       = currentUser.UserID,
                CreateUserName     = currentUser.UserName,
                SpaceID            = file.Space.ID,
                Type               = type.ToString(),
                Detail             = detail,
                CreateDept         = currentUser.UserDeptNames,
                InventoryAmount    = inventoryAmount,
                TotalAmount        = totalAmount,
                RelateID           = file.ID,
                RelateName         = file.Name,
                RelateType         = ListConfigType.File.ToString(),
                RelateDetailInfoID = relateDetailInfoID,
                TargetUserID       = targetUserID,
                TargetUserName     = targetUserName
            };

            var qNum = int.Parse(string.IsNullOrEmpty(file.DataEntity.GetValue("Quantity")) ? "0" : file.DataEntity.GetValue("Quantity")) + totalAmount;

            file.DataEntity.SetValue("Quantity", qNum);
            var sNum = int.Parse(string.IsNullOrEmpty(file.DataEntity.GetValue("StorageNum")) ? "0" : file.DataEntity.GetValue("StorageNum")) + inventoryAmount;

            file.DataEntity.SetValue("StorageNum", sNum);
            if (qNum < 0 || sNum < 0)
            {
                throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写");
            }

            file.Save(false);
            entities.Set <S_A_InventoryLedger>().Add(InventoryLedger);
            entities.SaveChanges();
        }
Exemplo n.º 21
0
        public static void CreateCarItem(S_FileInfo fileInfo, string type)
        {
            var user     = FormulaHelper.GetUserInfo();
            var entities = FormulaHelper.GetEntities <DocConstEntities>();

            if (fileInfo.Space == null)
            {
                throw new Formula.Exceptions.BusinessException("没有获取到申请文件的配置空间信息,无法进行申请下载");
            }
            if (fileInfo.ConfigInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("没有获取到申请文件的文件配置类别信息,无法进行申请下载");
            }
            var carItem = entities.Set <S_CarInfo>().FirstOrDefault(d => d.FileID == fileInfo.ID &&
                                                                    d.State == "New" && d.UserID == user.UserID && d.Type == type);

            if (carItem == null)
            {
                carItem = new S_CarInfo
                {
                    ID           = FormulaHelper.CreateGuid(),
                    UserID       = user.UserID,
                    UserName     = user.UserName,
                    Name         = fileInfo.CreateCarName(),
                    Code         = fileInfo.DataEntity.GetValue("Code"),
                    DataType     = fileInfo.ConfigInfo.Name,
                    Type         = type,
                    FileID       = fileInfo.ID,
                    NodeID       = fileInfo.NodeID,
                    State        = ItemState.New.ToString(),
                    CreateDate   = DateTime.Now,
                    CreateUser   = user.UserName,
                    CreateUserID = user.UserID,
                    ConfigID     = fileInfo.ConfigInfo.ID,
                    SpaceID      = fileInfo.Space.ID,
                };
                entities.Set <S_CarInfo>().Add(carItem);
            }
        }
Exemplo n.º 22
0
 //遗失损毁校验
 public void LostDamageVerifica(Dictionary <string, string> dic, List <Dictionary <string, object> > lostReplenishList)
 {
     foreach (var lostReplenishDetail in lostReplenishList)
     {
         string      relateID      = lostReplenishDetail.ContainsKey("RelateDocID") ? lostReplenishDetail["RelateDocID"].ToString() : "";//文件或节点ID
         string      spaceID       = lostReplenishDetail.ContainsKey("SpaceID") ? lostReplenishDetail["SpaceID"].ToString() : "";
         S_DOC_Space space         = Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID));
         string      relateDocType = lostReplenishDetail.ContainsKey("RelateDocType") ? lostReplenishDetail["RelateDocType"].ToString() : "";//文件或结点
         string      state         = "";
         if (dic.ContainsKey("LostDetail"))
         {
             state = lostReplenishDetail.ContainsKey("LoseDamageState") ? lostReplenishDetail["LoseDamageState"].ToString() : "";//遗失损毁状态
         }
         int lostReplenishCount = lostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]);
         if (relateDocType.ToLower() == "node")
         {
             S_NodeInfo node       = new S_NodeInfo(relateID, space);
             object     storageNum = null;
             node.DataEntity.TryGetValue("StorageNum", out storageNum);
             if (lostReplenishCount > Convert.ToInt32(storageNum))
             {
                 throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写");
             }
             continue;
         }
         else
         {
             S_FileInfo file       = new S_FileInfo(relateID, space);
             object     storageNum = null;
             file.DataEntity.TryGetValue("StorageNum", out storageNum);
             if (lostReplenishCount > Convert.ToInt32(storageNum))
             {
                 throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写");
             }
             continue;
         }
     }
 }
Exemplo n.º 23
0
        public static void CreateNewInventoryLedger(S_FileInfo file, string detail = "", InventoryType type = InventoryType.StorageIn)
        {
            DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>();
            var currentUser           = FormulaHelper.GetUserInfo();
            var InventoryLedger       = new S_A_InventoryLedger
            {
                SpaceID            = file.Space.ID,
                RelateID           = file.ID,
                RelateName         = file.Name,
                RelateType         = InventoryRelateType.File.ToString(),
                RelateDetailInfoID = "",
                CarItemName        = "",
                Type           = type.ToString(),
                Detail         = detail,
                CreateDept     = currentUser.UserDeptNames,
                CreateDate     = System.DateTime.Now,
                CreateUserID   = currentUser.UserID,
                CreateUserName = currentUser.UserName,
                TargetUserID   = "",
                TargetUserName = ""
            };

            if (!string.IsNullOrEmpty(file.DataEntity.GetValue("Quantity")))
            {
                var num = 0;
                if (int.TryParse(file.DataEntity.GetValue("Quantity"), out num))
                {
                    InventoryLedger.TotalAmount     = num;
                    InventoryLedger.InventoryAmount = num;
                }
                if (num == 0)
                {
                    return;
                }
            }
            entities.Set <S_A_InventoryLedger>().Add(InventoryLedger);
            entities.SaveChanges();
        }
Exemplo n.º 24
0
        public JsonResult ReturnFile()
        {
            var ids = this.GetQueryString("ListIDs").Split(',');

            if (ids.Length == 0)
            {
                ids = this.GetQueryString("ID").Split(',');
            }
            var spaceID = this.GetQueryString("SpaceID");
            var user    = FormulaHelper.GetUserInfo();
            var space   = DocConfigHelper.CreateConfigSpaceByID(spaceID);

            foreach (var fileID in ids)
            {
                var file = new S_FileInfo(fileID, space);
                file.DataEntity.SetValue("BorrowState", "");
                file.DataEntity.SetValue("BorrowUserID", "");
                file.DataEntity.SetValue("BorrowUserName", "");
                file.Save(false);
            }
            var list = this.BusinessEntities.Set <S_BorrowDetail>().Where(a => ids.Contains(a.RelateID)).ToList();

            foreach (var item in list)
            {
                if (item.BorrowState == BorrowReturnState.Return.ToString())
                {
                    continue;
                }
                item.ReturnDate   = DateTime.Now;
                item.ReturnUserID = user.UserID;
                item.ReturnUser   = user.UserName;
                item.BorrowState  = BorrowReturnState.Return.ToString();
            }
            this.BusinessEntities.SaveChanges();
            return(Json(""));
        }
Exemplo n.º 25
0
        public JsonResult GetGalleryData(string FileID, string SpaceID)
        {
            var result     = new Dictionary <string, object>();
            var space      = DocConfigHelper.CreateConfigSpaceByID(SpaceID);
            var file       = new S_FileInfo(FileID, space);
            var titleInfos = file.ConfigInfo.S_DOC_AtlasConfigDetail.Where(a => a.Type == "List" && a.Dispaly == "True")
                             .OrderBy(a => a.DetailSort).Take(3).ToArray();
            var     blockInfos = file.ConfigInfo.S_DOC_AtlasConfigDetail.Where(a => a.Type == "Block" && a.Dispaly == "True");
            var     dt         = file.InstanceDB.ExecuteDataTable(@"
select S_FileInfo.*,S_Attachment.AtlasFile from S_FileInfo
left join S_Attachment on S_FileInfo.ID = S_Attachment.FileID and CurrentVersion = 'True'
where S_FileInfo.ID = '" + file.ID + "'");
            DataRow fileData   = null;

            if (dt.Rows.Count > 0)
            {
                fileData = dt.Rows[0];
            }
            if (fileData == null)
            {
                new Formula.Exceptions.BusinessException("未找到指定的文件信息");
            }
            var titles = new List <object>();

            foreach (var item in titleInfos)
            {
                var value = "";
                if (dt.Columns.Contains(item.AttrField) && fileData[item.AttrField] != DBNull.Value)
                {
                    if (dt.Columns[item.AttrField].DataType.Name.Contains("DateTime"))
                    {
                        value = ((DateTime)fileData[item.AttrField]).ToString("yyyy年MM月dd日");
                    }
                    else
                    {
                        value = (fileData[item.AttrField]).ToString();
                    }
                }
                titles.Add(new { Left = item.AttrName, Right = value, Field = item.AttrField, DataType = dt.Columns[item.AttrField].DataType.Name });
            }
            result.Add("TitleInfos", titles);

            var blocks = new List <object>();

            foreach (var item in blockInfos)
            {
                var value = "";
                if (dt.Columns.Contains(item.AttrField) && fileData[item.AttrField] != DBNull.Value)
                {
                    if (dt.Columns[item.AttrField].DataType.Name.Contains("DateTime"))
                    {
                        value = ((DateTime)fileData[item.AttrField]).ToString("yyyy年MM月dd日");
                    }
                    else
                    {
                        value = (fileData[item.AttrField]).ToString();
                    }
                }
                blocks.Add(new { Left = item.AttrName, Right = value, Field = item.AttrField, DataType = dt.Columns[item.AttrField].DataType.Name });
            }
            result.Add("BlockInfos", blocks);

            var attList = new List <object>();

            if (fileData["AtlasFile"] != DBNull.Value && !string.IsNullOrEmpty(fileData["AtlasFile"].ToString()))
            {
                var AtlasFile = JsonHelper.ToList(fileData["AtlasFile"].ToString());
                foreach (var item in AtlasFile)
                {
                    attList.Add(new
                    {
                        PictureFileID = item.GetValue("PictureFileID"),
                        ThumbFileID   = item.GetValue("ThumbFileID"),
                        Description   = item.GetValue("Description")
                    });
                }
            }
            result.Add("AtlasList", attList);

            return(Json(result));
        }
Exemplo n.º 26
0
 protected virtual void AfterSave(S_FileInfo file, Dictionary <string, object> row, bool isNew)
 {
 }
Exemplo n.º 27
0
        public static void FileValidateDataAttr(S_FileInfo file)
        {
            bool   isNew             = true;
            var    valiateAttr       = file.ConfigInfo.S_DOC_FileAttr.Where(d => d.ValidateType != ValidateType.None.ToString()).ToList();
            var    uniqueList        = valiateAttr.Where(d => d.ValidateType == ValidateType.Unique.ToString()).ToList();
            var    typeUniqueList    = valiateAttr.Where(d => d.ValidateType == ValidateType.TypeUnique.ToString()).ToList();
            var    bortherUniqueList = valiateAttr.Where(d => d.ValidateType == ValidateType.BortherUnique.ToString()).ToList();
            string sql       = " SELECT Name FROM " + file.TableName + " WHERE 1=1";
            string whereStr  = string.Empty;
            string fileNames = string.Empty;
            string attrNames = string.Empty;

            foreach (var item in uniqueList)
            {
                whereStr  += item.FileAttrField + " = '" + file.DataEntity.GetValue(item.FileAttrField) + "' OR ";
                attrNames += item.FileAttrName + ",";
            }

            if (!String.IsNullOrEmpty(whereStr))
            {
                whereStr  = whereStr.Trim().TrimEnd(new char[] { 'O', 'R' });
                whereStr += ")";
                if (!isNew)
                {
                    whereStr += " AND ID !='" + file.ID + "'";
                }
                DataRowCollection rows = file.InstanceDB.ExecuteDataTable(sql + "AND (" + whereStr).Rows;
                foreach (DataRow row in rows)
                {
                    fileNames += row["Name"] + ",";
                }
                if (fileNames.Length > 0)
                {
                    throw new Formula.Exceptions.BusinessException("文件【" + attrNames.TrimEnd(',') + "】重复,请修改后重新归档\n文件【" + fileNames.TrimEnd(',') + "】");
                }
            }

            attrNames = string.Empty; whereStr = string.Empty;
            foreach (var item in typeUniqueList)
            {
                whereStr  += item.FileAttrField + " = '" + file.DataEntity.GetValue(item.FileAttrField) + "' OR ";
                attrNames += item.FileAttrName + ",";
            }
            if (!String.IsNullOrEmpty(whereStr))
            {
                whereStr  = whereStr.Trim().TrimEnd(new char[] { 'O', 'R' });
                whereStr += ") AND CONFIGID='" + file.ConfigInfo.ID + "' ";
                if (!isNew)
                {
                    whereStr += " AND ID !='" + file.ID + "'";
                }
                DataRowCollection rows = file.InstanceDB.ExecuteDataTable(sql + "AND (" + whereStr).Rows;
                foreach (DataRow row in rows)
                {
                    fileNames += row["Name"] + ",";
                }
                if (fileNames.Length > 0)
                {
                    throw new Formula.Exceptions.BusinessException("文件【" + attrNames.TrimEnd(',') + "】重复,在" + file.ConfigInfo.Name + "范围内不存在重复的内容,请修改后重新归档\n文件【" + fileNames.TrimEnd(',') + "】");
                }
            }

            attrNames = string.Empty; whereStr = string.Empty;
            foreach (var item in bortherUniqueList)
            {
                whereStr  += item.FileAttrField + " = '" + file.DataEntity.GetValue(item.FileAttrField) + "' OR ";
                attrNames += item.FileAttrName + ",";
            }
            if (!String.IsNullOrEmpty(whereStr))
            {
                whereStr  = whereStr.Trim().TrimEnd(new char[] { 'O', 'R' });
                whereStr += ") AND NodeID='" + file.DataEntity.GetValue("NodeID") + "' ";
                if (!isNew)
                {
                    whereStr += " AND ID !='" + file.ID + "'";
                }
                DataRowCollection rows = file.InstanceDB.ExecuteDataTable(sql + "AND (" + whereStr).Rows;
                foreach (DataRow row in rows)
                {
                    fileNames += row["Name"] + ",";
                }
                if (fileNames.Length > 0)
                {
                    throw new Formula.Exceptions.BusinessException("文件【" + attrNames.TrimEnd(',') + "】重复,请修改后重新归档\n文件【" + fileNames.TrimEnd(',') + "】");
                }
            }
        }
Exemplo n.º 28
0
 protected virtual void BeforeDelete(S_FileInfo file)
 {
 }
Exemplo n.º 29
0
 protected virtual void AfterDelete(S_FileInfo file)
 {
 }
Exemplo n.º 30
0
        public virtual JsonResult Save()
        {
            var    user        = FormulaHelper.GetUserInfo();
            string json        = Request.Form["FormData"];
            bool   isUpVersion = string.IsNullOrEmpty(this.Request["UpVersion"]) ? false : this.Request["UpVersion"].ToLower() == "true";
            bool   isNew       = false;

            var        row = JsonHelper.ToObject <Dictionary <string, object> >(json);
            S_FileInfo file;

            if (!row.ContainsKey("ID") || Tool.IsNullOrEmpty(row["ID"]))
            {
                isNew = true;
                file  = new S_FileInfo(this.SpaceID, this.ConfigID);
                file.SetData(row);
                var node = new S_NodeInfo(file.NodeID, this.Space);
                file.FullNodeID = node.FullPathID;
                file.ID         = FormulaHelper.CreateGuid();
                file.DataEntity.SetValue("State", DocState.Normal.ToString());
                string mainFile    = row.GetValue("MainFile");
                string attachments = row.GetValue("Attachments");
                string pdfFile     = row.GetValue("PdfFile");
                string plotFile    = row.GetValue("PlotFile");
                string xrefFile    = row.GetValue("XrefFile");
                string dwfFile     = row.GetValue("DwfFile");
                string tiffFile    = row.GetValue("TiffFile");
                string signPdfFile = row.GetValue("SignPdfFile");
                string atlasFile   = row.GetValue("AtlasFile");
                if (!String.IsNullOrEmpty(mainFile) || !String.IsNullOrEmpty(attachments) ||
                    !String.IsNullOrEmpty(pdfFile) || !String.IsNullOrEmpty(plotFile) ||
                    !String.IsNullOrEmpty(plotFile) || !String.IsNullOrEmpty(xrefFile) ||
                    !String.IsNullOrEmpty(dwfFile) || !String.IsNullOrEmpty(signPdfFile) ||
                    !string.IsNullOrEmpty(atlasFile))
                {
                    S_Attachment attach = new S_Attachment(this.SpaceID);
                    attach.DataEntity.SetValue("MainFile", mainFile);
                    attach.DataEntity.SetValue("Attachments", attachments);
                    attach.DataEntity.SetValue("PDFFile", pdfFile);
                    attach.DataEntity.SetValue("PlotFile", plotFile);
                    attach.DataEntity.SetValue("XrefFile", xrefFile);
                    attach.DataEntity.SetValue("DwfFile", dwfFile);
                    attach.DataEntity.SetValue("TiffFile", tiffFile);
                    attach.DataEntity.SetValue("SignPdfFile", signPdfFile);
                    attach.DataEntity.SetValue("AtlasFile", atlasFile);
                    attach.DataEntity.SetValue("CreateDate", DateTime.Now.ToString());
                    attach.DataEntity.SetValue("CreateUser", user.UserID);
                    attach.DataEntity.SetValue("CreateUserName", user.UserName);
                    file.AddAttachment(attach);
                }
            }
            else
            {
                file = new S_FileInfo(row["ID"].ToString(), this.Space);
                string mainFile    = row.GetValue("MainFile");
                string attachments = row.GetValue("Attachments");
                string pdfFile     = row.GetValue("PdfFile");
                string plotFile    = row.GetValue("PlotFile");
                string xrefFile    = row.GetValue("XrefFile");
                string dwfFile     = row.GetValue("DwfFile");
                string tiffFile    = row.GetValue("TiffFile");
                string signPdfFile = row.GetValue("SignPdfFile");
                string atlasFile   = row.GetValue("AtlasFile");
                if (!String.IsNullOrEmpty(mainFile) || !String.IsNullOrEmpty(attachments) ||
                    !String.IsNullOrEmpty(pdfFile) || !String.IsNullOrEmpty(plotFile) ||
                    !String.IsNullOrEmpty(plotFile) || !String.IsNullOrEmpty(xrefFile) ||
                    !String.IsNullOrEmpty(dwfFile) || !String.IsNullOrEmpty(signPdfFile) ||
                    !string.IsNullOrEmpty(atlasFile))
                {
                    if (isUpVersion || file.CurrentAttachment == null || mainFile != file.CurrentAttachment.DataEntity.GetValue("MainFile"))
                    {
                        S_Attachment attach = new S_Attachment(this.SpaceID);
                        attach.DataEntity.SetValue("MainFile", mainFile);
                        attach.DataEntity.SetValue("Attachments", attachments);
                        attach.DataEntity.SetValue("PDFFile", pdfFile);
                        attach.DataEntity.SetValue("PlotFile", plotFile);
                        attach.DataEntity.SetValue("XrefFile", xrefFile);
                        attach.DataEntity.SetValue("DwfFile", dwfFile);
                        attach.DataEntity.SetValue("TiffFile", tiffFile);
                        attach.DataEntity.SetValue("SignPdfFile", signPdfFile);
                        attach.DataEntity.SetValue("AtlasFile", atlasFile);
                        attach.DataEntity.SetValue("CreateDate", DateTime.Now.ToString());
                        attach.DataEntity.SetValue("CreateUser", user.UserID);
                        attach.DataEntity.SetValue("CreateUserName", user.UserName);
                        file.AddAttachment(attach);
                    }
                    else
                    {
                        file.CurrentAttachment.DataEntity.SetValue("Attachments", attachments);
                        file.CurrentAttachment.DataEntity.SetValue("PDFFile", pdfFile);
                        file.CurrentAttachment.DataEntity.SetValue("PlotFile", plotFile);
                        file.CurrentAttachment.DataEntity.SetValue("XrefFile", xrefFile);
                        file.CurrentAttachment.DataEntity.SetValue("DwfFile", dwfFile);
                        file.CurrentAttachment.DataEntity.SetValue("TiffFile", tiffFile);
                        file.CurrentAttachment.DataEntity.SetValue("SignPdfFile", signPdfFile);
                        file.CurrentAttachment.DataEntity.SetValue("AtlasFile", atlasFile);
                        file.CurrentAttachment.Save();
                    }
                }
                file.SetData(row);
            }
            if (file.DataEntity.ContainsKey("DocIndexID"))
            {
                file.DataEntity.Remove("DocIndexID");
            }
            BeforeSave(file, row, isNew);
            file.Save(false);
            AfterSave(file, row, isNew);
            return(Json(file.DataEntity));
        }