Пример #1
0
        /// <summary>
        /// Processes the TableColumnInformation and gets it ready for writing to files.
        /// </summary>
        /// <param name="tableColumnInformation">The table column information.</param>
        /// <param name="preserveOrdering">if set to <c>true</c> [preserve ordering].</param>
        /// <param name="overallMode"></param>
        public virtual void ProcessTableData(IEnumerable <TableColumnInformation> tableColumnInformation, bool preserveOrdering, Mode overallMode)
        {
            CheckAndAddDirectory("DATA");

            // If whatever is passed in doesn't want to preserve ordering, we won't order the columns.
            // We always reorder the rows to be ordered by PK.
            // This will make sure Git is happy and only shows new, geniune changes.
            foreach (TableColumnInformation tableColumn in tableColumnInformation)
            {
                tableColumn.Data.DefaultView.Sort = $"{tableColumn.PrimaryKey} ASC";

                if (!preserveOrdering)
                {
                    tableColumn.Data.SetColumnsOrder(tableColumn.ColumnNames.OrderBy(column => column.ToUpperInvariant()).ToArray());
                }
            }

            if (overallMode == Mode.Add || overallMode == Mode.Edit)
            {
                _fileWriter.WriteAllFilesToDirectory($"{_fullPath}/DATA", ConvertToFileWriterModel(tableColumnInformation));
                return;
            }

            if (overallMode == Mode.Delete)
            {
                // Just delete all the files.
                Directory.Delete(_fullPath);
                return;
            }
        }