コード例 #1
0
        /// <summary>
        /// 当窗体完全显示出来后,开始执行Server程序。
        /// </summary>
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            this.InitOption();///初始化选项

            //启动一个线程,监听关键词客户端请求
            ServerCore serverCore = new ServerCore();

            thread = new Thread(new ThreadStart(serverCore.Listen));
            thread.IsBackground = true;
            thread.Start();

            this.Text         = AssemblyProduct + ", Application Start time: " + DateTime.Now.ToShortDateString() + " | " + DateTime.Now.ToLongTimeString();
            this.StatusString = "初始化关键词词库...";
            InitializeApplication.InitializeWords();
            this.StatusString = "初始化广告数据...";
            _AdHelper.Initialize();
            this.StatusString = "Server程序启动就绪";

            //this.Start();/// Server程序启动
        }
コード例 #2
0
        private BllPost GetAd(ref int imagesOnPage)
        {
            BllPost ad;

            AdHelper.Initialize(_postService.GetAllWithAd());
            if (User.Identity.IsAuthenticated)
            {
                var user        = _accountService.GetUserByLogin(User.Identity.Name);
                var disabledAds = _postService.GetDisabledAds(user.UserId).ToList();
                ad            = AdHelper.GetAd(disabledAds, user.AgeId, user.SexId, user.CountryId, user.LanguageId);
                imagesOnPage -= 1;
            }
            else
            {
                ad = AdHelper.GetRandomAd();
            }

            return(ad);
        }