我正在尝试将社交媒体与 siebel
我收到一个错误
“索引超出了数组的范围”
我无法修复错误
代码:
public void Call_Tweet_Update()
{
var service = new TwitterService(Consumer_Key, Consumer_Secret);
service.AuthenticateWith(Access_Token, AccessToken_Secret);
var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions { Count = 100 });
string[] twt_id = new string[100];
long id = 0;
int i = 0;
int increment = 0;
string twtid;
string screenname;
foreach (var tweet in tweets)
{
if (tweet.InReplyToStatusId.ToString() != "")
{
if ((tweet.User.ScreenName == "IIPL_LTD") || (tweet.Text.StartsWith("@IIPL_LTD")))
{
string replyid = tweet.InReplyToStatusId.ToString();
while (replyid != "")
{
if (i == 0)
{
twt_id[i] = tweet.Id.ToString();
}
id = Convert.ToInt64(replyid);
twtid = Convert.ToInt64(tweet.Id).ToString();
i = i + 1;
twt_id[i] = twtid;
increment = increment + 1;//Here I get an error
}
if (increment == 1)
{
//Reply related reply information
i = 0;
tweet_id = tweet.Id.ToString();
DbCommand = new OleDbCommand("select cust.first_name from mw_response resp, mw_customer cust where resp.response_id = '" + twt_id[i] + "' and resp.post_id is null and resp.customer_id= cust.customer_id", DbConnection);
OleDbDataReader DbReader = DbCommand.ExecuteReader();
while (DbReader.Read())
{
screenname = DbReader[0].ToString();
DbCommand = new OleDbCommand("select post_id,prod_id from mw_post where post_id = '" + id + "'", DbConnection);
OleDbDataReader DbReader0 = DbCommand.ExecuteReader();
while (DbReader0.Read())
{
post_id = DbReader0[0].ToString();
prod_id = DbReader0[1].ToString();
DbCommand = new OleDbCommand("update mw_response set prod_id = '" + prod_id + "',post_id = '" + post_id + "' where response_id = '" + twt_id[i] + "'", DbConnection);
DbCommand.ExecuteNonQuery();
//Invoking Siebel Web Service
if (screenname != "IIPL_LTD")
{
createComment(twt_id[i]);
}
}
DbReader0.Close();
}
DbReader.Close();
increment = 0;
i = 0;
}
else
{
i = 0;
while (increment > 0)
{
//Reply related reply information
DbCommand = new OleDbCommand("select cust.first_name from mw_response resp, mw_customer cust where resp.response_id = '" + twt_id[i] + "' and resp.post_id is null and resp.customer_id= cust.customer_id", DbConnection);
OleDbDataReader DbReader = DbCommand.ExecuteReader();
while (DbReader.Read())
{
screenname = DbReader[0].ToString();
DbCommand = new OleDbCommand("select post_id,prod_id from mw_post where post_id = '" + id + "'", DbConnection);
OleDbDataReader DbReader0 = DbCommand.ExecuteReader();
while (DbReader0.Read())
{
post_id = DbReader0[0].ToString();
prod_id = DbReader0[1].ToString();
DbCommand = new OleDbCommand("update mw_response set prod_id = '" + prod_id + "',post_id = '" + post_id + "' where response_id = '" + twt_id[i] + "'", DbConnection);
DbCommand.ExecuteNonQuery();
//Invoking Siebel Web Service
if (screenname != "IIPL_LTD")
{
createComment(twt_id[i]);
}
}
DbReader0.Close();
}
DbReader.Close();
increment = increment - 1;
i = i + 1;
}
i = 0;
}
}
}
}
DbConnection.Close();
}
这是程序被终止的地方 Index 超出了数组的范围
if(i == 0)
{
twt_id[i] = tweet.Id.ToString();
}
id = Convert.ToInt64(replyid);
twtid = Convert.ToInt64(tweet.Id).ToString();
i = i + 1;
twt_id[i] = twtid;
increment = increment + 1;
有任何想法吗?提前致谢。