Exemplo n.º 1
0
        private void ExportUserEmails()
        {
            string gid = "";

            if (base.CheckCookie())
            {
                gid = this.Usergroups.GetSelectString(",");
            }
            if (String.IsNullOrEmpty(gid))
            {
                return;
            }

            //DataTable emailListByGroupidList = Users.GetEmailListByGroupidList(gid);
            //string text2 = "";
            //if (emailListByGroupidList.Rows.Count > 0)
            //{
            //    for (int i = 0; i < emailListByGroupidList.Rows.Count; i++)
            //    {
            //        text2 = text2 + emailListByGroupidList.Rows[i][1].ToString().Trim() + "; ";
            //    }
            //}
            var sb = new StringBuilder();

            foreach (var item in XUser.GetEmailListByGroupidList(gid.SplitAsInt()))
            {
                if (item.Email.IsNullOrWhiteSpace())
                {
                    continue;
                }

                if (sb.Length > 0)
                {
                    sb.Append("; ");
                }
                sb.Append(item.Email);
            }
            string file = "Useremail.txt";

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer          = false;
            HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + base.Server.UrlEncode(file));
            HttpContext.Current.Response.ContentType = "text/plain";
            this.EnableViewState = false;
            HttpContext.Current.Response.Write(sb.ToString());
            HttpContext.Current.Response.End();
        }