Beispiel #1
0
 /// <summary>
 /// 保存历史记录
 /// </summary>
 /// <param name="obj"></param>
 protected void SaveHistory(TB_AccountHistory obj)
 {
     obj.ActionTime = DateTime.Now;
     if (obj.Account <= 0 || (int?)null == obj.Account)
     {
         obj.Account = Account.id;
     }
     obj.Ip = Utility.GetClientIP(this.Context);
     HistoryInstance.Add(obj);
 }
Beispiel #2
0
        private void ShowHistory()
        {
            var now   = DateTime.Now;
            var then  = now.AddDays(-5);
            var time1 = start.Value;

            if (!string.IsNullOrEmpty(time1))
            {
                then = DateTime.Parse(time1 + " 00:00:00");
            }
            var time2 = end.Value;

            if (!string.IsNullOrEmpty(time2))
            {
                now = DateTime.Parse(time2 + " 23:59:59");
            }

            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = HistoryInstance.FindPageList <TB_AccountHistory>(pageIndex, PageSize, out totalRecords,
                                                                                f => f.ActionTime >= then && f.ActionTime <= now && f.Account == Account.id, "ActionTime", true);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"5\">No records.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    html += "<tr>" +
                            "<td style=\"text-align: center; height: 25px;\">" + cnt + "</td>" +
                            "<td>" + obj.ActionTime.Value.ToString("yyyy/MM/dd HH:mm:ss") + "</td>" +
                            "<td><a href=\"#u\">" + obj.TB_AccountAction.Description + "</a></td>" +
                            "<td>" + obj.Ip + "</td>" +
                            "<td>" + obj.ObjectA + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./account_history.aspx", divPagging);
            }
        }
Beispiel #3
0
        private void ShowHistory()
        {
            var now   = DateTime.Now;
            var then  = now.AddDays(-5);
            var time1 = start.Value;

            if (!string.IsNullOrEmpty(time1))
            {
                then = DateTime.Parse(time1 + " 00:00:00");
            }
            var time2 = end.Value;

            if (!string.IsNullOrEmpty(time2))
            {
                now = DateTime.Parse(time2 + " 23:59:59");
            }

            var name  = txtName.Value.Trim();
            var login = -1;

            if (cbIgnoreLogin.Checked)
            {
                login = ActionInstance.Find(f => f.Name.Equals("Login")).id;
            }
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);

            Expression <Func <TB_AccountHistory, bool> > expression = PredicateExtensions.True <TB_AccountHistory>();

            // 时间查询
            expression = expression.And(a => a.ActionTime >= then && a.ActionTime <= now);
            // 姓名模糊查询
            if (!string.IsNullOrEmpty(name))
            {
                pageIndex  = 1;
                expression = expression.And(a => a.TB_Account.Name.Contains(name));
            }
            // 屏蔽登录信息
            if (login > 0)
            {
                expression = expression.And(a => a.ActionId != login);
            }
            // Summary模糊查询
            var summary = txtSummary.Value.Trim();

            if (!string.IsNullOrEmpty(summary))
            {
                pageIndex  = 1;
                expression = expression.And(a => a.ObjectA.Contains(summary));
            }

            var    list       = HistoryInstance.FindPageList <TB_AccountHistory>(pageIndex, PageSize, out totalRecords, expression, "ActionTime", true);
            var    totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);
            string html       = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"6\">No records.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    html += "<tr>" +
                            "<td style=\"width: 60px; text-align: center; height: 25px;\">" + cnt + "</td>" +
                            "<td style=\"width: 150px;\">" + obj.ActionTime.Value.ToString("yyyy/MM/dd HH:mm:ss") + "</td>" +
                            "<td style=\"width: 150px;\">" + CheckQueryString(name, obj.TB_Account.Name) + "</td>" +
                            "<td style=\"width: 100px;\"><a href=\"#u\">" + obj.TB_AccountAction.Description + "</a></td>" +
                            "<td>" + obj.Ip + "</td>" +
                            "<td>" + CheckQueryString(summary, obj.ObjectA) + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./user_history.aspx", divPagging);
            }
        }