public JsonResult DeleteDataDome()
        {
            try
            {
                var            url            = "http://192.168.3.122:8086/";
                var            username       = "******";
                var            password       = "******";
                InfluxDBHelper influxDBHelper = new InfluxDBHelper(url, username, password, "testInfluxdb");
                string         sql            = "delete from cpu_load_short where time=1537261373570440200; ";

                var str = influxDBHelper.Query(sql);
                return(Json(new
                {
                    success = true,
                    message = "删除数据成功",
                    data = str
                }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = "删除数据失败" + ex.Message,
                }));
            }
        }
        private async Task <ImportDeviceData> ImportDataForDevice(int refID, DeviceData deviceData)
        {
            ImportDeviceData importDeviceData = deviceData.Data;

            //start as task to fetch data
            double?deviceValue = null;

            try
            {
                var queryData = await InfluxDBHelper.GetSingleValueForQuery(importDeviceData.Sql, dbLoginInformation).ConfigureAwait(false);

                deviceValue = Convert.ToDouble(queryData, CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                Trace.TraceWarning(Invariant($"Failed to get value from Db for {importDeviceData.Name} with {ex.GetFullMessage()}"));
            }

            try
            {
                Trace.WriteLine(Invariant($"Updating {importDeviceData.Name} with {deviceValue}"));
                deviceData.Update(HS, refID, deviceValue);
            }
            catch (Exception ex)
            {
                Trace.TraceWarning(Invariant($"Failed to write value to HS for {importDeviceData.Name} with {ex.GetFullMessage()}"));
            }

            return(importDeviceData);
        }
        public JsonResult GetDataDome()
        {
            try
            {
                var            url            = "http://192.168.3.122:8086/";
                var            username       = "******";
                var            password       = "******";
                InfluxDBHelper influxDBHelper = new InfluxDBHelper(url, username, password, "testInfluxdb");
                string         sql            = "select * from cpu_load_short";
                //string sql = "select * from test;select * from test";        多条


                var str = influxDBHelper.Query(sql);
                return(Json(new
                {
                    success = true,
                    message = "读取数据成功",
                    data = str
                }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = "读取数据失败" + ex.Message,
                }));
            }
        }
示例#4
0
        //写日志,失败时不写到文件中,参数为单数
        internal bool WriteLogAgain(object oneLog)
        {
            var model1 = oneLog as Log_OperateTrace;

            if (model1 != null)
            {
                var bOK = WriteLog(model1);

                if (bOK.ErrCode == 0)
                {
                    bool bok = new InfluxDBHelper("LogTraceW").WriteData(model1);
                }
                return(bOK.ErrCode == 0);
            }
            else
            {
                var model2 = oneLog as Log_SystemMonitorMQ;
                if (model2 != null)
                {
                    var bOK = WriteLog(model2);
                    if (bOK.ErrCode == 0)
                    {
                        bool bok = new InfluxDBHelper("LogMonitorW").WriteData(model2);
                    }
                    return(bOK.ErrCode == 0);
                }
            }
            return(false);
        }
示例#5
0
        public void RecordPoolState(string chainId, DateTime time, bool isAlive, bool isForked)
        {
            var fields = new Dictionary <string, object> {
                { "alive", isAlive }, { "forked", isForked }
            };

            InfluxDBHelper.Set(chainId, "node_state", fields, null, time);
        }
示例#6
0
        public void RecordPoolSize(string chainId, DateTime time, ulong poolSize)
        {
            var fields = new Dictionary <string, object> {
                { "size", poolSize }
            };

            InfluxDBHelper.Set(chainId, "transaction_pool_size", fields, null, time);
        }
示例#7
0
        public void RecordPoolState(string chainId, DateTime time, int requestPoolSize, int receivePoolSize)
        {
            var fields = new Dictionary <string, object> {
                { "request", requestPoolSize }, { "receive", receivePoolSize }
            };

            InfluxDBHelper.Set(chainId, "network_pool_state", fields, null, time);
        }
示例#8
0
        public async Task RecordPoolSize(string chainId, DateTime time)
        {
            var poolSize = await GetPoolSize(chainId);

            var fields = new Dictionary <string, object> {
                { "size", poolSize }
            };

            InfluxDBHelper.Set(chainId, "transaction_pool_size", fields, null, time);
        }
