public bool GetResponse(Uri requestUri, Stream stream)
        {
            var query = new RequestQuery(requestUri);

            if (query.IsValid)
            {
                // Get Current Agent
                var agent = Database.ReadAgent(query.DeviceId);
                if (agent != null)
                {
                    // Get Components
                    var components = Database.ReadComponents(query.DeviceId, agent.InstanceId);

                    // Get Data Items
                    var dataItems = Database.ReadDataItems(query.DeviceId, agent.InstanceId);

                    var processor = new Processor(query, dataItems, components, agent.Version);
                    var oees      = processor.Run();
                    if (oees != null)
                    {
                        // Write JSON to stream
                        string json  = Json.Convert.ToJson(oees, true);
                        var    bytes = Encoding.UTF8.GetBytes(json);
                        stream.Write(bytes, 0, bytes.Length);
                    }
                }

                return(true);
            }

            return(false);
        }
Exemple #2
0
 public Processor(RequestQuery query, List <DataItemDefinition> dataItems, List <ComponentDefinition> components, string agentVersion)
 {
     RequestQuery = query;
     DataItems    = dataItems;
     Components   = components;
     AgentVersion = agentVersion;
 }