Ejemplo n.º 1
0
        void Application_Error(object sender, EventArgs e)
        {
            // 在出现未处理的错误时运行的代码
            Exception objErr = Server.GetLastError().GetBaseException();

            if (objErr.GetType() == typeof(HttpException))
            {
                int i = ((HttpException)objErr).GetHttpCode();
                if (i == 404)
                {
                    //Response.Redirect("~/ErrorPage/FileNotFind.html");
                }
                else if (i == 403)
                {
                    //Response.Redirect("~/ErrorPage/NoAccess.html");
                }
            }
            else
            {
                BLL.Sys_log_Err   ssle  = new BLL.Sys_log_Err();
                Model.Sys_log_Err model = new Model.Sys_log_Err();

                model.Err_typeid  = 2;
                model.Err_type    = "CRM系统";
                model.Err_time    = DateTime.Now;
                model.Err_url     = Common.PageValidate.InputText(Request.Url.ToString(), 500);
                model.Err_message = Common.PageValidate.InputText(objErr.Message, int.MaxValue);
                model.Err_source  = Common.PageValidate.InputText(objErr.Source, 500);
                model.Err_trace   = Common.PageValidate.InputText(objErr.StackTrace, int.MaxValue);
                model.Err_ip      = Request.UserHostAddress;

                var    cookie     = Request.Cookies[FormsAuthentication.FormsCookieName];
                var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
                string CoockiesID = ticket.UserData;

                //检验Cookie是否已经存在
                if (null == cookie)
                {
                    model.Err_emp_id   = -1;
                    model.Err_emp_name = "未登录";
                }
                else
                {
                    if (Common.PageValidate.IsNumber(CoockiesID))
                    {
                        BLL.hr_employee emp     = new BLL.hr_employee();
                        int             emp_id  = int.Parse(CoockiesID);
                        DataSet         dsemp   = emp.GetList("id=" + emp_id);
                        string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();

                        model.Err_emp_id   = emp_id;
                        model.Err_emp_name = empname;
                    }
                    else
                    {
                        model.Err_emp_id   = -1;
                        model.Err_emp_name = "异常登录";
                    }
                }

                ssle.Add(model);

                //Server.ClearError();
            }
        }
Ejemplo n.º 2
0
        void Application_Error(object sender, EventArgs e)
        {
            // �ڳ���δ����Ĵ���ʱ���еĴ���
            Exception objErr = Server.GetLastError().GetBaseException();

            if (objErr.GetType() == typeof(HttpException))
            {
                int i = ((HttpException)objErr).GetHttpCode();
                if (i == 404)
                {
                    //Response.Redirect("~/ErrorPage/FileNotFind.html");
                }
                else if (i == 403)
                {
                    //Response.Redirect("~/ErrorPage/NoAccess.html");
                }
            }
            else
            {
                BLL.Sys_log_Err ssle = new BLL.Sys_log_Err();
                Model.Sys_log_Err model = new Model.Sys_log_Err();

                model.Err_typeid = 2;
                model.Err_type = "CRMϵͳ";
                model.Err_time = DateTime.Now;
                model.Err_url = Common.PageValidate.InputText(Request.Url.ToString(), 500);
                model.Err_message = Common.PageValidate.InputText(objErr.Message, 10000);
                model.Err_source = Common.PageValidate.InputText(objErr.Source, 500);
                model.Err_trace = Common.PageValidate.InputText(objErr.StackTrace, 10000);
                model.Err_ip = Request.UserHostAddress;

                //��ô�cookie����
                HttpCookie cookie = Request.Cookies["UserID"];
                //����Cookie�Ƿ��Ѿ�����
                if (null == cookie)
                {
                    model.Err_emp_id = -1;
                    model.Err_emp_name = "δ��¼";
                }
                else
                {
                    if (Common.PageValidate.IsNumber(cookie.Value))
                    {
                        BLL.hr_employee emp = new BLL.hr_employee();
                        int emp_id = int.Parse(cookie.Value);
                        DataSet dsemp = emp.GetList("id=" + emp_id);
                        string empname = dsemp.Tables[0].Rows[0]["name"].ToString();

                        model.Err_emp_id = emp_id;
                        model.Err_emp_name = empname;
                    }
                    else
                    {
                        model.Err_emp_id = -1;
                        model.Err_emp_name = "�쳣��¼";
                    }
                }

                ssle.Add(model);

                //Server.ClearError();
            }
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            if (request["Action"] == "grid")
            {
                BLL.Sys_log_Err log = new BLL.Sys_log_Err();

                int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                    sortname = " Err_time";
                if (string.IsNullOrEmpty(sortorder))
                    sortorder = " desc";

                string sorttext = " " + sortname + " " + sortorder;

                string Total = "0";

                DataSet ds = null;

                string serchtext = "1=1";

                if (!string.IsNullOrEmpty(request["stype"]))
                    serchtext += " and EventType = '" + request["stype"] + "'";

                if (!string.IsNullOrEmpty(request["sstart"]))
                    serchtext += " and Err_time >= '" + DateTime.Parse(request["sstart"]) + "'";

                if (!string.IsNullOrEmpty(request["sdend"]))
                    serchtext += " and Err_time <= '" + DateTime.Parse(request["sdend"]).AddHours(23).AddMinutes(59).AddSeconds(59) + "'";

                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    serchtext += " and (Err_url like N'%" + request["stext"] + "%'";
                    serchtext += " or Err_message like N'%" + request["stext"] + "%'";
                    serchtext += " or Err_source like N'%" + request["stext"] + "%'";
                    serchtext += " or Err_ip like N'%" + request["stext"] + "%'";
                }

                ds = log.GetList(PageSize, PageIndex, serchtext, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "logtype")
            {
                BLL.Sys_log_Err log = new BLL.Sys_log_Err();

                DataSet ds = log.GetLogtype();

                StringBuilder str = new StringBuilder();

                str.Append("[");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{value:'" + ds.Tables[0].Rows[i]["Err_type"].ToString() + "',text:'" + ds.Tables[0].Rows[i]["Err_type"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            if (request["Action"] == "grid")
            {
                BLL.Sys_log_Err log = new BLL.Sys_log_Err();

                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " Err_time";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = " desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total = "0";

                DataSet ds = null;

                string serchtext = "1=1";

                if (!string.IsNullOrEmpty(request["stype"]))
                {
                    serchtext += " and EventType = '" + request["stype"] + "'";
                }

                if (!string.IsNullOrEmpty(request["sstart"]))
                {
                    serchtext += " and Err_time >= '" + DateTime.Parse(request["sstart"]) + "'";
                }

                if (!string.IsNullOrEmpty(request["sdend"]))
                {
                    serchtext += " and Err_time <= '" + DateTime.Parse(request["sdend"]).AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }

                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    serchtext += " and (Err_url like N'%" + request["stext"] + "%'";
                    serchtext += " or Err_message like N'%" + request["stext"] + "%'";
                    serchtext += " or Err_source like N'%" + request["stext"] + "%'";
                    serchtext += " or Err_ip like N'%" + request["stext"] + "%'";
                }

                ds = log.GetList(PageSize, PageIndex, serchtext, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "logtype")
            {
                BLL.Sys_log_Err log = new BLL.Sys_log_Err();

                DataSet ds = log.GetLogtype();

                StringBuilder str = new StringBuilder();

                str.Append("[");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{value:'" + ds.Tables[0].Rows[i]["Err_type"].ToString() + "',text:'" + ds.Tables[0].Rows[i]["Err_type"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
        }