[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());
}
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());
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步