示例#9
0
        public async Task RecordInvalidBlockCount(string chainId, DateTime time)
        {
            var count = await GetInvalidBlockCount(chainId);

            var fields = new Dictionary <string, object> {
                { "count", count }
            };

            InfluxDBHelper.Set(chainId, "block_invalid", fields, null, time);
        }
示例#10
0
        public async Task RecordRollBackTimes(string chainId, DateTime time)
        {
            var times = await GetRollBackTimes(chainId);

            var fields = new Dictionary <string, object> {
                { "times", times }
            };

            InfluxDBHelper.Set(chainId, "chain_rollback", fields, null, time);
        }
示例#11
0
        //写日志,失败时写到文件中
        internal bool WriteLogAndHandFail(object model)
        {
            //return true;
            bool bList = model.GetType().IsGenericType || model.GetType().IsArray;
            IEnumerable <Log_OperateTrace> obj = bList ? model as IEnumerable <Log_OperateTrace> : new List <Log_OperateTrace>()
            {
                model as Log_OperateTrace
            };

            if (obj != null && obj.Count() > 0)//是操作轨迹类数据
            {
                foreach (var item in obj)
                {
                    var res = WriteLog(item);
                    if (res.ErrCode != 0)
                    {
                        WriteExceptToFile(res.ExBody, (res.ErrMsg + "," + res.Module).Trim(','));
                        //  System.Threading.Thread.Sleep(10);
                        WriteBackupLogToFile(item, Models.MQType.TraceLog);
                    }
                    else
                    {
                        bool bok = new InfluxDBHelper("LogTraceW").WriteData(item);
                    }
                }
            }
            else
            {
                IEnumerable <Log_SystemMonitorMQ> obj2 = bList ? model as IEnumerable <Log_SystemMonitorMQ> : new List <Log_SystemMonitorMQ>()
                {
                    model as Log_SystemMonitorMQ
                };
                if (obj2 != null && obj2.Count() > 0)//是监控类数据
                {
                    foreach (var item in obj2)
                    {
                        if (item.OnlineCnt <= 0 || item.AllVisitors <= 0)
                        {
                            continue;
                        }
                        var res = WriteLog(item);
                        if (res.ErrCode != 0)
                        {
                            WriteExceptToFile(res.ExBody, (res.ErrMsg + "," + res.Module).Trim(','));
                            WriteBackupLogToFile(item, Models.MQType.MonitorLog);
                        }
                        else
                        {
                            bool bok = new InfluxDBHelper("LogMonitorW").WriteData(item);
                        }
                    }
                }
            }
            return(true);
        }
示例#12
0
        public async Task RecordPoolState(string chainId, DateTime time)
        {
            var isAlive = await IsAlive(chainId);

            var isForked = await IsForked(chainId);

            var fields = new Dictionary <string, object> {
                { "alive", isAlive }, { "forked", isForked }
            };

            InfluxDBHelper.Set(chainId, "node_state", fields, null, time);
        }
示例#13
0
        public static async Task <string> GetDeviceHistogramTabQuery(DevicePersistenceData data,
                                                                     QueryDuration queryDuration,
                                                                     InfluxDBLoginInformation loginInformation)
        {
            string duration = GetInfluxDBDuration(queryDuration);

            // Find last element before duration
            string query = Invariant($"SELECT last(*) from \"{data.Measurement}\" WHERE \"{PluginConfig.DeviceRefIdTag}\" = '{data.DeviceRefId}' and time < now() - {duration} order by time asc");

            var time = await InfluxDBHelper.GetTimeValueForQuery(query, loginInformation).ConfigureAwait(false);

            string timeRestriction = time.HasValue ? Invariant($"time >= {new DateTimeOffset(time.Value).ToUnixTimeSeconds()}s") : Invariant($"time >= now() - {duration}");

            return(Invariant($"SELECT {GetFields(data)[0]} FROM \"{data.Measurement}\" WHERE \"{PluginConfig.DeviceRefIdTag}\" = '{data.DeviceRefId}' AND {timeRestriction} ORDER BY time ASC"));
        }
示例#14
0
        public List <PoolSizeHistory> GetPoolSizeHistory(string chainId)
        {
            var result = new List <PoolSizeHistory>();
            var record = InfluxDBHelper.Get(chainId, "select * from transaction_pool_size");

            foreach (var item in record.First().Values)
            {
                result.Add(new PoolSizeHistory
                {
                    Time = Convert.ToDateTime(item[0]),
                    Size = Convert.ToUInt64(item[1])
                });
            }

            return(result);
        }
示例#15
0
        private string BuildStatsPage(NameValueCollection parts)
        {
            StringBuilder stb = new StringBuilder();

            IncludeResourceScript(stb, "iframeResizer.contentWindow.min.js");

            var culture = CultureInfo.CurrentUICulture;

            var query = parts[QueryPartId] ?? string.Empty;

            try
            {
                var queryData = GetData(HttpUtility.UrlDecode(query));
                if (queryData.Count > 0)
                {
                    //Display the first row/column only
                    stb.Append("<table id=\"results\" class=\"cell-border compact\" style=\"width:100%\">");

                    var firstRow = queryData[0];

                    foreach (var pair in firstRow)
                    {
                        if (string.CompareOrdinal(pair.Key, InfluxDBHelper.TimeColumn) != 0)
                        {
                            stb.Append(@"<tr class='tablecell'>");
                            stb.Append(@"<td>");
                            stb.Append(HtmlEncode(FirstCharToUpper(pair.Key, culture)));
                            stb.Append(@"</td>");

                            stb.Append(@"<td>");
                            stb.Append(HtmlEncode(InfluxDBHelper.GetSerieValue(culture, pair.Value)));
                            stb.Append(@"</td>");

                            stb.Append(@"</tr>");
                        }
                    }
                    stb.AppendLine(@"</table>");
                }

                return(stb.ToString());
            }
            catch (Exception ex)
            {
                return(Invariant($"<br><div style='color:Red'>{ex.GetFullMessage()}</div><br>"));
            }
        }
示例#16
0
        public List <PoolStateHistory> GetPoolStateHistory(string chainId)
        {
            var result = new List <PoolStateHistory>();
            var record = InfluxDBHelper.Get(chainId, "select * from network_pool_state");

            foreach (var item in record.First().Values)
            {
                result.Add(new PoolStateHistory
                {
                    Time            = Convert.ToDateTime(item[0]),
                    ReceivePoolSize = Convert.ToInt32(item[1]),
                    RequestPoolSize = Convert.ToInt32(item[2])
                });
            }

            return(result);
        }
示例#17
0
        public async Task <List <NodeStateHistory> > GetHistoryState(string chainId)
        {
            var result = new List <NodeStateHistory>();
            var record = InfluxDBHelper.Get(chainId, "select * from node_state");

            foreach (var item in record.First().Values)
            {
                result.Add(new NodeStateHistory
                {
                    Time     = Convert.ToDateTime(item[0]),
                    IsAlive  = Convert.ToBoolean(item[1]),
                    IsForked = Convert.ToBoolean(item[2])
                });
            }

            return(result);
        }
示例#18
0
        private static async Task <string> CreateRegularTimeSeries(DevicePersistenceData data,
                                                                   QueryDuration queryDuration,
                                                                   InfluxDBLoginInformation loginInformation,
                                                                   TimeSpan groupByInterval,
                                                                   bool fileLinear = false)
        {
            string duration = GetInfluxDBDuration(queryDuration);

            // Find last element before duration
            string query = Invariant($"SELECT last(*) from \"{data.Measurement}\" WHERE \"{PluginConfig.DeviceRefIdTag}\" = '{data.DeviceRefId}' and time < now() - {duration} order by time asc");

            var time = await InfluxDBHelper.GetTimeValueForQuery(query, loginInformation).ConfigureAwait(false);

            string timeRestriction = time.HasValue ? Invariant($"time >= {new DateTimeOffset(time.Value).ToUnixTimeSeconds()}s") : Invariant($"time >= now() - {duration}");
            string fillOption      = fileLinear ? "linear" : "previous";

            return(Invariant($"SELECT MEAN(\"{data.Field}\") as \"{data.Field}\" from \"{data.Measurement}\" WHERE \"{PluginConfig.DeviceRefIdTag}\" = '{data.DeviceRefId}' and {timeRestriction} GROUP BY time({(int)groupByInterval.TotalSeconds}s) fill({fillOption})"));
        }
        /// <summary>
        ///插入数据 1条或多条
        /// </summary>
        /// <param name="dbName"></param>
        /// <returns></returns>
        public JsonResult InsertDataDome(string dbName)
        {
            try
            {
                var url      = "http://192.168.3.122:8086/";
                var username = "******";
                var password = "******";
                dbName = "testInfluxdb";
                InfluxDBHelper influxDBHelper = new InfluxDBHelper(url, username, password, dbName);
                string         sql            = "cpu_load_short,host=server02 value=0.67 "; //插入一条

                #region 插入多条
                //  List<string> list = new List<string>();
                //  list.Add("test code=code002,mac=aaa");    //requestsQueued为指标的名称
                //  list.Add("test code=code003,mac=aaa");
                //  list.Add("test code=code004,mac=aaa");
                //var   sqlpaem = string.Join("\n", list);
                //  sql = sql + "\n" + sqlpaem;

                #endregion

                var str = influxDBHelper.Write(sql);

                // 'http://localhost:8086/write?db=mydb'--data - binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
                var mmm = "cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000";

                var mkkk = InfluxDBHelper.HttpHelperPost("http://localhost:8086/write?db=testInfluxdb", mmm);

                return(Json(new
                {
                    success = true,
                    message = "插入数据成功",
                    data = str
                }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = "插入数据失败" + ex.Message,
                }));
            }
        }
示例#20
0
        //[Fact]
        public void TestSetAndGet()
        {
            var database = "unittest";

            InfluxDBHelper.CreateDatabase(database);

            var used = 50;
            var time = DateTime.Now;

            InfluxDBHelper.Set(database, "cpu", new Dictionary <string, object> {
                { "used", used }
            }, null, time);
            Thread.Sleep(1000);
            var result = InfluxDBHelper.Get(database, "select * from cpu");

            Assert.True(Convert.ToInt32(result[0].Values[0][1]) == used);

            InfluxDBHelper.DropDatabase(database);
        }
示例#21
0
        public async Task RecordBlockInfo(string chainId)
        {
            ulong currentHeight;
            var   currentRecord = InfluxDBHelper.Get(chainId, "select last(height) from block_info");

            if (currentRecord.Count == 0)
            {
                currentHeight = await GetCurrentChainHeight(chainId);
            }
            else
            {
                var record = currentRecord.First().Values.First();
                var time   = Convert.ToDateTime(record[0]);

                if (time < DateTime.Now.AddHours(-1))
                {
                    currentHeight = await GetCurrentChainHeight(chainId);
                }
                else
                {
                    currentHeight = Convert.ToUInt64(record[1]) + 1;
                }
            }

            var blockInfo = await GetBlockInfo(chainId, currentHeight);

            while (blockInfo.Result != null && blockInfo.Result.Body != null && blockInfo.Result.Header != null)
            {
                var fields = new Dictionary <string, object> {
                    { "height", currentHeight }, { "tx_count", blockInfo.Result.Body.TransactionsCount }
                };
                InfluxDBHelper.Set(chainId, "block_info", fields, null, blockInfo.Result.Header.Time);

                Thread.Sleep(1000);

                currentHeight++;
                blockInfo = await GetBlockInfo(chainId, currentHeight);
            }
        }
 public JsonResult DropDatabase(string url, string dbName)
 {
     try
     {
         url    = "http://192.168.3.122:8086/query";
         dbName = "testInfluxdb";
         string pathAndQuery = string.Format("q=DROP DATABASE {0}", dbName);
         var    result       = InfluxDBHelper.HttpHelperPost(url, pathAndQuery);
         return(Json(new
         {
             success = true,
             message = "删除数据库成功",
             data = result
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             success = false,
             message = "删除数据库失败" + ex.Message,
         }));
     }
 }
示例#23
0
 public void Action(DeployArg arg)
 {
     InfluxDBHelper.CreateDatabase(arg.SideChainId);
 }
示例#24
0
        //[Fact]
        public void TestVerison()
        {
            var version = InfluxDBHelper.Version();

            Assert.NotNull(version);
        }
