コード例 #1
0
ファイル: BookThemAll.cs プロジェクト: Zelxin/RPiKeg
 public DateTime FindNextAvailableTimeSlot(AtomEntryCollection users, DateTime limit)
 {
     DateTime nextHour = NextHour();
     while (nextHour < limit)
     {
         if (AreUsersAvailable(users, nextHour))
         {
             return nextHour;
         }
         nextHour += new System.TimeSpan(0, 0, 30, 0);
     }
     throw new NoAvailableSlotWithinLimitException();
 }
コード例 #2
0
ファイル: BookThemAll.cs プロジェクト: Zelxin/RPiKeg
 public bool AreUsersAvailable(AtomEntryCollection users, DateTime datetime)
 {
     foreach (AppsExtendedEntry entry in users)
     {
         string user = entry.getPropertyValueByName("memberId");
         bool isAvailable = IsUserAvailable(user, datetime);
         if (!isAvailable)
         {
             return false;
         }
     }
     return true;
 }
コード例 #3
0
 public void TestConvertEventsToFreeBusy()
 {
     ExchangeUser user = new ExchangeUser();
     EventEntry googleAppsEvent = new EventEntry("title", "description", "location");
     DateTimeRange coveredRange = new DateTimeRange(DateTime.MaxValue, DateTime.MinValue);
     List<DateTimeRange> busyTimes = new List<DateTimeRange>();
     List<DateTimeRange> tentativeTimes = new List<DateTimeRange>();
     DateTime startDate = new DateTime(2007, 07, 1, 10, 0, 0, DateTimeKind.Utc);
     DateTime endDate = new DateTime(2007, 07, 1, 11, 0, 0, DateTimeKind.Utc);
     When when = new When(startDate, endDate);
     Uri uri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full");
     EventFeed googleAppsFeed = new EventFeed(uri, null);
     AtomEntryCollection entries = new AtomEntryCollection(googleAppsFeed);
 }
コード例 #4
0
ファイル: Syncronizer.cs プロジェクト: cjingle/gocontactsync
        public void LoadGoogleGroups()
        {
            GroupsQuery query = new GroupsQuery(GroupsQuery.CreateGroupsUri("default"));
            query.NumberToRetrieve = 256;
            query.StartIndex = 0;
            query.ShowDeleted = false;

            GroupsFeed feed;
            feed = _googleService.Query(query);
            _googleGroups = feed.Entries;
            while (feed.Entries.Count == query.NumberToRetrieve)
            {
                query.StartIndex = _googleGroups.Count;
                feed = _googleService.Query(query);
                foreach (AtomEntry a in feed.Entries)
                {
                    _googleGroups.Add(a);
                }
            }
        }
コード例 #5
0
ファイル: Syncronizer.cs プロジェクト: cjingle/gocontactsync
        public void LoadGoogleContacts()
        {
            ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
            query.NumberToRetrieve = 256;
            query.StartIndex = 0;
            query.ShowDeleted = false;
            //query.OrderBy = "lastmodified";

            ContactsFeed feed;
            feed = _googleService.Query(query);
            _googleContacts = feed.Entries;
            while (feed.Entries.Count == query.NumberToRetrieve)
            {
                query.StartIndex = _googleContacts.Count;
                feed = _googleService.Query(query);
                foreach (AtomEntry a in feed.Entries)
                {
                    _googleContacts.Add(a);
                }
            }
        }
