/// <summary> /// Sorts a fixed width file given a alphanumeric key. /// </summary> /// <param name="sourcefilePath">Full path and file name of file to be sorted</param> /// <param name="getKey">Function to construct the key</param> /// <param name="dataFilter">Function to filter out a data line (true to include data or false to exclude data)</param> /// <param name="dataTransportation">Define the data transportation method.</param> /// <param name="destinationFolder">Folder path where sorted and/or duplicate files will be place. (Uses folder of sourcefilePath when null)</param> /// <param name="hasHeader">Does the file have a header row</param> /// <param name="isUniqueKey">If true duplicates will not be included in the sorted file.</param> /// <param name="returnDuplicates">If true duplicates will be written out to file only if isUniqueKey is true.</param> /// <param name="sortDir">The sort direction of the key.</param> /// <param name="progress">A method to report progress</param> /// <param name="maxBatchSize">Control the max insert batch size</param> public static SortResults SortFixedWidthByAlphaNumKey(string sourcefilePath, Func<string, string> getKey, Func<string, bool> dataFilter = null, DataTransportation dataTransportation = null, string destinationFolder = null, bool hasHeader = true, bool isUniqueKey = false, bool returnDuplicates = false, SortDirection sortDir = SortDirection.Ascending, Action<SortProgress> progress = null, int maxBatchSize = 250000) { SortDefinitions sortDefs = new SortDefinitions(); sortDefs.Add(new SortDefinition { DataType = KeyType.AlphaNumeric, Direction = sortDir, IsUniqueKey = isUniqueKey }); return SortFile.SortFixedWidthByKeyDefinitions( sourcefilePath: sourcefilePath, sortDefinitions: sortDefs, dataFilter: dataFilter, setKeys: (line, keyValues) => keyValues[0] = getKey(line), dataTransportation: dataTransportation, destinationFolder: destinationFolder, hasHeader: hasHeader, returnDuplicates: returnDuplicates, progress: progress, maxBatchSize: maxBatchSize); }
internal static SortResults SortFixedWidth <T>(MasterFixedWidthFileSource <T> master, string destinationFolder) { return(SortFile.SortFixedWidthByKeyCore <T>(sourcefilePath: master.SourceFilePath, getKey: master.GetKey, destinationFolder: destinationFolder, hasHeader: master.HasHeader, isUniqueKey: false, sortDir: master.SortDirection, deleteDbConnPath: false, writeOutSortFile: false)); }