示例#1
0
        /// <summary>
        /// Writes all workbooks associated with a workbook creation plugin to the output directory.
        /// </summary>
        /// <param name="outputLocation">The absolute path where plugin output was 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="outputDatabaseName">The name of the Postgres database that the workbook should connect to.</param>
        protected IEnumerable <string> WriteWorkbooksToDisk(string outputLocation, IWorkbookCreationPlugin plugin, IPluginResponse response, string outputDatabaseName)
        {
            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)
                {
                    var workbookEditor = new WorkbookEditor(outputLocation, postgresConnectionInfo, outputDatabaseName);

                    using (var workbookInputStream = plugin.GetWorkbook(workbookName))
                    {
                        var processedWorkbook = workbookEditor.Process(workbookInputStream, workbookName);
                        workbookFilePaths.Add(processedWorkbook.FullName);
                        Log.InfoFormat("Saved workbook to '{0}'!", processedWorkbook.FullName);
                    }
                }
            }

            return(workbookFilePaths);
        }