Exemplo n.º 1
0
        public ActionResult Create(FormCollection collection)
        {
            var model = new TestPhysicalReport();

            this.TryUpdateModel <TestPhysicalReport>(model);
            this.IDKLManagerService.InsertTestPhysicalReport(model);
            return(RefreshParent());
        }
Exemplo n.º 2
0
        public ActionResult DownLoadTsetDocFile(FormCollection collection)
        {
            //try
            //{
            string strFileName = "";

            //1.判断是否满足下载条件
            //2.从各个数据库获取数据
            //3.调用接口生成报告

            List <string>             strc           = new List <string>(); //物理检测项目(查询,制表用)
            List <string>             str            = new List <string>(); //化学采样项目 控制打印表格时打印的项目
            ProjectInfo               projectmodels  = new ProjectInfo();
            List <TestPhysicalReport> physicalmodels = new List <TestPhysicalReport>();
            List <TestChemicalReport> chemicalmodels = new List <TestChemicalReport>();

            if ((m_ProjectWholeInfoViewModel == null) || (m_ProjectWholeInfoViewModel.projectBasicinfo == null))
            {
                return(Back("123"));
            }

            List <SampleRegisterTable> models = this.IDKLManagerService.GetSampleRegisterListByProjectNumber(m_ProjectWholeInfoViewModel.projectBasicinfo.ProjectNumber);

            #region 化学数据对接
            foreach (var item in models)
            {
                TestChemicalReport model = new TestChemicalReport();
                model.SampleNumber  = item.SampleRegisterNumber;
                model.ProjectNumber = item.ProjectNumber;
                model.SampleProject = item.ParameterName;
                model.Factor        = item.ParameterName;
                model.ID            = item.ID;
                model.CreateTime    = item.SamplingDay;
                model.WorkShop      = item.WorkShop;
                model.Job           = item.Job;
                model.Location      = item.Location;
                model.CSTEL         = item.CSTEL;
                model.CTWA          = item.CTWA;
                model.CMAC          = item.CMAC;
                chemicalmodels.Add(model);
            }
            #endregion

            foreach (var item in chemicalmodels)
            {
                str.Add(item.SampleProject);
            }
            str = str.Distinct().ToList();
            #region 采样项目打印
            List <SampleProjectGist> ProjectGistmodels = this.IDKLManagerService.GetSampleProjectGistBySampleProject(str);

            #endregion
            #region 基本信息
            projectmodels.CompaneName    = m_ProjectWholeInfoViewModel.projectBasicinfo.CompaneName;
            projectmodels.CompanyAddress = m_ProjectWholeInfoViewModel.projectBasicinfo.CompanyAddress;
            projectmodels.ProjectName    = m_ProjectWholeInfoViewModel.projectBasicinfo.ProjectName;
            projectmodels.CompanyContact = m_ProjectWholeInfoViewModel.projectBasicinfo.CompanyContact;
            projectmodels.ZipCode        = m_ProjectWholeInfoViewModel.projectBasicinfo.ZipCode;
            projectmodels.ContactTel     = m_ProjectWholeInfoViewModel.projectBasicinfo.ContactTel;
            projectmodels.ProjectNumber  = m_ProjectWholeInfoViewModel.projectBasicinfo.ProjectNumber;
            #endregion
            #region 物理检测部分录入
            foreach (var item in m_ProjectWholeInfoViewModel.projectTestBasicinfoList)
            {
                strc.Add(item.TestContent);
                if (item.TestContent == "噪声" || item.TestContent == "噪音")
                {
                    var modeltemp = new TestPhysicalReport();
                    modeltemp.ProjectNumber  = item.ProjectNumber;
                    modeltemp.WordShop       = item.WordShop;
                    modeltemp.TestContent    = item.TestContent;
                    modeltemp.Job            = item.Job;
                    modeltemp.Location       = item.Location;
                    modeltemp.SampleNumber   = item.SampleNumber;
                    modeltemp.ContactTime    = item.TouchTime;
                    modeltemp.NoiseIntensity = item.NoiseStrength;
                    modeltemp.Lex8hLexw      = item.Lex8hLexw;
                    modeltemp.LexCategory    = item.LexCategory;
                    physicalmodels.Add(modeltemp);
                }
            }

            strc = strc.Distinct().ToList();   //去重

            #endregion
            #region 检测部分打印(物理+化学)
            List <Parameter> Parametermodels = this.IDKLManagerService.GetParameterListBySampleProject(str, strc);
            #endregion
            #region 化学限值部分
            List <Parameter> ParmeterChemicalModels = this.IDKLManagerService.GetParameterListBySampleProject(str);  //重载

            #endregion
            #region 报告生成+下载


            CreatTestDoc cr = new CreatTestDoc(projectmodels);
            if ((ProjectGistmodels != null) && (Parametermodels != null) && (ParmeterChemicalModels != null) && (projectmodels != null) && (physicalmodels != null) && (chemicalmodels != null))
            {
                List <string> appList = new List <string>();

                appList = cr.CreateReportWord(str, strc, ProjectGistmodels, Parametermodels, ParmeterChemicalModels, projectmodels, physicalmodels, chemicalmodels);


                #region 判断报告生成运行状态
                if (appList[0] == "1")
                {
                    FileInfo fr = new FileInfo(appList[1]);
                    fr.Delete();
                    return(Back("检测项目中缺少对应参数,请联系实验室人员添加相应参数"));
                }
                if (appList[0] == "2")
                {
                    FileInfo fr = new FileInfo(appList[1]);
                    fr.Delete();
                    return(Back("采样项目中缺少对应参数,请联系实验室人员添加相应参数"));
                }
                if (appList[0] == "3")
                {
                    FileInfo fr = new FileInfo(appList[1]);
                    fr.Delete();
                    return(Back("采样项目未检测到数据,请联系实验室人员添加相应数据"));
                }

                #endregion

                strFileName = appList[1];
            }                                    //报告下载



            if (!string.IsNullOrEmpty(strFileName))
            {
                string fileNewName = strFileName.Substring(strFileName.LastIndexOf("\\") + 1);
                Response.Clear();
                Response.ContentType     = "application/octet-stream";
                Response.ContentEncoding = Encoding.UTF8;
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileNewName, Encoding.UTF8));
                Response.WriteFile(strFileName);
                Response.End();
            }
            else
            {
                return(Back("下载报告失败"));
            }

            #endregion
            //}
            //catch (Exception e)
            //{
            //    return Back("1"+e.Message);
            //}
            return(Back("成功"));
        }