public JArray PrepareBatchQueryRequest()

in wvd-templates/diagnostics-sample/src/MSFT.WVD.Diagnostics.Common/Services/LogAnalyticsService.cs [30:78]


        public JArray PrepareBatchQueryRequest(string hostName, out List<Counter> counters, XmlDocument xDoc)
        {
            counters = new List<Counter>();
            string WorkspaceID = Configuration.GetSection("AzureAd").GetSection("LogAnalyticsWorkspaceId").Value;
            JArray jArrayQry = new JArray();
            foreach (XmlNode node in xDoc.DocumentElement.ChildNodes)
            {
                int id = 0;
                foreach (XmlNode childNode in node)
                {
                    id++;
                    string query = "", timespan = "";
                    foreach (XmlNode childnode in childNode)
                    {
                        if (childnode.Name == "Query")
                        {
                            query = childnode.InnerText.Replace(System.Environment.NewLine, "").Trim();
                        }

                        if (!string.IsNullOrEmpty(query) && childnode.Name == "timespan")
                        {
                            timespan = childnode.InnerText.Replace(System.Environment.NewLine, "").Trim();
                        }
                    }

                    if (!string.IsNullOrEmpty(query) && !string.IsNullOrEmpty(timespan))
                    {
                        jArrayQry.Add(new JObject() {
                        new JProperty("id",id),
                        new JProperty("body",new JObject(){
                        new JProperty("query",String.Format(query,"'"+hostName+"'").Trim()),
                        new JProperty("timespan",timespan)
                    }),
                    new JProperty("method","POST"),
                    new JProperty("path","/query"),
                    new JProperty("workspace",WorkspaceID),
                    });
                    }
                    counters.Add(new Counter()
                    {
                        id = id,
                        ObjectName = childNode.Name.Replace('_', ' ')

                    });
                }
            }

            return jArrayQry;
        }