Beispiel #1
0
        public void googlecalendarSMSreminder(string sendstring)
        {
            CalendarService service = new CalendarService("exampleCo-exampleApp-1");
            service.setUserCredentials(UserName.Text, Password.Text);

            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = sendstring;
            entry.Content.Content = "Nadpis Test SMS.";
            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "Test sms";
            entry.Locations.Add(eventLocation);

            When eventTime = new When(DateTime.Now.AddMinutes(3), DateTime.Now.AddHours(1));
            entry.Times.Add(eventTime);

            //Add SMS Reminder
            Reminder fiftyMinReminder = new Reminder();
            fiftyMinReminder.Minutes = 1;
            fiftyMinReminder.Method = Reminder.ReminderMethod.sms;
            entry.Reminders.Add(fiftyMinReminder);

            Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");

            // Send the request and receive the response:
            AtomEntry insertedEntry = service.Insert(postUri, entry);
        }
Beispiel #2
0
 /// <summary>
 /// Constructs a new EventEntry instance with provided data.
 /// </summary>
 /// <param name="title">The descriptive title of the event ("What" in the UI)</param>
 /// <param name="description">A longer description of the event 
 /// ("Description" in the UI)</param>
 /// <param name="location">The location of the event ("Where" in the UI)</param>
 public EventEntry(string title, string description, string location)
     : this(title, description)
 {
     Where eventLocation = new Where();
     eventLocation.ValueString = location;
     this.Locations.Add(eventLocation);
     
 }
        //add an event to google calendar
        public static void addEvent(Appointment appt)
        {
            if (authenticated == true) {

                Dictionary<int, string> insertedId = new Dictionary<int, string>();

                //create new thread for add event
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += delegate(object s, DoWorkEventArgs args) {
                    try {
                        //add event to Google Calendar
                        EventEntry entry = new EventEntry();

                        // Set the title and content of the entry.
                        entry.Title.Text = appt.Subject;
                        entry.Content.Content = appt.Note;

                        // Set a location for the event.
                        Where eventLocation = new Where();
                        eventLocation.ValueString = appt.Location;
                        entry.Locations.Add(eventLocation);

                        When eventTime = new When(appt.StartDate, appt.EndDate);
                        entry.Times.Add(eventTime);

                        lock (threadLock) {
                            EventEntry insertedEntry = service.Insert(postUri, entry);
                            eventIDs.Add(appt.AppointmentId, insertedEntry.EventId);
                            insertedId.Add(appt.AppointmentId, insertedEntry.EventId);
                        }
                    }
                    catch (Exception e) {
                        Util.logError("Google Calendar Error: " + e.Message);
                    }
                };

                bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) {
                    foreach (int apptId in insertedId.Keys) {
                        Database.modifyDatabase("UPDATE Event SET GoogleEventID = '" + insertedId[apptId] + "' WHERE EventID = '" + apptId + "';");
                    }
                };

                //start the thread
                bw.RunWorkerAsync();
            }
        }
        /// <summary>
        /// Creates a google calendar event
        /// </summary>
        public void CreateEvent(CalendarEvent cEvent)
        {
            EventEntry entry = new EventEntry();

            entry.Title.Text = cEvent.Subject;
            entry.Content.Content = cEvent.Body;

            ExtendedProperty property = new ExtendedProperty();
            property.Name = syncExtendedParameterName;
            property.Value = cEvent.Id;
            entry.ExtensionElements.Add(property);

            Where eventLocation = new Where();
            eventLocation.ValueString = cEvent.Location;
            entry.Locations.Add(eventLocation);

            When eventTime = new When(cEvent.StartDate, cEvent.EndDate);
            entry.Times.Add(eventTime);

            Uri postUri = new Uri(string.Format(calendarUrl, this.calendarId));

            AtomEntry insertedEntry = this.calService.Insert(postUri, entry);
        }
        public void send(string info)
        {
            EventEntry entry = new EventEntry();
            entry.Title.Text = "iPhone4 开卖状况改变";
            entry.Content.Content = info;

            Where eventLocation = new Where();
            eventLocation.ValueString = "Apple Store";
            entry.Locations.Add(eventLocation);

            When eventTime = new When(DateTime.Now.AddMinutes(2), DateTime.Now.AddMinutes(30));
            entry.Times.Add(eventTime);

            Reminder reminder = new Reminder();
            reminder.Minutes = 1;
            reminder.Method = Reminder.ReminderMethod.all;

            entry.Reminders.Add(reminder);

            Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");

            AtomEntry insertedEntry = svc.Insert(postUri, entry);
        }
Beispiel #6
0
 /// <summary>standard typed add method </summary>
 public int Add(Where value)
 {
     return base.Add(value);
 }
