protected override void ExecuteCore()
        {
            var channels = ClientState.Current.DataService.SelectAll <ChannelConfig>()
                           .Select(ChannelFactory.Create)
                           .Select(s => new ChannelInstance(s))
                           .ToList();

            // Get the keywords we need to perform a search for
            foreach (var kw in VirtualMailBox.Current.StreamSearchKeywords.GetKeyWords())
            {
                #region Parse channelname and keyword

                var parts = kw.Split('|');

                if (parts.Length != 2)
                {
                    Logger.Warn("Invalid search keyword. Keyword = {0}", LogSource.Sync, kw);
                    return;
                }

                var channelname = parts[0];
                var keyword     = parts[1];

                // Find channel with given name
                var channel = channels.FirstOrDefault(c => c.StatusUpdatesChannel != null && c.Configuration.DisplayName == channelname);

                if (channel == null)
                {
                    Logger.Warn("Could not find channel for search keyword. ChannelName = {0}, Keyword = {1}", LogSource.Sync, channelname, keyword);
                    return;
                }

                #endregion

                // Perform keyword search
                try
                {
                    var parser  = new UserStatusParser(channel.Configuration, kw);
                    var updates = channel.StatusUpdatesChannel.GetUpdates(keyword, 50);

                    foreach (var statusupdate in updates)
                    {
                        parser.ProcessStatusUpdate(statusupdate, StatusTypes.SearchUpdate);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("An error has occured while getting search result from {0}. Keyword = {1} Exception = {2}", LogSource.Sync, channelname, keyword, ex);
                }
            }

            // Save last run time
            ChannelContext.Current.ClientContext.SaveSetting("LastSyncSearchStreamDate", DateTime.Now);

            EventBroker.Publish(AppEvents.SyncStatusUpdatesFinished);
        }
Exemple #2
0
        void GetMentions()
        {
            try
            {
                // Get updates for the last 7 days
                var parser  = new UserStatusParser(config);
                var updates = channel.GetMentions(50).Where(u => u.DatePosted > DateTime.Now.AddDays(-7));

                foreach (var statusupdate in updates)
                {
                    parser.ProcessStatusUpdate(statusupdate, StatusTypes.Mention);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("An error has occured while trying to get mentions. Exception = {0}", LogSource.Sync, ex);
            }
        }
        protected override void ExecuteCore()
        {
            var channels = ClientState.Current.DataService.SelectAll<ChannelConfig>()
                .Select(ChannelFactory.Create)
                .Select(s => new ChannelInstance(s))
                .ToList();

            // Get the keywords we need to perform a search for
            foreach (var kw in VirtualMailBox.Current.StreamSearchKeywords.GetKeyWords())
            {
                #region Parse channelname and keyword

                var parts = kw.Split('|');

                if (parts.Length != 2)
                {
                    Logger.Warn("Invalid search keyword. Keyword = {0}", LogSource.Sync, kw);
                    return;
                }

                var channelname = parts[0];
                var keyword = parts[1];

                // Find channel with given name
                var channel = channels.FirstOrDefault(c => c.StatusUpdatesChannel != null && c.Configuration.DisplayName == channelname);

                if (channel == null)
                {
                    Logger.Warn("Could not find channel for search keyword. ChannelName = {0}, Keyword = {1}", LogSource.Sync, channelname, keyword);
                    return;
                }

                #endregion

                // Perform keyword search
                try
                {
                    var parser = new UserStatusParser(channel.Configuration, kw);
                    var updates = channel.StatusUpdatesChannel.GetUpdates(keyword, 50);

                    foreach (var statusupdate in updates)
                        parser.ProcessStatusUpdate(statusupdate, StatusTypes.SearchUpdate);
                }
                catch (Exception ex)
                {
                    Logger.Error("An error has occured while getting search result from {0}. Keyword = {1} Exception = {2}", LogSource.Sync, channelname, keyword, ex);
                }
            }

            // Save last run time
            ChannelContext.Current.ClientContext.SaveSetting("LastSyncSearchStreamDate", DateTime.Now);

            EventBroker.Publish(AppEvents.SyncStatusUpdatesFinished);
        }