예제 #1
0
        /// <summary>
        /// Writes all workbooks associated with a workbook creation plugin to the output directory.
        /// </summary>
        /// <param name="outputLocation">The absolute path where the workbooks should be written.</param>
        /// <param name="plugin">The workbook creation plugin that ran.</param>
        /// <param name="response">The response object, containing information about the results of executing the plugin.</param>
        /// <param name="postgresDatabaseName">The name of the Postgres database that the workbook should connect to.</param>
        protected IEnumerable <string> WriteWorkbooksToDisk(string outputLocation, IWorkbookCreationPlugin plugin, IPluginResponse response, string postgresDatabaseName)
        {
            var workbookFilePaths = new List <string>();

            // Make sure we have something to do.
            if (!response.SuccessfulExecution)
            {
                return(workbookFilePaths);
            }
            if (response.GeneratedNoData)
            {
                Log.InfoFormat("Skipped saving workbooks for {0} because the plugin did not generate any backing data.", plugin.GetType().Name);
                return(workbookFilePaths);
            }

            // Replace connection information in workbook and flush to disk.
            if (plugin.WorkbookNames != null)
            {
                foreach (var workbookName in plugin.WorkbookNames)
                {
                    WorkbookEditor workbookEditor = new WorkbookEditor(workbookName, plugin.GetWorkbookXml(workbookName));
                    workbookEditor.ReplacePostgresConnections(postgresConnectionInfo, postgresDatabaseName);
                    workbookEditor.RemoveThumbnails();

                    string workbookFilePath = workbookEditor.Save(outputLocation);
                    workbookFilePaths.Add(workbookFilePath);
                    Log.InfoFormat("Saved workbook to '{0}'!", workbookFilePath);
                }
            }

            return(workbookFilePaths);
        }
예제 #2
0
        /// <summary>
        /// Writes all workbooks associated with a workbook creation plugin to the output directory.
        /// </summary>
        /// <param name="plugin">The workbook creation plugin that ran.</param>
        /// <param name="response">The response object, containing information about the results of executing the plugin.</param>
        protected void WriteWorkbooksToDisk(IWorkbookCreationPlugin plugin, IPluginResponse response)
        {
            // Replace connection information in workbook and flush to disk.
            if (response.SuccessfulExecution)
            {
                ICollection <string> workbookNames = plugin.WorkbookNames;

                if (response.GeneratedNoData)
                {
                    Log.InfoFormat("Skipped saving {0} {1} because the plugin did not generate any backing data.", plugin.GetType().Name, "workbook".Pluralize(workbookNames.Count));
                    return;
                }

                foreach (var workbookName in workbookNames)
                {
                    WorkbookEditor workbookEditor = new WorkbookEditor(workbookName, plugin.GetWorkbookXml(workbookName));
                    workbookEditor.ReplacePostgresConnections(logsharkRequest.Configuration.PostgresConnectionInfo, logsharkRequest.PostgresDatabaseName);
                    workbookEditor.RemoveThumbnails();

                    string workbookFilePath = workbookEditor.Save(GetOutputLocation(logsharkRequest.RunId));
                    response.WorkbooksOutput.Add(workbookFilePath);
                    Log.InfoFormat("Saved workbook to '{0}'!", workbookFilePath);
                }
            }
        }