C#コード、プロセスdiscuzフォーラムの一括または自動投稿


使用するasp.Net+c#はdiscuzフォーラムのロットや自動投稿のプログラムを開発し、2、3日間模索し、ついに成功した.次に、ソースコードとプロセスの説明を示します.
protected void Button8_Click(object sender, EventArgs e)
{
string tl, tr, cl, cr;
tl = TBtitleLeft.Text;
tr = "\r
";// TBtitleRigt.Text; cl = "\r
";//TBContentLeft.Text; cr = TBContentRigt.Text; string title,content; string tMemo = TextBox8.Text + cr; int pos, pos1; int add = int.Parse(TBtitleRigt.Text); int zhutiid = int.Parse(TextBox2.Text); pos = 1; pos1 = 1; cSjksql.open(); int sj=int.Parse(TextBox7.Text); while (pos != -1) //-- , { sj = sj - 2; TextBox7.Text = sj.ToString(); pos = tMemo.IndexOf(tl, pos); pos1 = tMemo.IndexOf(tr, pos); if (pos1 == -1) break; title = tMemo.Substring(pos + 1, pos1 - pos - 1).Trim(); pos = tMemo.IndexOf(cl, pos); pos1 = tMemo.IndexOf(cr, pos); if (pos1 == -1) break; content = tMemo.Substring(pos + 1, pos1 - pos - 1).Trim(); //TextBox6.Text = add.ToString() + "." + TBtitleLeft0.Text + title + TBtitleRigt0.Text; //-- , TextBox6.Text = title + TBtitleRigt0.Text; TextBox8.Text = content; //-- sql = "insert into pre_forum_post(fid,tid,first,author,authorid,subject,dateline,message,useip,tags) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox11.Text+","+TextBox10.Text + "')"; cSjksql.SqlCmd1(sql) ; //-- sql = "insert into pre_forum_thread(fid,tid,author,authorid,subject,dateline,lastpost,lastposter) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox7.Text + "','" + TextBox4.Text + "')"; cSjksql.SqlCmd1(sql); //-- //pre_forum_thread(fid,tid,author,authorid,subject,dateline,lastpost=dateline,lastposter=author) //-- add++; zhutiid++; TextBox2.Text = zhutiid.ToString(); TBtitleRigt.Text = add.ToString(); } sql = "update pre_forum_forum set threads=threads+" + add.ToString() + ",todayposts=todayposts+" + add.ToString() + " where fid=" + TextBox1.Text; if (cSjksql.SqlCmd1(sql)) Label1.Text = add.ToString(); //-- : //--- pre_forum_post ID, 。discuz pre_forum_post pid 。 discuz pid , , , pre_forum_post pid 。 sql = "delete from pre_forum_post_tableid "; //-- : pre_forum_post_tableid cSjksql.SqlCmd1(sql); sql="select max(pid) from pre_forum_post"; //-- : pre_forum_post pid msDataSet=cSjksql.GetDatas1(sql); string maxid=msDataSet.Tables[0].Rows[0][0].ToString(); int tmi = int.Parse(maxid) + 1; sql = "insert into pre_forum_post_tableid(pid) values('" + tmi.ToString() + "')"; if (cSjksql.SqlCmd1(sql)) Label1.Text = "<br/>insert into max_post_id OK"; //-- : pre_forum_post pid //-- pre_common_tagitem if (TextBox11.Text != "") { sql = "insert into pre_common_tagitem(tagid,tagname,itemid,idtype) select '" + TextBox11.Text + "','" + TextBox10.Text + "',tid,'tid' from pre_forum_post where tags='" + TextBox11.Text + "," + TextBox10.Text + "'"; if (cSjksql.SqlCmd1(sql)) Label1.Text = "<br/>pre_common_tagitem OK";//-- : pre_common_tagitem //-- , : id, 。 pre_forum_post tags。 } cSjksql.close(); }