コード例 #1
0
        //[HttpPost]
        public JsonResult EventList(int id = 0, int jtStartIndex = 1, int jtPageSize = 100)
        {
            try
            {
                // var plcEventsViewPagedList = plcEvents.ToPagedList(jtStartIndex, jtPageSize);
                var plc             = _db.GetPLC(id);
                var plcEventListDTO = new PlcEventListDTO()
                {
                    Plc = plc,
                };

                /*
                 * plcEventListDTO.PlcEventDTOList = _db.GetPlcEventDTOList(
                 *      plcEventListDTO.Plc,
                 *      plcEventListDTO.DateBegin,
                 *      plcEventListDTO.DateEnd,
                 *      plcEventListDTO.NumberList,
                 *      plcEventListDTO.Message,
                 *      plcEventListDTO.HideBreak,
                 *      plcEventListDTO.SortOrderDesc
                 *      );
                 */
                return(Json(new { Result = "OK", Records = plcEventListDTO.PlcEventDTOList }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
コード例 #2
0
        //
        // GET: /Plc/Events/5
        public ActionResult Events(object id,
                                   string from    = null, string to      = null,
                                   string numbers = null, string message = null,
                                   bool hideBreak = false, bool desc     = false, bool groups = false)
        {
            PLC plc = null;

            try
            {
                int plcid = Convert.ToInt32(id);
                plc = _db.GetPLC(plcid);
            }
            catch (Exception)
            { }

            if (plc == null)
            {
                plc = _db.GetPLC(id.ToString());
            }

            if (plc == null)
            {
                return(RedirectToAction("Index"));
            }


            //ViewBag.PlcFullName = plc.FullName;

            var plcEventListDTO = new PlcEventListDTO
            {
                Plc       = plc,
                Numbers   = numbers,
                Message   = message,
                From      = DateTime.Now.Date,
                To        = DateTime.Now.Date,
                HideBreak = hideBreak,
                Desc      = desc,
                Group     = groups,
            };

            if (!string.IsNullOrWhiteSpace(from))
            {
                try
                {
                    plcEventListDTO.From = DateTime.Parse(from);
                }
                catch { }
            }
            if (!string.IsNullOrWhiteSpace(to))
            {
                try
                {
                    plcEventListDTO.To = DateTime.Parse(to);
                }
                catch {}
            }

            plcEventListDTO.PlcEventDTOList = _db.GetPlcEventDTOList(
                plcEventListDTO.Plc,
                plcEventListDTO.From,
                plcEventListDTO.To.AddDays(1),
                plcEventListDTO.NumberList,
                plcEventListDTO.Message,
                plcEventListDTO.HideBreak,
                plcEventListDTO.Desc
                );


            if (plcEventListDTO.PlcEventDTOList == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(plcEventListDTO));
        }