Ejemplo n.º 1
0
        /// <summary>
        /// 导出execl
        /// </summary>
        /// <param name="execlModel"></param>
        /// <returns></returns>
        public List <UserReferDetail> ExportExeclss(ExportExeclModel execlModel)
        {
            bool result = false;
            List <UserReferDetail> list = null;

            //查询数据
            var req             = Mapper.Map <ExportExeclModel, QueryUserReferListRequest>(execlModel);
            var userReferResult = OpcClient.Send <QueryUserReferListResponse>(req);

            if (userReferResult.DoFlag)
            {
                list = Mapper.MappGereric <User_ReferExt, UserReferDetail>(userReferResult.ReferDos);
            }
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 导出execl
        /// </summary>
        /// <param name="execlModel"></param>
        /// <returns></returns>
        public JsonResult ExportExecl(ExportExeclModel execlModel)
        {
            var result = new BaseResponse();
            List <UserReferDetail> list = null;

            //查询数据
            list = UserReferClient.Instance.ExportExeclss(execlModel);
            try
            {
                string        strFile = "咨询管理-" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv"; //生成的Excel名称
                StringBuilder sb      = new StringBuilder();
                sb.Append("编号,用户编号,商品编号,商品名称,咨询内容.,咨询类型,咨询日期,回复内容,回复人,回复日期,是否可见");
                sb.AppendLine();
                if (list != null && list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        sb.Append(list[i].IntReferID + "," + list[i].IntUserID + "," + list[i].IntProductID + "," +
                                  list[i].VchProductName + "," + list[i].VchContent + "," + list[i].IntReferType +
                                  "," +
                                  list[i].DtDatetime + "," + list[i].VchReplyContent + "," + list[i].VchReplyPerson +
                                  "," + list[i].DtReplyDatetime + "," + list[i].IntOtherIsVisible);
                        sb.AppendLine();
                    }
                }
                StringWriter sw = new StringWriter(sb);

                Response.Clear();
                Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", "e:\\" + strFile));
                Response.ContentType     = "text/xml";
                Response.Charset         = "UTF-8";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                Response.Write(sw);
                Response.Flush();
                Response.End();
                sw.Close();
                result.DoFlag = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }