-  1         [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
-  2         [WebMethod(Description = " 获取筛选条件", EnableSession = true)]
-  3         public void GetTestList(string Type,string UserID)
-  4         {
-  5             Context.Response.ContentType = "text/plain";
-  6             Context.Response.Charset = "UTF-8";
-  7             Context.Response.ContentEncoding = System.Text.Encoding.UTF8;
-  8             Dictionary<string, object> dicReturn = new Dictionary<string, object>();
-  9             Dictionary<string, object> dic = new Dictionary<string, object>();
- 10             string jsonStr = string.Empty;//保存返回的json字符串
- 11             try
- 12             {
- 13                   //将返回的结果放到dic中
- 14                   //可以放到list里也可以放到DataTable中
- 15                   List<SortModel> list = xxx.GetXXXXXList(parames1, parames2);
- 16                  dic.Add("Count", xxx.GetXXXXXCount(parames1, parames2));
- 17                  dic.Add("List", list);
- 18                  //或者
- 19                  DataTable dt = xxx.GetXXXXX(parames1, parames2);
- 20                  dic.Add("Count", xxx.GetXXXXXCount(parames1, parames2);
- 21                  dic.Add("List2", dt);
- 22                  //获取成功
- 23                 dicReturn.Add("State", "1");
- 24                 dicReturn.Add("ErrorMsg", "获取成功");
- 25                 dicReturn.Add("Data", dic);
- 26                 dicReturn.Add("ErrCode", "0");
- 27           }
- 28           catch (Exception ex)
- 29           {
- 30                dicReturn.Add("State", "0");
- 31                dicReturn.Add("ErrorMsg", ex.Message);
- 32                dicReturn.Add("Data", "");
- 33                dicReturn.Add("ErrCode", "1");
- 34           }
- 35           //序列化 json字符串
- 36           jsonStr = JsonConvert.SerializeObject(dicReturn);
- 37           Context.Response.Write(jsonStr);
- 38           Context.Response.End();
- 39 
- 40 }