| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <%@ WebHandler Language="C#" Class="intelligence" %>
- using System.Web;
- using System.Web.SessionState;
- using System.Data;
- using System.Collections.Generic;
- using Curtain.DataAccess;
- using Newtonsoft.Json;
- public class intelligence : IHttpHandler, IReadOnlySessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- //筛选记录
- if (context.Request["m"].ToString() == "getcontent")
- {
- //获取前端传递的表单
- var formData = context.Request.Form;
- //开始时间
- string opentime = formData["opentime"] != null ? formData["opentime"].ToString() : null;
- //结束时间
- string closetime = formData["closetime"] != null ? formData["closetime"].ToString() : null;
- //项目名称
- string name = formData["name"] != null ? formData["name"].ToString() : null;
- //参与人员
- string people = formData["people"] != null ? formData["people"].ToString() : null;
- //产品型号
- string modelid = formData["modelid"] != null ? formData["modelid"].ToString() : null;
- using (IDataAccess conn = DataAccess.Create())
- {
- 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 ";
- //添加开始时间
- if (opentime != string.Empty)
- {
- sqlStr += " AND Q.CREATETIME >= TO_date('" + opentime.Trim() + " 00:00:00' ,'yy-mm-dd hh24:mi:ss')";
- }
- //添加结束时间
- if (closetime != string.Empty)
- {
- sqlStr += " AND Q.CREATETIME <= TO_date('" + closetime.Trim() + " 23:59:59' ,'yy-mm-dd hh24:mi:ss')";
- }
- //添加项目名陈
- if (name != string.Empty)
- {
- sqlStr += " AND Q.LIBRARYNAME LIKE '%" + name.Trim() + "%'";
- }
- //添加产品型号
- if (modelid != string.Empty)
- {
- sqlStr += " AND Q.GOODSID = " + modelid;
- }
- //添加参与人员
- if (people != string.Empty)
- {
- bool a = true;
- foreach (var item in people.Split('/'))
- {
- if (a)
- {
- sqlStr += " AND (Q.PARTICIPANTS LIKE '%" + item.Trim() + "%'";
- a = false;
- }
- else
- {
- sqlStr += " OR Q.PARTICIPANTS LIKE '%" + item.Trim() + "%'";
- }
- }
- sqlStr += ")";
- }
- DataTable dt = conn.ExecuteDatatable(sqlStr);
- List<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- Dictionary<string, string> content = new Dictionary<string, string>();
- //id
- content.Add("id", dt.Rows[i]["LIBRARYID"].ToString());
- //项目名称
- content.Add("name", dt.Rows[i]["LIBRARYNAME"].ToString());
- //产品型号id
- content.Add("modelid", dt.Rows[i]["GOODSID"].ToString());
- //产品型号
- content.Add("modelname", dt.Rows[i]["GOODSCODE"].ToString());
- //参与人员
- content.Add("participants", dt.Rows[i]["PARTICIPANTS"].ToString());
- //问题
- content.Add("problem", dt.Rows[i]["QUESTION"].ToString());
- //解决方式
- content.Add("solution", dt.Rows[i]["SOLUTION"].ToString());
- //解决效果
- content.Add("solutioneffect", dt.Rows[i]["SOLUTIONEFFECT"].ToString());
- //附件
- content.Add("annex", dt.Rows[i]["ANNEX"].ToString());
- //创建时间
- content.Add("createtime", dt.Rows[i]["CREATETIME"].ToString());
- //创建人
- content.Add("username", dt.Rows[i]["USERNAME"].ToString());
- result.Add(content);
- }
- context.Response.Write(JsonConvert.SerializeObject(result, Formatting.Indented));
- }
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|