AddDataTuples() public method

Add Datatuples and Datastructure to a Ascii file
public AddDataTuples ( DatasetManager datasetManager, List dataTuplesIds, string filePath, long dataStructureId ) : List
datasetManager BExIS.Dlm.Services.Data.DatasetManager
dataTuplesIds List
filePath string Path of the excel template file
dataStructureId long Id of datastructure
return List
Beispiel #1
0
        public string GenerateAsciiFile(long id, string title, string mimeType, string[] visibleColumns)
        {
            string ext  = "";
            string path = "";

            DatasetManager datasetManager = new DatasetManager();

            try
            {
                DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(id);
                AsciiWriter    writer         = new AsciiWriter(TextSeperator.comma);

                // Javad: It is better to have a list of tuple IDs and pass it to the AddDataTuples method.
                // This method is using a special iterator to reduce the number of queries. 18.11.2016

                List <long> datatuples = new List <long>(); //GetFilteredDataTuples(datasetVersion);

                long datastuctureId = datasetVersion.Dataset.DataStructure.Id;

                path = generateDownloadFile(id, datasetVersion.Id, datastuctureId, "data", ext, writer);

                if (visibleColumns != null)
                {
                    writer.VisibleColumns = visibleColumns;
                }

                writer.AddDataTuples(datasetManager, datatuples, path, datastuctureId);

                return(path);
            }
            finally
            {
                datasetManager.Dispose();
            }
        }
Beispiel #2
0
        public string GenerateAsciiFile(string ns, DataTable table, string title, string mimeType, long dataStructureId)
        {
            string        ext           = "";
            TextSeperator textSeperator = TextSeperator.semicolon;

            switch (mimeType)
            {
            case "text/csv":
            {
                ext           = ".csv";
                textSeperator = TextSeperator.semicolon;
                break;
            }

            default:
            {
                ext           = ".txt";
                textSeperator = TextSeperator.tab;
                break;
            }
            }

            AsciiWriter writer = new AsciiWriter(textSeperator);

            // write to file
            // if there is already a file, replace it
            string path = generateDownloadFile(ns, dataStructureId, title, ext, writer);

            writer.AddDataTuples(table, path, dataStructureId);

            return(path);
        }
Beispiel #3
0
        public string GenerateAsciiFile(long id, long versionId, string title, string mimeType)
        {
            DatasetManager datasetManager = new DatasetManager();

            try
            {
                DatasetVersion datasetVersion = datasetManager.GetDatasetVersion(versionId);

                string contentDescriptorTitle = "";
                string ext = "";

                TextSeperator textSeperator = TextSeperator.semicolon;

                switch (mimeType)
                {
                case "text/csv":
                {
                    contentDescriptorTitle = "generatedCSV";
                    ext           = ".csv";
                    textSeperator = TextSeperator.semicolon;
                    break;
                }

                default:
                {
                    contentDescriptorTitle = "generatedTXT";
                    ext           = ".txt";
                    textSeperator = TextSeperator.tab;
                    break;
                }
                }

                AsciiWriter writer = new AsciiWriter(textSeperator);

                string path = "";

                //ascii allready exist
                if (datasetVersion.ContentDescriptors.Count(p => p.Name.Equals(contentDescriptorTitle) && p.URI.Contains(datasetVersion.Id.ToString())) > 0)
                {
                    #region FileStream exist

                    ContentDescriptor contentdescriptor = datasetVersion.ContentDescriptors.Where(p => p.Name.Equals(contentDescriptorTitle)).FirstOrDefault();
                    path = Path.Combine(AppConfiguration.DataPath, contentdescriptor.URI);

                    if (FileHelper.FileExist(path))
                    {
                        return(path);
                    }
                    else
                    {
                        List <long> datatupleIds   = datasetManager.GetDatasetVersionEffectiveTupleIds(datasetVersion);
                        long        datastuctureId = datasetVersion.Dataset.DataStructure.Id;

                        path = generateDownloadFile(id, datasetVersion.Id, datastuctureId, "Data", ext, writer);

                        storeGeneratedFilePathToContentDiscriptor(id, datasetVersion, ext);

                        writer.AddDataTuples(datasetManager, datatupleIds, path, datastuctureId);

                        return(path);
                    }

                    #endregion
                }
                // not exist needs to generated
                else
                {
                    #region FileStream not exist

                    List <long> datatupleIds   = datasetManager.GetDatasetVersionEffectiveTupleIds(datasetVersion);
                    long        datastuctureId = datasetVersion.Dataset.DataStructure.Id;

                    path = generateDownloadFile(id, datasetVersion.Id, datastuctureId, "data", ext, writer);

                    storeGeneratedFilePathToContentDiscriptor(id, datasetVersion, ext);

                    writer.AddDataTuples(datasetManager, datatupleIds, path, datastuctureId);

                    return(path);

                    #endregion
                }
            }
            finally
            {
                datasetManager.Dispose();
            }
        }