<%@ Page Language="C#" MasterPageFile="Admin.Master" AutoEventWireup="true" CodeBehind="Logmanage.aspx.cs" Inherits="Mvcb2b.admin.Logmanage" Title="安全日志" %>
<%@ Import Namespace="Mvcmode"%>
<%@ MasterType VirtualPath="Admin.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"><%string logtype = "";
                                                                                       if (Logtype != null)
                                                                                           logtype = Logtype.ToString();
                                                                                       string curlogtype1 = "";
                                                                                       string curlogtype2 = "";
                                                                                       switch (logtype)
                                                                                       {
                                                                                           case "1":
                                                                                               curlogtype1 = "class=\"act-state\"";
                                                                                               break;
                                                                                           case "2":
                                                                                               curlogtype2= "class=\"act-state\"";
                                                                                               break;
                                                                                           default:
                                                                                               break;
                                                                                       }%>
<script type="text/javascript" src="../Comja/val_num.js"></script>  
<script type="text/javascript">
$(document).ready(function () {
    $(".com_suc_cancel").click(function (e) { e.preventDefault(); hidesucbox(); });
});
function show(logid) {
    var file = "jquery/showlog.aspx?logid=" + logid;
    $.ajax({
        type: "GET",
        url: file,
        dataType: "json",
        success: function (msg, textStatus, jqXHR) {
            if (msg == "没有权限!") {
                alert(msg);
                return;
            }
            if (msg != "0") {
                var fromcon = "<p>来源页面：" + msg.Fromurl + "</p>";
                var con = "<p>" + msg.Logcon.replace(/\n/g, "<br>") + "</p>";
                con = con + fromcon;
                $("#logcon_txt").html(con);
                showsucbox();
            }
        }, error: function () { alert("ajax error!"); }
    });
}
function dellog(id) {
  //  if (confirm("确认删除此条记录吗？")) {
        $.ajax({
            type: "POST",
            url: "jquery/logdel.aspx",
            dataType: "text",
            data: { "id": "" + id + "" }, /*传输的参数*/
            success: function (msg) {
                if (msg == "没有权限!") {
                    alert(msg);
                    return;
                }
                if (msg == "ok") {
                    /*显示*/
                    tr_logid = "log" + id;
                    $('#' + tr_logid).remove();
                }
            }, error: function (html) { alert("error-$.ajax" + html); }
        });
  //  }
}
function clearlog() {
    var logtype = "<%=logtype %>";
    if (logtype=="")
       logtype="1";
      if (confirm("确认清空记录吗？")) {
          $.ajax({
              type: "POST",
              url: "jquery/logdel.aspx",
              dataType: "text",
              data: { "logtype": "" + logtype + "" }, /*传输的参数*/
              success: function (msg) {
                  //console.log(msg);
                  if (msg == "没有权限!") {
                      alert(msg);
                      return;
                  }
                  if (msg == "ok") {
                      window.location.href = "Logmanage.aspx?logtype=" + logtype;
                  }

              }, error: function (html) { alert("error-$.ajax" + html); }
          });
     }
  }
  function clearall() { 
      if (confirm("确认清空数据库全部日志记录吗？")) {
          $.ajax({
              type: "POST",
              url: "jquery/logdel.aspx",
              dataType: "text",
              data: { "delaction": "all" }, /*传输的参数*/
              success: function (msg) {
                  //console.log(msg);
                  if (msg == "没有权限!") {
                      alert(msg);
                      return;
                  }
                  if (msg == "ok") {
                      window.location.href = "Logmanage.aspx";
                  }

              }, error: function (html) { alert("error-$.ajax" + html); }
          });
      }
  }
function showsucbox() {
    $(".com_suc_mask").show();
    $(".com_suc_box").show();
}
function hidesucbox() {
    $(".com_suc_mask").hide();
    $(".com_suc_box").hide();
}

