Example #1
0
        protected static LastCheck GetLastCheck(ulong simA, ulong simB, bool createNew, out bool created)
        {
            Dictionary <ulong, LastCheck> lookup;

            if (!sLastCheck.TryGetValue(simA, out lookup))
            {
                lookup = new Dictionary <ulong, LastCheck>();
                sLastCheck.Add(simA, lookup);
            }

            created = false;

            LastCheck lastCheck;

            if (!lookup.TryGetValue(simB, out lastCheck))
            {
                if (createNew)
                {
                    created   = true;
                    lastCheck = new LastCheck();
                    lookup.Add(simB, lastCheck);
                }
            }

            return(lastCheck);
        }
 public ChunkRequest(Vector3 worldPos, float voxelSize, OnReceived callback, LastCheck lastCheck)
 {
     this.worldPos  = worldPos;
     this.voxelSize = voxelSize;
     this.callback  = callback;
     this.lastCheck = lastCheck;
 }
        public void start()
        {
            while (this.isRunning)
            {
                if (LastCheck.AddMinutes(5) < DateTime.UtcNow)
                {
                    this.LastCheck = DateTime.UtcNow;
                    var newVersions = GetCurrentVersion();
                    if (LastUSVersion == null)
                    {
                        this.LastUSVersion = newVersions.Find(x => x.Location == "us");
                    }

                    if (LastUSVersion.BuildNumber != newVersions.Find(x => x.Location == "us").BuildNumber)
                    {
                        //change detection (update or might even a downgrade, this happends when blizzard f***s $#!@ up
                        this.LastUSVersion = newVersions.Find(x => x.Location == "us");
                        foreach (var user in this.SubscriberUsers)
                        {
                            //var newDM = this.Client.CreateDmAsync(this.Client.GetUserAsync(user).GetAwaiter().GetResult()).GetAwaiter().GetResult();
                            //newDM.SendMessageAsync($"World of Warcraft (Retail) has been updated to {this.LastUSVersion.Version} ({this.LastUSVersion.BuildNumber})");
                        }
                    }
                }
                Thread.Sleep(LastCheck.AddMinutes(5) - DateTime.UtcNow);
            }
        }
Example #4
0
 private void CheckCache(bool forced = false)
 {
     if (!_initialized)
     {
         Initialize();
         _initialized = true;
     }
     if (string.IsNullOrWhiteSpace(_file))
     {
         Setup();
         if (File.Exists(ResolvedFilePath))
         {
             _file = ResolvedFilePath;
         }
         else
         {
             return;
         }
     }
     if (forced || LastCheck.AddMilliseconds(CheckRate) < DateTime.Now)
     {
         if (File.GetLastWriteTime(_file) > LastFileTime)
         {
             _cache.Clear();
             Initialize();
         }
         LastCheck = DateTime.Now;
     }
 }
Example #5
0
        private bool UpdateCheckStatus()
        {
            // TODO: verify for check;
            LastCheck.Clear();
            foreach (PieceColor color in Enum.GetValues(typeof(PieceColor)))
            {
                List <Piece> pieces = GetPieces(PieceType.King, color);

                foreach (Piece pcs in pieces)
                {
                    KingPiece kingPcs = pcs as KingPiece;

                    int[] checkmap = kingPcs.GetCheckMap();
                    for (int i = 0; i < TableStatus.Length; ++i)
                    {
                        if (IsSpecificFlagSet(checkmap[i], CellStatus.Checking))
                        {
                            LastCheck.Add(i);
                        }
                    }
                }
            }



            return(true);
        }
Example #6
0
        protected static void SetLastCheck(ulong simA, ulong simB, LastCheck check)
        {
            Dictionary<ulong, LastCheck> lookup;
            if (!sLastCheck.TryGetValue(simA, out lookup))
            {
                lookup = new Dictionary<ulong, LastCheck>();
                sLastCheck.Add(simA, lookup);
            }

            lookup[simB] = check;        
        }
Example #7
0
        protected static void SetLastCheck(ulong simA, ulong simB, LastCheck check)
        {
            Dictionary <ulong, LastCheck> lookup;

            if (!sLastCheck.TryGetValue(simA, out lookup))
            {
                lookup = new Dictionary <ulong, LastCheck>();
                sLastCheck.Add(simA, lookup);
            }

            lookup[simB] = check;
        }
Example #8
0
        protected static void OnSocialEvent(Event e)
        {
            using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration AttractionHelper:OnSocialEvent"))
            {
                if (Common.AssemblyCheck.IsInstalled("NRaasChemistry"))
                {
                    return;
                }

                SocialEvent socialEvent = e as SocialEvent;
                if ((socialEvent != null) && (socialEvent.WasAccepted))
                {
                    Sim actor  = socialEvent.Actor as Sim;
                    Sim target = socialEvent.TargetObject as Sim;

                    if ((actor != null) && (target != null))
                    {
                        bool      created   = false;
                        LastCheck lastCheck = GetLastCheck(actor.SimDescription.SimDescriptionId, target.SimDescription.SimDescriptionId, true, out created);

                        if (created)
                        {
                            SetLastCheck(target.SimDescription.SimDescriptionId, actor.SimDescription.SimDescriptionId, lastCheck);
                        }

                        bool force = false;
                        if ((!lastCheck.mAttractionNotice) && ((SimTypes.IsSelectable(actor)) || (SimTypes.IsSelectable(target))))
                        {
                            force = true;
                        }

                        if ((force) || ((lastCheck.mTime + SimClock.kSimulatorTicksPerSimDay) > SimClock.CurrentTicks))
                        {
                            lastCheck.mTime = SimClock.CurrentTicks;

                            Relationship relation = Relationship.Get(actor, target, false);
                            if (relation != null)
                            {
                                RelationshipEx.CalculateAttractionScore(relation, !lastCheck.mAttractionNotice);

                                if ((SimTypes.IsSelectable(actor)) || (SimTypes.IsSelectable(target)))
                                {
                                    lastCheck.mAttractionNotice = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #9
0
        public string Serialize()
        {
            StringBuilder builder = new StringBuilder();

            AddVar(builder, " Error", Error.ToString(), true);
            AddVar(builder, " ErrorString", ErrorString);
            AddVar(builder, " LTouchVersion", ((int)LTouchVersion).ToString());
            if (XEXCRC != null)
            {
                AddVar(builder, " XEXCRC", ((int)XEXCRC.Status).ToString() + "|" + XEXCRC.Crc.ToString("X8"));
            }
            if (VideoCRC != null)
            {
                AddVar(builder, " VideoCRC", ((int)VideoCRC.Status).ToString() + "|" + VideoCRC.Crc.ToString("X8"));
            }
            if (V0CRC != null)
            {
                AddVar(builder, " V0CRC", ((int)V0CRC.Status).ToString() + "|" + V0CRC.Crc.ToString("X8"));
            }
            if (V1CRC != null)
            {
                AddVar(builder, " V1CRC", ((int)V1CRC.Status).ToString() + "|" + V1CRC.Crc.ToString("X8"));
            }
            if (PFICRC != null)
            {
                AddVar(builder, " PFICRC", ((int)PFICRC.Status).ToString() + "|" + PFICRC.Crc.ToString("X8"));
            }
            if (DMICRC != null)
            {
                AddVar(builder, " DMICRC", ((int)DMICRC.Status).ToString() + "|" + DMICRC.Crc.ToString("X8"));
            }
            if (SSCRC != null)
            {
                AddVar(builder, " SSCRC", ((int)SSCRC.Status).ToString() + "|" + SSCRC.Crc.ToString("X8"));
            }
            if (GameCRC != null)
            {
                AddVar(builder, " GameCRC", ((int)GameCRC.Status).ToString() + "|" + GameCRC.Crc.ToString("X8"));
            }
            AddVar(builder, " RAWSS", RAWSS.ToString("X8"));
            AddVar(builder, " RegionCode", RegionCode.ToString("X8"));
            AddVar(builder, " MediaId", MediaId);
            AddVar(builder, " AnyDVDCorruption", AnyDVDCorruption.ToString());
            AddVar(builder, " MinKernel", MinKernel);
            AddVar(builder, " LastCheck", LastCheck.ToString());
            AddVar(builder, " Wave", Wave);
            AddVar(builder, " Size", Size.ToString());
            return(builder.ToString());
        }
Example #10
0
        /// <summary>
        /// Return the suggested next update time
        /// </summary>
        /// <returns></returns>
        /// <remarks>Override to honor TTL (within reason)</remarks>
        public override DateTime NextUpdate()
        {
            DateTime baseUpdate = base.NextUpdate();

            if (TTL > 0)
            {
                int limitedTTL = TTL;
                if (limitedTTL > 86400)
                {
                    limitedTTL = 86400;
                }
                DateTime subscriptionUpdate = LastCheck.AddSeconds((double)limitedTTL);
                if (subscriptionUpdate > baseUpdate)
                {
                    return(subscriptionUpdate);
                }
            }
            return(baseUpdate);
        }
Example #11
0
        private void CheckCache(bool forced = false)
        {
            if (!_initialized)
            {
                Initialize();
                _initialized = true;
            }
            if (!forced && EsClient.InvalidConnection)
            {
                if (EsClient.LastPing.AddMilliseconds(PingRate) > DateTime.Now)
                {
                    return;
                }
            }
            if (!forced && LastCheck.AddMilliseconds(CacheRate) > DateTime.Now)
            {
                return;
            }
            var currentETag    = ETag;
            var currentVersion = Version;
            var url            = GetBaseUrl() + "_search?search_type=count";
            var query          = leasequery;
            var json           = EsClient.ExecuteCommand(url, query);

            if (null == json)
            {
                ETag      = null;
                Version   = DateTime.MinValue;
                LastCheck = DateTime.MinValue;
            }
            else
            {
                var j = json.jsonify();
                ETag    = j.str("aggregations._version.value");
                Version = j.date("aggregations._timestamp.value_as_string");
            }
            if (ETag != currentETag || Version != currentVersion)
            {
                _cache.Clear();
            }
        }
    public static void Enqueue(Vector3 worldPos, float voxelSize, OnReceived callback, LastCheck lastCheck, float priority, int id = -1)
    {
        ChunkRequest cr = new ChunkRequest(worldPos, voxelSize, callback, lastCheck);

        cr.id = id;
        queue.Enqueue(cr, priority);
    }
        public ConsistencyMonitor(MonitorSettings monitorSettings,
                                  IConsistencyService consistencyService,
                                  IMtSlackNotificationsSender slackNotificationsSender,
                                  ICheckResultRepository checkResultRepository,
                                  IBalanceAndTransactionAmountRepository balanceAndTransactionAmountRepository,
                                  IBalanceAndOrderClosedRepository balanceAndOrderClosedRepository,
                                  IOrdersReportAndOrderClosedOpenedRepository ordersReportAndOrderClosedOpenedRepository,
                                  IPriceCandlesConsistencyRepository priceCandlesConsistencyRepository,
                                  IMarginEventsAccountStatusRepository marginEventsAccountStatusRepository,
                                  IHedgingServiceRepository hedgingServiceRepository,
                                  IAlertSeverityLevelService alertSeverityLevelService,
                                  ILog log)
        {
            _log                   = log;
            _monitorSettings       = monitorSettings;
            _consistencyService    = consistencyService;
            MonitorInterval        = _monitorSettings.ConsistencyCheckInterval;
            _checkResultRepository = checkResultRepository;
            _balanceAndTransactionAmountRepository      = balanceAndTransactionAmountRepository;
            _balanceAndOrderClosedRepository            = balanceAndOrderClosedRepository;
            _ordersReportAndOrderClosedOpenedRepository = ordersReportAndOrderClosedOpenedRepository;
            _priceCandlesConsistencyRepository          = priceCandlesConsistencyRepository;
            _marginEventsAccountStatusRepository        = marginEventsAccountStatusRepository;
            _hedgingServiceRepository  = hedgingServiceRepository;
            _alertSeverityLevelService = alertSeverityLevelService;
            _slackNotificationsSender  = slackNotificationsSender;

            var lastCheckResult = Task.Run(async() => await _checkResultRepository.GetLastAsync()).Result;

            if (lastCheckResult == null)
            {
                LastCheck = null;
            }
            else
            {
                LastCheck = lastCheckResult.DateTo;
            }

            _log.WriteInfo(nameof(ConsistencyMonitor), null, $"Consistency Monitor Started. LastCheck:[{LastCheck?.ToString("u")}]");
        }
Example #14
0
        protected static LastCheck GetLastCheck(ulong simA, ulong simB, bool createNew, out bool created)
        {
            Dictionary<ulong, LastCheck> lookup;
            if (!sLastCheck.TryGetValue(simA, out lookup))
            {
                lookup = new Dictionary<ulong, LastCheck>();
                sLastCheck.Add(simA, lookup);
            }

            created = false;

            LastCheck lastCheck;
            if (!lookup.TryGetValue(simB, out lastCheck))
            {
                if (createNew)
                {
                    created = true;
                    lastCheck = new LastCheck();
                    lookup.Add(simB, lastCheck);
                }
            }

            return lastCheck;
        }
Example #15
0
 /// <summary>
 /// Return the suggested next update time
 /// </summary>
 /// <returns></returns>
 /// <remarks>This is run in the foregroud (dispatcher) thread.</remarks>
 virtual public DateTime NextUpdate()
 {
     // TODO make this user-configurable
     return(LastCheck.AddHours(1));
 }