ItemMaster item = ItemMaster.Finder.Find($"Org.id ={Context.LoginOrg.ID} and Code='{param.ItemCode}'");
if (item != null)
{
long itemid = item.ID;
UFIDA.U9.Base.Attachment.Attachment.EntityList attEntity = UFIDA.U9.Base.Attachment.Attachment.Finder.FindAll($"id ={itemid} and EntityFullName='UFIDA.U9.CBO.SCM.Item.ItemMaster'");
DataSet ds = new DataSet();
DataTable newTable = new DataTable();
newTable.Columns.Add("Idx", typeof(int));
newTable.Columns.Add("AttachType", typeof(string));
newTable.Columns.Add("URI", typeof(string));
newTable.Columns.Add("Title", typeof(string));
newTable.Columns.Add("Size", typeof(string));
newTable.Columns.Add("Description", typeof(string));
if (attEntity != null)
{
foreach (Attachment attachment in attEntity)
{
DataRow dr = newTable.NewRow();
dr["Idx"] = attachment.Idx;//序号
dr["AttachType"] = attachment.AttachType?.Name;//附件类型
dr["URI"] = attachment.URI;//附件
dr["Title"] = attachment.Title;//标题
dr["Size"] = attachment.Size;//大小
dr["Description"] = attachment.Description;//描述
newTable.Rows.Add(dr);
}
ds.Tables.Add(newTable);
string json = JsonConvert.SerializeObject(ds, Formatting.None, jsonSetting);
result.state = "success";
result.msg = "查询成功";
result.data = json;
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
else
{
result.state = "fail";
result.msg = "未查到该料品附件信息";
result.data = "";
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}
}
else
{
result.state = "fail";
result.msg = "未查到该料品";
result.data = "";
return JsonConvert.SerializeObject(result, Formatting.None, jsonSetting);
}