예제 #1
0
        public JsonResult AddDocument(string FileID, string InputID, string Catagory = "Project")
        {
            var input = this.GetEntityByID <S_D_Input>(InputID);

            if (input == null)
            {
                throw new Formula.Exceptions.BusinessException("ID为【" + InputID + "】的设计输入文件目录不存在");
            }
            var existNameList = input.S_D_InputDocument.ToList().Select(a => a.Name).ToList();

            foreach (var item in FileID.Split(','))
            {
                var doc  = new S_D_InputDocument();
                var name = item.Substring(FileID.IndexOf("_") + 1, item.LastIndexOf(".") - item.IndexOf("_") - 1);
                if (existNameList.Any(a => a == name))
                {
                    throw new Exception("已经存在名称为【" + name + "】的文件,请先删除");
                }
                doc.ID           = FormulaHelper.CreateGuid();
                doc.Name         = name;
                doc.Files        = item;
                doc.CreateDate   = DateTime.Now;
                doc.CreateUser   = this.CurrentUserInfo.UserName;
                doc.CreateUserID = this.CurrentUserInfo.UserID;
                doc.Catagory     = Catagory;
                doc.AuditState   = CommonConst.unAuditState;
                input.S_D_InputDocument.Add(doc);
                existNameList.Add(doc.Name);
            }
            this.entities.SaveChanges();
            return(Json(""));
        }
예제 #2
0
        public JsonResult ImportInput(string ListData, string ProjectInfoID)
        {
            var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法导入资料");
            }
            var list = JsonHelper.ToList(ListData);

            foreach (var item in list)
            {
                var orlInput = this.GetEntityByID(item.GetValue("ID"));
                if (orlInput == null)
                {
                    continue;
                }
                var input = projectInfo.S_D_Input.FirstOrDefault(d => d.InfoName == orlInput.InfoName && d.InputType == orlInput.InputType);
                if (input == null)
                {
                    input                   = this.entities.Set <S_D_Input>().Create();
                    input.InfoName          = orlInput.InfoName;
                    input.InputType         = orlInput.InputType;
                    input.ID                = FormulaHelper.CreateGuid();
                    input.DBSCode           = orlInput.DBSCode;
                    input.Catagory          = "Project";
                    input.InputTypeIndex    = orlInput.InputTypeIndex;
                    input.SortIndex         = orlInput.SortIndex;
                    input.State             = CommonConst.unAuditState;
                    input.DocType           = orlInput.DocType;
                    input.EngineeringInfoID = projectInfo.GroupID;
                    input.CreateDate        = DateTime.Now;
                    input.CreateUser        = this.CurrentUserInfo.UserName;
                    input.CreateUserID      = this.CurrentUserInfo.UserID;
                    input.ModifyDate        = DateTime.Now;
                    input.ModifyUser        = this.CurrentUserInfo.UserName;
                    input.ModifyUserID      = this.CurrentUserInfo.UserID;
                    projectInfo.S_D_Input.Add(input);
                }
                foreach (var doc in orlInput.S_D_InputDocument.ToList())
                {
                    var newDoc = new S_D_InputDocument();
                    newDoc.ID           = FormulaHelper.CreateGuid();
                    newDoc.Name         = doc.Name;
                    newDoc.Files        = doc.Files;
                    newDoc.Catagory     = "Project";
                    newDoc.CreateDate   = DateTime.Now;
                    newDoc.CreateUser   = this.CurrentUserInfo.UserName;
                    newDoc.CreateUserID = this.CurrentUserInfo.UserID;
                    newDoc.Attachments  = doc.Attachments;
                    input.S_D_InputDocument.Add(newDoc);
                }
            }
            this.entities.SaveChanges();
            return(Json(""));
        }
예제 #3
0
        public JsonResult ImportFiles(string InputID, string ListData, string FileField, string NameField, string CodeField, string Catagory)
        {
            var input = this.GetEntityByID(InputID);

            if (input == null)
            {
                throw new Formula.Exceptions.BusinessException("ID为【" + InputID + "】的设计输入文件目录不存在");
            }
            var fileList      = JsonHelper.ToList(ListData);
            var existNameList = input.S_D_InputDocument.ToList().Select(a => a.Name).ToList();

            foreach (var item in fileList)
            {
                var name         = item.GetValue(NameField);
                var documentName = name;

                string code = "";
                if (!string.IsNullOrEmpty(CodeField) && item.Keys.Contains(CodeField))
                {
                    code = item.GetValue(CodeField);
                }
                if (!string.IsNullOrEmpty(code))
                {
                    documentName += "(" + code + ")";
                }
                var fileID = item.GetValue(FileField);
                var doc    = input.S_D_InputDocument.FirstOrDefault(d => d.Files == fileID);
                if (doc == null)
                {
                    doc    = new S_D_InputDocument();
                    doc.ID = FormulaHelper.CreateGuid();
                    if (existNameList.Any(a => a == documentName))
                    {
                        throw new Exception("已经存在名称为【" + name + "】的文件,请先删除");
                    }
                    doc.Name         = documentName;
                    doc.CreateDate   = DateTime.Now;
                    doc.CreateUser   = this.CurrentUserInfo.UserName;
                    doc.CreateUserID = this.CurrentUserInfo.UserID;
                    doc.Catagory     = String.IsNullOrEmpty(Catagory) ? "Project" : Catagory;
                    doc.Files        = item.GetValue(FileField);
                    doc.AuditState   = CommonConst.unAuditState;
                    input.S_D_InputDocument.Add(doc);
                    existNameList.Add(doc.Name);
                }
            }
            this.entities.SaveChanges();
            return(Json(""));
        }