Пример #1
0
        private static void AddEventThread(CalEvent cEvent)
        {
            lock (EventsDirLock)
            {
                lock (ContactsDirLock)
                {
                    CreateEventsXml();
                    cEvent.InitNullValues();
                    string concatenated = string.Join(",",
                                                      cEvent.GetRecurringType().Select(x => x.ToString()).ToArray());

                    XDocument doc;
                    doc = XDocument.Load(EventsDir);
                    string person;
                    if (cEvent.IsAppointment())
                    {
                        person = cEvent.GetContact().ToString();
                    }
                    else
                    {
                        person = "NIL";
                    }

                    //int cId = GetContactId(cEvent.GetContact());
                    //MessageBox.Show(cEvent.ToString() + "xmlAddEvent");
                    doc.Element("Events").Add(new XElement("event",
                                                           new XElement("dateStart", new XText(cEvent.GetStartDate().ToString())),
                                                           new XElement("dateEnd", new XText(cEvent.GetEndDate().ToString())),
                                                           new XElement("title", new XText(cEvent.GetTitle())),
                                                           new XElement("appointment", new XText(cEvent.IsAppointment().ToString())),
                                                           new XElement("recurring", new XText(cEvent.IsRecurring().ToString())),
                                                           new XElement("recurringType", new XText(concatenated)),
                                                           new XElement("person",
                                                                        new XElement("id", new XText(cEvent.GetContact().GetId().ToString())),
                                                                        new XElement("name", new XText(cEvent.GetContact().FName)),
                                                                        new XElement("surname", new XText(cEvent.GetContact().SName)),
                                                                        new XElement("address1", new XText(cEvent.GetContact().Address1)),
                                                                        new XElement("address2", new XText(cEvent.GetContact().Address2)),
                                                                        new XElement("postcode", new XText(cEvent.GetContact().Postcode))),
                                                           new XElement("postcode", new XText(cEvent.GetLocation().ToString()))
                                                           ));
                    doc.Save(EventsDir);
                }
            }
        }