Пример #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
        private static void Main()
        {
            var service = new PointService(new PointIconFactory());

            foreach (var point in service.GetPoints())
            {
                point.Draw();
            }
        }
Пример #3
0
        public RootJsonReponse Get(int id)
        {
            var result = PointService.GetPoints(id);;

            var geoPoits    = result.AsEnumerable <GeoPointDTO>();
            var matchResult = RouteMatchingService.MatchRoute(result);

            return(matchResult);
        }
Пример #4
0
        public static void Structural_FlyWeight()
        {
            var service = new PointService(new PointIconFactory());

            foreach (var point in service.GetPoints())
            {
                point.Draw();
            }
        }
Пример #5
0
        public static void Run()
        {
            var service = new PointService(new PointIconFactory());

            Console.WriteLine("Points of Interest:");
            foreach (var point in service.GetPoints())
            {
                point.Draw();
            }
        }
Пример #6
0
        private static void ExecuteFlyWeight()
        {
            var factory      = new PointIconFactory();
            var pointService = new PointService(factory);

            foreach (var p in pointService.GetPoints())
            {
                p.Draw();
            }
        }
Пример #7
0
        private static void FlyWeightSection()
        {
            var pointService = new PointService(new PointFactory());

            foreach (var point in pointService.GetPoints())
            {
                point.Draw();
            }


            // Example 2
            // var sheet = new ExcelSheet(new FontFactory());
            // sheet.SetFontFamily(0, 0, "Hello");
            // sheet.SetIsBold(0,0,true);
            // sheet.SetIsBold(1,0, true);
            // sheet.SetIsBold(1,1, true);
            // sheet.SetFontFamily(1,1,"Hello");
            // sheet.Render();
        }
Пример #8
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
            }));
        }