예제 #1
0
        public static string HandleReportRequest(byte[] body, bool zipped, out int statusCode)
        {
            var html     = "";
            var reportId = "";

            try
            {
                var json = "";

                if (zipped)
                {
                    json = body.Decompress();
                }
                else
                {
                    json = Encoding.UTF8.GetString(body);
                }

                // Remove BOM char if present.
                if (json[0] == 65279)
                {
                    json = json.Remove(0, 1);
                }

                html = PageGenerator.GenerateReportPage(json, out reportId);
            }
            catch (PageGenerator.ParsingException ex)
            {
                statusCode = 400;
                return(ex.Message);
            }
            catch (Exception)
            {
                statusCode = 400;
                return("Invalid report JSON received.");
            }

            try
            {
                var dataDir = Path.Combine(Config.ContentDir, "reports");

                if (!Directory.Exists(dataDir))
                {
                    Directory.CreateDirectory(dataDir);
                }

                var file = Path.Combine(dataDir, reportId + ".html");

                File.WriteAllText(file, html);

                statusCode = 200;
                return($"http://{Config.FQD}/{reportId}");
            }
            catch (Exception)
            {
                statusCode = 500;
                return($"An unknown error occurred while processing report {reportId}.");
            }
        }
예제 #2
0
        public static string HandleReportRequest(byte[] body, bool zipped, out int statusCode)
        {
            var roomID  = "";
            var batchID = "";
            var html    = "";

            try
            {
                var json = "";

                if (zipped)
                {
                    json = body.Decompress();
                }
                else
                {
                    json = Encoding.UTF8.GetString(body);
                }

                var jObj = JSON.Deserialize <Dictionary <string, object> >(json);
                roomID  = jObj["room_id"].ToString();
                batchID = jObj["batch_nr"].ToString();

                html = PageGenerator.GenerateReportPage(json);
            }
            catch (Exception)
            {
                statusCode = 400;
                return("Invalid report JSON received.");
            }

            try
            {
                var dataDir = Path.Combine(Config.ContentDir, roomID);

                if (!Directory.Exists(dataDir))
                {
                    Directory.CreateDirectory(dataDir);
                }

                var file = Path.Combine(dataDir, batchID + ".html");

                File.WriteAllText(file, html);

                statusCode = 200;
                return($"http://{Config.FQD}/{roomID}/{batchID}");
            }
            catch (Exception)
            {
                statusCode = 500;
                return($"An unknown error occurred while processing report {roomID}/{batchID}.");
            }
        }
예제 #3
0
 static void Main()
 {
     PageGenerator.GenerateReportPage();
     //PageGenerator.GenerateReportPageWithFirstPartyEmbedding();
     //PageGenerator.GenerateReportPageWithPhasedLoading();
     //PageGenerator.GenerateReportWithPageNavigation();
     //PageGenerator.GenerateReportWithToolbarPage();
     //PageGenerator.GenerateReportWithContextMenusPage();
     //PageGenerator.GenerateReportWithBookmarks();
     //PageGenerator.GenerateReportWithCustomFiltering();
     //PageGenerator.GenerateNewReportPage();
     //PageGenerator.GenerateNewReportPageFirstParty();
     //PageGenerator.GenerateDashboardPage();
     //PageGenerator.GenerateDashboardTilePage();
     //PageGenerator.GenerateReportInspectorPage();
     //PageGenerator.GenerateReportVisualPage();
     //PageGenerator.GenerateQnaPage();
     //PageGenerator.GenerateReportWithRls();
 }