Пример #1
0
        public JsonResult RequestPoints(string node, int[] types)
        {
            var data = new AjaxDataModel <List <PointModel> > {
                success = true,
                message = "无数据",
                total   = 0,
                data    = new List <PointModel>()
            };

            try {
                if (types != null && types.Length > 0)
                {
                    var keys = Common.SplitKeys(node);
                    if (keys.Length == 2)
                    {
                        var type     = int.Parse(keys[0]);
                        var id       = int.Parse(keys[1]);
                        var gid      = Common.GroupId;
                        var nodeType = Enum.IsDefined(typeof(EnmScType), type) ? (EnmScType)type : EnmScType.None;
                        if (nodeType == EnmScType.Device)
                        {
                            var points = _pointService.GetPoints(id, types.Contains((int)EnmScType.Aic), types.Contains((int)EnmScType.Aoc), types.Contains((int)EnmScType.Dic), types.Contains((int)EnmScType.Doc));
                            var values = _valueService.GetValues(id, types.Contains((int)EnmScType.Aic), types.Contains((int)EnmScType.Aoc), types.Contains((int)EnmScType.Dic), types.Contains((int)EnmScType.Doc));
                            var pWv    = from point in points
                                         join value in values on new { Id = point.Id, Type = point.Type } equals new { Id = value.NodeId, Type = value.NodeType } into temp
                            from pv in temp.DefaultIfEmpty()
                            select new {
                                Point = point,
                                Value = pv
                            };

                            foreach (var pv in pWv)
                            {
                                data.data.Add(new PointModel {
                                    id            = pv.Point.Id,
                                    name          = pv.Point.Name,
                                    type          = (int)pv.Point.Type,
                                    typeDisplay   = Common.GetScTypeDisplay(pv.Point.Type),
                                    value         = pv.Value != null ? pv.Value.Value : 0f,
                                    valueDisplay  = pv.Value != null ? Common.GetValueDisplay(pv.Point, pv.Value.Value) : Common.GetValueDisplay(pv.Point, 0),
                                    status        = pv.Value != null ? (int)pv.Value.State : (int)EnmPointStatus.Invalid,
                                    statusDisplay = pv.Value != null ? Common.GetPointStatusDisplay(pv.Value.State) : Common.GetPointStatusDisplay(EnmPointStatus.Invalid),
                                    timestamp     = pv.Value != null ? CommonHelper.DateTimeConverter(pv.Value.UpdateTime) : CommonHelper.DateTimeConverter(DateTime.Now),
                                    shortTime     = pv.Value != null ? CommonHelper.ShortTimeConverter(pv.Value.UpdateTime) : CommonHelper.ShortTimeConverter(DateTime.Now)
                                });
                            }

                            data.total   = data.data.Count;
                            data.message = "200 Ok";
                        }
                    }
                }
            } catch (Exception exc) {
                data.success = false;
                data.message = exc.Message;
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public void GetValues_ListAllValues()
        {
            ValueService valueService = new ValueService();

            var result = valueService.GetValues();

            Assert.NotEmpty(result);
        }
Пример #3
0
        // GET: Default
        public async Task <IEnumerable <string> > Get()
        {
            // Should really do something with the AuthZ result. But this is just a sample
            // to show that the policy can be run.

            var succeeded = (await authorizationService.AuthorizeAsync(User, "ViewValues")).Succeeded;

            return(valueService.GetValues());
        }
Пример #4
0
        public IActionResult Index()
        {
            ValueService  valueService = new ValueService();
            List <string> stringvalues = valueService.GetValues();

            List <Value> values = new List <Value>();

            for (int i = 0; i < stringvalues.Count; i++)
            {
                Value  value    = new Value();
                string variable = stringvalues.ElementAt <string>(i);
                value.StringValue = variable;
                values.Add(value);
            }

            return(View(values));
        }
Пример #5
0
        public Data Get()
        {
            string filter = "";
            string sort   = "";

            if (Request.QueryString.Value.ToString().Length > 1)
            {
                var queryDictionary = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(Request.QueryString.Value);
                foreach (var kvp in queryDictionary)
                {
                    if (kvp.Key.ToString().Equals("filter"))
                    {
                        filter = kvp.Value.ToString().ToLower();
                    }
                    if (kvp.Key.ToString().Equals("sort"))
                    {
                        sort = kvp.Value.ToString().ToLower();
                    }
                }
            }
            ValueService valueService = new ValueService();

            return(valueService.GetValues(filter, sort));
        }
Пример #6
0
        public string GetPoints(string token, int node, int[] types = null)
        {
            var data = new AjaxDataModel <List <PointModel> > {
                success = true,
                message = "无数据",
                total   = 0,
                data    = new List <PointModel>()
            };

            try {
                if (string.IsNullOrWhiteSpace(token))
                {
                    throw new Exception("无效的令牌");
                }

                if (!_cacheManager.IsSet(token))
                {
                    throw new Exception("无效的令牌");
                }

                var user = _cacheManager.Get <User>(token);

                if (types == null || types.Length == 0)
                {
                    types = new int[] { (int)EnmScType.Aic, (int)EnmScType.Aoc, (int)EnmScType.Dic, (int)EnmScType.Doc }
                }
                ;

                var gid    = user.GroupId;
                var points = _pointService.GetPoints(node, types.Contains((int)EnmScType.Aic), types.Contains((int)EnmScType.Aoc), types.Contains((int)EnmScType.Dic), types.Contains((int)EnmScType.Doc));
                var values = _valueService.GetValues(node, types.Contains((int)EnmScType.Aic), types.Contains((int)EnmScType.Aoc), types.Contains((int)EnmScType.Dic), types.Contains((int)EnmScType.Doc));
                var pWv    = from point in points
                             join value in values on new { Id = point.Id, Type = point.Type } equals new { Id = value.NodeId, Type = value.NodeType } into temp
                from pv in temp.DefaultIfEmpty()
                select new {
                    Point = point,
                    Value = pv
                };

                foreach (var pv in pWv)
                {
                    data.data.Add(new PointModel {
                        id            = pv.Point.Id,
                        name          = pv.Point.Name,
                        type          = (int)pv.Point.Type,
                        typeDisplay   = Common.GetScTypeDisplay(pv.Point.Type),
                        value         = pv.Value != null ? pv.Value.Value : 0d,
                        valueDisplay  = pv.Value != null ? Common.GetValueDisplay(pv.Point, pv.Value.Value) : Common.GetValueDisplay(pv.Point, 0),
                        status        = pv.Value != null ? (int)pv.Value.State : (int)EnmPointStatus.Invalid,
                        statusDisplay = pv.Value != null ? Common.GetPointStatusDisplay(pv.Value.State) : Common.GetPointStatusDisplay(EnmPointStatus.Invalid),
                        timestamp     = pv.Value != null ? CommonHelper.DateTimeConverter(pv.Value.UpdateTime) : CommonHelper.DateTimeConverter(DateTime.Now),
                        shortTime     = pv.Value != null ? CommonHelper.ShortTimeConverter(pv.Value.UpdateTime) : CommonHelper.ShortTimeConverter(DateTime.Now)
                    });
                }

                data.total   = data.data.Count;
                data.message = "200 Ok";
            } catch (Exception exc) {
                data.success = false;
                data.message = exc.Message;
            }

            return(JsonConvert.SerializeObject(data, new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Include
            }));
        }
Пример #7
0
 public ActionResult <IEnumerable <string> > Get()
 {
     return(valueService.GetValues().ToList());
 }