Exemplo n.º 1
0
        private async Task <List <EventClass> > GetEventsAPIAsync()
        {
            List <EventClass> eve = new List <EventClass>();

            using (HttpClient client = new HttpClient())
            {
                try
                {
                    ListEventAPI E1       = new ListEventAPI();
                    ListSchedule E2       = new ListSchedule();
                    var          response = await client.GetStringAsync("http://api.mitportals.in/events");

                    E1 = JsonConvert.DeserializeObject <ListEventAPI>(response);

                    var response1 = await client.GetStringAsync("http://api.mitportals.in/schedule");

                    E2 = JsonConvert.DeserializeObject <ListSchedule>(response1);

                    HashSet <Schedule> hash2 = new HashSet <Schedule>(E2.data);

                    foreach (Schedule schedule in hash2)
                    {
                        List <EventAPI> eventList   = new HashSet <EventAPI>(E1.data).Where(even => even.eid == schedule.eid).ToList();
                        EventClass      eventObject = new EventClass(schedule, eventList.First());
                        eve.Add(eventObject);
                    }
                }
                catch
                {
                    //Do nothing
                }

                return(eve);
            }
        }
Exemplo n.º 2
0
 public TesterWindow(Tester tester)
 {
     InitializeComponent();
     bl                   = BL.Factory.GetBL();
     Tester               = tester;
     DataContext          = Tester;
     ListSchedule         = bl.getTesterSchedule(Tester);
     schedule.ItemsSource = ListSchedule.ScheduleAsList;
 }
Exemplo n.º 3
0
        public AddTesterWindow()
        {
            InitializeComponent();
            bl           = BL.Factory.GetBL();
            ListSchedule = new ListSchedule();
            genderComboBox.ItemsSource = Enum.GetValues(typeof(Gender));

            carTypeComboBox.ItemsSource = Enum.GetValues(typeof(VehicleType));

            schedule.ItemsSource = ListSchedule.ScheduleAsList;
        }
Exemplo n.º 4
0
        // A function that returns the shedules of the current tester
        ListSchedule IBL.getTesterSchedule(Tester tester)
        {
            ListSchedule listschedule = new ListSchedule();

            //Convert from matrix to list Each object in the list contains the working hours of a particular day.
            listschedule.ScheduleAsList[0] = (new ListSchedule.coulmonInputs("Sunday", tester.TableSchedule[0, 0], tester.TableSchedule[0, 1], tester.TableSchedule[0, 2], tester.TableSchedule[0, 3], tester.TableSchedule[0, 4], tester.TableSchedule[0, 5]));
            listschedule.ScheduleAsList[1] = (new ListSchedule.coulmonInputs("Monday", tester.TableSchedule[1, 0], tester.TableSchedule[1, 1], tester.TableSchedule[1, 2], tester.TableSchedule[1, 3], tester.TableSchedule[1, 4], tester.TableSchedule[1, 5]));
            listschedule.ScheduleAsList[2] = (new ListSchedule.coulmonInputs("Tuesday", tester.TableSchedule[2, 0], tester.TableSchedule[2, 1], tester.TableSchedule[2, 2], tester.TableSchedule[2, 3], tester.TableSchedule[2, 4], tester.TableSchedule[2, 5]));
            listschedule.ScheduleAsList[3] = (new ListSchedule.coulmonInputs("Wednesday", tester.TableSchedule[3, 0], tester.TableSchedule[3, 1], tester.TableSchedule[3, 2], tester.TableSchedule[3, 3], tester.TableSchedule[3, 4], tester.TableSchedule[3, 5]));
            listschedule.ScheduleAsList[4] = (new ListSchedule.coulmonInputs("Thursday", tester.TableSchedule[4, 0], tester.TableSchedule[4, 1], tester.TableSchedule[4, 2], tester.TableSchedule[4, 3], tester.TableSchedule[4, 4], tester.TableSchedule[4, 5]));

            return(listschedule);
        }