コード例 #6
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a number or rows and delets them again</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void DefaultHostMassiveInsertAndDelete()
        {
            Tracing.TraceMsg("Entering DefaultHostMassiveInsertAndDelete");

            int iCount=0; 
            FeedQuery query = new FeedQuery();

            Service service = new Service();
            service.RequestFactory = this.factory; 

            query.Uri = new Uri(this.defaultHost);
            AtomFeed returnFeed = service.Query(query);
            AtomEntry entry; 


            iCount = returnFeed.Entries.Count; 

            AtomEntryCollection newEntries = new AtomEntryCollection(null); 


            // now we have all we need. 

            for (int i = 0; i < this.iIterations; i++)
            {
                entry = ObjectModelHelper.CreateAtomEntry(i); 
                entry = returnFeed.Insert(entry); 
                newEntries.Add(entry);
            }

            Tracing.TraceMsg("DefaultHostMassiveInsert: inserted lot's of  entries");
            // done doing the inserts...

            // now query the guy again. 

            returnFeed = service.Query(query);
            Assert.AreEqual(iCount+this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now"); 

            // now udpate the 100 entries we have added

            for (int i = 0; i < this.iIterations; i++)
            {
                entry = newEntries[i];
                entry.Title.Text = Guid.NewGuid().ToString(); 
                entry.Update(); 
            }
            Tracing.TraceMsg("DefaultHostMassiveInsert: updated lot's of entries");

            returnFeed = service.Query(query);
            Assert.AreEqual(iCount+this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now"); 

            // let's find them and delete them...
            for (int i = 0; i < this.iIterations; i++)
            {
                entry = newEntries[i];
                foreach (AtomEntry feedEntry in returnFeed.Entries )
                {
                    if (String.Compare(feedEntry.Title.Text, entry.Title.Text) == 0)
                    {
                        // got him
                        Tracing.TraceMsg("trying to delete entry: " + feedEntry.Title.Text +" = " + entry.Title.Text);
                        feedEntry.Delete(); 
                        break;
                    }
                }
            }


            // and a last time
            returnFeed = service.Query(query);
            Assert.AreEqual(iCount, returnFeed.Entries.Count, "feed should have the same number again"); 

            Tracing.TraceMsg("DefaultHostMassiveInsertAndDelete: deleted lot's of entries");

        }
コード例 #7
0
 private void _add_videos_to_list(AtomEntryCollection entries)
 {
     foreach (YouTubeEntry e in entries)
     {
         _videos.Add(e);
         VideoAdded(e);
     }
 }
コード例 #8
0
ファイル: BloggerDaoGData.cs プロジェクト: Letractively/rpcwc
        private IList<BlogEntry> MapEntries(AtomEntryCollection entries)
        {
            // Perform mapping asynchronously

            IList<BlogEntry> entryList = new List<BlogEntry>();
            IList<IAsyncResult> entryAsyncResultList = new List<IAsyncResult>();
            MapEntryDelegate mapEntryDelegate = MapEntry;

            // Invoke all calls to mapping method
            foreach (AtomEntry entry in entries)
            {
                entryAsyncResultList.Add(mapEntryDelegate.BeginInvoke(entry, delegate(IAsyncResult result) { }, null));
            }

            // Collect all results
            foreach (IAsyncResult result in entryAsyncResultList)
            {
                BlogEntry entry = mapEntryDelegate.EndInvoke(result);
                if (entry != null)
                {
                    entryList.Add(entry);
                }
                else
                {
                    Console.Error.WriteLine("blog entry is null");
                }
            }

            return entryList;
        }
コード例 #9
0
        private List<Event> mapEvents(AtomEntryCollection entries)
        {
            List<Event> events = new List<Event>();

            foreach (EventEntry entry in entries)
                foreach (When time in entry.Times)
                    events.Add(mapEvent(entry, time));

            return events;
        }
コード例 #10
0
        private static void ConvertEventsToFreeBusy(
            ExchangeUser user,
            AtomEntryCollection entries,
            DateTimeRange coveredRange,
            List<string> busyMonthValues,
            List<string> busyBase64Data,
            List<string> tentativeMonthValues,
            List<string> tentativeBase64Data)
        {
            List<DateTimeRange> busyTimes = new List<DateTimeRange>();
            List<DateTimeRange> tentativeTimes = new List<DateTimeRange>();

            foreach (EventEntry googleAppsEvent in entries)
            {
                ConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes);
            }

            FreeBusyConverter.CondenseFreeBusyTimes(busyTimes);
            FreeBusyConverter.CondenseFreeBusyTimes(tentativeTimes);

            FreeBusyConverter.ConvertDateTimeBlocksToBase64String(coveredRange.Start,
                                                                  coveredRange.End,
                                                                  busyTimes,
                                                                  busyMonthValues,
                                                                  busyBase64Data);

            FreeBusyConverter.ConvertDateTimeBlocksToBase64String(coveredRange.Start,
                                                                  coveredRange.End,
                                                                  tentativeTimes,
                                                                  tentativeMonthValues,
                                                                  tentativeBase64Data);
        }
コード例 #11
0
        private void GoogleSpreadsheetBrowser_Load(object sender, EventArgs e)
        {
            var zWait = new WaitDialog(1,
                () =>
                {
                    AtomEntryCollection zSheetAtomCollection = getAtomEntryCollection(
                        () => GoogleSpreadsheet.GetSpreadsheetList(m_zSpreadsheetsService),
                        () => listViewSpreadsheets.InvokeAction(() => listViewSpreadsheets.Clear()));

                    if (null == zSheetAtomCollection)
                    {
                        this.InvokeAction(
                            () => MessageBox.Show(this, "Failed to access Google Spreadsheets", "Access Failed", MessageBoxButtons.OK, MessageBoxIcon.Error));
                        this.InvokeAction(Close);
                        WaitDialog.Instance.CloseWaitDialog();
                        return;
                    }

                    m_zAllEntries = zSheetAtomCollection;
                    var listNewItems = new List<ListViewItem>();
                    foreach (var entry in zSheetAtomCollection)
                    {
                        var zLvi = new ListViewItem(entry.Title.Text)
                        {
                            Tag = entry
                        };
                        listNewItems.Add(zLvi);
                    }
                    listViewSpreadsheets.InvokeAction(() =>
                    {
                        listViewSpreadsheets.Items.AddRange(listNewItems.ToArray());
                    });
                    WaitDialog.Instance.CloseWaitDialog();
                },
                "Getting Google Spreadsheets...",
                null,
                400);
            zWait.ShowDialog(this);
        }
コード例 #12
0
    private List<DatablockDetectionInfo> ParseSpreadsheet(SpreadsheetEntry spreadsheet)
    {
        WorksheetFeed wsFeed = spreadsheet.Worksheets;

        if (wsFeed.Entries.Count == 0)
            return null;

        var worksheet = (WorksheetEntry) wsFeed.Entries[0];

        if (worksheet.Rows < 2)
            return null;

        // Define the URL to request the list feed of the worksheet.
        AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

        // Fetch the list feed of the worksheet.
        var listQuery = new ListQuery(listFeedLink.HRef.ToString());
        ListFeed listFeed = sheetsAPI.Service.Query(listQuery);

        var headers = new List<string>();
        spreadsheetRows = listFeed.Entries;
        nameColumnIndex = -1;

        var row = (ListEntry) spreadsheetRows[0];
        for (int index = 0; index < row.Elements.Count; index++)
        {
            ListEntry.Custom element = row.Elements[index];

            if (element.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase))
                nameColumnIndex = index;

            headers.Add(element.LocalName);
        }

        List<DatablockDetectionInfo> datablockTypes = AutoDetectDatablockType(headers);
        if (datablockTypes == null)
        {
            Debug.Log("Unable to auto detect datablock type");
            return null;
        }

        return datablockTypes;
    }
コード例 #13
0
ファイル: BookThemAll.cs プロジェクト: Zelxin/RPiKeg
 public EventEntry CreateEvent(string title, DateTime date, AtomEntryCollection users)
 {
     EventEntry entry = new EventEntry();
     entry.Title.Text = title;
     entry.Content.Content = title + "Content";
     When eventTime = new When(date, date + new System.TimeSpan(0, 0, 30, 0));
     entry.Times.Add(eventTime);
     foreach (AppsExtendedEntry user in users)
     {
         string member = user.getPropertyValueByName("memberId");
         Who who = new Who();
         who.Email = member;
         who.Rel = Who.RelType.EVENT_ATTENDEE;
         entry.Participants.Add(who);
     }
     Uri postUri = new Uri(string.Format(feedUrl, admin));
     return calendar.Insert(postUri, entry);
 }