public HttpResponseMessage getLostInfo() { DataTable dt = new BLL.Lost().GetLostInfo(); Object data; if (dt.Rows.Count > 0) { List <lost> list = new List <lost>(); for (int i = 0; i < dt.Rows.Count; i++) { lost lost = new lost(); lost.id = dt.Rows[i]["id"].ToString(); lost.companyId = dt.Rows[i]["companyId"].ToString(); lost.lost_content = dt.Rows[i]["lost_content"].ToString(); lost.create_time = dt.Rows[i]["create_time"].ToString(); list.Add(lost); } data = new { success = true, backData = list }; } else { data = new { success = false, backMsg = "数据异常" }; } JavaScriptSerializer serializer = new JavaScriptSerializer(); string json = serializer.Serialize(data); return(new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }); }
public HttpResponseMessage getCompanyLostInfo(string companyId) { DataTable dt = new BLL.Lost().GetCompanyLostInfo(companyId); Object data; if (dt.Rows.Count == 1) { lost lost = new lost(); lost.id = dt.Rows[0]["id"].ToString(); lost.companyId = dt.Rows[0]["companyId"].ToString(); lost.lost_content = dt.Rows[0]["lost_content"].ToString(); lost.create_time = dt.Rows[0]["create_time"].ToString(); data = new { success = true, backData = lost }; } else { data = new { success = false, backMsg = "数据异常" }; } JavaScriptSerializer serializer = new JavaScriptSerializer(); string json = serializer.Serialize(data); return(new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }); }
// Use this for initialization void Start() { name = GetComponent <lost>(); }