| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Collections.Concurrent;
- namespace HXX.Scanner.Biz
- {
- class biz_limit
- {
- private static object lockObj = new object();
- private static ConcurrentDictionary<string, DateTime> dic = new ConcurrentDictionary<string, DateTime>();
- private static List<string> WH = new List<string>() { "startScan", "loadImage", "reUpload" };
- public static bool check(string key)
- {
- bool result = false;
- lock (lockObj)
- {
- if (WH.Contains(key))
- {
- if (dic.Keys.Contains(key))
- {
- if ((DateTime.Now - dic[key]).TotalSeconds > 1)
- {
- dic[key] = DateTime.Now;
- result = true;
- }
- else
- {
- result = false;
- }
- }
- else
- {
- dic[key] = DateTime.Now;
- result = true;
- }
- }
- else
- {
- result = true;
- }
- }
- return result;
- }
- }
- }
|