Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var sheetParser = new SheetParser("1FgbLOKoa1FuXnyiDLsweLoAtU60u3i0MlnMLJRCnE38");

            sheetParser.GetValues("B2:C");
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WinForms.FolderBrowserDialog folderBrowser = new WinForms.FolderBrowserDialog();
            var result = folderBrowser.ShowDialog();

            string[] docLocations;
            if (result == WinForms.DialogResult.OK)
            {
                var pathToDocs = folderBrowser.SelectedPath;
                docLocations = Directory.GetFiles(pathToDocs);
            }
            else
            {
                return;
            }
            List <Room>   rooms   = new List <Room>();
            List <Course> courses = SheetParser.Parse(docLocations, new InMemoryRoomRepository(rooms));

            InMemoryCourseRepository.initInstance(courses);


            if (courses.FindAll(m => m.AmbiguousState).Count > 0)
            {
                AmbiguityResolverWindow mainWindow = new AmbiguityResolverWindow();
                mainWindow.Show();
            }
            else
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
            }

            this.Close();
        }
Example #3
0
        public static void Initialize(TestContext context)
        {
            var debugLocation = Assembly.GetExecutingAssembly().Location;
            var debugFolder   = Path.GetDirectoryName(debugLocation);
            var testFolder    = Path.Combine(debugFolder, "testData");
            var files         = Directory.GetFiles(testFolder);

            InMemoryRoomRepository.initInstance(roomList);
            courseList        = SheetParser.Parse(files, InMemoryRoomRepository.getInstance());
            firstCourseRecord = courseList.First();
        }
Example #4
0
        private void ParseQuestions(DateTime lastDateFromDB)
        {
            var parser = new SheetParser("1FgbLOKoa1FuXnyiDLsweLoAtU60u3i0MlnMLJRCnE38");
            var values = parser.GetValues("A2:C");

            foreach (var value in values.Where(x => x.Count > 2))
            {
                var currentDate = DateTime.Parse(value[0].ToString());
                if (currentDate > lastDateFromDB)
                {
                    this.Insert(new QuestionEntity(Guid.NewGuid(), currentDate, value[1].ToString(), value[2].ToString()));
                }
            }
        }
        private void NewProjectButton_Click(object sender, RoutedEventArgs e)
        {
            string[] docLocations = GetSheetPaths();
            if (docLocations == null)
            {
                return;
            }

            List <Course> courses = null;

            try
            {
                courses = SheetParser.Parse(docLocations, RoomRepository.GetInstance());
            }
            catch { }

            if (courses == null || courses.Count == 0)
            {
                OnNewProjectCreationError();
                return;
            }

            //InitCrossListedCourses(courses);

            MemoryStream stream    = new MemoryStream();
            IFormatter   formatter = new BinaryFormatter();

            formatter.Serialize(stream, courses);
            stream.Seek(0, SeekOrigin.Begin);

            var copy = formatter.Deserialize(stream) as List <Course>;

            App.Current.Resources["originalCourses"] = copy;

            CourseRepository.InitInstance(courses);


            NextPage(courses);
        }
Example #6
0
        /// <summary>
        /// Create a new project on click. Read all the courses from the csv files.
        /// </summary>
        /// <param name="sender">A reference to the control/object that raised the event.</param>
        /// <param name="e">State information and event data associated with a routed event.</param>
        private void NewProjectButton_Click(object sender, RoutedEventArgs e)
        {
            string[]      docLocations = GetSheetPaths();
            List <string> badFiles     = new List <string>();

            if (docLocations == null)
            {
                return;
            }
            var courses  = new List <Course>();
            var tempList = new List <Course>();

            courses = null;

            try
            {
                foreach (string file in docLocations)
                {
                    var fileName = new DirectoryInfo(file).Name;
                    tempList = SheetParser.Parse(file, RoomRepository.GetInstance());

                    if (tempList == null || tempList.Count == 0)
                    {
                        badFiles.Add(fileName);
                        Console.WriteLine(fileName);
                        tempList = null;
                    }
                    else if (tempList != null && courses == null)
                    {
                        courses  = tempList;
                        tempList = null;
                    }
                    else if (tempList != null && courses != null)
                    {
                        courses.AddRange(tempList);
                        tempList = null;
                    }
                }
            }
            catch (NullReferenceException nre)
            {
                Console.Out.WriteLine("NRE: " + nre);
            }

            string[] output = null;

            if (badFiles.Count > 0)
            {
                output = badFiles.Select(i => i.ToString()).ToArray();
            }

            //try
            //{
            //    courses = SheetParser.Parse(docLocations, RoomRepository.GetInstance(), courses);
            //}
            //catch { }

            if (output != null || courses.Count == 0 || courses == null)
            {
                OnNewProjectCreationError(string.Join(", ", output));
                return;
            }

            MemoryStream stream    = new MemoryStream();
            IFormatter   formatter = new BinaryFormatter();

            formatter.Serialize(stream, courses);
            stream.Seek(0, SeekOrigin.Begin);

            var copy = formatter.Deserialize(stream) as List <Course>;

            App.Current.Resources["originalCourses"] = copy;

            CourseRepository.InitInstance(courses);

            NextPage(courses);
        }