Example #1
0
        static void Main(string[] args)
        {
            int    afterTeamNum = 0;
            String filedir      = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;

            // GET ARGS
            if (args.Length == 0 || args.Length > 2)
            {
                // Illigal Arguments
                Console.WriteLine("Usage: <ProgramName> <Number of After Team> [input directory path(option)]");
                return;
            }
            if (args.Length == 2 && args[0] == "-s")
            {
                // Score Mode
                Console.WriteLine("### SCORE MODE ###");
                scoreCSV(args[1]);
                return;
            }

            Console.WriteLine($"### SHUFFLE MODE ###");
            // Number of After Team
            afterTeamNum = int.Parse(args[0]);
            if (args.Length > 1)
            {
                // input file path
                filedir = args[1];
            }
            if (!filedir.EndsWith(System.IO.Path.DirectorySeparatorChar))
            {
                filedir += System.IO.Path.DirectorySeparatorChar;
            }

            // READ
            var beforeTeamMembers = readCSV(filedir + BEFORE_CSV_NAME);

            // slice body (no header)
            beforeTeamMembers = beforeTeamMembers.GetRange(1, beforeTeamMembers.Count - 1);

            // CONVERT
            Console.WriteLine($"# Convert {beforeTeamMembers.Count} members to {afterTeamNum} teams");
            var afterTeamMembers = TeamReform.ReformTeam(beforeTeamMembers, 1, afterTeamNum);

            Console.WriteLine($"# Score (lower is better-shuffled):{TeamReform.ReformScore(afterTeamMembers, 0, 2, true)}");

            // WRITE
            // add headr
            afterTeamMembers.Insert(0, new String[] { "TEAM", "NO", "SCHOOL", "NAME" }.ToList());
            writeCSV(filedir + AFTER_CSV_NAME, afterTeamMembers);
        }
Example #2
0
        static public void scoreCSV(String filepath)
        {
            try
            {
                // READ
                var teamMembers = readCSV(filepath);
                // slice body (no header)
                teamMembers = teamMembers.GetRange(1, teamMembers.Count - 1);

                Console.WriteLine($"# Score (lower is better-shuffled):{TeamReform.ReformScore(teamMembers, 0, 2, true)}");
            }
            catch (IOException ioEx)
            {
                Console.WriteLine($"Can't get Score by file({filepath})", ioEx);
            }
        }