Beispiel #7
0
        private static EventEntry InsertEvent(EventFeed feed, String title, 
            String author, DateTime startTime, DateTime endTime, bool fAllDay,
            String place)
        {
            EventEntry entry = new EventEntry();

            entry.Title = new AtomTextConstruct(
                                AtomTextConstructElementType.Title, 
                                title);
            entry.Authors.Add(new AtomPerson(AtomPersonType.Author, author));
            entry.Published = DateTime.Now;
            entry.Updated = DateTime.Now;


            Where newPlace = new Where();
            newPlace.ValueString = place;
            entry.Locations.Add(newPlace);

            When newTime = new When();
            newTime.StartTime = startTime;
            newTime.EndTime = endTime;
            newTime.AllDay = fAllDay; 
            entry.Times.Add(newTime);

            return feed.Insert(entry) as EventEntry;
        }
        public static void AddEvent(CalendarService service, string title, string contents, string location, DateTime startTime, DateTime endTime)
        {
            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = title;
            entry.Content.Content = contents;

            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = location;
            entry.Locations.Add(eventLocation);

            When eventTime = new When(startTime, endTime);
            entry.Times.Add(eventTime);

            Uri postUri = new Uri
            ("http://www.google.com/calendar/feeds/default/private/full");

            // Send the request and receive the response:
            AtomEntry insertedEntry = service.Insert(postUri, entry);
        }  
        public static void AddMenuButton()
        {
            var accessHelper = new FISCA.UDT.AccessHelper();
            var ribbonBarItem = K12.Presentation.NLDPanels.Course.RibbonBarItems["課程行事曆"];
            var syncButton = ribbonBarItem["同步行事曆"];

            Catalog button_syncCalendar = RoleAclSource.Instance["課程"]["功能按鈕"];
            button_syncCalendar.Add(new RibbonFeature("Sync_Course_Calendar", "同步課程行事曆"));
            bool isEnabled = UserAcl.Current["Sync_Course_Calendar"].Executable;

            syncButton.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0) && isEnabled);
            K12.Presentation.NLDPanels.Course.SelectedSourceChanged += delegate(object sender, EventArgs e)
            {

                syncButton.Enable = ((K12.Presentation.NLDPanels.Course.SelectedSource.Count > 0) && isEnabled);
            };
            syncButton.Click += delegate
            {
                bool hasFaild = false;
                FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆同步中...", 0);
                List<string> selectedSource = new List<string>(K12.Presentation.NLDPanels.Course.SelectedSource);
                BackgroundWorker bkw = new System.ComponentModel.BackgroundWorker() { WorkerReportsProgress = true };
                bkw.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
                {
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆同步中...", e.ProgressPercentage);
                };
                bkw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    SectionSyncColumn.Reload();
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("課程行事曆同步完成");
                    if (hasFaild)
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("課程行事曆同步完成,其中部分資料同步失敗,請稍後再試。");
                    }
                };
                bkw.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    Dictionary<string, Calendar> calendars = new Dictionary<string, Calendar>();
                    Dictionary<string, List<string>> courseAttend = new Dictionary<string, List<string>>();
                    Dictionary<string, List<Section>> publishItems = new Dictionary<string, List<Section>>();
                    Dictionary<string, string> studentLoginAccount = new Dictionary<string, string>();
                    List<string> syncCourses = new List<string>();
                    int count = 0;
                    string condition = "RefCourseID in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition != "RefCourseID in (")
                            condition += ",";
                        condition += "'" + key + "'";
                    }
                    condition += ")";
                    string condition2 = "ref_course_id in (";
                    foreach (string key in selectedSource)
                    {
                        if (condition2 != "ref_course_id in (")
                            condition2 += ",";
                        condition2 += "'" + key + "'";
                    }
                    condition2 += ")";
                    bkw.ReportProgress(3);
                    foreach (Section section in accessHelper.Select<Section>(condition))
                    {
                        if (!section.IsPublished || section.Removed)
                        {
                            if (!publishItems.ContainsKey(section.RefCourseID))
                                publishItems.Add(section.RefCourseID, new List<Section>());
                            publishItems[section.RefCourseID].Add(section);
                            count++;
                        }
                    }
                    foreach (Calendar cal in accessHelper.Select<Calendar>(condition))
                    {
                        if (!calendars.ContainsKey(cal.RefCourseID))
                            calendars.Add(cal.RefCourseID, cal);
                    }
                    syncCourses.AddRange(publishItems.Keys);
                    foreach (var item in accessHelper.Select<SCAttendExt>(condition2))
                    {
                        if (!courseAttend.ContainsKey(item.CourseID.ToString()))
                            courseAttend.Add(item.CourseID.ToString(), new List<string>());
                        courseAttend[item.CourseID.ToString()].Add(item.StudentID.ToString());
                        if (!studentLoginAccount.ContainsKey(item.StudentID.ToString()))
                            studentLoginAccount.Add(item.StudentID.ToString(), "");
                        count++;
                    }
                    foreach (string key in selectedSource)
                    {
                        if (!courseAttend.ContainsKey(key))
                            courseAttend.Add(key, new List<string>());
                    }
                    foreach (var student in K12.Data.Student.SelectByIDs(studentLoginAccount.Keys))
                    {
                        if (student.SALoginName != "")
                        {
                            studentLoginAccount[student.ID] = student.SALoginName.ToLower();
                        }
                    }
                    foreach (string calid in courseAttend.Keys)
                    {
                        if (calendars.ContainsKey(calid))
                        {
                            Calendar cal = calendars[calid];
                            List<string> aclList = new List<string>(cal.ACLList.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                            List<string> attentAccounts = new List<string>();
                            foreach (string sid in courseAttend[calid])
                            {
                                if (studentLoginAccount[sid] != "")
                                    attentAccounts.Add(studentLoginAccount[sid]);
                            }
                            if (aclList.Count != attentAccounts.Count)
                            {
                                if (!syncCourses.Contains(calid))
                                    syncCourses.Add(calid);
                            }
                            else
                            {
                                foreach (string acc in aclList)
                                {
                                    if (!attentAccounts.Contains(acc.ToLower()))
                                    {
                                        if (!syncCourses.Contains(calid))
                                            syncCourses.Add(calid);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    bkw.ReportProgress(5);
                    CalendarService myService = new CalendarService("ischool.CourseCalendar");
                    myService.setUserCredentials(googleAcc, googlePWD);
                    bkw.ReportProgress(20);
                    List<Section> syncedSections = new List<Section>();
                    foreach (K12.Data.CourseRecord course in K12.Data.Course.SelectByIDs(syncCourses))
                    {
                        //CalendarEntry targetCalender = null;
                        Calendar targetCal = null;
                        try
                        {
                            if (!calendars.ContainsKey(course.ID))
                            {
                                #region 建立新Calender
                                string[] colorLists = new string[]{"#A32929","#B1365F","#7A367A","#5229A3","#29527A","#2952A3","#1B887A",
                            "#28754E","#0D7813","#528800","#88880E","#AB8B00","#BE6D00","#B1440E",
                            "#865A5A","#705770","#4E5D6C","#5A6986","#4A716C","#6E6E41","#8D6F47"};
                                CalendarEntry newCal = new CalendarEntry();
                                newCal.Title.Text = course.Name;
                                newCal.Summary.Text = "科目:" + course.Subject
                                    + "\n學年度:" + course.SchoolYear
                                    + "\n學期:" + course.Semester
                                    + "\n學分數:" + course.Credit;
                                newCal.TimeZone = "Asia/Taipei";
                                //targetCalender.Hidden = false;
                                newCal.Color = colorLists[new Random(DateTime.Now.Millisecond).Next(0, colorLists.Length)];
                                Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full");
                                newCal = (CalendarEntry)myService.Insert(postUri, newCal);
                                #endregion
                                String calendarURI = newCal.Id.Uri.ToString();
                                String calendarID = calendarURI.Substring(calendarURI.LastIndexOf("/") + 1);
                                targetCal = new Calendar() { RefCourseID = course.ID, GoogleCalanderID = calendarID };
                                targetCal.Save();
                            }
                            else
                            {
                                targetCal = calendars[course.ID];
                            }
                        }
                        catch
                        {
                            hasFaild = true;
                        }
                        if (targetCal != null)
                        {
                            try
                            {
                                #region ACL
                                if (courseAttend.ContainsKey(course.ID))
                                {
                                    List<string> aclList = new List<string>(targetCal.ACLList.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                                    for (int i = 0; i < aclList.Count; i++)
                                    {
                                        aclList[i] = aclList[i].ToLower();
                                    }
                                    List<string> attentAccounts = new List<string>();
                                    foreach (string sid in courseAttend[course.ID])
                                    {
                                        if (studentLoginAccount[sid] != "")
                                            attentAccounts.Add(studentLoginAccount[sid]);
                                    }
                                    foreach (string acc in attentAccounts)
                                    {
                                        if (!aclList.Contains(acc))
                                        {
                                            try
                                            {
                                                #region 新增分享
                                                AclEntry entry = new AclEntry();
                                                entry.Scope = new AclScope();
                                                entry.Scope.Type = AclScope.SCOPE_USER;
                                                entry.Scope.Value = acc;
                                                entry.Role = AclRole.ACL_CALENDAR_READ;
                                                try
                                                {
                                                    AclEntry insertedEntry = myService.Insert(new Uri("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/acl/full"), entry);
                                                }
                                                catch (GDataRequestException gex)
                                                {
                                                    if (!gex.InnerException.Message.Contains("(409)"))
                                                        throw;
                                                }
                                                #endregion
                                                aclList.Add(acc);
                                            }
                                            catch
                                            {
                                                hasFaild = true;
                                            }
                                        }
                                    }
                                    List<string> removeList = new List<string>();
                                    if (aclList.Count != attentAccounts.Count)
                                    {
                                        #region 移除分享
                                        AtomFeed calFeed = myService.Query(new FeedQuery("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/acl/full"));
                                        foreach (string acc in aclList)
                                        {
                                            if (!attentAccounts.Contains(acc))
                                            {
                                                try
                                                {
                                                    foreach (AtomEntry atomEntry in calFeed.Entries)
                                                    {
                                                        if (atomEntry is AtomEntry)
                                                        {
                                                            AclEntry aclEntry = (AclEntry)atomEntry;
                                                            if (aclEntry.Scope.Value.ToLower() == acc)
                                                            {
                                                                aclEntry.Delete();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    removeList.Add(acc);
                                                }
                                                catch
                                                {
                                                    hasFaild = true;
                                                }
                                            }
                                        }
                                        #endregion
                                    }
                                    foreach (string acc in removeList)
                                    {
                                        if (aclList.Contains(acc)) aclList.Remove(acc);
                                    }
                                    targetCal.ACLList = "";
                                    foreach (string acc in aclList)
                                    {
                                        targetCal.ACLList += (targetCal.ACLList == "" ? "" : "%") + acc;
                                    }
                                }
                                #endregion
                                #region Events
                                if (publishItems.ContainsKey(course.ID))
                                {
                                    EventFeed feed = myService.Query(new EventQuery("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/private/full"));
                                    AtomFeed batchFeed = new AtomFeed(feed);
                                    foreach (Section section in publishItems[course.ID])
                                    {
                                        if (!section.Removed)
                                        {
                                            #region 新增Event
                                            Google.GData.Calendar.EventEntry eventEntry = new Google.GData.Calendar.EventEntry();

                                            eventEntry.Title.Text = course.Name;
                                            //eventEntry
                                            Where eventLocation = new Where();
                                            eventLocation.ValueString = section.Place;
                                            eventEntry.Locations.Add(eventLocation);
                                            eventEntry.Notifications = true;
                                            eventEntry.Times.Add(new When(section.StartTime, section.EndTime));
                                            eventEntry.Participants.Add(new Who()
                                            {
                                                ValueString = googleAcc,
                                                Attendee_Type = new Who.AttendeeType() { Value = Who.AttendeeType.EVENT_REQUIRED },
                                                Attendee_Status = new Who.AttendeeStatus() { Value = Who.AttendeeStatus.EVENT_ACCEPTED },
                                                Rel = Who.RelType.EVENT_ATTENDEE
                                            });
                                            eventEntry.BatchData = new GDataBatchEntryData(section.UID, GDataBatchOperationType.insert);
                                            batchFeed.Entries.Add(eventEntry);
                                            #endregion
                                        }
                                        else
                                        {
                                            #region 刪除Event

                                            EventEntry toDelete = (EventEntry)feed.Entries.FindById(new AtomId(feed.Id.AbsoluteUri + "/" + section.EventID));
                                            if (toDelete != null)
                                            {
                                                toDelete.Id = new AtomId(toDelete.EditUri.ToString());
                                                toDelete.BatchData = new GDataBatchEntryData(section.UID, GDataBatchOperationType.delete);
                                                batchFeed.Entries.Add(toDelete);
                                            }
                                            else
                                            {
                                                section.Deleted = true;
                                                syncedSections.Add(section);
                                            }
                                            #endregion
                                        }
                                        int p = syncedSections.Count * 80 / count + 20;
                                        if (p > 100) p = 100;
                                        if (p < 0) p = 0;
                                        bkw.ReportProgress(p);
                                    }
                                    EventFeed batchResultFeed = (EventFeed)myService.Batch(batchFeed, new Uri(feed.Batch));
                                    foreach (Section section in publishItems[course.ID])
                                    {
                                        if (syncedSections.Contains(section)) continue;
                                        #region 儲存Section狀態
                                        bool match = false;
                                        if (section.Removed)
                                        {
                                            foreach (EventEntry entry in batchResultFeed.Entries)
                                            {
                                                if (entry.BatchData.Status.Code == 200)
                                                {
                                                    if (section.UID == entry.BatchData.Id)
                                                    {
                                                        section.Deleted = true;
                                                        match = true;
                                                        syncedSections.Add(section);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            foreach (EventEntry entry in batchResultFeed.Entries)
                                            {
                                                if (entry.BatchData.Status.Code == 201)
                                                {
                                                    if (section.UID == entry.BatchData.Id)
                                                    {
                                                        section.IsPublished = true;
                                                        match = true;
                                                        section.EventID = entry.EventId;
                                                        syncedSections.Add(section);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        if (!match)
                                            hasFaild = true;
                                        #endregion
                                    }
                                }
                                #endregion
                            }
                            catch
                            {
                                hasFaild = true;
                            }
                            targetCal.Save();
                        }
                    }
                    syncedSections.SaveAll();
                };
                bkw.RunWorkerAsync();
            };
        }
Beispiel #10
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static EventEntry CreateEventEntry(int iCount)
        {
            EventEntry entry = new EventEntry();
            // some unicode chars
            Char[] chars = new Char[] {
                                          '\u0023', // #
                                          '\u0025', // %
                                          '\u03a0', // Pi
                                          '\u03a3',  // Sigma
                                          '\u03d1', // beta
            };

            // if unicode needs to be disabled for testing, just uncomment this line
            // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'}; 

    
    
            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3]; 
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);
    
            AtomCategory cat = new AtomCategory();
    
            cat.Label = "Default";
            cat.Term = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);
    
            entry.Content.Content = "this is the default text entry";
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);  
            entry.Title.Text = "This is a entry number: " + iCount;
            entry.Updated = DateTime.Now; 

            When newTime = new When();
            newTime.StartTime = DateTime.Today.AddDays(-3);
            newTime.EndTime = DateTime.Today.AddDays(1);
            entry.Times.Add(newTime);


            entry.Reminder = new Reminder();
            entry.Reminder.Minutes = DEFAULT_REMINDER_TIME; 

            Who someone = new Who();
            someone.ValueString = "*****@*****.**";
            Who.AttendeeStatus status = new Who.AttendeeStatus();
            status.Value = "event.accepted"; 
            someone.Attendee_Status = status;
            someone.Rel = "http://schemas.google.com/g/2005#event.organizer";

            entry.Participants.Add(someone);


            Where newPlace = new Where();
            newPlace.ValueString = "A really nice place";
            entry.Locations.Add(newPlace);
            newPlace = new Where();
            newPlace.ValueString = "Another really nice place";
            newPlace.Rel = Where.RelType.EVENT_ALTERNATE;
            entry.Locations.Add(newPlace);
            return entry;
        }
        private void AddItem(CalendarItem calendarItem)
        {
            var entry = new EventEntry(calendarItem.Title);
            var w = new Where {ValueString = calendarItem.Location};
            var eventTime = new When(calendarItem.Start, calendarItem.End);
            entry.Times.Add(eventTime);
            entry.Locations.Add(w);
            entry.EventVisibility = calendarItem.IsPrivateItem ? EventEntry.Visibility.CONFIDENTIAL : EventEntry.Visibility.PUBLIC;
            CalendarService calendarService = Service;

            calendarService.Insert(new Uri(GOOGLE_CALENDAR_URI), entry);
        }
Beispiel #12
0
        public void googlecalendarSMSreminder(string sendstring)
        {
            CalendarService service = new CalendarService("exampleCo-exampleApp-1");
            service.setUserCredentials("*****@*****.**", "joneson55");

            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = sendstring;
            entry.Content.Content = "Lockerz Login Page Check.";
            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "Lockerz Login";
            entry.Locations.Add(eventLocation);

            When eventTime = new When(DateTime.Now.AddMinutes(3), DateTime.Now.AddHours(1));
            entry.Times.Add(eventTime);

            if (checkBox1.Checked == true)  //Reminder ON/OFF
            {
                //Add SMS Reminder
                Reminder fiftyMinReminder = new Reminder();
                fiftyMinReminder.Minutes = 1;
                fiftyMinReminder.Method = Reminder.ReminderMethod.sms;
                entry.Reminders.Add(fiftyMinReminder);
            }
            else
            {
            }

            Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");

            // Send the request and receive the response:
            AtomEntry insertedEntry = service.Insert(postUri, entry);
        }
Beispiel #13
0
 /// <summary>standard typed remove method </summary>
 public void Remove(Where value)
 {
     base.Remove(value);
 }
Beispiel #14
0
 /// <summary>standard typed indexOf method </summary>
 public int IndexOf(Where value)
 {
     return (List.IndexOf(value));
 }
        public static void updateEvent(Appointment newAppt)
        {
            if (authenticated == true) {

                //create new thread for updating event
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += delegate(object s, DoWorkEventArgs args) {
                    lock (threadLock) {
                        try {
                            if (eventIDs.ContainsKey(newAppt.AppointmentId) == false) {
                                return;
                            }

                            EventQuery myQuery = new EventQuery(postUri.ToString() + "/" + eventIDs[newAppt.AppointmentId]);
                            EventFeed resultFeed = (EventFeed)service.Query(myQuery);

                            //only update if an event is found
                            if (resultFeed.Entries.Count > 0) {
                                EventEntry calendar = (EventEntry)resultFeed.Entries[0];
                                calendar.Title.Text = newAppt.Subject;
                                calendar.Content.Content = newAppt.Note;
                                calendar.Locations.Clear();

                                Where eventLocation = new Where();
                                eventLocation.ValueString = newAppt.Location;
                                calendar.Locations.Add(eventLocation);

                                When eventTime = new When(newAppt.StartDate, newAppt.EndDate);
                                calendar.Times.Clear();
                                calendar.Times.Add(eventTime);

                                calendar.Update();
                            }
                        }

                        catch (Exception e) {
                            Util.logError("Google Calendar Error: " + e.Message);
                        }
                    }
                };

                //start the thread
                bw.RunWorkerAsync();
            }
        }
        /// <summary>
        /// Update a calendar event
        /// </summary>
        public void UpdateEvent(CalendarEvent cEvent)
        {
            EventQuery query = new EventQuery(string.Format(calendarUrl, this.calendarId));
            query.ExtraParameters = string.Format("extq=[{1}:{0}]", cEvent.Id, syncExtendedParameterName);
            EventFeed myResultsFeed = this.calService.Query(query);
            if (myResultsFeed.Entries.Count == 1)
            {
                EventEntry firstMatchEntry = (EventEntry)myResultsFeed.Entries[0];
                firstMatchEntry.Content.Content = cEvent.Body;
                firstMatchEntry.Title.Text = cEvent.Subject;

                Where eventLocation = new Where();
                eventLocation.ValueString = cEvent.Location;
                firstMatchEntry.Locations.Clear();
                firstMatchEntry.Locations.Add(eventLocation);

                When eventTime = new When(cEvent.StartDate, cEvent.EndDate);
                firstMatchEntry.Times.Clear();
                firstMatchEntry.Times.Add(eventTime);

                this.calService.Update(firstMatchEntry);
            }
            else if (myResultsFeed.Entries.Count > 1)
            {
                throw new Exception("UpdateEvent: Found more then one event with the given id.");
            }
        }
        /// <summary>
        /// Translates a Microsoft® Project task into a Google® Data API CalendarEntry for Google® Calendar.
        /// </summary>
        /// <param name="task">Microsoft® Project task instance.</param>
        /// <returns>A new EventEntry from Google® Data API.</returns>
        protected EventEntry translateProjectTaskToCalendarEntry(Task task)
        {
            //create EventEntry for Google® API
            EventEntry eventEntry = new EventEntry();

            //assign title to EventEntry from Microsoft® Project Task name
            eventEntry.Title.Text = task.getName();
            eventEntry.Content.Content = task.getName();

            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "Microsoft® Project";
            eventEntry.Locations.Add(eventLocation);

            //create When object for Google® API
            When dateTime = new When();

            //write these down
            java.util.Date taskStart = task.getStart();
            java.util.Date taskFinish = task.getFinish();

            //now split them up
            string[] taskStartComponents = new string[] { };
            if (taskStart != null) taskStartComponents = taskStart.toString().Split(new char[] { ' ', ':' }, StringSplitOptions.RemoveEmptyEntries);
            string[] taskFinishComponents = new string[] { };
            if (taskFinish != null) taskFinishComponents = taskFinish.toString().Split(new char[] { ' ', ':' }, StringSplitOptions.RemoveEmptyEntries);

            //now convert them from Java to .Net and tell Google®'s When what's up
            if (taskStart != null) dateTime.StartTime = DateTime.ParseExact(
                taskStartComponents[7] + " " + //year
                taskStartComponents[1] + " " + //month
                taskStartComponents[2],
                "yyyy MMM dd", System.Globalization.CultureInfo.InvariantCulture
                );
            if (taskFinish != null) dateTime.EndTime = DateTime.ParseExact(
                taskFinishComponents[7] + " " + //year
                taskFinishComponents[1] + " " + //month
                taskFinishComponents[2],
                "yyyy MMM dd", System.Globalization.CultureInfo.InvariantCulture
                );

            //add the When to the event entry
            eventEntry.Times.Add(dateTime);

            //return the EventEntry
            return eventEntry;
        }
Beispiel #18
0
 /// <summary>standard typed insert method </summary>
 public void Insert(int index, Where value)
 {
     base.Insert(index, value);
     
 }
        private static string addEvent(string calID)
        {
            string result = "";
            #region 新增Event
            {
                CalendarService myService = new CalendarService("ischool.CourseCalendar");
                myService.setUserCredentials(googleAcc, googlePWD);
                EventFeed feed = myService.Query(new EventQuery("https://www.google.com/calendar/feeds/" + calID + "/private/full"));
                AtomFeed batchFeed = new AtomFeed(feed);
                Google.GData.Calendar.EventEntry eventEntry = new Google.GData.Calendar.EventEntry();

                eventEntry.Title.Text = "TEST";
                //eventEntry
                Where eventLocation = new Where();
                eventLocation.ValueString = "地點";
                eventEntry.Locations.Add(eventLocation);
                eventEntry.Notifications = true;
                eventEntry.Times.Add(new When(DateTime.Parse("2012/4/5 15:00"), DateTime.Parse("2012/4/5 17:00")));
                eventEntry.Participants.Add(new Who()
                {
                    ValueString = googleAcc,
                    Attendee_Type = new Who.AttendeeType() { Value = Who.AttendeeType.EVENT_REQUIRED },
                    Attendee_Status = new Who.AttendeeStatus() { Value = Who.AttendeeStatus.EVENT_ACCEPTED },
                    Rel = Who.RelType.EVENT_ATTENDEE
                });
                eventEntry.BatchData = new GDataBatchEntryData("TEST", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(eventEntry);
                EventFeed batchResultFeed = (EventFeed)myService.Batch(batchFeed, new Uri(feed.Batch));
                foreach (EventEntry entry in batchResultFeed.Entries)
                {
                    if (entry.BatchData.Status.Code == 201)
                    {
                        result = entry.EventId;
                        break;

                    }
                }
            }
            #endregion
            return result;
        }
Beispiel #20
0
 /// <summary>standard typed Contains method </summary>
 public bool Contains(Where value)
 {
     // If value is not of type AtomEntry, this will return false.
     return (List.Contains(value));
 }
Beispiel #21
0
        /// <summary>
        /// Sets the contents of an entry from a row of the table.
        /// </summary>
        /// <param name='entry'>
        /// The EventEntry to modify
        /// </param>
        /// <param name='row'>
        /// The row number in which the data sits.
        /// </param>
        protected void CnvtRowToEntry(EventEntry entry, int row)
        {
            DateTime start;
            DateTime end;
            const int DateStartColumnIndex = 0;
            const int TimeStartColumnIndex = 1;
            const int TitleColumnIndex = 2;
            const int TimeEndColumnIndex = 3;
            const int PlaceColumnIndex = 4;
            string timeSeparator = CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator;
            string dateStart = "";
            string timeStart = "";
            string timeEnd = "";

            // Prepare time information
            entry.Times.Clear();
            entry.Locations.Clear();

            try {
                dateStart = ( (string) this.grdEventsList.Rows[ row ].Cells[ DateStartColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                throw new FormatException( StringsL18n.Get( StringsL18n.StringId.ErStartDateMissing ) );
            }

            try {
                timeStart = ( (string) this.grdEventsList.Rows[ row ].Cells[ TimeStartColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                throw new FormatException( StringsL18n.Get( StringsL18n.StringId.ErStartDateMissing ) );
            }

            try {
                timeEnd = ( (string) this.grdEventsList.Rows[ row ].Cells[ TimeEndColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                timeEnd = timeStart;
            }

            // Prepare times
            timeEnd = timeEnd.Trim();
            timeStart = timeStart.Trim();

            if ( timeStart.ToLower().EndsWith( GCalFramework.EtqHourMark ) ) {
                timeStart = timeStart.Substring( 0, timeStart.Length -1 ) + timeSeparator + "00";
            }

            if ( timeEnd.ToLower().EndsWith( GCalFramework.EtqHourMark ) ) {
                timeEnd = timeEnd.Substring( 0, timeEnd.Length -1 ) + timeSeparator + "00";
            }

            // Set start/end date/time
            timeEnd = dateStart + ' ' + timeEnd;
            dateStart = dateStart + ' ' + timeStart;

            try {
                start = DateTime.Parse( dateStart, CultureInfo.CurrentCulture.DateTimeFormat  );
            } catch(FormatException exc) {
                throw new FormatException( StringsL18n.Get( StringsL18n.StringId.ErParsingStartTime )
                    + ": " + exc.Message );
            }

            try {
                end = DateTime.Parse( timeEnd, CultureInfo.CurrentCulture.DateTimeFormat  );
            } catch(FormatException)
            {
                // Adapt the end time by one hour from the start
                end = start.AddHours( 1 );
            }

            // Set times
            if ( start == end ) {
                end = start.AddHours( 1 );
            }

            var eventTime = new When( start, end );
            entry.Times.Add( eventTime );

            // Set title
            try {
                entry.Title.Text = ( (string) this.grdEventsList.Rows[ row ].Cells[ TitleColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                entry.Title.Text = GCalFramework.EtqNotAvailable;
            }

            if ( entry.Title.Text.Trim().Length == 0 ) {
                entry.Title.Text = GCalFramework.EtqNotAvailable;
            }

            // Set place
            string strPlace = null;
            try {
                strPlace = ( (string) this.grdEventsList.Rows[ row ].Cells[ PlaceColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                strPlace = GCalFramework.EtqNotAvailable;
            }

            if ( strPlace.Trim().Length == 0 ) {
                entry.Title.Text = GCalFramework.EtqNotAvailable;
            }

            var eventLocation = new Where();
            eventLocation.ValueString = strPlace;
            entry.Locations.Add( eventLocation );

            // Set alarm
            Reminder reminder = new Reminder();
            reminder.Minutes = 30;
            reminder.Method = Reminder.ReminderMethod.all;
            entry.Reminder = reminder;

            return;
        }
Beispiel #22
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Where  object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Where  object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            Where where = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace))
                {
                    return null;
                }
            }

            where = new Where();
            if (node != null) {

                if (node.Attributes != null)
                {
                    if (node.Attributes[GDataParserNameTable.XmlAttributeRel] != null)
                    {
                        where.Rel = node.Attributes[GDataParserNameTable.XmlAttributeRel].Value;
                    }
    
                    if (node.Attributes[GDataParserNameTable.XmlAttributeLabel] != null)
                    {
                        where.Label = node.Attributes[GDataParserNameTable.XmlAttributeLabel].Value;
                    }
    
                    if (node.Attributes[GDataParserNameTable.XmlAttributeValueString] != null)
                    {
                        where.ValueString = node.Attributes[GDataParserNameTable.XmlAttributeValueString].Value;
                    }
                }
    
                if (node.HasChildNodes)
                {
                    foreach (XmlNode childNode in node.ChildNodes)
                    {
                        if (childNode.LocalName == GDataParserNameTable.XmlEntryLinkElement)
                        {
                            if (where.EntryLink == null)
                            {
                                where.EntryLink = EntryLink.ParseEntryLink(childNode, parser);
                            }
                            else
                            {
                                throw new ArgumentException("Only one entryLink is allowed inside the g:where");
                            }
                        }
                    }
                }
            }
            return where;
        }
Beispiel #23
0
		private EventEntry FillKalenderEntry (EventEntry KalenderEntry, DataRow KalenderRow)
			{

			KalenderEntry.Title.Text = KalenderRow ["Titel"].ToString ();
			KalenderEntry.Content.Content = CreateFullBeschreibung (KalenderRow);

			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["ID"].ToString (), "WPMediaID"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["KontaktPerson"].ToString (), "WPMediaKontaktPerson"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["Veranstalter"].ToString (), "WPMediaVeranstalter"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["Typ"].ToString (), "WPMediaTyp"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["ZielGruppe"].ToString (), "WPMediaZielGruppe"));

			Where EntryLocation;
			if (KalenderEntry.Locations.Count > 0)
				EntryLocation = KalenderEntry.Locations [0];
			else
				{
				EntryLocation = new Where ();
				KalenderEntry.Locations.Add (EntryLocation);
				}
			EntryLocation.ValueString = KalenderRow ["VeranstaltungsOrt"].ToString ();
			EntryLocation.Label = KalenderRow ["VeranstaltungsOrt"].ToString ();

			When EntryTiming;
			if (KalenderEntry.Times.Count > 0)
				{
				EntryTiming = KalenderEntry.Times [0];
				EntryTiming.StartTime = Convert.ToDateTime (KalenderRow ["Von"]);
				EntryTiming.EndTime = Convert.ToDateTime (KalenderRow ["Bis"]);
				}
			else
				{
				EntryTiming = new When (Convert.ToDateTime (KalenderRow ["Von"]), Convert.ToDateTime (KalenderRow ["Bis"]));
				KalenderEntry.Times.Add (EntryTiming);
				}

			return KalenderEntry;
			}
        /// <summary>
        /// Helper method to create either single-instance or recurring events.
        /// For simplicity, some values that might normally be passed as parameters
        /// (such as author name, email, etc.) are hard-coded.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        /// <param name="entryTitle">Title of the event to create.</param>
        /// <param name="recurData">Recurrence value for the event, or null for
        ///                         single-instance events.</param>
        /// <returns>The newly-created EventEntry on the calendar.</returns>
        static EventEntry CreateEvent(CalendarService service, String entryTitle,
                                     String recurData)
        {
            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = entryTitle;
            entry.Content.Content = "Meet for a quick lesson.";

            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "South Tennis Courts";
            entry.Locations.Add(eventLocation);

            // If a recurrence was requested, add it.  Otherwise, set the
            // time (the current date and time) and duration (30 minutes)
            // of the event.
            if (recurData == null) {
                When eventTime = new When();
                eventTime.StartTime = DateTime.Now;
                eventTime.EndTime = eventTime.StartTime.AddMinutes(30);
                entry.Times.Add(eventTime);
            } else {
                Recurrence recurrence = new Recurrence();
                recurrence.Value = recurData;
                entry.Recurrence = recurrence;
            }

            // Send the request and receive the response:
            Uri postUri = new Uri(feedUri);
            AtomEntry insertedEntry = service.Insert(postUri, entry);

            return (EventEntry)insertedEntry;
        }
Beispiel #25
0
		public Dictionary<String, String> RunPublishWordUpCalendar(String CalendarTitle, String LastUpdate, 
			List<String> TerminTypeIDsToProcess, int GoogleIDIndex)
			{
			int UpdateCounter = 0;
			DataTable KalenderTable = CreateKalendarTable ();
			String TypeIDSelectClause = WordUp23.Basics.Instance.GetTypSelectPart (TerminTypeIDsToProcess);
			String SelectStatement = "Select * from Termine where " + TypeIDSelectClause + "Order by LastUpdateToken desc";
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
										"Before Select Statement \"" + SelectStatement + "\"");

			DataSet ToProcessCalendarDataSet =
				WordUpWCFAccess.GetCommonDataSet (SelectStatement);

			if (ToProcessCalendarDataSet.Tables ["Termine"].Rows.Count == 0)
				{
				if (WMB.Basics.IsTestRun)
					WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
						"Number of Termine-Entries to Process = 0");
				return new Dictionary<String, String> ();
				}
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
					"Number of Termine-Entries to Process = "
						+ Convert.ToString (ToProcessCalendarDataSet.Tables ["Termine"].Rows.Count));

			List<System.Guid> ListOfTerminTypenWithTypOrtNaming = WordUp23.Basics.Instance.GetTerminTypenWithTypOrtNaming ();
	
			WPMediaGoogleCalendarUpdate.DoUpdate GoogleUpdate = new DoUpdate ();
			GoogleUpdate.CalendarTitle = CalendarTitle;
			GoogleUpdate.MissingGoogleEventIDs.Clear ();

			bool AllRunsCorrect = true;
			int CountHasGoogleIDAndIsProcessedBefore = 0;

			foreach (DataRow IwTRow in ToProcessCalendarDataSet.Tables ["Termine"].Rows)
				{
				String EventEntryElementID = String.Empty;
				try
					{
					if (IwTRow ["ID"] == Convert.DBNull)
						{
						continue;
						}

					if ((IwTRow ["Von"] == Convert.DBNull)
						|| (IwTRow ["Bis"] == Convert.DBNull))
						continue;
		
					EventEntryElementID = IwTRow ["ID"].ToString ();
					String [] GoogleEventID = IwTRow ["GoogleEventID"].ToString ().Split (';');
					if (GoogleEventID.Length == 0)
						GoogleEventID = new String[] {"", ""};

					if (GoogleEventID.Length == 1)
						GoogleEventID = new String [] { GoogleEventID [0], "" };

					if (!String.IsNullOrEmpty (GoogleEventID [GoogleIDIndex]))
						CountHasGoogleIDAndIsProcessedBefore++;
					if (CountHasGoogleIDAndIsProcessedBefore > 20)
						break;

					EventEntry EventEntryElement = GoogleUpdate.GetEventEntry (EventEntryElementID, GoogleEventID [GoogleIDIndex]);
					if (EventEntryElement == null)
						{
						WMB.Basics.ReportErrorToEventViewer ("Beim Eintrag \"" + EventEntryElementID
							+ "\" mit der GoogleIDEventID \"" + GoogleEventID + "\"\r\n" + "kam es zu einem Fehler");
						continue;
						}
					if (EventEntryElement.EventId != GoogleEventID [GoogleIDIndex])		// do BackLink activities
						{
						GoogleEventID [GoogleIDIndex] = EventEntryElement.EventId;
						String ModifyStatement = "Update Termine set GoogleEventID = '"
												 + String.Join (";", GoogleEventID) + "' where ID = '" + EventEntryElementID + "'";
						WordUpWCFAccess.RunSQLBatch (ModifyStatement);
						}
					EventEntryElement.Dirty = true;
					String OrteID = IwTRow ["OrteID"].ToString ();
					String Ortsbezeichnung = "Nicht definiert";
					if (String.IsNullOrEmpty (OrteID) == false)
						Ortsbezeichnung = WordUp23.Basics.Instance.Orte [OrteID] ["Bezeichnung"].ToString ()
							+ " " + WordUp23.Basics.Instance.Orte [OrteID] ["Beschreibung"].ToString ();
					if (ListOfTerminTypenWithTypOrtNaming.Contains ((System.Guid) IwTRow ["TermineTypID"]) == true)
						{
						EventEntryElement.Title.Text = WordUp23.Basics.Instance.GetTypeBeschreibung (IwTRow) + "-" + Ortsbezeichnung;
						}
					else
						{
						//if (String.IsNullOrEmpty (IwTRow ["NameID"].ToString ()) == false)
						//    EventEntryElement.Title.Text = IwTRow ["NameID"].ToString ();
						//else
							EventEntryElement.Title.Text = WordUp23.Basics.Instance.GetTypeBeschreibung (IwTRow) + "-" + Ortsbezeichnung;
						}

					if (IwTRow ["TermineTypID"].ToString () == "f61d9cb1-59a4-430b-ad67-ebdcc5df1d11")
						{
						EventEntryElement.IsDraft = true;
						}


					When EntryTiming;
					if (EventEntryElement.Times.Count > 0)
						{
						EntryTiming = EventEntryElement.Times [0];
						EntryTiming.StartTime = Convert.ToDateTime (IwTRow ["Von"]);
						EntryTiming.EndTime = Convert.ToDateTime (IwTRow ["Bis"]);
						}
					else
						{
						EntryTiming = new When (Convert.ToDateTime (IwTRow ["Von"]), Convert.ToDateTime (IwTRow ["Bis"]));
						EventEntryElement.Times.Add (EntryTiming);
						}

					Where EntryLocation;
					if (EventEntryElement.Locations.Count > 0)
						EntryLocation = EventEntryElement.Locations [0];
					else
						{
						EntryLocation = new Where ();
						EventEntryElement.Locations.Add (EntryLocation);
						}

					String TerminBeschreibung = FillTerminBeschreibung (IwTRow);
					String OrtsBeschreibung = FillLocation (IwTRow, EntryLocation);
					String PersonenBeschreibung = WordUp23.Basics.Instance.GetTypeParticipantText (IwTRow);

// da passiert es
					Google.GData.Extensions.ExtensionCollection<Who> Participants = new Google.GData.Extensions.ExtensionCollection<Who>();
//					PersonenBeschreibung = FillPersonen(IwTRow, EventEntryElement.Participants);
					PersonenBeschreibung = FillPersonen(IwTRow, Participants);

// da ist es passiert		
					String OrganisationsBeschreibung = FillOrganisationsBeschreibung (IwTRow);

					EventEntryElement.Content.Content = TerminBeschreibung + OrtsBeschreibung
						+ OrganisationsBeschreibung + PersonenBeschreibung;

					if (GoogleUpdate.SaveEventEntry (EventEntryElement, EventEntryElementID) == false)
						{
						WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						                                     "Beim \"" + CalendarTitle + "\" Eintrag \"" + EventEntryElementID +
						                                     "\" ist ein Fehler aufgetreten\r\n"
						                                     + EntryTiming.StartTime.ToString () + " - " + EntryTiming.EndTime.ToString ());
						GoogleEventID[GoogleIDIndex] = "";
						String ModifyStatement = "Update Termine set GoogleEventID = '"
												 + String.Join(";", GoogleEventID) + "' where ID = '" + EventEntryElementID + "'";
						WordUpWCFAccess.RunSQLBatch(ModifyStatement);
						}
					//else
					//	{
					//	WMB.Basics.ReportInformationToEventViewer("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
					//		"Beim \"" + CalendarTitle + "\" Eintrag \"" + EventEntryElementID + "\" ist alles OK\r\n"
					//		+ EntryTiming.StartTime.ToString() + " - " + EntryTiming.EndTime.ToString());
					//	}
					continue;
					}

				catch (Exception Excp)
					{
					WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						"Beim Eintrag \"" + EventEntryElementID + "\" ist folgender Fehler aufgetreten:\r\n"
						+ Excp.ToString());
					AllRunsCorrect = false;
					
					}
				}

			if ((AllRunsCorrect == true)
				&& (CloseRequestedCall != null))
				{
				CloseRequestedCall (this, "SaveNextStartDataTime");
				}
			return GoogleUpdate.MissingGoogleEventIDs;
			}
Beispiel #26
0
		String FillLocation (DataRow IwTRow, Where EntryLocation)
			{
			if (IwTRow ["OrteID"] == Convert.DBNull)
				return String.Empty;
			String OrteID = IwTRow ["OrteID"].ToString ();
			DataRow OrtsRow = WordUpWCFAccess.GetCommonDataSet
				("Select * from Orte where ID = '" + OrteID + "'").Tables ["Orte"].Rows [0];
			String Label = "Österreich, Wien";
			String Beschreibung = OrtsRow ["Bezeichnung"].ToString () + " " + OrtsRow ["Beschreibung"].ToString ();
			if (String.IsNullOrEmpty (Beschreibung))
				Beschreibung = OrtsRow ["NameID"].ToString ();
			EntryLocation.Label = OrtsRow ["NameID"].ToString ();
			//EntryLocation.ValueString = "Österreich, Wien, " + OrtsRow ["GoogleAdressString"].ToString ();
			//EntryLocation.ValueString = "Österreich, Wien, " + OrtsRow ["GoogleAdressString"].ToString ();
			EntryLocation.ValueString = OrtsRow ["WBreite"].ToString ().Replace (",", ".") + ","
							+ OrtsRow ["WLaenge"].ToString ().Replace (",", ".")
							+ " (" + Beschreibung.Replace ("(", "").Replace (")", "") + ") ";
		
			return "<br/>" + Beschreibung;
			}
Beispiel #27
0
        /// <summary>
        /// Inserts a new event
        /// </summary>
        /// <param name='start'>
        /// The start, date and time, of the event, as a DateTime object.
        /// </param>
        /// <param name='title'>
        /// The title of the event.
        /// </param>
        /// <param name='end'>
        /// The end, date and time, of the event, as a DateTime object.
        /// </param>
        /// <param name='place'>
        /// The place in which the event will happen.
        /// </param>
        public void InsertEvent(DateTime start, string title, DateTime end, string place)
        {
            // Wait to have a slot
            while( this.OnTransaction ) {}

            // Prepare the entry
            this.OnTransaction = true;
            var entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = title;

            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = place;
            entry.Locations.Add( eventLocation );

            // Set when it happens
            When eventTime = new When( start, end );
            entry.Times.Add( eventTime );

            // Really insert
            this.InsertEvent( entry );
            this.OnTransaction = false;
            return;
        }