コード例 #1
0
        /// <summary>
        /// 清除黑名单
        /// </summary>
        /// <param name="readingRooms"></param>
        public void BlacklistOperating()
        {
            try
            {
                DateTime             nowDateTime = ServiceDateTime.Now;
                List <BlackListInfo> bllist      = T_SM_Blacklist.GetBlackListInfo(null);
                if (bllist != null)
                {
                    foreach (BlackListInfo bli in bllist)
                    {
                        if ((bli.OutTime < nowDateTime) && (bli.OutBlacklistMode == LeaveBlacklistMode.AutomaticMode))
                        {
                            bli.BlacklistState = LogStatus.Fail;
                            T_SM_Blacklist.UpdateBlackList(bli);
                            WriteLog.Write("监控服务:读者" + bli.CardNo + ",处罚结束,离开黑名单");

                            //ReaderNoticeInfo notice = new ReaderNoticeInfo();
                            //notice.CardNo = bli.CardNo;
                            //notice.Type = NoticeType.DeleteBlacklistWarning;
                            //notice.Note = "您的黑名单处罚已结束,请遵守座位使用规则,请勿再次违规。";
                            //T_SM_ReaderNotice.AddReaderNotice(notice);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                WriteLog.Write(string.Format("监控服务:黑名单处理遇到异常:{0}", e.Message));
            }
        }
コード例 #2
0
        public static void WriteLogs(string geturl)
        {
            string IllegalityLoginIsAddBlackList = System.Configuration.ConfigurationManager.AppSettings["IllegalityLoginIsAddBlackList"].ToString();

            if (IllegalityLoginIsAddBlackList == "1")
            {
                #region 非法登录的,捕获到学号,一律加入黑名单
                if (loginId != "admin" && loginId.Length > 0)
                {
                    SeatManage.SeatManageComm.WriteLog.Write(string.Format("用户通过非法登录访问网站,访问页面地址为:{0},用户IP地址为:{1},登录名为:{2}", geturl, GetIP(), loginId));
                    if (T_SM_Blacklist.GetBlackListInfo(loginId).Count == 0)
                    {
                        SeatManage.ClassModel.BlackListInfo          bli = new SeatManage.ClassModel.BlackListInfo();
                        SeatManage.ClassModel.RegulationRulesSetting regulationRulesSetting = SeatManage.Bll.T_SM_SystemSet.GetRegulationRulesSetting();
                        string CardNo = loginId;
                        string Remark = "登录名为" + loginId + "的用户有非法登录访问网站行为,被拉入黑名单";

                        bli.CardNo  = CardNo;
                        bli.AddTime = SeatManage.Bll.ServiceDateTime.Now;

                        bli.OutTime          = DateTime.Parse(SeatManage.Bll.ServiceDateTime.Now.AddDays(30).ToShortDateString() + " 23:59:59");
                        bli.OutBlacklistMode = LeaveBlacklistMode.ManuallyMode;//(SeatManage.EnumType.LeaveBlacklistMode)int.Parse(ddlleaveMode.SelectedValue);

                        bli.ReMark = Remark;
                        int blackId   = 0;
                        int roomCount = 0;
                        List <SeatManage.ClassModel.ReadingRoomInfo> roomlist = SeatManage.Bll.ClientConfigOperate.GetReadingRooms(null);
                        foreach (SeatManage.ClassModel.ReadingRoomInfo roominfo in roomlist)
                        {
                            if (roominfo.Setting.BlackListSetting.Used)
                            {
                                bli.ReadingRoomID = roominfo.No;
                                if (!(SeatManage.Bll.T_SM_Blacklist.AddBlackList(bli) > 0))
                                {
                                    // FineUI.Alert.Show("添加失败!");
                                    WriteLog.Write("添加黑名单失败:" + loginId + "");
                                    continue;// return;
                                }
                                else
                                {
                                    roomCount++;
                                }
                            }
                        }
                        if (roomCount == 0)
                        {
                            blackId = SeatManage.Bll.T_SM_Blacklist.AddBlackList(bli);
                        }
                    }
                }
                #endregion
            }
            else
            {
                SeatManage.SeatManageComm.WriteLog.Write(string.Format("用户通过非法登录访问网站,访问页面地址为:{0},用户IP地址为:{1},登录名为:{2}", geturl, GetIP(), loginId));
            }

            HttpContext.Current.Response.Redirect("~/Default.aspx");
        }