Ejemplo n.º 1
0
        public JsonResult GetWpfCtrlObj(string node)
        {
            var data = new AjaxDataModel <GviewCtrlModel> {
                success = false,
                message = "No data",
                total   = 0,
                data    = null
            };

            try {
                if (string.IsNullOrWhiteSpace(node))
                {
                    throw new ArgumentNullException("node");
                }

                var ids = Common.SplitKeys(node);
                if (ids.Length != 2)
                {
                    throw new ArgumentException("node");
                }

                var device = _workContext.Devices().Find(r => r.Current.Id.Equals(ids[0]));
                if (device == null)
                {
                    throw new iPemException("未找到设备信息");
                }

                var point = _workContext.Points().Find(p => p.Id.Equals(ids[1]));
                if (point == null)
                {
                    throw new iPemException("未找到信号信息");
                }

                if (point.Type != EnmPoint.AO && point.Type != EnmPoint.DO)
                {
                    throw new iPemException("信号类型错误");
                }

                data.success         = true;
                data.message         = "200 Ok";
                data.total           = 1;
                data.data            = new GviewCtrlModel();
                data.data.deviceId   = device.Current.Id;
                data.data.deviceName = device.Current.Name;
                data.data.pointId    = point.Id;
                data.data.pointName  = point.Name;
                data.data.pointType  = (int)point.Type;
            } catch (Exception exc) {
                data.success = false;
                data.message = exc.Message;
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }