Beispiel #1
0
        public WebhookRegistry.HTTPResponseData renderChart(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData();
            if (ChartMemory.HasChartID(arguments[0]))
            {
                hrd.Status            = 200;
                hrd.ReturnContentType = "text/html";
                Chart  C    = ChartMemory.GetChartByID(arguments[0]);
                string page = "<html><head><title>Chart - " + C.ChartName + "</title></head><body bgcolor='black'>";
                // Don't prepend the Table CSS since we need to set colors custom
                page += "<center><a style='color:white'><h2>" + C.ChartDescription + "</h2></a>";
                page += "<table style=\"border:1px inset #00FFFF;border-collapse:separate;border-spacing:0px;padding:6px;\">";
                ChartColumn col = C.ColumnData;
                page += "<thead><th style=\"background:#F0F0F0;border:1px inset #00FFFF;padding:6px\">" + C.ChartName + "</th>";
                foreach (ChartColumnField field in col.Fields)
                {
                    page += "<th style=\"background:" + field.ColorCode + "\";border:1px inset #00FFFF;padding:6px\">" + field.Label + "</th>";
                }
                page += "</thead><tbody>";
                int Pos = 0;
                foreach (ChartRow row in C.RowData)
                {
                    Pos   = 0;
                    page += "<tr><td style=\"border:1px inset #00FFFF;padding:6px;background:#F0F0F0;color:black\">" + row.Label + "</td>";
                    foreach (ChartColumnField field in col.Fields)
                    {
                        // Begin processing row. Keep index of what position we are at
                        int    MaskForPos = col.Pos2Bit(Pos);
                        string ColorCode  = "#000000";
                        if ((row.Mask & MaskForPos) == MaskForPos)
                        {
                            // set the color code to the col code
                            ColorCode = col.Fields[Pos].ColorCode;
                        }
                        page += "<td style=\"border:1px inset #00FFFF;padding:6px;background:" + ColorCode + ";color:white\"> </td>";



                        Pos++;
                    }
                    page += "</tr>";
                }

                page           += "</tbody></table></body>";
                page           += "<script type='text/javascript'>";
                page           += "setInterval(function(){window.location.reload(true);}, 30000);";
                page           += "</script>";
                hrd.ReplyString = page;
            }
            else
            {
                hrd.ReplyString       = "Not found";
                hrd.Status            = 404;
                hrd.ReturnContentType = "text/plain";
            }


            return(hrd);
        }
Beispiel #2
0
 public Chart(string ChartNm)
 {
     ChartName        = ChartNm;
     ColumnData       = new ChartColumn();
     RowData          = new List <ChartRow>();
     ChartID          = UUID.Random();
     ChartDescription = "A chart generated by the BotCore5 system";
 }
Beispiel #3
0
        public void setChartCols(UUID client, int level, string[] additionalArgs,
                                 Destinations source,
                                 UUID agentKey, string agentName)
        {
            if (ChartMemory.HasChart(additionalArgs[0]))
            {
                Chart       v     = ChartMemory.GetNamedChart(additionalArgs[0]);
                int         index = ChartMemory.Instance.Charts.IndexOf(v);
                ChartColumn col   = v.ColumnData;
                if (col == null)
                {
                    col = new ChartColumn();
                }
                if (col.Fields == null)
                {
                    col.Fields = new List <ChartColumnField>();
                }


                if (col.Fields.Where(x => x.Label == additionalArgs[1]).Count() > 0)
                {
                    // already has this column
                    MHE(source, client, "That column already exists");
                    return;
                }
                else
                {
                    ChartColumnField field = new ChartColumnField();
                    field.ColorCode = additionalArgs[2];
                    field.Label     = additionalArgs[1];


                    if (additionalArgs.Length == 4)
                    {
                        // insert at index
                        col.Fields.Insert(Convert.ToInt32(additionalArgs[3]), field);
                    }
                    else
                    {
                        col.Fields.Add(field);
                    }
                }

                v.ColumnData = col;
                ChartMemory.Instance.Charts[index] = v;
                ChartMemory.SaveToFile();

                MHE(source, client, "Column data has been updated");
            }
            else
            {
                MHE(source, client, "No such chart");
            }
        }