コード例 #1
0
        /// <summary>
        /// Get the most recent 20 meetings from our local database
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        private static async Task <IWalker.MRU[]> FetchMeetingsFromDB(MRUDatabaseAccess m)
        {
            // Run this in the SQL engine
            var mruMeetings =
                (await m.QueryMRUDB())
                .OrderByDescending(mru => mru.LastLookedAt)
                .Take(NumberOfMRUMeetings)
                .ToListAsync();

            var r = (await mruMeetings)
                    .Distinct(new MURCompare())
                    .ToArray();

            return(r);
        }
コード例 #2
0
        /// <summary>
        /// Generate a MRU[] stream from the local database. Each time it updates, we update here too.
        /// </summary>
        /// <returns></returns>
        private static IObservable <IWalker.MRU[]> FetchMRUSFromLocalDB()
        {
            // Generate an observable that will grab everything from our local MRU database.
            var m = new MRUDatabaseAccess();

            // Return the MRU updated guy
            return(MRUDatabaseAccess.MRUDBUpdated
                   .StartWith(default(Unit))
                   .SelectMany(async _ =>
            {
                IWalker.MRU[] r = await FetchMeetingsFromDB(m);

                return r;
            }));
        }
コード例 #3
0
        /// <summary>
        /// Returns an observable stream.
        /// </summary>
        /// <returns>The observable of the MRU listing</returns>
        /// <remarks>
        /// As soon as you subscribe you'll get the most recent version of the MRU list.
        ///
        /// Combines MRU's from the following sources:
        /// 1. The internal database we maintain of our own stuff (that we've visited on this machine).
        /// </remarks>
        public static IObservable <IWalker.MRU[]> GetMRUListStream()
        {
            if (_MRUStream != null)
            {
                return(_MRUStream);
            }

            // Get streams from all the sources we are going to have to deal with
            var locals  = FetchMRUSFromLocalDB();
            var remotes = FetchMRUSFromRoamingData();

            // Combine the streams (without crossing them!!)
            var result = locals
                         .CombineLatest(remotes, (l, r) => MergeStreams(l, r))
                         .Select(mlst => mlst
                                 .OrderByDescending(k => k.StartTime)
                                 .Take(NumberOfMRUMeetings)
                                 .ToArray())
                         .Distinct(lst => MRUListHash(lst));

            // Make sure that it replays so when new folks join us (or a page gets re-initialized) they get the same
            // thing.
            _MRUStream = result
                         .Replay(1)
                         .RefCount();

            // When there is a MRU update, cache MRU to our remote file so others can see it.
            var db = new MRUDatabaseAccess();

            _MRUDBSubscription = MRUDatabaseAccess.MRUDBUpdated
                                 .SelectMany(_ => FetchMeetingsFromDB(db))
                                 .Subscribe(mrus =>
            {
                MRUSettingsCache.UpdateForMachine(MachineName, mrus);
            });

            return(_MRUStream);
        }