DataWriter is an abstract class that has basic functions for storing file.
コード例 #1
0
ファイル: OutputDataManager.cs プロジェクト: payamad/Core
        /// <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("");
            }
        }
コード例 #2
0
ファイル: OutputDataManager.cs プロジェクト: payamad/Core
        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("");
        }