Exemple #1
0
        //[OutputCache(Duration = 5, VaryByParam = "pageIndex")]
        public ActionResult Articles(string domain, int?year, int?mouth, int?tag, int?articleTypeId, int?pageIndex)
        {
            var user      = UserQueryService.GetUserByDomain(domain);
            var userId    = user.ID;
            var result    = _articleQueryService.FindAllPager(userId, articleTypeId, tag, year, mouth, true, pageIndex ?? 1, PageSize);
            var viewModel = result.Select(CreateArticleViewModel).ToPagedList(pageIndex ?? 1, PageSize, result.TotalCount);

            ViewData["domain"] = HistoryUser.Domain;


            #region 如果未登录或者当前用户是当前访问用户 不进行访问信息记录
            if (!IsLogin)
            {
                return(View("Index", viewModel));
            }

            if (CurrentUser.UserId == HistoryUser.UserId)
            {
                return(View("Index", viewModel));
            }
            #endregion

            // 更新访问信息
            try
            {
                const int maxCount = 50;
                using (var transaction = UnitOfWork.Begin())
                {
                    _processor.Process <CreateUserTourLogCommand>(
                        new CreateUserTourLogCommand(CurrentUser.UserId, HistoryUser.UserId)
                    {
                        MaxTourUserCount = maxCount
                    });
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                // 记录日志
                LogServer.Error("更新阅读次数失败", ex.Message, HttpContext.Request.Path);
            }
            return(View("Index", viewModel));
        }
Exemple #2
0
        public static void Main()
        {
            int clientCount = 1;
            var port        = 8888;

            TcpListener serverSocket = new TcpListener(IPAddress.Any, port);

            serverSocket.Start();

            Thread serverListeningMessageOnDisplayThread = new Thread(ServerListeningMessageOnDisplay);

            serverListeningMessageOnDisplayThread.Start();

            while (true)
            {
                try
                {
                    TcpClient client = serverSocket.AcceptTcpClient();
                    lock (_lock)
                    {
                        clientTable.Add(clientCount, client);
                    }

                    LogServer.Message("Client connected!");
                    Console.WriteLine("Client connected!");

                    Thread clientThread = new Thread(HandleClients);
                    clientThread.Start(clientCount);
                    clientCount++;
                }
                catch (Exception ex)
                {
                    LogServer.Error(ex);
                }
            }
        }