protected override void ExecuteCore() { // 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 channels = ChannelsManager.GetStatusChannels(); var channel = channels.FirstOrDefault(c => 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) { Logger.Debug("Received search update. ChannelStatusKey = {0}, DatePosted = {1}", LogSource.Sync, statusupdate.ChannelStatusKey, statusupdate.DatePosted); 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); }
void GetFriendUpdates() { try { // Get updates for the last 7 days var parser = new UserStatusParser(config); var updates = channel.GetUpdates(50).Where(u => u.DatePosted > DateTime.Now.AddDays(-7)); foreach (var statusupdate in updates) { Logger.Debug("Received friend update. ChannelStatusKey = {0}, DatePosted = {1}", LogSource.Sync, statusupdate.ChannelStatusKey, statusupdate.DatePosted); parser.ProcessStatusUpdate(statusupdate, StatusTypes.FriendUpdate); } } catch (Exception ex) { Logger.Error("An error has occured while trying to get friend updates. Exception = {0}", LogSource.Sync, ex); } }
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) { Logger.Debug("Received mention. ChannelStatusKey = {0}, DatePosted = {1}", LogSource.Sync, statusupdate.ChannelStatusKey, statusupdate.DatePosted); parser.ProcessStatusUpdate(statusupdate, StatusTypes.Mention); } } catch (Exception ex) { Logger.Error("An error has occured while trying to get mentions. Exception = {0}", LogSource.Sync, ex); } }