Ejemplo n.º 1
0
        public JsonResult Reorganize(string ProjectInfoID, bool IsAll, string Files)
        {
            S_I_ProjectInfo projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档");
            }

            var docList = this.entities.Set <S_D_Document>().Where(d => d.ProjectInfoID == ProjectInfoID && d.State != "Archive").ToList();
            var _group  = docList.GroupBy(a => a.RelateID).Select(a =>
                                                                  new { a.Key, MaxVersion = a.Max(b => (string.IsNullOrEmpty(b.Version) ? 0d : Convert.ToDouble(b.Version))) }
                                                                  ).ToList();
            var fileList = JsonHelper.ToList(Files);

            if (fileList.Count == 0)
            {
                throw new Formula.Exceptions.BusinessException("暂无文件清单,请先添加归档文件");
            }
            if (!IsAll)
            {
                docList = docList.Where(a => _group.Any(g => g.Key == a.RelateID && g.MaxVersion == (string.IsNullOrEmpty(a.Version) ? 0d : Convert.ToDouble(a.Version)))).ToList();
            }
            if (docList.Count > 0)
            {
                S_R_Reorganize entity = new S_R_Reorganize();
                entity.TaskName   = projectInfo.Name;
                entity.BusinessID = projectInfo.ID;
                foreach (var doc in docList)
                {
                    S_R_Reorganize_DocumentList item = new S_R_Reorganize_DocumentList();
                    entity.S_R_Reorganize_DocumentList.Add(item);
                    FormulaHelper.UpdateModel(item, doc);
                    item.RelateID    = doc.ID;
                    item.RelateTable = "S_D_Document";
                    item.MainFile    = doc.MainFiles;

                    doc.State       = "Archive";
                    doc.ArchiveDate = new DateTime?(DateTime.Now);
                }
                new ReorganizeFO().CreateReorganize("DesignDoc", entity);
                this.entities.SaveChanges();
            }
            return(Json(""));
        }
Ejemplo n.º 2
0
        public JsonResult ReorganizeFile(string ProjectInfoID, string Files)
        {
            S_I_ProjectInfo projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档");
            }
            var fileList = JsonHelper.ToList(Files);

            if (fileList.Count == 0)
            {
                throw new Formula.Exceptions.BusinessException("暂无文件清单,请先添加归档文件");
            }
            fileList = fileList.Where(a => !a.Keys.Contains("NewAdd") || (a.Keys.Contains("NewAdd") && a.GetValue("NewAdd") != "T")).ToList();

            if (fileList.Count > 0)
            {
                S_R_Reorganize entity = new S_R_Reorganize();
                entity.TaskName   = projectInfo.Name;
                entity.BusinessID = projectInfo.ID;
                foreach (var filedic in fileList)
                {
                    var doc = this.GetEntityByID <S_D_Document>(filedic.GetValue("DocumentID"));
                    if (doc == null)
                    {
                        continue;
                    }
                    S_R_Reorganize_DocumentList item = new S_R_Reorganize_DocumentList();
                    entity.S_R_Reorganize_DocumentList.Add(item);
                    FormulaHelper.UpdateModel(item, doc);
                    item.RelateID    = doc.ID;
                    item.RelateTable = "S_D_Document";
                    item.MainFile    = doc.MainFiles;

                    doc.State       = "Archive";
                    doc.ArchiveDate = new DateTime?(DateTime.Now);
                }
                new ReorganizeFO().CreateReorganize("DesignDoc", entity);
                this.entities.SaveChanges();
            }
            return(base.Json(""));
        }