Exemplo n.º 1
0
        private void Create(string[] options)
        {
            string            path;
            string            settingsFileName = Properties.Settings.RdsSubsettingSettingsFileName;
            string            rdsDir           = Properties.Settings.RdsDirectoryName;
            FileInfo          settingsFile     = new FileInfo($"{Environment.CurrentDirectory}\\{rdsDir}\\{settingsFileName}");
            SubsettingOptions ssOptions        = new SubsettingOptions().LoadFromFile(settingsFile.FullName);

            if (options.Length > 3) //wut?
            {
                Console.Error.WriteLine("error: too many arguments");
                return;
            }
            if (options.Length == 3) //path specfied?
            {
                path = options[2];
                if (!Directory.Exists(path))
                {
                    Console.Error.WriteLine($"Path not found: {path}");
                    return;
                }
                ssOptions.TargetPath = path;
                ssOptions.SaveToFile(settingsFile.FullName);
            }

            Subsetter s = new Subsetter(ssOptions);

            s.CreateSubsetAsync().Wait();
        }
Exemplo n.º 2
0
        private void Factor(string[] obj)
        {
            string            settingsFileName = Properties.Settings.RdsSubsettingSettingsFileName;
            string            rdsDir           = Properties.Settings.RdsDirectoryName;
            FileInfo          settingsFile     = new FileInfo($"{Environment.CurrentDirectory}\\{rdsDir}\\{settingsFileName}");
            SubsettingOptions options          = new SubsettingOptions().LoadFromFile(settingsFile.FullName);

            if (obj.Length != 3) //subset factor double
            {
                Console.Error.Write("Incorrect amount of arguments specified. see help for usage");
                return;
            }
            double value;

            if (double.TryParse(obj[2], out value))
            {
                options.Factor = value;
                options.SaveToFile(settingsFile.FullName);
                Console.Out.Write($"Factor of subsetting set to {value}");
                return;
            }
            else
            {
                Console.Error.WriteLine($"Could not parse {obj[2]} to a double value.");
                return;
            }
        }
Exemplo n.º 3
0
        private void Setbase(string[] obj)
        {
            string            settingsFileName = Properties.Settings.RdsSubsettingSettingsFileName;
            string            rdsDir           = Properties.Settings.RdsDirectoryName;
            FileInfo          settingsFile     = new FileInfo($"{Environment.CurrentDirectory}\\{rdsDir}\\{settingsFileName}");
            SubsettingOptions options          = new SubsettingOptions().LoadFromFile(settingsFile.FullName);

            if (obj.Length != 4)//usage: subset setbase file column
            {
                Console.Error.WriteLine("Incorrect amount of arguments specified. see help for usage");
                return;
            }
            string FileOrTable = obj[2];
            string column      = obj[3];

            if (!IsValidInputForSetbase(FileOrTable, column))
            {
                return;
            }
            options.BaseColumn   = column;
            options.BaseFileName = FileOrTable;
            options.SaveToFile(settingsFile.FullName);
            Console.Out.WriteLine($"Base set to column {column} in {FileOrTable}");
            return;
        }
Exemplo n.º 4
0
        public void Run()
        {
            string[] extensionWhiteList = new string[]
            {
                ".txt"
                , ".csv"
            };
            string ext = Properties.Settings.DataSourceFileExtension;
            string settingsFileName    = Properties.Settings.RdsSubsettingSettingsFileName;
            string keyrelationFileName = Properties.Settings.KeyRelationshipFileName;
            string rdsDir = Properties.Settings.RdsDirectoryName;
            string dir    = Environment.CurrentDirectory;

            Console.Out.WriteLine($"Initializing in {dir}");
            DirectoryInfo directoryInfo = new DirectoryInfo(dir);
            var           settingsdir   = directoryInfo.CreateSubdirectory($".\\{rdsDir}");

            settingsdir.Attributes = settingsdir.Attributes | FileAttributes.Hidden; //set folder to hidden
            var files = directoryInfo.EnumerateFiles().
                        Where(leFile => leFile.Extension.InList(extensionWhiteList)).
                        ToList();

            foreach (var f in files)
            {
                Console.Out.WriteLine($"Found file {f.Name}");
                DataFileInfo df  = new DataFileInfo(f);
                int          idx = f.Name.LastIndexOf('.');
                string       nameWithoutExtension = f.Name.Substring(0, idx);
                df.SaveToFile($"{settingsdir.FullName}\\{nameWithoutExtension}{ext}");
            }
            List <KeyRelationship> keyRelationships = new List <KeyRelationship>();

            keyRelationships.SaveToFile($"{settingsdir.FullName}\\{keyrelationFileName}");
            SubsettingOptions subsettingOptions = new SubsettingOptions();

            subsettingOptions.TargetPath = dir + "\\subset";
            Directory.CreateDirectory(subsettingOptions.TargetPath);
            subsettingOptions.SaveToFile($"{settingsdir.FullName}\\{settingsFileName}");
        }