示例#25
0
        private string BuildChartsPage(NameValueCollection parts)
        {
            CultureInfo   cultureInfo = CultureInfo.CurrentUICulture;
            StringBuilder stb         = new StringBuilder();
            var           query       = parts[QueryPartId] ?? string.Empty;
            var           title       = parts[TitlePartId] ?? string.Empty;

            try
            {
                var queryData = GetData(HttpUtility.UrlDecode(query));

                IncludeResourceCSS(stb, "metricsgraphics.css");
                IncludeResourceScript(stb, "d3.min.js");
                IncludeResourceScript(stb, "metricsgraphics.min.js");
                stb.AppendLine("<table align=\"center\" ");
                stb.AppendLine("<tr><td id='chartGraph2' align=\"center\"></td>");
                stb.AppendLine("<tr><td id='legend' align=\"center\"></td>");
                stb.AppendLine("</table>");

                stb.AppendLine("<script>");
                stb.AppendLine(@"function chartData() {");

                var legands = new List <string>();
                if (queryData.Count > 0)
                {
                    var nonTimeColumns = queryData.First().Keys.Where(x => (0 != string.CompareOrdinal(x, InfluxDBHelper.TimeColumn)));

                    foreach (var nonTimeColumn in nonTimeColumns)
                    {
                        legands.Add(Invariant($"'{FirstCharToUpper(nonTimeColumn, cultureInfo)}'"));
                    }

                    var dataStrings = new Dictionary <string, StringBuilder>();
                    foreach (var row in queryData)
                    {
                        long jsMilliseconds = 0;
                        foreach (var pair in row)
                        {
                            if (string.CompareOrdinal(pair.Key, InfluxDBHelper.TimeColumn) == 0)
                            {
                                var timePoint = (DateTime)pair.Value;
                                jsMilliseconds = (new DateTimeOffset(timePoint)).ToLocalTime().ToUnixTimeMilliseconds();
                            }
                            else
                            {
                                if (pair.Value != null)
                                {
                                    if (!dataStrings.TryGetValue(pair.Key, out StringBuilder stringBuilder))
                                    {
                                        stringBuilder = new StringBuilder();
                                        dataStrings.Add(pair.Key, stringBuilder);
                                    }
                                    stringBuilder.AppendLine(Invariant($"{{ date: new Date({jsMilliseconds}),value: {InfluxDBHelper.GetSerieValue(CultureInfo.InvariantCulture, pair.Value)}}},"));
                                }
                            }
                        }
                    }

                    stb.AppendLine("return [");
                    foreach (var nonTimeColumn in nonTimeColumns)
                    {
                        stb.AppendLine("[");
                        stb.Append(dataStrings[nonTimeColumn].ToString());
                        stb.AppendLine("],");
                    }
                    stb.AppendLine("]");
                }

                stb.AppendLine(@"}
                var chartDataFromDB = chartData();");

                stb.AppendLine(@"MG.data_graphic({
                            data: chartDataFromDB,
                            target: document.getElementById('chartGraph2'),
                            width: 900,
                            x_extended_ticks: true,
                            height: 450,
                            area: true,
                            interpolate: d3.curveStep,
                            min_y_from_data: true,
                            right: 40,
                            // y_rollover_format: function(d) { return ' ' + String(d.value); },
                            x_rollover_format: function(d) { return d.date.toLocaleString() + ' '; },");
                stb.AppendLine(Invariant($"     title:'{title}',"));
                stb.AppendLine(Invariant($"     legend:[{string.Join(",", legands)}],"));
                stb.AppendLine("legend_target: document.getElementById('legend'),");
                stb.AppendLine("});");
                stb.AppendLine("</script>");
                IncludeResourceScript(stb, "iframeResizer.contentWindow.min.js");

                return(stb.ToString());
            }
            catch (Exception ex)
            {
                return(Invariant($"<br><div style='color:Red'>{ex.GetFullMessage()}</div><br>"));
            }
        }
示例#26
0
        private string BuildHistogramPage(NameValueCollection parts)
        {
            StringBuilder stb      = new StringBuilder();
            var           query    = parts[QueryPartId] ?? string.Empty;
            var           duration = parts[QueryDurationId] ?? string.Empty;

            QueryDuration queryDuration = QueryDuration.D1h;

            _ = Enum.TryParse <QueryDuration>(duration, out queryDuration);

            IncludeDataTableFiles(stb);
            IncludeResourceScript(stb, "iframeResizer.contentWindow.min.js");

            try
            {
                var      culture          = CultureInfo.CurrentUICulture;
                TimeSpan durationTimeSpan = InfluxDbQueryBuilder.GetTimeSpan(queryDuration);
                var      queryData        = GetData(HttpUtility.UrlDecode(query));

                var histogram = InfluxDBHelper.CreateHistogram(queryData, durationTimeSpan);

                if (histogram.Count > 0)
                {
                    //Display the first row/column only
                    stb.Append("<table id=\"results\" class=\"cell-border compact\" style=\"width:100%\">");

                    stb.Append(@"<thead align='left'><tr>");
                    stb.Append(@"<th>Value</th>");
                    stb.Append(@"<th>Total time</th>");
                    stb.Append(@"<th>Percentage</th>");
                    stb.Append(@"</tr></thead>");

                    stb.Append(@"<tbody>");

                    var firstRow = queryData[0];

                    foreach (var pair in histogram)
                    {
                        stb.Append(@"<tr class='tablecell'>");
                        stb.Append(@"<td>");
                        stb.Append(HtmlEncode(FirstCharToUpper(pair.Key, culture)));
                        stb.Append(@"</td>");

                        stb.Append(@"<td>");
                        stb.Append(HtmlEncode(InfluxDBHelper.GetSerieValue(culture, pair.Value)));
                        stb.Append(@"</td>");
                        stb.Append(@"<td>");
                        double percentage = 100 * pair.Value.TotalMilliseconds / durationTimeSpan.TotalMilliseconds;
                        stb.Append(HtmlEncode(InfluxDBHelper.GetSerieValue(culture, percentage)));
                        stb.Append(@"</td>");

                        stb.Append(@"</tr>");
                    }
                    stb.Append(@"</tbody>");

                    stb.AppendLine(@"</table>");
                }

                return(stb.ToString());
            }
            catch (Exception ex)
            {
                return(Invariant($"<br><div style='color:Red'>{ex.GetFullMessage()}</div><br>"));
            }
        }
示例#27
0
        private void BuildTable(string query, StringBuilder stb, int pageLength)
        {
            try
            {
                var culture   = CultureInfo.CurrentUICulture;
                var queryData = GetData(query);

                if (queryData.Count > 0)
                {
                    var columns = queryData[0].Keys;

                    stb.Append("<table id=\"results\" class=\"cell-border compact\" style=\"width:100%\">");
                    stb.Append(@"<thead><tr>");
                    foreach (var column in columns)
                    {
                        stb.Append(Invariant($"<th>{ HtmlEncode(FirstCharToUpper(column, culture))}</th>"));
                    }
                    stb.Append(@"</tr></thead>");
                    stb.Append(@"<tbody>");

                    DateTimeOffset today = DateTimeOffset.Now.Date;
                    foreach (var row in queryData)
                    {
                        bool anyValue = row.Any(x => (string.CompareOrdinal(x.Key, InfluxDBHelper.TimeColumn) != 0) && (x.Value != null));

                        if (!anyValue)
                        {
                            continue;
                        }

                        stb.Append(@"<tr>");

                        foreach (var columnName in columns)
                        {
                            object column    = row[columnName];
                            string value     = string.Empty;
                            string sortValue = null;

                            if (string.CompareOrdinal(columnName, InfluxDBHelper.TimeColumn) == 0)
                            {
                                DateTime timePoint = ((DateTime)column).ToLocalTime();
                                sortValue = (new DateTimeOffset(timePoint)).ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture);
                                value     = ConvertInfluxDBDateTimeToString(today, culture, timePoint);
                            }
                            else
                            {
                                value = InfluxDBHelper.GetSerieValue(culture, column);
                            }

                            if (sortValue != null)
                            {
                                stb.Append(Invariant($"<td data-order='{HtmlEncode(sortValue)}' class='tablecell'>{HtmlEncode(value)}</td>"));
                            }
                            else
                            {
                                stb.Append(Invariant($"<td class='tablecell'>{HtmlEncode(value)}</td>"));
                            }
                        }
                        stb.Append(@"</tr>");
                    }
                    stb.Append(@"</tbody>");
                    stb.Append(@"</table>");

                    stb.AppendLine("<script type='text/javascript'>");
                    stb.AppendLine(@"$(document).ready(function() {");
                    stb.AppendLine(@"$('#results').DataTable({
                                        'order': [],");
                    stb.AppendLine(Invariant($"  'pageLength': {pageLength}, "));
                    stb.AppendLine(@"   'columnDefs': [
                                            { 'className': 'dt-left', 'targets': '_all'}
                                        ]
                                    });
                                });");
                    stb.AppendLine("</script>");
                }
                else
                {
                    stb.AppendLine("No data");
                }
            }
            catch (Exception ex)
            {
                stb.Append(Invariant($"<br><div style='color:Red'>{ex.GetFullMessage()}</div><br>"));
            }
        }
示例#28
0
        private IList <IDictionary <string, object> > GetData(string query)
        {
            var loginInformation = pluginConfig.DBLoginInformation;

            return(InfluxDBHelper.ExecuteInfluxDBQuery(query, loginInformation).ResultForSync());
        }