Exemplo n.º 1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, PowerplanthandleEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void ExportDataByCode(string keyValue, string tempPath, string fileName)
        {
            var    userInfo   = OperatorProvider.Provider.Current(); //获取当前用户
            string strDocPath = Server.MapPath(tempPath);

            Aspose.Words.Document doc = new Aspose.Words.Document(strDocPath);
            DataTable             dt  = new DataTable("people");

            dt.Columns.Add("ApplyCode");                  //编号
            dt.Columns.Add("CreateDate");                 //填报日期
            dt.Columns.Add("AccidentEventName");          //事故事件名称
            dt.Columns.Add("HappenTime");                 //发生时间
            dt.Columns.Add("BelongDept");                 //责任归属
            dt.Columns.Add("AccidentEventProperty");      //性质
            dt.Columns.Add("SituationIntroduction");      //情况简述
            dt.Columns.Add("ReasonAndProblem");           //暴露原因及问题
            dt.Columns.Add("RectificationMeasures");      //防范措施及要求
            dt.Columns.Add("SignDeptName");               //发至单位
            dt.Columns.Add("RealSignPersonName");         //签收人
            dt.Columns.Add("ApproveDept");                //审核部门
            dt.Columns.Add("ApprovePerson");              //审核人
            dt.Columns.Add("RectificationPerson");        //整改负责人
            dt.Columns.Add("RectificationDutyDept");      //责任部门
            dt.Columns.Add("RectificationTime");          //完成期限
            dt.Columns.Add("RectificationSituation");     //措施完成情况
            dt.Columns.Add("RectificationPersonSignImg"); //措施完成责任人签名
            dt.Columns.Add("ReformDate");                 //整改日期
            dt.Columns.Add("CheckPerson1");               //部门负责人
            dt.Columns.Add("CheckIdea1");                 //验收意见1
            dt.Columns.Add("CheckIdea2");                 //验收意见2
            dt.Columns.Add("CheckPerson2");               //验收人2
            dt.Columns.Add("CheckDate2");                 //验收日期2
            dt.Columns.Add("CheckIdea3");                 //验收意见3
            dt.Columns.Add("CheckPerson3");               //验收人3
            dt.Columns.Add("CheckDate3");                 //验收日期3
            dt.Columns.Add("CheckDept3");                 //验收部门3
            dt.Columns.Add("CheckIdea4");                 //验收意见4
            dt.Columns.Add("CheckPerson4");               //验收人4
            dt.Columns.Add("CheckDate4");                 //验收日期4
            dt.Columns.Add("CheckDept4");                 //验收部门4

            HttpResponse resp         = System.Web.HttpContext.Current.Response;
            string       defaultimage = Server.MapPath("~/content/Images/no_1.png");
            DataRow      row          = dt.NewRow();
            PowerplanthandledetailEntity   powerplanthandledetailentity   = powerplanthandledetailbll.GetEntity(keyValue);
            PowerplanthandleEntity         powerplanthandleentity         = powerplanthandlebll.GetEntity(powerplanthandledetailentity.PowerPlantHandleId);
            AptitudeinvestigateauditEntity aptitudeinvestigateauditentity = aptitudeinvestigateauditbll.GetAuditList(powerplanthandleentity.Id).Where(t => t.Disable == "0").OrderByDescending(t => t.AUDITTIME).FirstOrDefault();
            PowerplantreformEntity         powerplantreformentity         = powerplantreformbll.GetList("").Where(t => t.Disable == 0 && t.PowerPlantHandleDetailId == keyValue).FirstOrDefault();
            IList <PowerplantcheckEntity>  powerplantcheckentitylist      = powerplantcheckbll.GetList("").Where(t => t.Disable == 0 && t.PowerPlantHandleDetailId == keyValue).OrderBy(t => t.CreateDate).ToList();

            row["ApplyCode"]                  = powerplanthandledetailentity.ApplyCode;
            row["CreateDate"]                 = Convert.ToDateTime(powerplanthandledetailentity.CreateDate).ToString("yyyy年MM月dd日");
            row["AccidentEventName"]          = powerplanthandleentity.AccidentEventName;
            row["HappenTime"]                 = Convert.ToDateTime(powerplanthandleentity.HappenTime).ToString("yyyy年MM月dd日");
            row["BelongDept"]                 = powerplanthandleentity.BelongDept;
            row["AccidentEventProperty"]      = scaffoldbll.getName(powerplanthandleentity.AccidentEventProperty, "AccidentEventProperty");
            row["SituationIntroduction"]      = powerplanthandleentity.SituationIntroduction;
            row["ReasonAndProblem"]           = powerplanthandledetailentity.ReasonAndProblem;
            row["RectificationMeasures"]      = powerplanthandledetailentity.RectificationMeasures;
            row["SignDeptName"]               = powerplanthandledetailentity.SignDeptName;
            row["RealSignPersonName"]         = powerplanthandledetailentity.RealSignPersonName;
            row["ApproveDept"]                = aptitudeinvestigateauditentity == null ? "" : aptitudeinvestigateauditentity.AUDITDEPT;
            row["ApprovePerson"]              = aptitudeinvestigateauditentity == null ? "" : (System.IO.File.Exists(Server.MapPath("~/") + aptitudeinvestigateauditentity.AUDITSIGNIMG.Replace("../../", "").ToString()) ? Server.MapPath("~/") + aptitudeinvestigateauditentity.AUDITSIGNIMG.Replace("../../", "").ToString() : defaultimage);
            row["RectificationPerson"]        = powerplantreformentity.RectificationPerson;
            row["RectificationDutyDept"]      = powerplantreformentity.RectificationDutyDept;
            row["RectificationTime"]          = Convert.ToDateTime(powerplantreformentity.RectificationTime).ToString("yyyy年MM月dd日");
            row["RectificationSituation"]     = powerplantreformentity.RectificationSituation;
            row["RectificationPersonSignImg"] = System.IO.File.Exists(Server.MapPath("~/") + powerplantreformentity.RectificationPersonSignImg.Replace("../../", "").ToString()) ? Server.MapPath("~/") + powerplantreformentity.RectificationPersonSignImg.Replace("../../", "").ToString() : defaultimage;
            row["ReformDate"]                 = Convert.ToDateTime(powerplantreformentity.CreateDate).ToString("yyyy年MM月dd日");
            for (int i = 0; i < powerplantcheckentitylist.Count; i++)
            {
                switch (i)
                {
                case 0:
                    row["CheckPerson1"] = System.IO.File.Exists(Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString()) ? Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString() : defaultimage;
                    row["CheckIdea1"]   = string.IsNullOrEmpty(powerplantcheckentitylist[i].AuditOpinion) ? "同意" : powerplantcheckentitylist[i].AuditOpinion;
                    break;

                case 1:
                    row["CheckIdea2"]   = powerplantcheckentitylist[i].AuditOpinion;
                    row["CheckPerson2"] = System.IO.File.Exists(Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString()) ? Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString() : defaultimage;
                    row["CheckDate2"]   = Convert.ToDateTime(powerplantcheckentitylist[i].AuditTime).ToString("yyyy年MM月dd日");
                    break;

                case 2:
                    row["CheckIdea3"]   = powerplantcheckentitylist[i].AuditOpinion;
                    row["CheckPerson3"] = System.IO.File.Exists(Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString()) ? Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString() : defaultimage;
                    row["CheckDate3"]   = Convert.ToDateTime(powerplantcheckentitylist[i].AuditTime).ToString("yyyy年MM月dd日");
                    row["CheckDept3"]   = powerplantcheckentitylist[i].AuditDept;
                    break;

                case 3:
                    row["CheckIdea4"]   = powerplantcheckentitylist[i].AuditOpinion;
                    row["CheckPerson4"] = System.IO.File.Exists(Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString()) ? Server.MapPath("~/") + powerplantcheckentitylist[i].AuditSignImg.Replace("../../", "").ToString() : defaultimage;
                    row["CheckDate4"]   = Convert.ToDateTime(powerplantcheckentitylist[i].AuditTime).ToString("yyyy年MM月dd日");
                    row["CheckDept4"]   = powerplantcheckentitylist[i].AuditDept;
                    break;

                default:
                    break;
                }
            }

            dt.Rows.Add(row);
            doc.MailMerge.Execute(dt);
            doc.MailMerge.DeleteFields();
            doc.Save(resp, Server.UrlEncode(fileName), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc));
        }