我正在尝试将 LinkedIn 集成到我的应用程序中,响应表中的值被覆盖
我有 3 张桌子
客户表(在 LinkedIn 中发布他们的详细信息的人将存储在此表中)
Customer_Id Name Cust_date User_id Community
Efthok xxxx 04-Mar-13 Efthok LinkedIn
df343n yyyy 27-Jun-13 df343n LinkedIn
4retee zzzz 01-Jul-13 4retee LinkedIn
Post Table(posts会存放在这里)Customer_Id是Customer表的外键
Customer_Id Post_Id Posts PostDate Community
Efthok guujjk intersted in car loan 04-Mar-2013 LinkedIn
df343n fdg4df we are offering loans 27-Jun-2013 LinkedIn
4retee hgf454 ******************** 01-Jul-2013 LinkedIn
响应表(谁给帖子发表评论)//这里的值在我的代码中被覆盖 Response_Id Customer_Id Post_Id Response ResponseDate Community
767hhjj Efthok guujjk let me know the interest 06-Apr-2013 Linked
gdf5654 Efthok guujjk let me know the interest 06-Apr-2013 Linked
我已经写了这段代码
获取 List<> 中的所有评论
public void commentM()
{
XmlDocument d = new XmlDocument();
d.LoadXml(content);
XmlNodeList comments = d.SelectNodes("//comments/comment");
foreach (XmlNode xncomment in comments)
{
commentId = xncomment["id"].InnerText;
memComments = xncomment["text"].InnerText;
string timeStamp = xncomment["creation-timestamp"].InnerText;
double cmtTimeStamp1 = Convert.ToDouble(timeStamp);
DateTime comment_timestamp1 = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Math.Round(cmtTimeStamp1 / 1000d)).ToLocalTime();
comment_timestamp = comment_timestamp1.ToString("dd-MMM-yy");
commentData = new CommentData { CommentId = commentId, Comments = memComments, CommentTimeStamp = comment_timestamp };
listComment.Add(commentData);
commentM1();
}
}
public void commentM1()
{
for (int i = 0; i < listCustomer.Count; i++)
{
var grt = listCustomer[i];
id = grt.UserId;
for (int k = 0; k < listPost.Count; k++)
{
string post_id1 = listPost[k].PostId;
for (int j = 0; j < listComment.Count; j++)
{
comId = listComment[j].CommentId;
comments1 = listComment[j].Comments;
commentTime = listComment[j].CommentTimeStamp;
DbConnection.Open();
DbCommand = new OleDbCommand("select count(response_id) from mw_response where response_id = '" + comId + "'", DbConnection);
OleDbDataReader DbReader = DbCommand.ExecuteReader();
while (DbReader.Read())
{
count = DbReader[0].ToString();
cnt = Convert.ToInt32(count);
if ((cnt == 0) && (memComments != ""))
{
DbCommand = new OleDbCommand("insert into mw_response(post_id,response,response_id, resp_date,community) values('" + post_id1 + "','" + comments1 + "','" + comId + "','" + commentTime + "','LinkedIn')", DbConnection);
DbCommand.ExecuteNonQuery();
//update productid and customerid
DbCommand = new OleDbCommand("update mw_response set prod_id = (select prod_id from mw_post where post_id='" + post_id1 + "'),customer_id = (select customer_id from mw_customer where customer_id = '" + id + "') where response_id = '" + comId + "'", DbConnection);
DbCommand.ExecuteNonQuery();
}
}
DbReader.Close();
DbConnection.Close();
}
}
}
}
我在 List<> 中为 Customer、Response 和 Post 值收集数据,然后在 CommentM1() 方法中循环这些值。
我想正确获得响应(帖子的评论)。
如果有人对这篇文章发表评论“我们正在提供贷款”,则来自(发布表)的 Post_id 和 customer_id 应该存储到响应表中。
有任何想法吗?提前致谢。