CreateFile() public method

return the filepath
public CreateFile ( long datasetId, long datasetVersionOrderNr, long dataStructureId, string title, string extention ) : string
datasetId long
datasetVersionOrderNr long
dataStructureId long
title string
extention string
return string
Exemplo n.º 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 createDownloadFile(string ns, long datastructureId, string title, string ext, DataWriter writer, string[] columns = null)
        {
            ExcelWriter excelwriter = null;

            switch (ext)
            {
            // text based files
            case ".csv":
            case ".txt":
            case ".tsv":
                AsciiWriter asciiwriter = (AsciiWriter)writer;
                return(asciiwriter.CreateFile(ns, title, ext));

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

            case ".xlsm":
                excelwriter = (ExcelWriter)writer;
                excelwriter.VisibleColumns = columns;
                return(excelwriter.CreateFile(ns, datastructureId, title, ext));

            // no valid extension given
            default:
                return("");
            }
        }
Exemplo n.º 2
0
        private string createDownloadFile(long id, long datasetVersionOrderNo, long dataStructureId, string title, string ext, DataWriter writer, string[] columns = null, bool withUnits = false)
        {
            string addtionalFileNameExt = "";

            if (withUnits)
            {
                addtionalFileNameExt = "_withunits";
            }

            string filename = "data" + addtionalFileNameExt;

            if (ext.Equals(".csv") || ext.Equals(".txt") || ext.Equals(".tsv"))
            {
                AsciiWriter asciiwriter = (AsciiWriter)writer;
                return(asciiwriter.CreateFile(id, datasetVersionOrderNo, dataStructureId, filename, ext));
            }
            else
            if (ext.Equals(".xlsm"))
            {
                ExcelWriter excelwriter = (ExcelWriter)writer;
                excelwriter.VisibleColumns = columns;
                return(excelwriter.CreateFile(id, datasetVersionOrderNo, dataStructureId, filename, ext));
            }
            else
            if (ext.Equals(".xlsx"))
            {
                ExcelWriter excelwriter = (ExcelWriter)writer;
                return(excelwriter.CreateFile(id, datasetVersionOrderNo, dataStructureId, filename, ext));
            }

            return("");
        }
Exemplo n.º 3
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("");
        }
Exemplo n.º 4
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("");
            }
        }