日期:2014-05-17 浏览次数:20530 次
protected void Page_Load(object sender, EventArgs e)
{
Stream instream = Request.InputStream;
BufferedStream buf = new BufferedStream(instream);
byte[] buffer = new byte[1024];
string str = "";
int a;
while ((a = buf.Read(buffer, 0, buffer.Length)) != 0)
{
str = str + System.Text.Encoding.GetEncoding("GB2312").GetString(buffer);
}
int returnval = 9;
if (!string.IsNullOrEmpty(str))
{
returnval = parseXML(str.Trim());
}
Response.Write(returnval.ToString());
sw.Flush();
sw.Close();
GC.Collect();
Response.End();
}
private int parseXML(string xmlstr, StreamWriter sw)
{
int val = 9;
try
{
XmlDocument document = new XmlDocument();
document.LoadXml(xmlstr);
XmlElement element = document.DocumentElement;
for (int i = 0; i < element.ChildNodes.Count; i++)
{
XmlNode node = element.ChildNodes[i];
string corp_id = node["corp_id"].InnerText;//用户名id
string mobile = node["mobile"].InnerText;//号码
string ext = node["ext"].InnerText;//小号
string time = node["time"].InnerText;//时间
string content = node["content"].InnerText;//内容
ReceiveMsgInfo info = new ReceiveMsgInfo();
info.Mobile = mobile;
info.Content = content;
info.Status = 0;
info.Recetime = DateTime.Parse(time);
info.Userport = Convert.ToInt32(ext);//小号
int sussress = Controller.AddReceiveInfo(info);//保存到数据库当中
}
val = 0;
}
catch (Exception exc)
{
}
return val;
}