コード例 #1
0
        public static void EntryUpload()
        {
            Console.WriteLine("Upload data by Answering the following questions:");
            Console.WriteLine("Race Course Name:");
            string CourseName = Console.ReadLine();

            Console.WriteLine("Date Race was Ran (YYYY-MM-DD):");
            string DateRan = Console.ReadLine();

            Console.WriteLine("Amount Bet:");
            string Amount = Console.ReadLine();

            Console.WriteLine("Result:(won or lost)");
            string res = Console.ReadLine();

            BsonDocument docu = new BsonDocument {
                { "CourseName", CourseName },
                { "DateRan", DateRan },
                { "AmountWon", ParseControl.AmountParse(Amount) },
                { "Result", ResCheck(res) }
            };

            DBInteractionClass.DbCSVUpload(docu);
            Console.WriteLine("docu added " + docu);
            //Startup.Start();
        }
コード例 #2
0
ファイル: FileControlCLI.cs プロジェクト: lavabyrd/Tipster
        // Parse file Method
        public static string[] ParseFile(string contents)
        {
            string splitString = "\n";

            string[] fileLines = contents.Split(new string[] { splitString }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var line in fileLines)
            {
                string   l     = line.Replace("(", "").Replace(")", ",").Replace(" ", "");
                string[] entry = l.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                // take each entry and do something
                string CourseName = entry[0];

                // Date comes in year/month/day, parse using DateTime.Parse and then .ToShortDateString().
                string DateRan = entry[1] + "-" + entry[2] + "-" + entry[3];
                string Amount  = entry[4];
                string Result  = entry[5];


                BsonDocument docu = new BsonDocument {
                    { "CourseName", CourseName },
                    { "DateRan", ParseControl.DateParse(DateRan) },
                    { "Amount", ParseControl.AmountParse(Amount) },
                    { "Result", ParseControl.ResultBoolCheck(Result) }
                };
                DBInteractionClass.DbCSVUpload(docu);
                Console.WriteLine(CourseName + " Added");
            }
            return(fileLines);
        }
コード例 #3
0
ファイル: MainFunctionality.cs プロジェクト: lavabyrd/Tipster
        public static void TakeAction(int parseAnswer)
        {
            switch (parseAnswer)
            {
            case 1:
                Task x = DBInteractionClass.DbQuery();
                Console.Read();
                Start();
                break;

            case 2:
                Console.WriteLine("Erasing all stored info");
                DBInteractionClass.DbWipe();
                Start();
                break;

            case 3:
                string   outname      = FileControl.FileGrab();
                string   fileContents = FileControl.ReadFile(outname);
                string[] output       = FileControl.ParseFile(fileContents);
                Console.WriteLine("upload done!");
                Console.WriteLine("back to the start we go!");
                Start();
                break;

            case 4:
                Task filter = DBInteractionClass.DbFilter();
                Console.Read();
                Start();
                break;

            case 5:
                Upload.EntryUpload();
                break;

            case 6:
                // output data from the DB to a text file
                Console.WriteLine("not currently implemented");
                break;

            default:
                Environment.Exit(1);
                break;
            }
        }