1 Star 3 Fork 0

Admin/MyWebSms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dxtask.aspx.cs 5.42 KB
一键复制 编辑 原始数据 按行查看 历史
Ai鹿子 提交于 2022-04-24 10:09 . 01
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Wuqi.Webdiyer;
using System.Data.SqlClient;
using System.IO;
using System.Text;
public partial class dxtask : WebPage
{
public string _username = "";
public string _orders = "";
public string _msg = "";
public string _bdate = "";
public string _edate = "";
protected void Page_Load(object sender, EventArgs e)
{
this.VerifyPage();
this.pcbtime.Value = DateTime.Now.Date.ToString();
this.pcetime.Value = DateTime.Now.ToString();
if (CheckCurUser())
{
if (!Page.IsPostBack)
{
DataBindlist();
}
}
else
{
this.message.Visible = true;
}
}
public bool CheckCurUser()
{
bool ret = false;
if (CurrentUser.UserPID == -1)
ret = true;
else
ret = false;
return ret;
}
protected void DataBindlist()
{
string sqlCount = string.Format("Select Count(1) From [Table_OutBox]");
int recordcount = GetData.GetScalar(sqlCount);
if (recordcount == 0)
{
this.message.Visible = true;
}
pagelist.AlwaysShow = true;
pagelist.RecordCount = recordcount; //读出数据库里一共有多少条数据
string sql = "select * from [Table_OutBox] order by id desc";
SqlDataAdapter ad = new SqlDataAdapter(sql, GetData.strConn);
DataSet ds = new DataSet();
ad.Fill(ds, pagelist.PageSize * (pagelist.CurrentPageIndex - 1), pagelist.PageSize, "temp");
rep_parent.DataSource = ds.Tables["temp"];
rep_parent.DataBind();
string sqlcount = "select sum(SendCount) from [Table_OutBox] ";
txtcounts.Text = GetData.GetScalar(sqlcount).ToString();
}
protected void PageChanging(object src, PageChangingEventArgs e)
{
pagelist.CurrentPageIndex = e.NewPageIndex;
DataBindlist();
}
protected void rep_parent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
}
protected void rep_parent_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "btnsydown")
{
string myorders = e.CommandArgument.ToString();
WebKey wk = new WebKey();
string dot = wk.Dot();
string SaveFolder = wk.ListSendFileFolder();
string SavePath = Server.MapPath(SaveFolder + "/"); //得到上传目录
Boolean fileOk = false;
string path = SavePath + myorders + ".txt";
if (File.Exists(path))
{
fileOk = true;
}
else
{
fileOk = false;
}
if (fileOk)
{
string filename = path;
string newfilename = myorders + ".txt";
FileInfo fi = new FileInfo(filename);
Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", newfilename)); //定义输出文件和文件名
Response.ContentType = "application/octet-stream";
//Response.ContentType = "application/ms-txt";// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.WriteFile(fi.FullName); // 把文件流发送到客户端
Response.End();
}
else
{
if (!System.IO.Directory.Exists(SavePath))
{
System.IO.Directory.CreateDirectory(SavePath);
}
OutBox ns = new OutBox();
ns.Orders = myorders;
ns = ns.Select(ns);
string[] mobiles = ns.Mobiles.Split(Convert.ToChar(dot));
string filename = path;
string newfilename = myorders + ".txt";
FileInfo fi = new FileInfo(filename);
FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("gb2312"));
sw.WriteLine(ns.SendTime);
sw.WriteLine(ns.UserName+"("+ns.SendCount+")");
sw.WriteLine("");
sw.WriteLine(ns.Content);
sw.WriteLine("");
foreach (string i in mobiles)
{
sw.WriteLine(i.ToString());
}
sw.Close();
Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", newfilename)); //定义输出文件和文件名
Response.ContentType = "application/octet-stream";
//Response.ContentType = "application/ms-txt";// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.WriteFile(fi.FullName); // 把文件流发送到客户端
Response.End();
}
}
}
public static string gettdname(string uid)
{
Users us = new Users();
int interid = us.Select(int.Parse(uid)).interid;
inters inter = new inters();
return inter.Select(interid).inter_name;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/huanghe_1_0/my-web-sms.git
git@gitee.com:huanghe_1_0/my-web-sms.git
huanghe_1_0
my-web-sms
MyWebSms
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385