intelligence.ashx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <%@ WebHandler Language="C#" Class="intelligence" %>
  2. using System.Web;
  3. using System.Web.SessionState;
  4. using System.Data;
  5. using System.Collections.Generic;
  6. using Curtain.DataAccess;
  7. using Newtonsoft.Json;
  8. public class intelligence : IHttpHandler, IReadOnlySessionState
  9. {
  10. public void ProcessRequest(HttpContext context)
  11. {
  12. context.Response.ContentType = "text/plain";
  13. //筛选记录
  14. if (context.Request["m"].ToString() == "getcontent")
  15. {
  16. //获取前端传递的表单
  17. var formData = context.Request.Form;
  18. //开始时间
  19. string opentime = formData["opentime"] != null ? formData["opentime"].ToString() : null;
  20. //结束时间
  21. string closetime = formData["closetime"] != null ? formData["closetime"].ToString() : null;
  22. //项目名称
  23. string name = formData["name"] != null ? formData["name"].ToString() : null;
  24. //参与人员
  25. string people = formData["people"] != null ? formData["people"].ToString() : null;
  26. //产品型号
  27. string modelid = formData["modelid"] != null ? formData["modelid"].ToString() : null;
  28. using (IDataAccess conn = DataAccess.Create())
  29. {
  30. string sqlStr = "SELECT Q.*,U.USERNAME FROM TP_PM_QUALITYLIBRARY Q LEFT JOIN TP_MST_USER U ON Q.CREATEUSERID=U.USERID WHERE Q.VALUEFLAG=1 ";
  31. //添加开始时间
  32. if (opentime != string.Empty)
  33. {
  34. sqlStr += " AND Q.CREATETIME >= TO_date('" + opentime.Trim() + " 00:00:00' ,'yy-mm-dd hh24:mi:ss')";
  35. }
  36. //添加结束时间
  37. if (closetime != string.Empty)
  38. {
  39. sqlStr += " AND Q.CREATETIME <= TO_date('" + closetime.Trim() + " 23:59:59' ,'yy-mm-dd hh24:mi:ss')";
  40. }
  41. //添加项目名陈
  42. if (name != string.Empty)
  43. {
  44. sqlStr += " AND Q.LIBRARYNAME LIKE '%" + name.Trim() + "%'";
  45. }
  46. //添加产品型号
  47. if (modelid != string.Empty)
  48. {
  49. sqlStr += " AND Q.GOODSID = " + modelid;
  50. }
  51. //添加参与人员
  52. if (people != string.Empty)
  53. {
  54. bool a = true;
  55. foreach (var item in people.Split('/'))
  56. {
  57. if (a)
  58. {
  59. sqlStr += " AND (Q.PARTICIPANTS LIKE '%" + item.Trim() + "%'";
  60. a = false;
  61. }
  62. else
  63. {
  64. sqlStr += " OR Q.PARTICIPANTS LIKE '%" + item.Trim() + "%'";
  65. }
  66. }
  67. sqlStr += ")";
  68. }
  69. DataTable dt = conn.ExecuteDatatable(sqlStr);
  70. List<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
  71. for (int i = 0; i < dt.Rows.Count; i++)
  72. {
  73. Dictionary<string, string> content = new Dictionary<string, string>();
  74. //id
  75. content.Add("id", dt.Rows[i]["LIBRARYID"].ToString());
  76. //项目名称
  77. content.Add("name", dt.Rows[i]["LIBRARYNAME"].ToString());
  78. //产品型号id
  79. content.Add("modelid", dt.Rows[i]["GOODSID"].ToString());
  80. //产品型号
  81. content.Add("modelname", dt.Rows[i]["GOODSCODE"].ToString());
  82. //参与人员
  83. content.Add("participants", dt.Rows[i]["PARTICIPANTS"].ToString());
  84. //问题
  85. content.Add("problem", dt.Rows[i]["QUESTION"].ToString());
  86. //解决方式
  87. content.Add("solution", dt.Rows[i]["SOLUTION"].ToString());
  88. //解决效果
  89. content.Add("solutioneffect", dt.Rows[i]["SOLUTIONEFFECT"].ToString());
  90. //附件
  91. content.Add("annex", dt.Rows[i]["ANNEX"].ToString());
  92. //创建时间
  93. content.Add("createtime", dt.Rows[i]["CREATETIME"].ToString());
  94. //创建人
  95. content.Add("username", dt.Rows[i]["USERNAME"].ToString());
  96. result.Add(content);
  97. }
  98. context.Response.Write(JsonConvert.SerializeObject(result, Formatting.Indented));
  99. }
  100. }
  101. }
  102. public bool IsReusable
  103. {
  104. get
  105. {
  106. return false;
  107. }
  108. }
  109. }