Exemplo n.º 1
0
        public CalEvent CalendarEventTest()
        {
            // Testing Calendar Event
            CalEvent e = new CalEvent();

            e.SetLocation("Brussels");
            e.SetTitle("Meeting with Zosha");

            e.SetRecurring(true);
            e.SetStartDate(new DateTime(2019, 12, 12));
            e.SetEndDate(new DateTime(2020, 01, 01));
            e.InitNullValues();
            // String[]  arr  ={ "Tuesday", "Monday", "Sunday" };

            e.SetRecurringType("Friday");
            var dates = e.GetDates();

            StringBuilder str = new StringBuilder();

            foreach (var item in dates)
            {
                Console.WriteLine(item.ToString());
                str.Append(item + "\n");
            }
            MessageBox.Show(str.ToString());

            return(e);
        }
Exemplo n.º 2
0
        public static ArrayList GetEventsList()
        {
            CreateEventsXml();
            lock (ContactsDirLock)
            {
                lock (EventsDirLock)
                {
                    eventsList = new ArrayList();

                    XDocument doc = XDocument.Load(EventsDir);
                    IEnumerable <XElement> enumEvents = doc.Elements("Events").Elements();


                    DateTime dateStart;
                    DateTime dateEnd;
                    bool     appointment;
                    bool     recurring;
                    //ArrayList recurringType;
                    Contact person;
                    int     cId;
                    string  cName, cSName, cAddr1, cAddr2, cLoc;
                    int     eId = 0;

                    foreach (var xmlEvents in enumEvents)
                    {
                        CalEvent ev = new CalEvent();

                        ev.SetId(eId);
                        eId++;
                        String format = (xmlEvents.Element("dateStart").Value);
                        dateStart = Convert.ToDateTime(format);
                        format    = (xmlEvents.Element("dateEnd").Value);
                        dateEnd   = Convert.ToDateTime(format);
                        ev.SetStartDate(dateStart);
                        ev.SetEndDate(dateEnd);

                        //dateStart = XmlConvert.ToDateTime(xmlEvents.Element("dateStart").Value);
                        Console.WriteLine(dateStart.ToString());
                        //dateStart = new DateTime((xmlEvents.Element("dateStart").Value).ToString());
                        //ev.SetStartDate(xmlEvents.Element("dateStart").Value);
                        //ev.SetEndDate(xmlEvents.Element("dateEnd").Value);
                        ev.SetTitle(xmlEvents.Element("title").Value);
                        if ((xmlEvents.Element("appointment").Value) == "False")
                        {
                            appointment = false;
                        }
                        else
                        {
                            appointment = true;
                        }
                        ev.SetAppointment(appointment);

                        if ((xmlEvents.Element("recurring").Value) == "False")
                        {
                            recurring = false;
                        }
                        else
                        {
                            recurring = true;
                        }
                        ev.SetRecurring(recurring);
                        //MessageBox.Show(recurring.ToString());
                        //MessageBox.Show(ev.IsRecurring().ToString());

                        //MessageBox.Show(xmlEvents.Element("recurringType").Value);
                        if (recurring)
                        {
                            string   recLong = xmlEvents.Element("recurringType").Value;
                            string[] recType = recLong.Split(',');
                            ev.SetRecurringType(recType);
                        }
                        else if (xmlEvents.Element("recurringType").Value == "NIL")
                        {
                            ev.SetRecurringType("NIL");
                        }
                        else if (ev.IsRecurring() && ev.GetRecurringTypeString().Contains("Weekly"))
                        {
                            ev.SetRecurring(true);
                            ev.SetRecurringType("Weekly");
                        }

                        else
                        {
                            MessageBox.Show("Something is wrong with recType: XmlControl.GetEventsList()");
                        }
                        //MessageBox.Show(ev.ToString());

                        cId    = int.Parse(xmlEvents.Element("person").Element("id").Value);
                        cName  = (xmlEvents.Element("person").Element("name").Value);
                        cSName = (xmlEvents.Element("person").Element("surname").Value);
                        cAddr1 = (xmlEvents.Element("person").Element("address1").Value);
                        cAddr2 = (xmlEvents.Element("person").Element("address2").Value);
                        cLoc   = (xmlEvents.Element("person").Element("postcode").Value);
                        Contact contact = new Contact(cName, cSName, cAddr1, cAddr2, cLoc);
                        contact.SetId(cId);

                        person = contact;
                        ev.SetContact(person);

                        ev.SetLocation(xmlEvents.Element("postcode").Value);
                        eventsList.Add(ev);
                    }
                }
            }

            return(eventsList);
        }