Exemplo n.º 1
0
        public ActionResult ExportSafetyCollect(string keyValue)
        {
            try
            {
                var    userInfo   = OperatorProvider.Provider.Current(); //获取当前用户
                var    tempconfig = new TempConfigBLL().GetList("").Where(x => x.DeptCode == userInfo.OrganizeCode && x.ModuleCode == "RYZZSC").ToList();
                string tempPath   = @"~/Resource/ExcelTemplate/外包工程竣工安全验收表.doc";
                var    tempEntity = tempconfig.FirstOrDefault();
                string fileName   = "外包工程竣工安全验收表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc";

                ExportDataByCode(keyValue, tempPath, fileName);
                return(Success("导出成功!"));
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
        public ActionResult ExportSGSJCLXX(string keyValue)
        {
            try
            {
                var    userInfo   = OperatorProvider.Provider.Current(); //获取当前用户
                var    tempconfig = new TempConfigBLL().GetList("").Where(x => x.DeptCode == userInfo.OrganizeCode && x.ModuleCode == "SGSJCLJL").ToList();
                string tempPath   = @"~/Resource/ExcelTemplate/事故事件导出模板-西塞山.doc";
                var    tempEntity = tempconfig.FirstOrDefault();
                string fileName   = "事故事件处理信息导出表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc";
                if (tempconfig.Count > 0)
                {
                    if (tempEntity != null)
                    {
                        switch (tempEntity.ProessMode)
                        {
                        case "TY":    //通用处理方式
                            tempPath = @"~/Resource/ExcelTemplate/事故事件导出模板-西塞山.doc";
                            break;

                        case "GDXY":    //国电荥阳
                            tempPath = @"~/Resource/ExcelTemplate/事故事件导出模板_国电荥阳.doc";
                            break;

                        case "HRCB":    //华润赤壁
                            tempPath = @"~/Resource/ExcelTemplate/事故事件导出模板-西塞山.doc";
                            break;

                        default:
                            break;
                        }
                    }
                }
                else
                {
                    tempPath = @"~/Resource/ExcelTemplate/事故事件导出模板-西塞山.doc";
                }
                ExportDataByCode(keyValue, tempPath, fileName);
                return(Success("导出成功!"));
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 入厂许可审批表
        /// </summary>
        /// <param name="keyValue">入厂许可审批ID</param>
        /// <returns></returns>
        public ActionResult ExportWord(string keyValue)
        {
            HttpResponse resp = System.Web.HttpContext.Current.Response;
            //报告对象

            string fileName   = "入厂许可审批表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc";
            var    user       = ERCHTMS.Code.OperatorProvider.Provider.Current();
            var    tempconfig = new TempConfigBLL().GetList("").Where(x => x.DeptCode == user.OrganizeCode && x.ModuleCode == "RCXK").ToList();
            var    tempEntity = tempconfig.FirstOrDefault();
            string tempPath   = "";

            if (tempconfig.Count > 0)
            {
                if (tempEntity != null)
                {
                    switch (tempEntity.ProessMode)
                    {
                    case "TY":    //通用处理方式
                        tempPath = "Resource\\ExcelTemplate\\入厂许可审批表.doc";
                        break;

                    case "HJB":
                        tempPath = "Resource\\ExcelTemplate\\黄金埠入厂许可审批表.doc";
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                tempPath = "Resource\\ExcelTemplate\\入厂许可审批表.doc";
            }
            string strDocPath = Request.PhysicalApplicationPath + tempPath;

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

            dt.Columns.Add("OutSourcingDept");    //外包单位
            dt.Columns.Add("OutSourcingProject"); //工程名称
            dt.Columns.Add("ApplyNo");            //申请编号
            dt.Columns.Add("ProjectManager");     //项目经理和电话
            dt.Columns.Add("ContractName");       //合同名称
            dt.Columns.Add("ContractNo");         //合同编号
            for (int i = 1; i < 16; i++)
            {
                dt.Columns.Add("Result" + i);
            }
            dt.Columns.Add("approveidea1");
            dt.Columns.Add("approveperson1");
            dt.Columns.Add("approvedate1");
            dt.Columns.Add("approveidea2");
            dt.Columns.Add("approveperson2");
            dt.Columns.Add("approvedate2");


            DataTable dt1 = new DataTable("A");

            dt1.Columns.Add("ApproveDate");
            dt1.Columns.Add("ApprovePerson");
            dt1.Columns.Add("ApproveIdea");
            dt1.Columns.Add("ApproveContent");
            DataRow row = dt.NewRow();
            //外包工程记录
            DataTable sdt = intromissionbll.GetOutSourcingProjectByIntromId(keyValue);

            if (sdt.Rows.Count == 1)
            {
                row["OutSourcingDept"]    = sdt.Rows[0]["fullname"].ToString();     //外包单位
                row["OutSourcingProject"] = sdt.Rows[0]["engineername"].ToString(); //工程名称
                row["ApplyNo"]            = sdt.Rows[0]["applyno"].ToString();
                row["ProjectManager"]     = sdt.Rows[0]["engineerletpeople"].ToString() + "    " + sdt.Rows[0]["engineerletpeoplephone"].ToString();
                row["ContractName"]       = sdt.Rows[0]["engineername"].ToString() + "合同";
                var engineer = Outsouringengineernll.GetEntity(sdt.Rows[0]["outengineerid"].ToString());
                var compact  = new CompactBLL().GetListByProjectId(sdt.Rows[0]["outengineerid"].ToString()).OrderByDescending(t => t.CREATEDATE).FirstOrDefault();
                row["ContractNo"] = compact == null ? "" : compact.COMPACTNO;
                //审核记录
                List <AptitudeinvestigateauditEntity> list = aptitudeinvestigateauditbll.GetAuditList(keyValue);
                int num = 1;
                for (int i = 0; i < list.Count; i++)
                {
                    DataRow row1     = dt1.NewRow();
                    var     filepath = (Server.MapPath("~/") + list[i].AUDITSIGNIMG.ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString();
                    if (System.IO.File.Exists(filepath))
                    {
                        row1["ApprovePerson"] = filepath;
                    }
                    else
                    {
                        row1["ApprovePerson"] = Server.MapPath("~/content/Images/no_1.png");
                    }
                    //row1["ApprovePerson"] = Server.MapPath("~/") + list[i].AUDITSIGNIMG.ToString().Replace("../../", "").ToString();

                    row1["ApproveIdea"] = !string.IsNullOrEmpty(list[i].AUDITOPINION) ? list[i].AUDITOPINION.ToString() : "";
                    DateTime ApproveDate = list[i].AUDITTIME.Value;
                    row1["ApproveDate"] = ApproveDate.Year.ToString() + "年" + ApproveDate.Month.ToString() + "月" + ApproveDate.Day.ToString() + "日";

                    if (i == 0)
                    {
                        row1["ApproveContent"] = "项目所在部门接收意见";
                    }
                    else if (i == list.Count - 1)
                    {
                        row1["ApproveContent"] = "分管领导意见";
                    }
                    else
                    {
                        row1["ApproveContent"] = list[i].AUDITDEPT + "审查意见";
                    }
                    dt1.Rows.Add(row1);
                }
                if (list.Count > 0)
                {
                    row["approveidea1"] = !string.IsNullOrEmpty(list[0].AUDITOPINION) ? list[0].AUDITOPINION.ToString() : "";
                    var filepath = (Server.MapPath("~/") + list[0].AUDITSIGNIMG.ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString();
                    if (System.IO.File.Exists(filepath))
                    {
                        row["approveperson1"] = filepath;
                    }
                    else
                    {
                        row["approveperson1"] = Server.MapPath("~/content/Images/no_1.png");
                    }
                    DateTime ApproveDate = list[0].AUDITTIME.Value;
                    row["approvedate1"] = ApproveDate.Year.ToString() + "年" + ApproveDate.Month.ToString() + "月" + ApproveDate.Day.ToString() + "日";
                }
                if (list.Count > 1)
                {
                    row["approveidea2"] = !string.IsNullOrEmpty(list[1].AUDITOPINION) ? list[1].AUDITOPINION.ToString() : "";
                    var filepath = (Server.MapPath("~/") + list[1].AUDITSIGNIMG.ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString();
                    if (System.IO.File.Exists(filepath))
                    {
                        row["approveperson2"] = filepath;
                    }
                    else
                    {
                        row["approveperson2"] = Server.MapPath("~/content/Images/no_1.png");
                    }
                    DateTime ApproveDate = list[1].AUDITTIME.Value;
                    row["approvedate2"] = ApproveDate.Year.ToString() + "年" + ApproveDate.Month.ToString() + "月" + ApproveDate.Day.ToString() + "日";
                }
                //foreach (AptitudeinvestigateauditEntity entity in list)
                //{
                //    DataRow row1 = dt1.NewRow();
                //    row1["ApprovePerson"] = Server.MapPath("~/") + entity.AUDITSIGNIMG.ToString().Replace("../../", "").ToString();

                //    row1["ApproveIdea"] = !string.IsNullOrEmpty(entity.AUDITOPINION) ? entity.AUDITOPINION.ToString() : "";
                //    DateTime ApproveDate = entity.AUDITTIME.Value;
                //    row1["ApproveDate"] = ApproveDate.Year.ToString() + "年" + ApproveDate.Month.ToString() + "月" + ApproveDate.Day.ToString() + "日";
                //    num++;

                //}
            }

            doc.MailMerge.ExecuteWithRegions(dt1);
            DataTable dtCert = intromissionbll.GetDtRecordList(keyValue);//人员证书信息

            for (int i = 0; i < dtCert.Rows.Count; i++)
            {
                if (dtCert.Rows[i]["investigateresult"].ToString() == "无此项")
                {
                    dtCert.Rows[i]["investigateresult"] = "/";
                    dtCert.Rows[i]["signpic"]           = Server.MapPath("~/content/Images/no_1.png");
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(dtCert.Rows[i]["signpic"].ToString()))
                    {
                        dtCert.Rows[i]["signpic"] = Server.MapPath("~/content/Images/no_1.png");
                    }
                    else
                    {
                        if (System.IO.File.Exists((Server.MapPath("~/") + dtCert.Rows[i]["signpic"].ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString()))
                        {
                            dtCert.Rows[i]["signpic"] = (Server.MapPath("~/") + dtCert.Rows[i]["signpic"].ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString();
                        }
                        else
                        {
                            dtCert.Rows[i]["signpic"] = Server.MapPath("~/content/Images/no_1.png");
                        }
                    }
                }
                int temp = i + 1;
                if (dt.Columns.Contains("Result" + temp))
                {
                    row["Result" + temp] = dtCert.Rows[i]["investigateresult"].ToString() == "已完成" ? "有" : "无";
                }
            }
            dt.Rows.Add(row);
            doc.MailMerge.Execute(dt);
            dtCert.TableName = "Investigate";
            doc.MailMerge.ExecuteWithRegions(dtCert);
            doc.MailMerge.DeleteFields();
            doc.Save(resp, Server.UrlEncode(fileName), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc));
            return(Success("导出成功!"));
        }