示例#1
0
        private async Task LoadAsync(UserDefinedFunction udf)
        {
            SpaceList = await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger);

            if (udf != null)
            {
                UDF     = udf;
                Content = await DigitalTwinsHelper.GetUserDefinedFunctionContent(UDF.Id, _cache, Loggers.SilentLogger);

                //We get the matcher list to add the related conditions
                List <Matcher> matchersWithConditions = new List <Matcher>();
                var            matchers = await DigitalTwinsHelper.GetMatchersBySpaceId(UDF.SpaceId, _cache, Loggers.SilentLogger, false);

                foreach (Matcher matcher in UDF.Matchers)
                {
                    matchersWithConditions.Add(matchers.First(t => t.Id == matcher.Id));
                }

                UDF.Matchers = new ObservableCollection <Matcher>(matchersWithConditions);
            }
            else
            {
                UDF = new UserDefinedFunction();
            }
        }
示例#2
0
        private async Task LoadAsync(Guid?id = null)
        {
            SpaceList = new List <Space>();
            SpaceList.Add(new Space()
            {
                Id = Guid.Empty, Name = "None"
            });
            SpaceList.AddRange(await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger));

            //SpaceList = await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger);

            SpaceTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.SpaceType, _cache, Loggers.SilentLogger, onlyEnabled : true);

            SpaceSubTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.SpaceSubtype, _cache, Loggers.SilentLogger, onlyEnabled : true);

            SpaceStatusList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.SpaceStatus, _cache, Loggers.SilentLogger, onlyEnabled : true);

            if (id != null)
            {
                this.SelectedSpaceItem = await DigitalTwinsHelper.GetSpaceAsync((Guid)id, _cache, Loggers.SilentLogger, false);

                this.UDFList = await DigitalTwinsHelper.GetUDFsBySpaceIdAsync((Guid)id, _cache, Loggers.SilentLogger, false);

                this.Blobs = await DigitalTwinsHelper.GetBlobsAsync((Guid)id, _cache, Loggers.SilentLogger, true);

                this.AvailableProperties = await DigitalTwinsHelper.GetPropertyKeysForSpace((Guid)id, _cache, Loggers.SilentLogger);
            }
            else
            {
                this.SelectedSpaceItem   = new Space();
                this.UDFList             = new List <UserDefinedFunction>();
                this.Blobs               = new List <BlobContent>();
                this.AvailableProperties = new List <PropertyKey>();
            }
        }
示例#3
0
 internal async Task LoadAsync(Guid?id = null)
 {
     SpaceList = new List <Space>();
     SpaceList.Add(new Space()
     {
         Name = "None", Id = Guid.Empty
     });
     SpaceList.AddRange(await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger));
 }
        private async Task LoadAsync()
        {
            SpaceList = await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger);

            DataTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.SensorDataType, _cache, Loggers.SilentLogger, onlyEnabled : true);

            DataUnitTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.SensorDataUnitType, _cache, Loggers.SilentLogger, onlyEnabled : true);

            DataSubTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.SensorDataSubtype, _cache, Loggers.SilentLogger, onlyEnabled : true);
        }
示例#5
0
        private async Task LoadAsync(Guid?id = null)
        {
            SpaceList = await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger);

            DeviceTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.DeviceType, _cache, Loggers.SilentLogger, onlyEnabled : true);

            DeviceSubTypeList = await DigitalTwinsHelper.GetTypesAsync(Models.Types.DeviceSubtype, _cache, Loggers.SilentLogger, onlyEnabled : true);

            if (id != null)
            {
                this.SelectedDeviceItem = await DigitalTwinsHelper.GetDeviceAsync((Guid)id, _cache, Loggers.SilentLogger, false);
            }
        }
