using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using SQLHelper; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using System.Windows.Forms; using WebAPI; using WebAPI.Models; namespace WebAPI.Controllers { public class ASSController : ApiController { public DataSet ds = new DataSet(); private json objJsonResult = new json(); SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); #region 售后接口一调用 /// /// 售后接口一调用 /// /// [Route("ASSController/GetASS_SellOutInterFace_Json")] [HttpGet] public object GetASS_SellOutInterFace_Json(string HBarCode) { try { ds = oCn.RunProcReturn("exec h_p_ASS_SellOut_InterFace '" + HBarCode + "'", "h_p_ASS_SellOut_InterFace"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何结果!"; objJsonResult.data = null; return objJsonResult; } else { List columnNameList = new List(); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); //获取到DataColumn列对象的列名 } objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "成功!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询售后接口一信息失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 售后接口二调用 /// /// 售后接口二调用 /// /// [Route("ASSController/GetASS_ProductInInterFace_Json")] [HttpGet] public object GetASS_ProductInInterFace_Json(string HBarCode) { try { ds = oCn.RunProcReturn("exec h_p_ASS_ProductIn_InterFace '" + HBarCode + "'", "h_p_ASS_ProductIn_InterFace"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何结果!"; objJsonResult.data = null; return objJsonResult; } else { List columnNameList = new List(); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); //获取到DataColumn列对象的列名 } objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "成功!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询售后接口二信息失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }