예제 #1
0
        private void CheckContributors()
        {
            List <UserListContainer> oldList = contributors;
            List <UserListContainer> newList = GetContributors();

            if (UserListDiff(oldList, newList, out List <UserListContainer> added, out List <UserListContainer> removed,
                             (UseCache.Contains("contributors") ? MonitoringCache["contributors"] : null)))
            {
                // Add the new entries to the appropriate cache, if enabled.  --Kris
                if (UseCache.Contains("contributors"))
                {
                    foreach (UserListContainer ulc in added)
                    {
                        foreach (UserListChild child in ulc.Data.Children)
                        {
                            MonitoringCache["contributors"].Add(child.Id);
                        }
                    }
                }

                // Event handler to alert the calling app that the list has changed.  --Kris
                LiveThreadContributorsUpdateEventArgs args = new LiveThreadContributorsUpdateEventArgs
                {
                    OldContributors = oldList,
                    NewContributors = newList,
                    Added           = added,
                    Removed         = removed
                };
                OnContributorsUpdated(args);
            }
        }
예제 #2
0
 /// <summary>
 /// Initializes the monitoring cache properties.
 /// </summary>
 /// <param name="useCache">Whether to cache the IDs of the monitoring results to prevent duplicate fires</param>
 /// <param name="type">Which monitoring sort's cache to initialize</param>
 internal void InitMonitoringCache(bool useCache, string type)
 {
     if (useCache)
     {
         MonitoringCache[type] = new HashSet <string>();
         if (!UseCache.Contains(type))
         {
             UseCache.Add(type);
         }
     }
     else if (UseCache.Contains(type))
     {
         UseCache.Remove(type);
     }
 }
예제 #3
0
        private void CheckUpdates()
        {
            List <LiveUpdate> oldList = updates;
            List <LiveUpdate> newList = GetUpdates();

            if (Lists.ListDiff(oldList, newList, out List <LiveUpdate> added, out List <LiveUpdate> removed,
                               (UseCache.Contains("updates") ? MonitoringCache["updates"] : null)))
            {
                // Event handler to alert the calling app that the list has changed.  --Kris
                LiveThreadUpdatesUpdateEventArgs args = new LiveThreadUpdatesUpdateEventArgs
                {
                    OldUpdates = oldList,
                    NewUpdates = newList,
                    Added      = added,
                    Removed    = removed
                };
                OnUpdatesUpdated(args);
            }
        }
예제 #4
0
        /// <inheritdocs />
        public override int GetHashCode()
        {
            var hashCode = -1775804580;

            hashCode = hashCode * -1521134295 + EqualityComparer <NameServer[]> .Default.GetHashCode(_endpoints);

            hashCode = hashCode * -1521134295 + EnableAuditTrail.GetHashCode();
            hashCode = hashCode * -1521134295 + UseCache.GetHashCode();
            hashCode = hashCode * -1521134295 + Recursion.GetHashCode();
            hashCode = hashCode * -1521134295 + Retries.GetHashCode();
            hashCode = hashCode * -1521134295 + ThrowDnsErrors.GetHashCode();
            hashCode = hashCode * -1521134295 + UseRandomNameServer.GetHashCode();
            hashCode = hashCode * -1521134295 + ContinueOnDnsError.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <TimeSpan> .Default.GetHashCode(Timeout);

            hashCode = hashCode * -1521134295 + UseTcpFallback.GetHashCode();
            hashCode = hashCode * -1521134295 + UseTcpOnly.GetHashCode();
            hashCode = hashCode * -1521134295 + AutoResolvedNameServers.GetHashCode();
            return(hashCode);
        }
        public override Dictionary <string, string> SaveState()
        {
            Dictionary <string, string> resultState = base.SaveState();

            resultState["IsZoomToExtentOfNewLayer"]       = IsZoomToExtentOfNewLayer.ToString();
            resultState["IsZoomToExtentOfOnlyFirstLayer"] = IsZoomToExtentOfOnlyFirstLayer.ToString();
            resultState["MaxRecordsToDraw"]              = MaxRecordsToDraw.ToString(CultureInfo.InvariantCulture);
            resultState["UseCache"]                      = UseCache.ToString();
            resultState["IsLimitDrawgingFeaturesCount"]  = IsLimitDrawgingFeaturesCount.ToString();
            resultState["TileSize"]                      = TileSize.ToString(CultureInfo.InvariantCulture);
            resultState["IsShowAddDataRepositoryDialog"] = IsShowAddDataRepositoryDialog.ToString();
            resultState["IsShowPanZoomBar"]              = IsShowPanZoomBar.ToString();
            resultState["HighQuality"]                   = HighQuality.ToString();
            resultState["DefaultBaseMapOption"]          = ((int)DefaultBaseMapOption).ToString(CultureInfo.InvariantCulture);
            resultState["PlaceSearchMaxResultCount"]     = PlaceSearchMaxValue.ToString(CultureInfo.InvariantCulture);
            resultState["AltitudeMode"]                  = ((int)AltitudeMode).ToString(CultureInfo.InvariantCulture);
            resultState["Height"]                      = Height.ToString(CultureInfo.InvariantCulture);
            resultState["ZoomSnapDirection"]           = ((int)ZoomSnapDirection).ToString(CultureInfo.InvariantCulture);
            resultState["DisableGlobeButton"]          = DisableGlobeButton.ToString();
            resultState["OverlayRefreshDelayInterval"] = OverlayRefreshDelayInterval.ToString();

            return(resultState);
        }
예제 #6
0
파일: Wiki.cs 프로젝트: sirkris/Reddit.NET
        private void MonitorPagesThread(string key, int startDelayMs = 0, int?monitoringDelayMs = null)
        {
            if (startDelayMs > 0)
            {
                Thread.Sleep(startDelayMs);
            }

            monitoringDelayMs = (monitoringDelayMs.HasValue ? monitoringDelayMs : Monitoring.Count() * MonitoringWaitDelayMS);

            while (!Terminate &&
                   Monitoring.Get(key).Contains(Subreddit))
            {
                if (MonitoringExpiration.HasValue &&
                    DateTime.Now > MonitoringExpiration.Value)
                {
                    MonitorModel.RemoveMonitoringKey(key, Subreddit, ref Monitoring);
                    Threads.Remove(key);

                    break;
                }

                while (!IsScheduled())
                {
                    if (Terminate)
                    {
                        break;
                    }

                    Thread.Sleep(15000);
                }

                if (Terminate)
                {
                    break;
                }

                List <string> oldList;
                List <string> newList;
                try
                {
                    oldList = pages;
                    newList = GetPages();
                    string type = "pages";
                    if (Lists.ListDiff(oldList, newList, out List <string> added, out List <string> removed, (UseCache.Contains(type) ? MonitoringCache[type] : null)))
                    {
                        // Add the new entries to the appropriate cache, if enabled.  --Kris
                        if (UseCache.Contains(type))
                        {
                            foreach (string page in added)
                            {
                                MonitoringCache[type].Add(page);
                            }
                        }

                        // Event handler to alert the calling app that the list has changed.  --Kris
                        WikiPagesUpdateEventArgs args = new WikiPagesUpdateEventArgs
                        {
                            NewPages = newList,
                            OldPages = oldList,
                            Added    = added,
                            Removed  = removed
                        };
                        OnPagesUpdated(args);
                    }
                }
                catch (Exception) when(!BreakOnFailure)
                {
                }

                Wait(monitoringDelayMs.Value);
            }
        }
예제 #7
0
        private void MonitorPrivateMessagesThread(string key, string type, int startDelayMs = 0, int?monitoringDelayMs = null)
        {
            if (startDelayMs > 0)
            {
                Thread.Sleep(startDelayMs);
            }

            monitoringDelayMs = (monitoringDelayMs.HasValue ? monitoringDelayMs : Monitoring.Count() * MonitoringWaitDelayMS);

            while (!Terminate &&
                   Monitoring.Get(key).Contains("PrivateMessages"))
            {
                if (MonitoringExpiration.HasValue &&
                    DateTime.Now > MonitoringExpiration.Value)
                {
                    MonitorModel.RemoveMonitoringKey(key, "PrivateMessages", ref Monitoring);
                    Threads.Remove(key);

                    break;
                }

                while (!IsScheduled())
                {
                    if (Terminate)
                    {
                        break;
                    }

                    Thread.Sleep(15000);
                }

                if (Terminate)
                {
                    break;
                }

                List <Message> oldList;
                List <Message> newList;
                try
                {
                    switch (type)
                    {
                    default:
                        throw new RedditControllerException("Unrecognized type '" + type + "'.");

                    case "inbox":
                        oldList = inbox;
                        newList = GetMessagesInbox();
                        break;

                    case "unread":
                        oldList = unread;
                        newList = GetMessagesUnread();
                        break;

                    case "sent":
                        oldList = sent;
                        newList = GetMessagesSent();
                        break;
                    }

                    if (Lists.ListDiff(oldList, newList, out List <Message> added, out List <Message> removed, (UseCache.Contains(type) ? MonitoringCache[type] : null)))
                    {
                        // Add the new entries to the appropriate cache, if enabled.  --Kris
                        if (UseCache.Contains(type))
                        {
                            foreach (Message message in added)
                            {
                                MonitoringCache[type].Add(message.Id);
                            }
                        }

                        // Event handler to alert the calling app that the list has changed.  --Kris
                        MessagesUpdateEventArgs args = new MessagesUpdateEventArgs
                        {
                            NewMessages = newList,
                            OldMessages = oldList,
                            Added       = added,
                            Removed     = removed
                        };
                        TriggerUpdate(args, type);
                    }
                }
                catch (Exception) when(!BreakOnFailure)
                {
                }

                Wait(monitoringDelayMs.Value);
            }
        }