示例#6
0
        private async Task LoadAsync(string id)
        {
            SpaceList = await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger);

            PrimitiveDataTypeList = new List <string>();
            PrimitiveDataTypeList.Add("Bool");
            PrimitiveDataTypeList.Add("String");
            PrimitiveDataTypeList.Add("Long");
            PrimitiveDataTypeList.Add("Int");
            PrimitiveDataTypeList.Add("Uint");
            PrimitiveDataTypeList.Add("DateTime");
            PrimitiveDataTypeList.Add("Set");
            PrimitiveDataTypeList.Add("Enum");
            PrimitiveDataTypeList.Add("Json");

            if (id != null)
            {
                this.SelectedPropertyKey = await DigitalTwinsHelper.GetPropertyKeyAsync(id, _cache, Loggers.SilentLogger, false);
            }
        }
        public async Task <ActionResult> ViewGraph()
        {
            CacheHelper.SetPreviousPage(_cache, Request.Headers["Referer"].ToString());

            try
            {
                Graph graph = new Graph();

                var spaceList = await DigitalTwinsHelper.GetSpacesAsync(_cache, Loggers.SilentLogger);

                foreach (Space space in spaceList)
                {
                    graph.nodes.Add(new Node()
                    {
                        id    = space.Id,
                        label = new Label()
                        {
                            content = space.Label
                        },
                        fill     = "orange",
                        shape    = NodeShape.roundedrect.ToString(),
                        nodeType = "Space"
                    });

                    if (space.ParentSpaceId != Guid.Empty)
                    {
                        graph.edges.Add(new Edge()
                        {
                            id = Guid.NewGuid(), source = space.ParentSpaceId, target = space.Id
                        });
                    }
                }

                var deviceList = await DigitalTwinsHelper.GetDevicesAsync(_cache, Loggers.SilentLogger);

                foreach (Device device in deviceList)
                {
                    graph.nodes.Add(new Node()
                    {
                        id    = device.Id,
                        label = new Label()
                        {
                            content = device.Label, fill = "white"
                        },
                        fill     = "green",
                        shape    = NodeShape.maxroundedrect.ToString(),
                        nodeType = "Device"
                    });

                    if (device.SpaceId != Guid.Empty)
                    {
                        graph.edges.Add(new Edge()
                        {
                            id = Guid.NewGuid(), source = device.SpaceId, target = device.Id
                        });
                    }

                    if (device.Sensors != null)
                    {
                        foreach (Sensor sensor in device.Sensors)
                        {
                            graph.nodes.Add(new Node()
                            {
                                id    = sensor.Id,
                                label = new Label()
                                {
                                    content = sensor.Label, fill = "white"
                                },
                                fill     = "blue",
                                shape    = NodeShape.maxroundedrect.ToString(),
                                nodeType = "Sensor"
                            });

                            if (sensor.DeviceId != Guid.Empty)
                            {
                                graph.edges.Add(new Edge()
                                {
                                    id = Guid.NewGuid(), source = sensor.DeviceId, target = sensor.Id
                                });
                            }
                        }
                    }
                }

                var udfList = await DigitalTwinsHelper.GetUserDefinedFunctions(_cache, Loggers.SilentLogger);

                foreach (UserDefinedFunction udf in udfList)
                {
                    graph.nodes.Add(new Node()
                    {
                        id    = udf.Id,
                        label = new Label()
                        {
                            content = udf.Label, fill = "white"
                        },
                        fill     = "brown",
                        shape    = NodeShape.maxroundedrect.ToString(),
                        nodeType = "UDF"
                    });

                    if (udf.SpaceId != Guid.Empty)
                    {
                        graph.edges.Add(new Edge()
                        {
                            id = Guid.NewGuid(), source = udf.SpaceId, target = udf.Id
                        });
                    }
                }

                ViewData["sourceJSON"] = JsonConvert.SerializeObject(graph, Formatting.Indented);
            }
            catch (Exception ex)
            {
                FeedbackHelper.Channel.SendMessageAsync($"Error - {ex.Message}", MessageType.Info).Wait();
            }

            return(View());
        }