</script>    
<div class="path">当前位置： 系统管理 >>  安全日志</div>
<h3 class="nob">安全日志 </h3>
<div class="menusearch">
    <div style="float:left;padding-left:0px;"><a href="Logmanage.aspx?logtype=1" <%=curlogtype1 %> style="margin-left:20px;margin-right:10px;">登录日志</a> <a href="Logmanage.aspx?logtype=2" <%=curlogtype2 %> style="margin-left:10px;margin-right:10px;">错误日志</a> </div>
</div>
<table width="96%" border="0" align="center" cellpadding="2" style="background-color:#f5f5f5;" cellspacing="1">
          <tr style="background-color:#ffffff;font-weight:bold;">
            <td style="width:30px;">编号</td>
            
            <td style="width:60px;"><%if (logtype=="1")
                                           Response.Write("登录用户");
              else
              Response.Write("状态码"); %></td>
            <td style="width:260px;">访问页面</td>                  
            <td>日志信息</td>  
            <td style="width:120px;text-align:center">IP</td>     
            <td style="width:120px;text-align:center">时间</td>  
            <td style="width:50px;text-align:center">删除</td>
          </tr>
        <asp:Repeater ID="Repeater1" runat="server">
          <ItemTemplate>
          <tr style="background-color:#ffffff" id="log<%#(Container.DataItem as Mvc_log).Id%>">
            <td><%#Eval("id")%></td>       
            <td><%#Msg((Container.DataItem as Mvc_log).Username, (Container.DataItem as Mvc_log).Tip)%></td>
	        <td><%#Fun.leftmore((Container.DataItem as Mvc_log).Cururl,40)%></td> 
            <td><%#Con((Container.DataItem as Mvc_log).Logcon, (Container.DataItem as Mvc_log).Id)%></td> 
            <td><%#(Container.DataItem as Mvc_log).Logip%></td>   
            <td><%#(Container.DataItem as Mvc_log).Addtime%></td> 
            <td style="text-align:center"><a href="javascript:void(0);" onclick="dellog(<%#(Container.DataItem as Mvc_log).Id%>);"><span>删除</span></a></td>
          </tr></ItemTemplate>
         </asp:Repeater>
         <asp:Literal runat="server"  ID="noms"  />
        </table> 

<div class="pagemsg"  style=" position:relative;"><div style="width:300px;text-align:right;padding-right:5px; position:absolute;right:2%;top:5px;"><a href="javascript:void(0);" class="showfapiao" onclick="clearlog();"><strong>清空日志</strong></a> <a href="javascript:void(0);" class="showfapiao" onclick="clearall();"><strong>清空所有</strong></a></div>
<table  border="0" align="center" cellpadding="0" cellspacing="0" width="90%">
          <tr><td><asp:Literal id="Message" runat="server" ></asp:Literal></td>
          </tr><tr>
          <td style="text-align:right;">&nbsp; 直接进入 <asp:textbox  id="gopage" Width="30px"   runat="server"  CssClass="gopage" > </asp:textbox> 页   <asp:button id ="Submithao"  Text="Go" runat="server" OnClick="Submithao_Click" CssClass="gopage" ></asp:button> </td>
          </tr></table>
</div>   

<p style="text-align:left;padding-left:80px;font-size:12px;line-height:20px;">? 帮助：<br />

</p>
<div class="com_suc_mask"></div>
<div class="com_suc_box">
<div class="com_suc" style="width:80%;height:520px;margin-top: -260px; margin-left: -40%;"> 
<div class="com_suc_form">
<span class="com_suc_tip">日志详细</span> 
<div class="clearfix"> 
<div class="com_suc_con2 clearfix" style="height:345px; overflow-y:scroll;"><div id="logcon_txt"><strong></strong></div></div>
 </div> 
 </div><!--com_suc_form-->
<div class="com_suc_action"> <a href="javascript:void(0);" class="com_suc_cancel">关闭</a> </div><!--com_suc_action-->
 </div></div><!--com_suc_box-->    
</asp:Content>
