- public void SaveMessage(string FromUserName,int FromUID, int ToUID, string Title,string Message, DateTime sendtime) {
- Title = Data.Filter(Title);
- Message = Data.Filter(Message);
- FromUserName = Data.Filter(FromUserName);
- string value = ToUID.ToString()+"_"+FromUID.ToString();
- long basetime=Discuz.MyMath.GetPhpTime(sendtime);
- string LastMessage="a:3:{s:12:"lastauthorid";s:1:""+FromUID.ToString()+"";s:10:"lastauthor";s:15:""+FromUserName+"";s:11:"lastsummary";s:"+(Title.Length+10).ToString()+":""+Message+"";}";
- int Plid=0;
- Data.MySqlDataVisit mysql=new Data.MySqlDataVisit("Discuz");
- if (Plid == 0)
- {
- mysql.Sql = "INSERT INTO pre_ucenter_pm_lists(authorid, pmtype, subject, members, min_max, dateline, lastmessage) VALUES('" + FromUID.ToString() + "', '1', '" + Title + "', 2, '" + value + "', '" + basetime + "', '" + LastMessage + "')";
- mysql.Execute();
- mysql.Sql = "Select max(Plid) from pre_ucenter_pm_lists";
- Plid = mysql.SelectFirstInt();
- mysql.Sql = "INSERT INTO pre_ucenter_pm_indexes(plid) VALUES('" + Plid.ToString() + "')";
- mysql.Execute();
- mysql.Sql = "Select max(Pmid) from pre_ucenter_pm_indexes";
- int Pmid = mysql.SelectFirstInt();
- mysql.Sql = "INSERT INTO " + getposttablename(Plid) + "(pmid, plid, authorid, message, dateline, delstatus) VALUES('" + Pmid.ToString() + "', '" + Plid.ToString() + "', '" + FromUID.ToString() + "', '" + Message + "', '" + basetime.ToString() + "', 0)";
- mysql.Execute();
- mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '" + ToUID.ToString() + "', '1', '1', '0', '" + basetime.ToString() + "')";
- mysql.Execute();
- mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '" + FromUID.ToString() + "', '0', '1', '" + basetime.ToString() + "', '" + basetime.ToString() + "')";
- mysql.Execute();
- }
- else
- {
- mysql.Sql = "INSERT INTO pre_ucenter_pm_indexes(plid) VALUES('" + Plid.ToString() + "')";
- mysql.Execute();
- mysql.Sql = "Select max(Pmid) from pre_ucenter_pm_indexes";
- int Pmid = mysql.SelectFirstInt();
- mysql.Sql = "INSERT INTO pre_ucenter_"+getposttablename(Plid)+"(pmid, plid, authorid, message, dateline, delstatus) VALUES('" + Pmid.ToString() + "', '" + Plid.ToString() + "', '" + FromUID.ToString() + "', '" + Message + "', '" + basetime.ToString() + "', 0)";
- mysql.Execute();
- mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '"+ToUID.ToString()+"', '1', '1', '0', '" + basetime.ToString() + "')";
- mysql.Execute();
- if(!mysql.IsHaveErrorPrivate) {
- mysql.Sql = "UPDATE pre_ucenter_pm_members SET isnew=1, pmnum=pmnum+1, lastdateline='" + basetime.ToString() + "' WHERE plid='" + Plid.ToString() + "' AND uid='"+ToUID.ToString()+"'";
- mysql.Execute();
- }
- mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '" + FromUID.ToString() + "', '0', '1', '" + basetime.ToString() + "', '" + basetime.ToString() + "')";
- mysql.Execute();
- if(!!mysql.IsHaveErrorPrivate) {
- mysql.Sql = "UPDATE pre_ucenter_pm_members SET isnew=0, pmnum=pmnum+1, lastupdate='" + basetime.ToString() + "', lastdateline='" + basetime.ToString() + "' WHERE plid='" + Plid.ToString() + "' AND uid='" + FromUID.ToString() + "'";
- mysql.Execute();
- }
- mysql.Sql = "UPDATE pre_ucenter_pm_lists SET lastmessage='"+LastMessage+"' WHERE plid='" + Plid.ToString() + "'";
- mysql.Execute();
- }
- }
- public string getposttablename(int id)
- {
- string str = id.ToString();
- string tableid = str.Substring(str.Length-1, 1);
- return "pre_ucenter_pm_messages_" + tableid;
- }
复制代码 |