コード例 #1
0
        private EPITimeout RemoveTimeout(int installationNo, EPIProcessType processType)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "RemoveTimeout"))
            {
                EPITimeout result = null;

                try
                {
                    string fullKey = this.PrepareKey(installationNo, processType);
                    _collection.TryRemove(fullKey, out result);
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
コード例 #2
0
        public void CheckEPITimeouts(int installationNo)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "CheckEPITimeouts"))
            {
                try
                {
                    EPITimeout timeout = this.GetTimeout(installationNo, EPIProcessType.IntervalRating);
                    if (timeout == null)
                    {
                        return;
                    }

                    if ((timeout.LastUpdatedTime.AddMinutes(_configStore.EPICardInMeterUpdate) - DateTime.Now).Seconds >= 0)
                    {
                        method.Info("Running EPI Interval Rating");

                        //  This happens due to two threads are executing this method at the same time.
                        if ((Interlocked.Read(ref timeout.IsInProcess) == 1))
                        {
                            method.Info("Some other thread is already generating the Interval Rating, So i am skipping now.");
                            return;
                        }
                        //  I am executing now
                        if ((Interlocked.CompareExchange(ref timeout.IsInProcess, 1, 0) == 1))
                        {
                            method.Info("Some other thread has already taken control, So i am skipping now.");
                            return;
                        }

                        EPICardDetail cardDetail = this.GetCardInDetail(installationNo);
                        SDTMessages.Instance.ProcessPlayerCardSessionRatings(installationNo);
                        timeout.LastUpdatedTime = DateTime.Now;
                        Interlocked.Exchange(ref timeout.IsInProcess, 0);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
            }
        }
コード例 #3
0
        private EPITimeout AddOrUpdateTimeout(int installationNo, EPIProcessType processType, DateTime lastUpdatedTime)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "AddOrUpdateTimeout"))
            {
                EPITimeout result = null;

                try
                {
                    string fullKey = this.PrepareKey(installationNo, processType);
                    result = _collection.AddOrGet(fullKey, () => { return(new EPITimeout()); });
                    result.InstallationNo  = installationNo;
                    result.ProcessType     = processType;
                    result.LastUpdatedTime = lastUpdatedTime;
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }