Add example template of using SupportObserver dataprovider

This commit is contained in:
Hawk Foreste 2018-03-22 10:09:23 -07:00
Родитель a6cea58585
Коммит 96af6c663a
1 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
[Definition(Id = "GetRuntimeSiteSlotMapData", Name = "GetRuntimeSiteSlotMapData", Description = "GetRuntimeSiteSlotMapData")]
public async static Task<Response> Run(DataProviders dp, OperationContext cxt, Response res)
{
var runtimeSiteSlotMap = await dp.Observer.GetRuntimeSiteSlotMap(cxt.Resource.Stamp, cxt.Resource.SiteName);
var diagnosticData = new DiagnosticData();
diagnosticData.Table.TableName = "n/a";
var list = new List<DataTableResponseColumn>();
list.Add(new DataTableResponseColumn() { ColumnName = "SlotName", DataType = "string", ColumnType = "string" });
list.Add(new DataTableResponseColumn() { ColumnName = "RuntimeSiteName", DataType = "string", ColumnType = "string" });
list.Add(new DataTableResponseColumn() { ColumnName = "StartTime", DataType = "datetime", ColumnType = "datetime" });
list.Add(new DataTableResponseColumn() { ColumnName = "EndTime", DataType = "datetime", ColumnType = "datetime" });
diagnosticData.Table.Columns = list;
diagnosticData.Table.Rows = new string[10][];
for (int i = 0; i < runtimeSiteSlotMap.Keys.Count; i++)
{
var slotName = runtimeSiteSlotMap.Keys.ElementAt(i);
foreach (var slotInfo in runtimeSiteSlotMap[slotName])
{
diagnosticData.Table.Rows[i] = new string[4] { slotName, slotInfo.RuntimeSitename, slotInfo.StartTime.ToString(), slotInfo.EndTime.ToString() };
}
}
res.Dataset.Add(diagnosticData);
return res;