Esempio n. 1
0
        /// <summary>
        /// Metoda creata pt stergerea unui calendar al unei persoane
        /// </summary>
        /// <param name="ledger"></param>
        private void DeleteCalendar(Ledger ledger)
        {
            Console.WriteLine("Removing Calendar of Person with id 3");
            Calendar cdelete = ledger.getCalendar("3");

            if (cdelete != null)
            {
                ledger.Delete(cdelete);
            }
            cdelete = ledger.getCalendar("3");
            if (cdelete == null)
            {
                Console.WriteLine("Calendar is deleted");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Metroda creata pt obtinerea evenimentelor unei persoane dintr-un anumit interval de timp
        /// </summary>
        /// <param name="ledger"></param>
        private void RetrievingEvents(Ledger ledger)
        {
            Console.Write("Retrieving Events for person with id `3` - method #1 (match found) - ");
            Calendar c3    = ledger.getCalendar("3");
            DateTime from1 = DateTime.ParseExact("15/04/2020 08:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
            DateTime to1   = DateTime.ParseExact("15/04/2020 17:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.WriteLine("from/to: " + from1 + " - " + to1);
            List <CalendarEvent> windowEvents1 = ledger.GetEvents(c3.GetPerson(), from1, to1);

            foreach (CalendarEvent ce in windowEvents1)
            {
                Console.WriteLine(ce);
            }
            Console.WriteLine();
            ////////////////////////////////////////////////////////////////////////

            Console.Write("Retrieving Events for person with id `3` - method #2 (match found) - ");
            Calendar c4    = ledger.getCalendar("3");
            DateTime from2 = DateTime.ParseExact("15/04/2020 08:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
            DateTime to2   = DateTime.ParseExact("15/04/2020 11:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.WriteLine("from/to: " + from2 + " - " + to2);
            List <CalendarEvent> windowEvents2 = c4.GetEvents(from2, to2);

            foreach (CalendarEvent ce in windowEvents2)
            {
                Console.WriteLine(ce);
            }
            Console.WriteLine();

            Console.Write("Retrieving Events for person with id `3` - method #2 (NO match found) - ");
            Calendar c5    = ledger.getCalendar("3");
            DateTime from3 = DateTime.ParseExact("15/04/2020 12:01", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
            DateTime to3   = DateTime.ParseExact("15/04/2020 20:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.WriteLine("from/to: " + from3 + " - " + to3);
            List <CalendarEvent> windowEvents3 = c4.GetEvents(from3, to3);

            foreach (CalendarEvent ce in windowEvents3)
            {
                Console.WriteLine(ce);
            }
            Console.WriteLine();
        }
Esempio n. 3
0
        /// <summary>
        /// Metoda creata pt obtinerea  calendarului unei persoane pt diferite scopuri
        /// </summary>
        /// <param name="ledger"></param>
        private void RetrievingCalendar4Person(Ledger ledger)
        {
            Console.WriteLine("Retrieving Calendar for person with id `1`");
            Calendar c = ledger.getCalendar("1");

            if (c != null)
            {
                Console.WriteLine("Calendar Owner is : " + c.GetPerson());
                Console.WriteLine("Calendar has : " + c.GetEvents().Count() + " events");

                //1,Birthday Party,13 / 04 / 2020 11:00,13 / 04 / 2020 12:00
                //pt test
                DateTime from1       = DateTime.ParseExact("13/04/2020 08:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                DateTime to1         = DateTime.ParseExact("13/04/2020 09:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                bool     isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 13:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 14:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 11:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 12:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 10:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 11:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 13:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 14:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 09:00", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 11:30", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 11:30", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 12:30", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);

                from1       = DateTime.ParseExact("13/04/2020 11:30", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                to1         = DateTime.ParseExact("13/04/2020 11:45", "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                isAvailable = c.isAvailable(from1, to1);
                Console.WriteLine("isAvailable : " + isAvailable);
            }
            Console.WriteLine();
        }
        //14/04/2020 15:50
        public void ScheduleEvent(List <Person> persons, String eventName, DateTime from, int forHowLongInMinutes)
        {
            DateTime to = from.AddMinutes(forHowLongInMinutes);

            DateTime begin = from;
            DateTime end   = to;
            bool     foundEmptySlot;

            while (true)
            {
                foundEmptySlot = true;
                foreach (Person person in persons)
                {
                    Calendar c = ledger.getCalendar(person);
                    if (c.isAvailable(begin, end) == false)
                    {
                        foundEmptySlot = false;
                        break;
                    }
                }

                if (foundEmptySlot == true)
                {
                    break;
                }

                begin = begin.AddMinutes(15);
                end   = begin.AddMinutes(forHowLongInMinutes);
            }

            if (foundEmptySlot == true)
            {
                foreach (Person person in persons)
                {
                    Calendar c = ledger.getCalendar(person);
                    c.AddEvent(eventName, begin, end);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Metoda creata pt obtinerea tuturor evenimentelor unei persoane
        /// </summary>
        /// <param name="ledger"></param>
        /// <param name="person"></param>
        private void RetrievingEvents(Ledger ledger, Person person)
        {
            Console.WriteLine("Retrieving Events for person with id `" + person.GetId() + "`");
            Calendar c = ledger.getCalendar(person);

            List <CalendarEvent> events = c.GetEvents();

            foreach (CalendarEvent ce in events)
            {
                Console.WriteLine(ce);
            }
            Console.WriteLine();
        }