123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using Interface;
- using Services;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Models.Entity.LotteryNumDB;
- using Cache.Entity;
- using Models;
- using Common;
- using Business.KJH;
- namespace Cache
- {
- public static class Ctrl
- {
- private static LotteryNumInterface services;
- private static Dictionary<string, LotteryData> MlotteryData;
-
- private static Object ZXView;
- private static int UpTK = 300;
- private static DateTime lotteryLastUpTime;
- private static DateTime ZXviewUpTime;
- static Ctrl()
- {
- services = new LotteryService();
- MlotteryData = new Dictionary<string, LotteryData>();
-
- lotteryLastUpTime = DateTime.Now;
- ZXviewUpTime = new DateTime();
- ZXView = new object();
-
- }
- private static void Test()
- {
-
- }
- private static void lotteryDoUpdate()
- {
- if (MlotteryData.Count==0)
- {
- GetList();
- }
- if ((DateTime.Now- lotteryLastUpTime).TotalSeconds> UpTK)
- {
- GetList();
- lotteryLastUpTime = DateTime.Now;
- }
- }
- public static bool ZXViewNeedUpdate()
- {
- if (ZXView==null)
- {
- return false;
- }
- if ((DateTime.Now - ZXviewUpTime).TotalSeconds > UpTK)
- {
-
-
- return false;
- }
- return true;
- }
- public static object GetZXView()
- {
- return ZXView;
- }
- public static void SETZXView(object data)
- {
- ZXView = data;
- ZXviewUpTime = DateTime.Now;
- }
-
- private static void GetList()
- {
- var list = KJBLL.GetLotteryList();
- for (int i = 0; i < list.Count; i++)
- {
- var lottery = Enum.Parse(typeof(SCCLottery), list[i].LotteryType);
- if (ZSlotterType.TypeOfNameDict.Keys.Contains(list[i].LotteryType))
- {
- list[i].HasLotteryZS = true;
- }
- list[i].LotteryText = EnumHelper.GetLotteryText((SCCLottery)lottery);
- MlotteryData[list[i].LotteryType] = list[i];
- }
-
-
- }
-
-
-
-
-
-
- public static LotteryData GetLottery(string typename)
- {
- try
- {
- if (!MlotteryData.Keys.Contains(typename))
- {
- lotteryDoUpdate();
- return MlotteryData[typename];
- }
- else
- {
- return MlotteryData[typename];
- }
- }
- catch (Exception ee)
- {
- return null; ;
- }
-
-
- }
-
-
-
-
- public static List<LotteryData> GetLottery()
- {
- try
- {
- if (MlotteryData.Keys.Count == 0)
- {
- lotteryDoUpdate();
-
- }
- return MlotteryData.Values.ToList();
- }
- catch (Exception ee)
- {
- return null;
- }
-
-
- }
-
- }
- }
|