[CustomAuthorize]
        public FileResult ExportQuestionCenterWord(SearchBaseQuestion search)
        {
            StringWriter strWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(strWriter);
            StringBuilder sb = null;
            string html = "";

try
            {
                search.PageSize = Int32.MaxValue;
                search.Status = DeleteMarkEnum.Active;
                search.isAnswer = IsAnswerEnum.Total;
                search.isReview = IsReviewEnum.Total;
                search.AddOrderBy("MODIFYDATE", SearchOrderType.Desc);
                
                if (search.SOURCE == "0")
                    search.SOURCE = "";
                if (search.MODULE == "0")
                    search.MODULE = "";
                if (search.QUESTIONTYPE == "0")
                    search.QUESTIONTYPE = "";
                if (search.QSTATUS == "0")
                    search.QSTATUS = "";
                if (search.ADMINID == "0")
                    search.ADMINID = "";
                if (!string.IsNullOrEmpty(search.IsSaleQuestion) && search.IsSaleQuestion == "1")
                    search.CUSTOMERMANAGERIDs = GetInPermissionCustomerMannagerIDs();
                 
                IList<BASE_QUESTION> baseQuestionList = questionManager.SearchQuestionList(search);

IList<BASE_CHOICECUSTOMERMANAGER> managerList = customerManagerService.GetChoiceCusManageList();
                SearchChoiceCusManager search_msg = new SearchChoiceCusManager();
                search_msg.SearchType = SearchTypeEnum.Total;
                search_msg.Status = DeleteMarkEnum.Active;
                search_msg.parentIdMany = "samedatakefu";
                IList<BASE_CHOICECUSTOMERMANAGER> choiceManagerList = choiceCusManagerManager.Search(search_msg);

if (baseQuestionList.Count > 0)
                {
                    foreach (var baseQuestion in baseQuestionList)
                    {
                        //获取受理人
                        string ADMINID_Str = "";
                        if (choiceManagerList != null && choiceManagerList.Count > 0)
                        {
                            BASE_CHOICECUSTOMERMANAGER em = choiceManagerList.Where(m => m.USERID == baseQuestion.ADMINID).FirstOrDefault();
                            if (em != null)
                            {
                                ADMINID_Str = em.NAME;
                            }
                        }
                        BASE_CHOICECUSTOMERMANAGER manager = managerList.FirstOrDefault(t => t.ID == baseQuestion.CUSTOMERMANAGERID);

string strSource = string.Empty;
                        switch (baseQuestion.SOURCE)
                        {
                            case 1:
                                strSource = "QQ";
                                break;
                            case 2:
                                strSource = "Email";
                                break;
                            case 3:
                                strSource = "Online";
                                break;
                            case 4:
                                strSource = "Sales";
                                break;
                            case 5:
                                strSource = "用户直通车";
                                break;
                            case 6:
                                strSource = "需求直通车";
                                break;
                            case 7:
                                strSource = "回访";
                                break;
                            case 8:
                                strSource = "QQ群";
                                break;
                            case 9:
                                strSource = "社区";
                                break;
                            case 10:
                                strSource = "微信群";
                                break;
                            default:
                                strSource = "全部";
                                break;
                        }

sb = new StringBuilder();
                        sb.Append("<table border='1' cellspacing='0' style=\"width;1200px;\">");
                        sb.Append("<tbody>");
                        //第一行
                        sb.Append("<tr align='center'>");
                        sb.Append("<td colspan='3' style='width:1200px;'>");
                        sb.Append(baseQuestion.TITLE == null ? StringConst.NAConst : baseQuestion.TITLE);
                        sb.Append("</td>");
                        sb.Append("</tr>");

//第二行
                        BASE_USER user = userManager.GetUserByUniqueId(baseQuestion.USERID);
                        if (user == null)
                            user = new BASE_USER();

sb.Append("<tr>");
                        sb.Append("<td style='width:400px;'>");
                        sb.Append("姓名:" + user.REALNAME);
                        sb.Append("</td>");

sb.Append("<td style='width:400px;'>");
                        sb.Append("账号:" + baseQuestion.USERNAME);
                        sb.Append("</td>");

sb.Append("<td style='width:400px;'>");
                        sb.Append("联系方式:" + baseQuestion.MOBILE);
                        sb.Append("</td>");
                        sb.Append("</tr>");

//第三行
                        sb.Append("<tr>");
                        sb.Append("<td style='width:400px;'>");
                        sb.Append("模块:" + (string.IsNullOrEmpty(baseQuestion.MODULE) ? "" : packageTreeCopy.GetOneById(baseQuestion.MODULE) == null ? "" : packageTreeCopy.GetOneById(baseQuestion.MODULE).FULLNAME));
                        sb.Append("</td>");

sb.Append("<td style='width:400px;'>");
                        sb.Append("问题类型:" + AttributesUtils.GetEnumDescription<QuestionCenterTypeEnum>(baseQuestion.QUESTIONTYPE));
                        sb.Append("</td>");

sb.Append("<td style='width:400px;'>");
                        sb.Append("状态:" + AttributesUtils.GetEnumDescription<QuestionCenterStatusEnum>(baseQuestion.STATUS));
                        sb.Append("</td>");
                        sb.Append("</tr>");

//第四行
                        sb.Append("<tr>");
                        sb.Append("<td style='width:400px;'>");
                        sb.Append("受理人:" + ADMINID_Str);
                        sb.Append("</td>");

sb.Append("<td style='width:400px;'>");
                        sb.Append("产品对接人:" + baseQuestion.PRODUCTMANAGERNAME);
                        sb.Append("</td>");

sb.Append("<td style='width:400px;'>");
                        sb.Append("下次跟踪时间:" + (baseQuestion.NEXTVIEWDATE.ToString() == "0001-01-01 00:00:00" ? "" : baseQuestion.NEXTVIEWDATE.ToString()));
                        sb.Append("</td>");
                        sb.Append("</tr>");

//第五行
                        sb.Append("<tr>");
                        sb.Append("<td style='width:400px;'>");
                        sb.Append("标签:" + baseQuestion.KEYWORD);
                        sb.Append("</td>");

sb.Append("<td colspan='2' style='width:800px;'>");
                        sb.Append("来源:" + strSource);
                        sb.Append("</td>");
                        sb.Append("</tr>");

//第六行
                        sb.Append("<tr'>");
                        sb.Append("<td colspan='3' style='width:1200px;'>");
                        sb.Append("内容:" + baseQuestion.CONTENT);
                        sb.Append("</td>");
                        sb.Append("</tr>");

//第七行
                        string questionID = baseQuestion.ID.ToString();
                        BASE_ANSWER answer = answerManager.GetAnswerByQuestionsID(questionID);
                        sb.Append("<tr'>");
                        sb.Append("<td colspan='3' style='width:1200px;'>");
                        sb.Append("回复:" + (answer == null ? "" : HtmlDecode(answer.CONTENT)));
                        sb.Append("</td>");
                        sb.Append("</tr>");

sb.Append("</tbody>");
                        sb.Append("</table>");

sb.Append("<br/>");
                        sb.Append("<br/>");

html += sb.ToString();
                    }

strWriter.Write(html);
                }
                else
                {
                    strWriter.WriteLine("没有数据!");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Instance.Error("ExportQuestionCenterWord error:", ex);
                strWriter.WriteLine("导出出现问题:" + ex.Message);
            }

byte[] fileContents = Encoding.GetEncoding("gb2312").GetBytes("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"><body>" + strWriter.ToString() + "</body></html>");
            return File(fileContents, "application/vnd.ms-word", string.Format("{0}.doc", "问题中心" + DateTime.Now.Date.ToString("yyyyMMdd")));
        }

最新文章

  1. Web APi之控制器选择Action方法过程(九)
  2. 常用的sql数据库语句
  3. sizeof &amp;&amp; strlen 的区别
  4. docker-proxy 实现容器代理访问
  5. hdu5344 MZL&#39;s xor(水题)
  6. 为什么和其他语言相比C语言是快速的语言
  7. JS中new的运行方式
  8. Python 远程部署 Fabric
  9. MySQL 数据库字符集 utf8 和 utf8mb4 的区别
  10. 常见dos命令行
  11. 安恒杯 3月线上个人赛WriteUp
  12. 如何编写最佳的Dockerfile
  13. EF部分字段更新,忽略为null字段
  14. React.js 入门与实战之开发适配PC端及移动端新闻头条平台课程上线了
  15. Android Studio向项目添加C/C++原生代码教程
  16. loadrunner json中文无法识别问题
  17. Blender快捷键设置
  18. &lt;NET CLR via c# 第4版&gt;笔记 第8章 方法
  19. 团队作业7——alpha阶段之事后诸葛亮分析
  20. Android 菜单和上下文演示

热门文章

  1. redhat6本地源NBD驱动安装
  2. 2018 kali linux install tools
  3. HDU1398 Square Coins(生成函数)
  4. window.moveTo(),window.moveBy()不生效
  5. Java : Netty 入门案例
  6. MQTT的学习之Mosquitto安装&amp;使用(1)
  7. 位域 (Bit field)
  8. 破解Wifi
  9. [NOIP2017]列队(树状数组)
  10. 十分钟搭建和使用ELK日志分析系统