예제 #1
0
        public void GetPlanList(DateTime sTime, DateTime eTime, string routeID, string areaID, string deviceID)
        {
            string idkey = Request.Cookies["ID_KEY"].Value.ToString();
            string userID = bl.GetUserNameById(idkey, out errMsg);
            PlanBLL plan = new PlanBLL();
            int page = Convert.ToInt32(Request["page"].ToString());
            int rows = Convert.ToInt32(Request["rows"].ToString());
            DataTable dt = plan.GetPlan(userID, routeID, areaID, deviceID, sTime, eTime, (page - 1) * rows + 1, page * rows);
            count = plan.GetPlanCount(userID, routeID, areaID, deviceID, sTime, eTime);
            IList<Hashtable> list = new List<Hashtable>();

            foreach (DataRow item in dt.Rows)
            {
                Hashtable ht = new Hashtable();
                string startTime = item["sTime"].ToString();
                string endTime = item["eTIme"].ToString();
                string cTime = item["cTime"].ToString();
                string uTime = item["uTime"].ToString();
                ht.Add("ID", item["ID"]);
                ht.Add("routeName", item["routeName"].ToString());
                ht.Add("areaName", item["areaName"].ToString());
                ht.Add("deviceName", item["deviceName"].ToString());
                ht.Add("T_ITEMPOSITION", item["T_ITEMPOSITION"].ToString());
                ht.Add("T_ITEMDESC", item["T_ITEMDESC"].ToString());
                ht.Add("type", item["type"].ToString());
                ht.Add("sTime", startTime);
                ht.Add("eTime", endTime);
                ht.Add("cTime", cTime);
                ht.Add("uTime", uTime);
                ht.Add("value", item["value"].ToString());
                ht.Add("state", item["state"].ToString());
                ht.Add("status", item["status"].ToString());
                list.Add(ht);
            }
            object obj = new
            {
                total = count,
                rows = list
            };

            string result = JsonConvert.SerializeObject(obj);
            Response.Write(result);
            Response.End();
        }
예제 #2
0
        public void GetString()
        {
            string idkey = Request.Cookies["ID_KEY"].Value.ToString();
            string userID = bl.GetUserNameById(idkey, out errMsg);
            PlanBLL plan = new PlanBLL();
            int page = Convert.ToInt32(Request["page"].ToString());
            int rows = Convert.ToInt32(Request["rows"].ToString());
            DataTable dt = plan.GetPlan(userID, Convert.ToDateTime(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")), Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")), (page - 1) * rows + 1, page * rows);

            count = plan.GetPlanCount(userID, "0", "0", "0", Convert.ToDateTime(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")), Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
            IList<Hashtable> list = new List<Hashtable>();

            foreach (DataRow item in dt.Rows)
            {
                Hashtable ht = new Hashtable();
                string startTime = item["sTime"].ToString();
                string endTime = item["eTIme"].ToString();
                string cTime = item["cTime"].ToString();
                string uTime = item["uTime"].ToString();
                ht.Add("ID", item["ID"]);
                ht.Add("routeName", item["routeName"].ToString());
                ht.Add("areaName", item["areaName"].ToString());
                ht.Add("deviceName", item["deviceName"].ToString());
                ht.Add("T_ITEMPOSITION", item["T_ITEMPOSITION"].ToString());
                ht.Add("T_ITEMDESC", item["T_ITEMDESC"].ToString());
                ht.Add("type", item["type"].ToString());
                ht.Add("sTime", startTime);
                ht.Add("eTime", endTime);
                ht.Add("cTime", cTime);
                ht.Add("uTime", uTime);
                ht.Add("value", item["value"].ToString());

                ht.Add("RouteID", item["ROUTEID"].ToString());
                ht.Add("AreaID", item["AREAID"].ToString());
                ht.Add("DeviceID", item["DEVICEID"].ToString());
                ht.Add("ItemID", item["ITEMID"].ToString());

                if (item["status"].ToString() == "新任务")
                {
                    if (DateTime.Now > Convert.ToDateTime(endTime))
                        ht.Add("status", "缺陷");
                }
                else
                    ht.Add("status", item["status"].ToString());

                ht.Add("state", item["state"].ToString());

                list.Add(ht);
            }
            object obj = new
            {
                total = count,
                rows = list
            };

            string result = JsonConvert.SerializeObject(obj);
            Response.Write(result);
            Response.End();
        }