Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        // 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);
        }