问题描述
各位大神好,小人菜鸟一枚,求指教一下目前情况是这样的,详见图片图1为页面A图2为页面B,页面A导入excel成功后,将邮箱整合为datatable并存入session["data"]又或者勾选部分数据后,将邮箱整合为datatable并存入session["data"]页面B解析session["data"]后,根据传过来的邮箱,操作发生邮件的方法;我现在的问题是:如果同一用户,第一次在页面A导入数据后,传到session中发送到页面B,(B还在发送邮件期间),用户又再一次导入另外一份邮件excel数据,并传到页面B,那这样,session里面的数据会混乱吗?如何防止这种情况呢?又或者,不用用户操作这个流程,那session会怎样呢?小弟求指教以下是页面B的处理代码:InfoTableBLLInfoBLL=newInfoTableBLL();publicintIDcount=0;DataTabledatatable;EmailAccountsemailacc=newEmailAccounts();protectedvoidPage_Load(objectsender,EventArgse){stringfilePath=Server.MapPath("EmailAccount.xml");emailacc=InfoBLL.GetEmailAccount(filePath);datatable=(DataTable)Session["emailCount"];IDcount=datatable.Rows.Count;if(!IsPostBack){ViewState["sum"]=datatable.Rows.Count-1;sendlog.Text=DateTime.Now.ToString()+"开始发送邮件!n"+sendlog.Text;count.InnerText=IDcount.ToString();}}protectedvoidTimer1_Tick(objectsender,EventArgse){inti=Convert.ToInt32(ViewState["sum"]);stringsuc=succount.InnerText;stringfal=failcount.InnerText;stringlogs=sendlog.Text;if(i<0){Timer1.Enabled=false;Session["emailCount"]=null;ViewState["sum"]=null;sendlog.Text=DateTime.Now.ToString()+"邮件已发送完毕!n"+sendlog.Text;}else{//sendlog.Text=DateTime.Now.ToString();//获取客户邮箱和ID,发件时间InfoTableinfo=InfoBLL.GetInfoByID(Convert.ToInt32(datatable.Rows[i]["ID"]));info.SendEmailLastTime=DateTime.Now.ToString();//发送邮件//参数加密stringIDs=InfoBLL.Encode(info.ID.ToString(),"Administrator");stringmsg=InfoBLL.SendEmail(emailacc,info.Email,"你好","内容:<ahref='http://192.168.0.3/UploadInfo.aspx?ID="+IDs+"'>点击链接</a>上传图片资料!");//msg发送状态if(msg=="true"){//发送成功,更新数据库发件时间InfoBLL.UpdateEmailTime(info);succount.InnerText=(Convert.ToInt32(succount.InnerText)+1).ToString();sendlog.Text=DateTime.Now.ToString()+""+info.Email+"发送成功!n"+sendlog.Text;}else{failcount.InnerText=(Convert.ToInt32(failcount.InnerText)+1).ToString();sendlog.Text=DateTime.Now.ToString()+""+info.Email+"发送失败!失败原因:"+msg+"n"+sendlog.Text;}}i--;ViewState["sum"]=i;}
解决方案
解决方案二:
能有大神给一下思路吗