[WebMethod(Description = "获取对应产品Id及Name,Productlist是以,分割的productid字符串")]
public string GetProductListByIds(string Productlist)
{
ProductMng productMng = new ProductMng(connString);
System.IO.MemoryStream productlist = new System.IO.MemoryStream();
XmlTextWriter writer = new XmlTextWriter(productlist, System.Text.Encoding.UTF8);
writer.WriteStartDocument();
writer.WriteStartElement("productlist");
string[] ids = Productlist.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string id in ids)
{
Model.Product product = productMng.GetItem(int.Parse(id));
writer.WriteStartElement("product");
writer.WriteElementString("ID", product.ID.ToString());
writer.WriteElementString("Name", product.Name);
writer.WriteElementString("NameEn", product.NameEn);
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
return System.Text.Encoding.UTF8.GetString(productlist.ToArray());
}