Esempio n. 1
0
        /// <summary>
        /// 刷新寄宿
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="storeId"></param>
        private static void ToRefreshHosted(int companyId, string storeId)
        {
            var ts = RefreshHosted(companyId, storeId);

            if (ts == default(TimeSpan))
            {
                return;
            }
            var info = new MarketingRefreshInfo()
            {
                StoreId = storeId, CompanyId = companyId, Timer = DateTime.Now.Add(ts)
            };

            lock (hostedDict)
            {
                hostedDict.Add(info);
            }
        }
Esempio n. 2
0
        public static void InitStore()
        {
            var stores = WarehouseService.GetStores();

            foreach (var item in stores)
            {
                var info = new MarketingRefreshInfo()
                {
                    StoreId = item.StoreId, CompanyId = item.CompanyId
                };
                RedisManager.Publish("MarketingRefresh", info);
            }
            Task.Factory.StartNew(() =>//定时更新加载每天数据
            {
                try
                {
                    Thread.Sleep(DateTime.Now.Date.AddDays(1).AddHours(1) - DateTime.Now);
                    InitStore();
                }
                catch { }
            });
        }
Esempio n. 3
0
        //public static void CloseStoreMarketing()
        //{
        //    RedisManager.UnSubscribe("RefreshHostedMarketing");
        //    RedisManager.UnSubscribe("MarketingRefresh");
        //}
        public static void InitStoreMarketing()
        {
#if Local
            var companyId = 0;
            try
            {
                companyId = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CompanyId"]);
            }
            catch
            {
                companyId = 0;
            }
            var storeId = System.Configuration.ConfigurationManager.AppSettings["StoreId"];
            if (string.IsNullOrEmpty(storeId) || companyId == 0)
            {
                Thread.CurrentThread.Abort();
                return;
            }
#endif

            Subscribe();
#if(Local!=true)
            var stores = WarehouseService.GetStores();
            foreach (var item in stores)
            {
                var info = new MarketingRefreshInfo() { StoreId = item.StoreId, CompanyId = item.CompanyId };
                RedisManager.Publish("MarketingRefresh", info);
                CreateSchedulerRefreshMarketing(JsonConvert.SerializeObject(info));
            }
#endif
#if Local
            var info = new MarketingRefreshInfo() { StoreId = storeId, CompanyId = companyId };
            StoreManager.PubEvent("MarketingRefresh", info);
            CreateSchedulerRefreshMarketing(JsonConvert.SerializeObject(info));
#endif
        }