Esempio n. 1
0
        private long GetCounterId(string path)
        {
            long id;

            if (!CounterIds.TryGetValue(path, out id))
            {
                SQLiteCommand cmd = new SQLiteCommand("SELECT id FROM counter WHERE path = @path", Database);
                cmd.Parameters.AddWithValue("@path", path);
                object result = cmd.ExecuteScalar();

                if (result == null)
                {
                    cmd = new SQLiteCommand("INSERT INTO counter (path) VALUES (@path)", Database);
                    cmd.Parameters.AddWithValue("@path", path);
                    cmd.ExecuteNonQuery();
                    cmd    = new SQLiteCommand("SELECT last_insert_rowid()", Database);
                    result = cmd.ExecuteScalar();
                }

                id = (long)result;
                CounterIds.Add(path, id);
            }

            return(id);
        }
        public int ReadCounter(CounterIds ids)
        {
            lock (_CounterLock)
            {
                if (!Counters.ContainsKey(ids))
                {
                    return(0);
                }

                return(Counters[ids]);
            }
        }
        public void IncrementCounter(CounterIds ids, int num)
        {
            lock (_CounterLock)
            {
                if (!Counters.ContainsKey(ids))
                {
                    return;
                }

                Counters[ids] += num;
            }
        }
        public int ReadCounter(CounterIds ids)
        {
            CheckManagerForNullReferenceBeforeUse();

            try
            {
                return(((StatisticsManager)Manager).ReadCounter(ids));
            }
            catch (BaseException baseException)
            {
                throw new StatisticsComponentException(this, -1, string.Format("Failed to read counter '{0}'.", ids), baseException);
            }
        }
        public void IncrementCounter(CounterIds ids, int num)
        {
            CheckManagerForNullReferenceBeforeUse();

            try
            {
                ((StatisticsManager)Manager).IncrementCounter(ids, num);
            }
            catch (BaseException baseException)
            {
                throw new StatisticsComponentException(this, -1, string.Format("Failed to increment counter '{0}' with '{1}'.", ids, num), baseException);
            }
        }
Esempio n. 6
0
        public int ReadCounter(CounterIds ids)
        {
            CheckManagerForNullReferenceBeforeUse();

              try
              {
            return ((StatisticsManager)Manager).ReadCounter(ids);
              }
              catch (BaseException baseException)
              {
            throw new StatisticsComponentException(this, -1, string.Format("Failed to read counter '{0}'.", ids), baseException);
              }
        }
Esempio n. 7
0
        public void IncrementCounter(CounterIds ids, int num)
        {
            CheckManagerForNullReferenceBeforeUse();

              try
              {
            ((StatisticsManager)Manager).IncrementCounter(ids, num);
              }
              catch (BaseException baseException)
              {
            throw new StatisticsComponentException(this, -1, string.Format("Failed to increment counter '{0}' with '{1}'.", ids, num), baseException);
              }
        }
Esempio n. 8
0
        public int ReadCounter(CounterIds ids)
        {
            lock (_CounterLock)
              {
            if (!Counters.ContainsKey(ids))
              return 0;

            return Counters[ids];
              }
        }
Esempio n. 9
0
        public void IncrementCounter(CounterIds ids, int num)
        {
            lock (_CounterLock)
              {
            if (!Counters.ContainsKey(ids))
              return;

            Counters[ids] += num;
              }
        }