DataWriter is an abstract class that has basic functions for storing file.
Exemple #1
0
        /// <summary>
        /// create a new file of given extension
        /// ns will be used to seperate from other files created of individual datasets
        /// </summary>
        /// <param name="ns">namespace</param>
        /// <param name="title"></param>
        /// <param name="ext"></param>
        /// <param name="writer"></param>
        /// <returns></returns>
        private string generateDownloadFile(string ns, long datastructureId, string title, string ext, DataWriter writer)
        {
            switch (ext)
            {
            // text based files
            case ".csv":
            case ".txt":
                AsciiWriter asciiwriter = (AsciiWriter)writer;
                return(asciiwriter.CreateFile(ns, title, ext));

            // excel files
            case ".xlsx":
            case ".xlsm":
                ExcelWriter excelwriter = (ExcelWriter)writer;
                return(excelwriter.CreateFile(ns, datastructureId, title, ext));

            // no valid extension given
            default:
                return("");
            }
        }
Exemple #2
0
        private string generateDownloadFile(long id, long datasetVersionOrderNo, long dataStructureId, string title, string ext, DataWriter writer)
        {
            if (ext.Equals(".csv") || ext.Equals(".txt"))
            {
                AsciiWriter asciiwriter = (AsciiWriter)writer;
                return(asciiwriter.CreateFile(id, datasetVersionOrderNo, dataStructureId, "data", ext));
            }
            else
            if (ext.Equals(".xlsm"))
            {
                ExcelWriter excelwriter = (ExcelWriter)writer;
                return(excelwriter.CreateFile(id, datasetVersionOrderNo, dataStructureId, "data", ext));
            }

            return("");
        }