示例#1
0
        public object Read(string taskId)
        {
            try
            {
                ProjectClosureModel        projectClosureModel  = new ProjectClosureModel();
                DDContext                  dDContext            = new DDContext();
                ProjectClosure             projectClosure       = dDContext.ProjectClosure.Where(p => p.TaskId == taskId).FirstOrDefault();
                List <DetailedList>        detailedLists        = dDContext.DetailedList.Where(d => d.TaskId == taskId).ToList();
                List <ApplicationUnit>     applicationUnitList  = dDContext.ApplicationUnit.Where(d => d.TaskId == taskId).ToList();
                List <ProjectFunding>      projectFundingList   = dDContext.ProjectFunding.Where(d => d.TaskId == taskId).ToList();
                List <LongitudinalProject> longitudinalProjects = dDContext.LongitudinalProject.Where(d => d.TaskId == taskId).ToList();

                projectClosureModel.projectClosure      = projectClosure;
                projectClosureModel.detailedLists       = detailedLists;
                projectClosureModel.applicationUnitList = applicationUnitList;
                projectClosureModel.projectFundingList  = projectFundingList;
                projectClosureModel.longitudinalProject = longitudinalProjects;

                return(new NewErrorModel()
                {
                    data = projectClosureModel,
                    error = new Error(0, "读取成功!", "")
                    {
                    },
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
 public object Save([FromBody] ProjectClosureModel projectClosureModel)
 {
     try
     {
         using (DDContext dDContext = new DDContext())
         {
             if (projectClosureModel.detailedLists.Count > 0)
             {
                 dDContext.DetailedList.AddRange(projectClosureModel.detailedLists);
             }
             if (projectClosureModel.applicationUnitList.Count > 0)
             {
                 dDContext.ApplicationUnit.AddRange(projectClosureModel.applicationUnitList);
             }
             if (projectClosureModel.projectFundingList.Count > 0)
             {
                 dDContext.ProjectFunding.AddRange(projectClosureModel.projectFundingList);
             }
             if (projectClosureModel.longitudinalProject.Count > 0)
             {
                 dDContext.LongitudinalProject.AddRange(projectClosureModel.longitudinalProject);
             }
             dDContext.ProjectClosure.Add(projectClosureModel.projectClosure);
             dDContext.SaveChanges();
         }
         return(new NewErrorModel()
         {
             error = new Error(0, "保存成功!", "")
             {
             },
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
        public async Task <NewErrorModel> Modify([FromBody] ProjectClosureModel projectClosureModel)
        {
            try
            {
                if (string.IsNullOrEmpty(projectClosureModel.NodeId))
                {
                    return(new NewErrorModel()
                    {
                        data = projectClosureModel,
                        error = new Error(1, "NodeId 没传!", "")
                        {
                        },
                    });
                }
                DDContext      dDContext      = new DDContext();
                Flows          flows          = dDContext.Flows.Where(f => f.FlowName.Contains("结题")).FirstOrDefault();
                ProjectClosure projectClosure = projectClosureModel.projectClosure;
                dDContext.Entry <ProjectClosure>(projectClosure).State = System.Data.Entity.EntityState.Modified;
                projectClosureModel.detailedLists.ToList().ForEach(d =>
                {
                    dDContext.Entry(d).State = System.Data.Entity.EntityState.Modified;
                });
                projectClosureModel.applicationUnitList.ToList().ForEach(d =>
                {
                    dDContext.Entry(d).State = System.Data.Entity.EntityState.Modified;
                });

                dDContext.ProjectFunding.AddRange(projectClosureModel.projectFundingList);

                projectClosureModel.longitudinalProject.ToList().ForEach(d =>
                {
                    dDContext.Entry(d).State = System.Data.Entity.EntityState.Modified;
                });
                List <NodeInfo> nodeInfos = dDContext.NodeInfo.Where(n => n.NodeName.Contains("财务负责人") && n.FlowId.ToString() == flows.FlowId.ToString() &&
                                                                     n.NodeId.ToString() == projectClosureModel.NodeId).ToList();
                if (nodeInfos.Count > 0)
                {
                    dDContext.ProjectFunding.AddRange(projectClosureModel.projectFundingList);
                }

                NodeInfo nodeInfo = dDContext.NodeInfo.Where(n => n.NodeName == "结束" && n.FlowId.ToString() == flows.FlowId.ToString()
                                                             ).FirstOrDefault();


                //最后一步保存路径
                if (nodeInfo.NodeId == Int32.Parse(projectClosureModel.NodeId) + 1)
                {
                    Tasks       tasks       = dDContext.Tasks.Where(t => t.TaskId.ToString() == projectClosureModel.projectClosure.TaskId.ToString() && t.NodeId.ToString() == "0").FirstOrDefault();
                    ProjectInfo projectInfo = dDContext.ProjectInfo.Where(p => p.ProjectId == tasks.ProjectId.ToString()).FirstOrDefault();
                    projectInfo.ProjectState = "已完成";
                    dDContext.Entry <ProjectInfo>(projectInfo).State = System.Data.Entity.EntityState.Modified;
                    SavePath(projectInfo.FilePath + "1立项书或建议书", projectClosureModel.projectClosure.SuggestBook1);
                    SavePath(projectInfo.FilePath + "2评审PPT", projectClosureModel.projectClosure.PPT2);
                    SavePath(projectInfo.FilePath + "3需求规格说明书、产品总体设计书", projectClosureModel.projectClosure.DemandBook3);
                    SavePath(projectInfo.FilePath + "4机械设计图纸", projectClosureModel.projectClosure.Drawing4);
                    SavePath(projectInfo.FilePath + "5电气图纸", projectClosureModel.projectClosure.Electrical5);
                    SavePath(projectInfo.FilePath + "6BOM表", projectClosureModel.projectClosure.Bom6);
                    SavePath(projectInfo.FilePath + "7软件源代码", projectClosureModel.projectClosure.SourceCode7);
                    SavePath(projectInfo.FilePath + "8使用说明书、操作手册、技术方案、规格说明书", projectClosureModel.projectClosure.UseBook8);
                    SavePath(projectInfo.FilePath + "9合作协议", projectClosureModel.projectClosure.CooperationAgreement9);
                    SavePath(projectInfo.FilePath + "10产品(样机、成品)图片、影像", projectClosureModel.projectClosure.Product10);
                    SavePath(projectInfo.FilePath + "11阶段性整理的问题的分析、解决方案及计划表", projectClosureModel.projectClosure.Solution11);
                    //SavePath(projectInfo.FilePath + "12项目采购清单、借用清单、领料清单、入库清单", projectClosureModel.projectClosure);
                    //SavePath(projectInfo.FilePath + "13受理知识产权清单及申请资料", projectClosureModel.projectClosure);
                    SavePath(projectInfo.FilePath + "14纵向项目申请、中期检查、验收资料", projectClosureModel.projectClosure.AcceptanceData14);
                    SavePath(projectInfo.FilePath + "15其他过程文档", projectClosureModel.projectClosure.ProcessDocumentation15);
                    SavePath(projectInfo.FilePath + "16项目终止情况报告", projectClosureModel.projectClosure.TerminationReport16);
                    SavePath(projectInfo.FilePath + "17装箱单", projectClosureModel.projectClosure.PackingList17);
                    SavePath(projectInfo.FilePath + "18客户验收单", projectClosureModel.projectClosure.AcceptanceSlip18);
                    //SavePath(projectInfo.FilePath + "19转化、应用单位情况表", projectClosureModel.projectClosure.);
                    //SavePath(projectInfo.FilePath + "20项目经费使用情况表", projectClosureModel.projectClosure);

                    foreach (var item in projectClosureModel.detailedLists)
                    {
                        if (item.Type.Contains("零部件采购"))
                        {
                            Tasks taskP = dDContext.Tasks.Where(t => t.TaskId.ToString() == item.OldTaskId && t.NodeId == 0).FirstOrDefault();
                            PrintAndSendPurcahse(taskP, System.Web.HttpContext.Current.Server.MapPath
                                                     (projectInfo.FilePath + string.Format("12项目采购清单、借用清单、领料清单、入库清单//零部件采购单流水号{0}.zip", item.OldTaskId)));
                        }
                    }

                    List <LongitudinalProject> longitudinalProject = dDContext.LongitudinalProject.Where(p => p.TaskId == projectClosureModel.projectClosure.TaskId).ToList();

                    await PrintsLongitudinalProject(longitudinalProject, "", "纵向项目基本情况表模板",
                                                    "纵向项目基本情况表", 1, 2, System.Web.HttpContext.Current.Server.MapPath
                                                        (projectInfo.FilePath + "14纵向项目申请、中期检查、验收资料//纵向项目基本情况表.xlsx"));

                    List <ApplicationUnit> applicationUnitList = dDContext.ApplicationUnit.Where(p => p.TaskId == projectClosureModel.projectClosure.TaskId).ToList();
                    await PrintsApplicationUnit(applicationUnitList, "", "转化应用单位情况表模板",
                                                "转化应用单位情况表", 1, 2, System.Web.HttpContext.Current.Server.MapPath
                                                    (projectInfo.FilePath + "19转化、应用单位情况表//转化应用单位情况表.xlsx"));

                    List <ProjectFunding> projectFundingList = dDContext.ProjectFunding.Where(p => p.TaskId == projectClosureModel.projectClosure.TaskId).ToList();
                    await PrintsProjectFunding(projectFundingList, "", "项目经费使用情况表模板",
                                               "项目经费使用情况表", 0, 3, System.Web.HttpContext.Current.Server.MapPath
                                                   (projectInfo.FilePath + "20项目经费使用情况表//项目经费使用情况表.xlsx"));
                }

                dDContext.SaveChanges();
                return(new NewErrorModel()
                {
                    data = projectClosureModel,
                    error = new Error(0, "修改成功!", "")
                    {
                    },
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }