BExIS.IO.Transform.Output.AsciiWriter.AddDataTuples C# (CSharp) Method

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
        public List<Error> AddDataTuples(DatasetManager datasetManager,List<long> dataTuplesIds, string filePath, long dataStructureId)
        {
            if (File.Exists(filePath))
            {
                StringBuilder data = new StringBuilder();
                data.AppendLine(dataStructureToRow(dataStructureId));

                DataTupleIterator tupleIterator = new DataTupleIterator(dataTuplesIds, datasetManager);
                foreach (var tuple in tupleIterator)
                {
                    string newline = datatupleToRow(tuple);
                    if (!String.IsNullOrEmpty(newline)) data.AppendLine(newline);
                }
                File.WriteAllText(filePath, data.ToString());
            }

            return ErrorMessages;
        }

Same methods

AsciiWriter::AddDataTuples ( List dataTuples, string filePath, long dataStructureId ) : List

Usage Example

Ejemplo n.º 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();
            }
        }
All Usage Examples Of BExIS.IO.Transform.Output.AsciiWriter::AddDataTuples