Ejemplo n.º 1
0
        public static DataTable ParseStringResource(TextReader stream, bool headers)
        {
            var stringResourceImporter = new StringResourceImporter();
            var table = stringResourceImporter.BuildEmptyStringResourceDataTable();

            return(ParseCSV(table, stream, headers));
        }
Ejemplo n.º 2
0
        static public void LoadStringResourceSpreadsheets(string localeSetting)
        {
            if (!CheckStringResourceExcelFileExists(localeSetting))
            {
                return;
            }

            // Find all string resource excel files in <appRoot>/StringResources pertaining to the specified locale
            var files = GetStringResourceFilesForLocale(localeSetting);

            try
            {
                var importer = new StringResourceImporter();
                importer.Import(localeSetting, files, StringResourceImporter.ImportOption.Default);
            }
            catch (Exception ex)
            {
                SysLog.LogException(ex, MessageTypeEnum.DatabaseException, MessageSeverityEnum.Alert);
            }
        }
Ejemplo n.º 3
0
        public static DataTable Parse(TextReader stream, bool headers)
        {
            var stringResourceImporter = new StringResourceImporter();

            var table = stringResourceImporter.BuildEmptyStringResourceDataTable();

            CsvStream csv = new CsvStream(stream);

            string[] row = csv.GetNextRow();
            if (row == null)
            {
                return(null);
            }
            if (headers)
            {
                foreach (string header in row)
                {
                    if (header != null && header.Length > 0 && !table.Columns.Contains(header))
                    {
                        table.Columns.Add(header, typeof(string));
                    }
                    else
                    {
                        table.Columns.Add(GetNextColumnHeader(table), typeof(string));
                    }
                }
                row = csv.GetNextRow();
            }
            while (row != null)
            {
                while (row.Length > table.Columns.Count)
                {
                    table.Columns.Add(GetNextColumnHeader(table), typeof(string));
                }
                table.Rows.Add(row);
                row = csv.GetNextRow();
            }
            return(table);
        }