Exemplo n.º 5
0
        public UpdateTesterWindow(Tester tester)
        {
            UpdatedTester = tester;
            DataContext   = UpdatedTester;
            bl            = BL.Factory.GetBL();
            InitializeComponent();
            genderComboBox.ItemsSource  = Enum.GetValues(typeof(Gender));
            carTypeComboBox.ItemsSource = Enum.GetValues(typeof(VehicleType));
            addressGrid.DataContext     = UpdatedTester.Address;
            ListSchedule = bl.getTesterSchedule(UpdatedTester);

            schedule.ItemsSource = ListSchedule.ScheduleAsList;
        }
Exemplo n.º 6
0
 private void DetailsUpdated(object sender, EventArgs e)
 {
     try
     {
         Tester               = bl.getTester(Tester.ID);
         ListSchedule         = bl.getTesterSchedule(Tester);
         DataContext          = Tester;
         schedule.ItemsSource = ListSchedule.ScheduleAsList;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
Exemplo n.º 7
0
        private void CreateSchedule(IEnumerable <string> listP)
        {
            foreach (var text in listP)
            {
                bool isDateExist  = false;
                bool isPlaceExist = false;
                int  index        = ListSchedule.Count();

                foreach (var day in _days)
                {
                    if (!isDateExist)
                    {
                        isDateExist = text.Contains(day.ToUpper());
                    }
                }

                foreach (var place in _places)
                {
                    if (!isPlaceExist)
                    {
                        isPlaceExist = text.Contains(place.ToUpper());
                    }
                }

                if (isDateExist && isPlaceExist)
                {
                    ListSchedule.Add(new Schedule(text));
                    continue;
                }

                if (index != 0)
                {
                    if (!text.ToUpper().Contains("ПОЛЕ"))
                    {
                        ListSchedule[index - 1].Games.AddRange(text.ToUpper()
                                                               .Split("\n")
                                                               .Select(x => new Game(x)));
                    }
                }
            }
        }
Exemplo n.º 8
0
        //A function that initializes the schedule, the function accepts the current tester and its schedule.
        void IBL.setTesterSchedule(Tester tester, ListSchedule listSchedule)
        {
            int j = 0;

            //Build a matrix of working hours.
            bool[,] tableSchedule = new bool[5, 6];
            //Go over each day in the ScheduleAsList
            foreach (var item in listSchedule.ScheduleAsList)
            {
                //They build a boolean array and put the working hours of the current tester
                bool[] hoursInDay = new bool[] { item.Nine, item.Ten, item.Eleven, item.Twelve, item.Thirteen, item.Fourteen };
                //Converting the working hours from the array into the matrix
                for (int i = 0; i < 6; i++)
                {
                    tableSchedule[j, i] = hoursInDay[i];
                }
                //Move to the second row in the matrix
                j++;
            }
            //We initialize the matrix of the taster from the matrix we built
            tester.TableSchedule = tableSchedule;
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            // Create schedule programmatically.
            ISchedule schedule1        = new IntervalSchedule(TimeSpan.FromSeconds(11), TimeSpan.Zero, DateTime.MinValue);
            ISchedule schedule2        = new IntervalSchedule(TimeSpan.FromMinutes(1), TimeSpan.Zero, DateTime.MinValue.AddSeconds(1));
            ISchedule schedule3        = new CronSchedule("*/5", "*", "*", "*", "*", TimeSpan.Zero);
            ISchedule combinedSchedule = new ListSchedule(new[] { schedule1, schedule2, schedule3 });

            // Print schedule TDL.
            Console.WriteLine("Forecasting events from expression:\n{0}", combinedSchedule.ToString());

            // Forecast timed events for the next hour.
            IEnumerable <TimedEvent> events = combinedSchedule.GetRange(DateTime.Now, DateTime.Now.AddHours(1));

            int eventCount = events.Count();

            Console.WriteLine("Found {0:d} events.", eventCount);

            // Print to screen.
            foreach (TimedEvent e in events)
            {
                Console.WriteLine("Event time: {0:G}", e.StartTime);
            }
        }
Exemplo n.º 10
0
 private void RefreshSchedule()
 {
     ListSchedule.BeginRefresh();
 }