Example #1
0
        /// <summary>
        /// Copies temporary CSV files to finished files.
        /// </summary>
        /// <param name="block">Information for the finished files.</param>
        /// <param name="about">Extra information for the finished files.</param>
        protected static void CopyCsv(SceneBlock block, string about)
        {
            StringWriter csvString = new StringWriter();

            using (var csv = new CsvWriter(csvString, GetConfiguration()))
            {
                foreach (string key in currentHeader)
                {
                    csv.WriteField(key);
                }

                csv.NextRecord();
            }

            // Write collected headers
            string path     = $"exported{Seperator}CSVs{Seperator}";
            string filename = $"{sessionId}.{about}.{block.Name}.{block.Index}.csv";

            AppendToFile(csvString.ToString(), filename, path);

            // Copy data contents to finalized location
            string temporaryLocation = $"{prefix}temporary{Seperator}CSVs{Seperator}{filename}";

            File.AppendAllText($"{prefix}{path}{filename}", File.ReadAllText(temporaryLocation));

            // Reset the headers, because a new scene should have differerent headers
            currentHeader = new List <string>();
        }
Example #2
0
        /// <summary>
        /// Converts a scene block to JSON.
        /// </summary>
        /// <returns>
        /// A flattened CSV representation of the sceneblock.
        /// </returns>
        /// <param name="block">A scene block to serialize.</param>
        protected static string ToCsv(SceneBlock block)
        {
            string json = ToFlatJson(block.Docs);
            string csv  = JsonToCsv(json);

            return(csv);
        }